...
|
...
|
@@ -6,7 +6,9 @@ var common = require('../common/common'); |
|
|
var util = require('../common/util');
|
|
|
|
|
|
var hasClickEvent = false;//判断保存按钮是否有点击事件;
|
|
|
|
|
|
//定义全局数据变量
|
|
|
var dataList={};
|
|
|
//点击搜索按钮
|
|
|
$(document).on('click', '#searchSku', function () {
|
|
|
var val = $.trim($("#skuInput").val());
|
|
|
if (!val.match(/^[0-9]+$/)) {
|
...
|
...
|
@@ -21,104 +23,117 @@ $(document).on('click', '#searchSku', function () { |
|
|
}, function (res) {
|
|
|
if (res.data.list && res.data.list.length > 0) {
|
|
|
var e = new common.edit("#add-list");
|
|
|
|
|
|
var item = res.data.list[0];
|
|
|
dataList = res.data.list[0];
|
|
|
//拼接分类字符串
|
|
|
var a = dataList.productType.replace(/<br>/g, "/");
|
|
|
dataList.productType = a.substring(0, a.length - 1);
|
|
|
var headList = [];
|
|
|
var j = 0;//创造一个变量以供赋值
|
|
|
if (item.sizeRelationsList.length > 0) {
|
|
|
if (dataList.sizeRelationsList.length > 0) {
|
|
|
headList.push({display: "尺码", name: "sizeName"});//尺码
|
|
|
headList.push({
|
|
|
display: "参考尺码(" + item.genderName + ")", name: "referenceName", render: function (item) {//参考尺码列
|
|
|
var refName = item.referenceName ? item.referenceName : "";//非空判断
|
|
|
var a =refName.split(/[|/]/g);
|
|
|
var refName1=a[0]||"",refName2=a[1]||"";
|
|
|
console.log("refName",item);
|
|
|
return '<input class="col-sm-2 refInfo refInfo1" data-index="' + item.__index + '"' + 'value="' + refName1 + '"/>'+'<div class="col-sm-1">'+'/</div>'+'<input class="col-sm-2 refInfo refInfo2" data-index="' + item.__index + '"' + 'value="' + refName2 + '"/>';
|
|
|
display: "参考尺码(" + dataList.genderName + ")", name: "referenceName", render: function (item1) {//参考尺码列
|
|
|
var refName = item1.referenceName ? item1.referenceName : "";//非空判断
|
|
|
var a = refName.split(/[|/]/g);
|
|
|
var refName1 = a[0] || "", refName2 = a[1] || "";
|
|
|
return '<input class="col-sm-2 refInfo refInfo1" data-index="' + item1.__index + '"' + 'value="' + refName1 + '"/>' + '<div class="col-sm-1">' + '/</div>' + '<input class="col-sm-2 refInfo refInfo2" data-index="' + item1.__index + '"' + 'value="' + refName2 + '"/>';
|
|
|
}
|
|
|
});
|
|
|
for (var i = 0; i < item.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
|
|
|
var sizeAttributes = item.sizeRelationsList[0].prdSizeAttributeBoList[i];//参考尺码数组里的数据
|
|
|
for (var i = 0; i < dataList.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
|
|
|
var sizeAttributes = dataList.sizeRelationsList[0].prdSizeAttributeBoList[i];//参考尺码数组里的数据
|
|
|
var chkbox = '<label style="cursor: pointer;"><input type="checkbox" name="noMeasureIds" value="' + sizeAttributes.sizeAttributeId + '"/>无需测量</label>';
|
|
|
headList.push({
|
|
|
display: sizeAttributes.sizeAttributeName + "<br>" + chkbox,
|
|
|
name: "sizeValue",
|
|
|
render: function (item) {
|
|
|
var prdList = item.prdSizeAttributeBoList;
|
|
|
render: function (item1) {
|
|
|
var prdList = item1.prdSizeAttributeBoList;
|
|
|
if (j == prdList.length) j = 0;//防止越界
|
|
|
var sizeVal = prdList[j].sizeValue ? prdList[j].sizeValue : "";
|
|
|
//j++;//
|
|
|
return '<input class="form-control sizeInfo ' + prdList[j++].sizeAttributeId
|
|
|
+ '" data-index="' + item.__index + '"' + 'value="' + sizeVal + '"/>';
|
|
|
+ '" data-index="' + item1.__index + '"' + 'value="' + sizeVal + '"/>';
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var grid = new common.grid({
|
|
|
el: "#content-list",
|
|
|
hash: false,
|
|
|
columns: headList
|
|
|
});
|
|
|
grid.init(item.sizeRelationsList);
|
|
|
//$("#add-saveArea").show();
|
|
|
$("#add-head").html(common.util.__template2($("#modifySize-template").html(), item));
|
|
|
$("#noMeasureIds").val(item.noMeasureIds ? item.noMeasureIds.join("|") : "");
|
|
|
grid.init(dataList.sizeRelationsList);
|
|
|
$("#add-head").html(common.util.__template2($("#modifySize-template").html(), dataList));
|
|
|
$("#noMeasureIds").val(dataList.noMeasureIds ? dataList.noMeasureIds.join("|") : "");
|
|
|
$("#add-list").show();
|
|
|
e.init();
|
|
|
if (!hasClickEvent) {
|
|
|
hasClickEvent = true;
|
|
|
$(document).on('click', '#add-saveBtn', function () {
|
|
|
|
|
|
var flag = false;
|
|
|
$("input[name='noMeasureIds']").not("input:checked").each(function () {
|
|
|
$("." + $(this).val()).each(function () {
|
|
|
if (!$(this).val()) {
|
|
|
flag = true;
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
if (flag) return false;
|
|
|
});
|
|
|
if (flag) {
|
|
|
util.__tip("请将没有勾选无需测量的列填写完整!", "warning");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//var flag = false;
|
|
|
//$("input[name='noMeasureIds']").not("input:checked").each(function () {
|
|
|
// $("." + $(this).val()).each(function () {
|
|
|
// if (!$(this).val()) {
|
|
|
// flag = true;
|
|
|
// return false;
|
|
|
// }
|
|
|
// });
|
|
|
// if (flag) return false;
|
|
|
//});
|
|
|
//if (flag) {
|
|
|
// util.__tip("请将没有勾选无需测量的列填写完整!", "warning");
|
|
|
// return false;
|
|
|
//}
|
|
|
//var flag = false;
|
|
|
//$("input[name='noMeasureIds']").not("input:checked").each(function () {
|
|
|
// $("." + $(this).val()).each(function () {
|
|
|
// if (!$(this).val()) {
|
|
|
// flag = true;
|
|
|
// return false;
|
|
|
// }
|
|
|
// });
|
|
|
// if (flag) return false;
|
|
|
//});
|
|
|
//if (flag) {
|
|
|
// util.__tip("请将没有勾选无需测量的列填写完整!", "warning");
|
|
|
// return false;
|
|
|
//}
|
|
|
var noMeasureIds = JSON.stringify($("#noMeasureIds").val() ? $("#noMeasureIds").val().split("|") : []);//无需测量的列
|
|
|
//尺码信息列表
|
|
|
var sizeInfoList = [];
|
|
|
for (var i = 0; i < $(".sizeInfo").length; i++) {
|
|
|
var info = $($(".sizeInfo")[i]);//当前尺码input对象
|
|
|
var prdList = grid.rows[info.data("index")].prdSizeAttributeBoList;//当前列的对象的尺码列表
|
|
|
var prdList = dataList.sizeRelationsList[info.data("index")].prdSizeAttributeBoList;//当前列的对象的尺码列表
|
|
|
var attrIndex = parseInt(i % prdList.length);//在当前列的索引
|
|
|
sizeInfoList[i] = ({
|
|
|
productSkn: item.productSkn,
|
|
|
sizeId: grid.rows[info.data("index")].sizeId,
|
|
|
productSkn: dataList.productSkn,
|
|
|
sizeId: dataList.sizeRelationsList[info.data("index")].sizeId,
|
|
|
sizeAttributeId: prdList[attrIndex].sizeAttributeId,
|
|
|
sizeValue: info.val()
|
|
|
});
|
|
|
}
|
|
|
//商品参考尺码
|
|
|
var productSizeReferList = [];
|
|
|
for (var i = 0; i < $(".refInfo").length/2; i++) {
|
|
|
for (var i = 0; i < $(".refInfo").length / 2; i++) {
|
|
|
var ref1 = $($(".refInfo1")[i]);
|
|
|
var ref2 = $($(".refInfo2")[i]);
|
|
|
productSizeReferList.push({
|
|
|
sizeId: grid.rows[ref1.data("index")].sizeId,
|
|
|
gender: item.gender,
|
|
|
referenceName: ref1.val()+'/'+ref2.val()
|
|
|
sizeId: dataList.sizeRelationsList[ref1.data("index")].sizeId,
|
|
|
gender: dataList.gender,
|
|
|
referenceName: ref1.val() + '/' + ref2.val()
|
|
|
});
|
|
|
console.log("productSizeReferList",productSizeReferList);
|
|
|
}
|
|
|
var data = {
|
|
|
productSkn: dataList.productSkn,
|
|
|
noMeasureIds: noMeasureIds,
|
|
|
sizeInfoList: JSON.stringify(sizeInfoList),
|
|
|
productSizeReferList: JSON.stringify(productSizeReferList)
|
|
|
};
|
|
|
common.util.__ajax({
|
|
|
url: "/meterManage/productSize/saveProdSizeInfo",
|
|
|
data: {
|
|
|
productSkn: item.productSkn,
|
|
|
noMeasureIds: noMeasureIds,
|
|
|
sizeInfoList: JSON.stringify(sizeInfoList),
|
|
|
productSizeReferList: JSON.stringify(productSizeReferList)
|
|
|
data: data
|
|
|
}, function (res) {
|
|
|
if(res.code=='200'){
|
|
|
}
|
|
|
}, function () {
|
|
|
|
|
|
});
|
|
|
return false;
|
|
|
});
|
...
|
...
|
|