/**
|
* 初始化商品信息详情对话框
|
*/
|
var MallGoodsInfoDlg = {
|
mallGoodsInfoData : {},
|
validFields: {
|
goodsName: Feng.def_valid_info( true, null, null, null, {
|
stringLength: {
|
max: 50,
|
message: "最多支持50个字符"
|
}
|
}), // 不能为空
|
// classifyIdOne: Feng.def_valid_info( true), // 不能为空
|
// goodsImage: Feng.def_valid_info( true), // 不能为空
|
// introImage: Feng.def_valid_info( true), // 不能为空
|
// introH5: Feng.def_valid_info( true) // 不能为空
|
}
|
};
|
|
/**
|
* 清除数据
|
*/
|
MallGoodsInfoDlg.clearData = function() {
|
this.mallGoodsInfoData = {};
|
};
|
|
/**
|
* 设置对话框中的数据
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MallGoodsInfoDlg.set = function(key, val) {
|
this.mallGoodsInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
};
|
|
/**
|
* 设置对话框中的数据
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MallGoodsInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
};
|
|
/**
|
* 关闭此对话框
|
*/
|
MallGoodsInfoDlg.close = function() {
|
parent.layer.close(window.parent.MallGoods.layerIndex);
|
};
|
|
/**
|
* 收集数据
|
*/
|
MallGoodsInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('groupType')
|
.set('goodsName')
|
.set('goodsTitle')
|
.set('goodsNo')
|
.set('price')
|
.set('priceSale')
|
.set('priceMember')
|
.set('stock')
|
.set('state')
|
.set('tagIds', Feng.get_chosen_selected( "#tagIds"))
|
.set('classifyIdOne')
|
.set('classifyIdTwo')
|
.set('goodsImage')
|
.set('introImage')
|
.set('purchaseH5', Feng.getEditorContent(MallGoodsInfoDlg.purchaseH5))
|
.set('introH5', Feng.getEditorContent(MallGoodsInfoDlg.introH5))
|
;
|
};
|
function isNull ( val) { return val == undefined || val == null || val == ""; }
|
|
/**
|
* 遍历循环规格表格的所有列input元素值,拼接字符串
|
*/
|
MallGoodsInfoDlg.getSpecGroup = function() {
|
// 定义规格组合值
|
let specGroup = [];
|
// 遍历循环规格表格的所有列
|
$(".specGroup").each(function (i, item) {
|
// 遍历循环拿到列中所有input元素值
|
let inputSpec = $(item).find(".inputSpec");
|
specGroup[i] = {"spec_ids": inputSpec[0].value, "grep_name": inputSpec[1].value, "stock": inputSpec[2].value, "priceMerchant": inputSpec[3].value}
|
});
|
return specGroup;
|
}
|
|
MallGoodsInfoDlg.getGoodsSet = function() {
|
// 定义规格组合值
|
let set = {
|
"buyCoef": $("#buyCoef").val(),
|
"v3BuyCoef": $("#v3BuyCoef").val(),
|
"v3BrokerageCoef": $("#v3BrokerageCoef").val(),
|
"v4BuyCoef": $("#v4BuyCoef").val(),
|
"v4BrokerageCoef": $("#v4BrokerageCoef").val(),
|
"v5BuyCoef": $("#v5BuyCoef").val(),
|
"v5BrokerageCoef": $("#v5BrokerageCoef").val(),
|
}
|
return set;
|
}
|
|
MallGoodsInfoDlg.clear_move_table = function() {
|
this.moveTable && this.moveTable.clear();
|
this.specs_item = {};
|
}
|
|
|
MallGoodsInfoDlg.chooseGoodsGroupSpec = function() {
|
$.ajax({
|
url : Feng.ctxPath + "/mallGoodsGroup/groupSpecByIdsList",
|
type : "get",
|
data : {"ids": Feng.getMultipleSelectVal("goodsIds")},
|
dataType : "json",
|
success : function (list) {
|
let goodsSelectTbodyStr = '';
|
$.each(list, function(i, item) {
|
goodsSelectTbodyStr += "<tr class='specGroup'>"
|
+ "<td>"
|
+ "<input class='inputSpec' type='hidden' value='" + item.id + "'>"
|
+ "<input class='inputSpec' type='hidden' value='" + item.specName + "'>"
|
+ item.specName + "</td>"
|
+ "<td>" + item.goodsNames + "</td>"
|
+ "<td style='text-align: center;'><input class='inputSpec' type='hidden' value='" + item.stock + "'>" + item.stock + "</td>"
|
+ "<td style='text-align: center;'>" + item.provinceName + "</td>"
|
+ "<td style='text-align: center;'><input class='inputSpec' type='number' value='" + item.priceMerchant + "'></td>"
|
+ "</tr>"
|
});
|
|
$("#goodsSelectTbody").html(goodsSelectTbodyStr);
|
}
|
});
|
}
|
MallGoodsInfoDlg.chooseGoodsGroupSpecDetail = function() {
|
$.ajax({
|
url : Feng.ctxPath + "/mallGoodsGroup/groupSpecByIdsList",
|
type : "get",
|
data : {"ids": Feng.getMultipleSelectVal("goodsIds")},
|
dataType : "json",
|
success : function (list) {
|
let goodsSelectTbodyStr = '';
|
$.each(list, function(i, item) {
|
goodsSelectTbodyStr += "<tr class='specGroup'>"
|
+ "<td>"
|
+ "<input class='inputSpec' type='hidden' value='" + item.id + "'>"
|
+ "<input class='inputSpec' type='hidden' value='" + item.specName + "'>"
|
+ item.specName + "</td>"
|
+ "<td>" + item.goodsNames + "</td>"
|
+ "<td>" + item.totalPrice + "</td>"
|
+ "<td style='text-align: center;'><input class='inputSpec' type='hidden' value='" + item.stock + "'>" + item.stock + "</td>"
|
+ "<td style='text-align: center;'>" + item.provinceName + "</td>"
|
+ "<td style='text-align: center;'><input class='inputSpec' type='number' value='" + item.priceMerchant + "'></td>"
|
+ "</tr>"
|
});
|
|
$("#goodsSelectTbody").html(goodsSelectTbodyStr);
|
}
|
});
|
}
|
|
/**
|
* 提交添加
|
*/
|
MallGoodsInfoDlg.addSubmit = function() {
|
this.clearData();
|
this.collectData();
|
|
if ( !Feng.check_form( "formId")) { return; }
|
|
this.mallGoodsInfoData.goodsSkusJson = JSON.stringify(MallGoodsInfoDlg.getSpecGroup());
|
this.mallGoodsInfoData.goodsSetJson = JSON.stringify(MallGoodsInfoDlg.getGoodsSet());
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/mallGoodsGroup/add", function(data){
|
if(data.code == 200){
|
Feng.success("添加成功!");
|
window.parent.MallGoods.table.refresh();
|
MallGoodsInfoDlg.close();
|
} else {
|
Feng.error("添加失败!" + data.message);
|
}
|
},function(){
|
Feng.error("添加失败!");
|
});
|
ajax.set(this.mallGoodsInfoData);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
MallGoodsInfoDlg.editSubmit = function() {
|
this.clearData();
|
this.collectData();
|
|
if ( !Feng.check_form( "formId")) { return; }
|
|
this.mallGoodsInfoData.goodsSkusJson = JSON.stringify(MallGoodsInfoDlg.getSpecGroup());
|
this.mallGoodsInfoData.goodsSetJson = JSON.stringify(MallGoodsInfoDlg.getGoodsSet());
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/mallGoodsGroup/update", function(data){
|
if(data.code == 200){
|
Feng.success("修改成功!");
|
window.parent.MallGoods.table.refresh();
|
MallGoodsInfoDlg.close();
|
} else {
|
Feng.error("修改失败!" + data.message);
|
}
|
},function(){
|
Feng.error("修改失败!");
|
});
|
ajax.set(this.mallGoodsInfoData);
|
ajax.start();
|
};
|
|
MallGoodsInfoDlg.editBuyCountSubmit = function() {
|
// 提交信息
|
var ajax = new $ax(Feng.ctxPath + "/mallGoodsGroup/updateBuyCount", function(data){
|
if(data.code == 200){
|
Feng.success("修改成功!");
|
window.parent.MallGoods.table.refresh();
|
MallGoodsInfoDlg.close();
|
} else {
|
Feng.error("修改失败!" + data.message);
|
}
|
},function(){
|
Feng.error("修改失败!");
|
});
|
ajax.set("mallGoodsId", $("#id").val());
|
ajax.set("buyCount", $("#buyCount").val());
|
ajax.start();
|
};
|
|
$(function() {
|
$("#tagIds").val((($("#tagIds").data("value")||"")+"").split(","));
|
|
Feng.initValidator( "formId", MallGoodsInfoDlg.validFields);
|
});
|