Authored by 陶雨

尺码测量

... ... @@ -5,6 +5,8 @@ var $ = require('jquery'),
common = require('../common/common'),
util = require('../common/util');
var hasClickEvent = false//判断保存按钮是否有点击事件;
$(document).on('click', '#searchSku', function() {
var val = $.trim($("#skuInput").val());
if(!val.match(/^[0-9]+$/)) {
... ... @@ -12,6 +14,7 @@ $(document).on('click', '#searchSku', function() {
return;
}
if(val) {
$("#add-list").hide();
common.util.__ajax({
url:'/meterManage/productSize/queryProdSizeList',
data:{productSku:val}
... ... @@ -19,20 +22,6 @@ $(document).on('click', '#searchSku', function() {
if(res.data.list && res.data.list.length > 0) {
var e = new common.edit("#add-list");
e.on('validate', 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)
return "请将没有勾选无需测量的列填写完整!";
});
var item = res.data.list[0];
var headList = [];
var j = 0;//创造一个变量以供赋值
... ... @@ -45,16 +34,18 @@ $(document).on('click', '#searchSku', function() {
}
});
for (var i = 0; i < item.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
var sizeAttributes = item.sizeRelationsList[0].prdSizeAttributeBoList[i];// 码数组里的数据
var sizeAttributes = item.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) {
if (j == item.prdSizeAttributeBoList.length) j = 0;//防止越界
var sizeVal = item.prdSizeAttributeBoList[j].sizeValue ? item.prdSizeAttributeBoList[j].sizeValue : "";
var prdList = item.prdSizeAttributeBoList;
if (j == prdList.length) j = 0;//防止越界
var sizeVal = prdList[j].sizeValue ? prdList[j].sizeValue : "";
//j++;//
return '<input class="form-control sizeInfo '+ item.prdSizeAttributeBoList[j++].sizeAttributeId +'" data-index="' + item.__index + '"' + 'value="' + sizeVal + '"/>';
return '<input class="form-control sizeInfo '+ prdList[j++].sizeAttributeId
+'" data-index="' + item.__index + '"' + 'value="' + sizeVal + '"/>';
}
});
}
... ... @@ -66,53 +57,76 @@ $(document).on('click', '#searchSku', function() {
columns:headList
});
grid.init(item.sizeRelationsList);
$("#add-saveArea").show();
//$("#add-saveArea").show();
$("#add-head").html(common.util.__template2($("#modifySize-template").html(), item));
$("#noMeasureIds").val(item.noMeasureIds? item.noMeasureIds.join("|"):"");
$("#add-list").show();
e.init();
$(document).on('click', '#add-saveBtn', function() {
e.submit("/meterManage/productSize/saveProdSizeInfo",function(option){
//option.data;=
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;
}
option.data.productSkn = item.productSkn;
option.data.noMeasureIds = $("#noMeasureIds").val()?$("#noMeasureIds").val().split("|"):[];
option.data.noMeasureIds = JSON.stringify(option.data.noMeasureIds);
option.data.sizeInfoList = [];
var noMeasureIds = JSON.stringify($("#noMeasureIds").val()?$("#noMeasureIds").val().split("|"):[]);//无需测量的列
//尺码信息列表
var sizeInfoList = [];
for(var i = 0; i < $(".sizeInfo").length; i++){
var info = $($(".sizeInfo")[i]);
option.data.sizeInfoList[i] = ({
var info = $($(".sizeInfo")[i]);//当前尺码input对象
var prdList = grid.rows[info.data("index")].prdSizeAttributeBoList;//当前列的对象的尺码列表
var attrIndex = parseInt(i%prdList.length);//在当前列的索引
sizeInfoList[i] = ({
productSkn: item.productSkn,
sizeId:grid.rows[info.data("index")].sizeId,
sizeAttributeId:grid.rows[info.data("index")].prdSizeAttributeBoList[parseInt(i%grid.rows[info.data("index")].prdSizeAttributeBoList.length)].sizeAttributeId,
sizeAttributeId:prdList[attrIndex].sizeAttributeId,
sizeValue:info.val()
});
}
option.data.sizeInfoList = JSON.stringify(option.data.sizeInfoList);
option.data.productSizeReferList = [];
//商品参考尺码
var productSizeReferList = [];
for(var i = 0; i < $(".refInfo").length; i++) {
var ref = $($(".refInfo")[i]);
option.data.productSizeReferList.push({
productSizeReferList.push({
sizeId: grid.rows[ref.data("index")].sizeId,
gender: item.gender,
referenceName: ref.val()
});
}
option.data.productSizeReferList = JSON.stringify(option.data.productSizeReferList);
option.success=function(res){
util.__tip(res.data.message, 'success');
grid.reload();
};
option.error=function(res){
//dialog.close();
util.__tip(res.message);
}
common.util.__ajax({
url:"/meterManage/productSize/saveProdSizeInfo",
data:{
productSkn: item.productSkn,
noMeasureIds: noMeasureIds,
sizeInfoList: JSON.stringify(sizeInfoList),
productSizeReferList: JSON.stringify(productSizeReferList)
}
},function() {
});
return false;
});
return false;
});
}
}else {
util.__tip("未搜索到sku:" + val);
}
},true);
}
});
$("#skuInput").keydown(function() {
if(event.keyCode == "13") {
$("#searchSku").click();
}
});
\ No newline at end of file
... ...
... ... @@ -9,12 +9,10 @@ var $ = require('jquery'),
new common.edit("#filter").init();
//new common.dropDown({el: "#brand-filter", "ajax": "getSelectItems"});
new common.dropDown({el: "#hasMeasure-filter"});
new common.dropDown({el: "#brand-filter", ajax: "brand",params:function(){
return {status:1};
}});
//new common.dropDown({el: "#category-filter", "ajax": "getHelpCategory"});
var tabTree=new common.tabTree("#category-filter",{
columns: [{
... ... @@ -26,8 +24,6 @@ var tabTree=new common.tabTree("#category-filter",{
datas:[{id:"",name:""}]
});
tabTree.init();
//tabTree.getAddress()&&tabTree.getAddress()[0].id
//tabTree.isfeeze=true;
var g = new common.grid({
el: "#content-list",
... ... @@ -90,67 +86,65 @@ var Bll = {
toast:function(url, item, hint) {
var e = new common.edit("#nidaye");
e.on('validate', 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)
return "请将没有勾选无需测量的列填写完整!";
});
var dialog=new common.dialog({
title:hint,
content:'<div id="nidaye"><input type="hidden" id="noMeasureIds" for="checkbox">'+ common.util.__template2($("#modifySize-template").html(), item) +'<div id="faGrid" style="height: 600px;overflow:auto;"></div></div>',
content:'<div id="nidaye"><input type="hidden" id="noMeasureIds" for="checkbox">'
+ common.util.__template2($("#modifySize-template").html(), item)
+ '<div id="faGrid" style="height: 600px;overflow:auto;"></div></div>',
width: "90%",
button:[{
value:"提交",
callback:function(){
e.submit(url,function(option){
//option.data;=
option.data.productSkn = item.productSkn;
option.data.noMeasureIds = $("#noMeasureIds").val()?$("#noMeasureIds").val().split("|"):[];
option.data.noMeasureIds = JSON.stringify(option.data.noMeasureIds);
option.data.sizeInfoList = [];
for(var i = 0; i < $(".sizeInfo").length; i++){
var info = $($(".sizeInfo")[i]);
option.data.sizeInfoList[i] = ({
productSkn: item.productSkn,
sizeId:grid.rows[info.data("index")].sizeId,
sizeAttributeId:grid.rows[info.data("index")].prdSizeAttributeBoList[parseInt(i%grid.rows[info.data("index")].prdSizeAttributeBoList.length)].sizeAttributeId,
sizeValue:info.val()
});
}
option.data.sizeInfoList = JSON.stringify(option.data.sizeInfoList);
option.data.productSizeReferList = [];
for(var i = 0; i < $(".refInfo").length; i++) {
var ref = $($(".refInfo")[i]);
option.data.productSizeReferList.push({
sizeId: grid.rows[ref.data("index")].sizeId,
gender: item.gender,
referenceName: ref.val()
});
}
option.data.productSizeReferList = JSON.stringify(option.data.productSizeReferList);
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;
}
option.success=function(res){
dialog.close();
util.__tip(res.data.message, 'success');
g.reload();
};
option.error=function(res){
//dialog.close();
util.__tip(res.message);
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 attrIndex = parseInt(i%prdList.length);//在当前列的索引
sizeInfoList[i] = ({
productSkn: item.productSkn,
sizeId:grid.rows[info.data("index")].sizeId,
sizeAttributeId:prdList[attrIndex].sizeAttributeId,
sizeValue:info.val()
});
}
//商品参考尺码
var productSizeReferList = [];
for(var i = 0; i < $(".refInfo").length; i++) {
var ref = $($(".refInfo")[i]);
productSizeReferList.push({
sizeId: grid.rows[ref.data("index")].sizeId,
gender: item.gender,
referenceName: ref.val()
});
}
common.util.__ajax({
url:url,
data:{
productSkn: item.productSkn,
noMeasureIds: noMeasureIds,
sizeInfoList: JSON.stringify(sizeInfoList),
productSizeReferList: JSON.stringify(productSizeReferList)
}
},function() {
g.reload();
});
return false;
}},
{
value:"取消"
... ... @@ -167,16 +161,18 @@ var Bll = {
}
});
for (var i = 0; i < item.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
var sizeAttributes = item.sizeRelationsList[0].prdSizeAttributeBoList[i];// 码数组里的数据
var sizeAttributes = item.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) {
if (j == item.prdSizeAttributeBoList.length) j = 0;//防止越界
var sizeVal = item.prdSizeAttributeBoList[j].sizeValue ? item.prdSizeAttributeBoList[j].sizeValue : "";
var prdList = item.prdSizeAttributeBoList;
if (j == prdList.length) j = 0;//防止越界
var sizeVal = prdList[j].sizeValue ? prdList[j].sizeValue : "";
//j++;//
return '<input class="form-control sizeInfo '+ item.prdSizeAttributeBoList[j++].sizeAttributeId +'" data-index="' + item.__index + '"' + 'value="' + sizeVal + '"/>';
return '<input class="form-control sizeInfo '+ prdList[j++].sizeAttributeId
+'" data-index="' + item.__index + '"' + 'value="' + sizeVal + '"/>';
}
});
}
... ...
... ... @@ -4,7 +4,7 @@
*/
exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.162:8088/platform'; //李建
//exports.domain = 'http://192.168.102.216:8180/platform'; //测试环境
//exports.domain = 'http://192.168.102.216:8180/platform'; //开发环境
exports.res = [
... ...
... ... @@ -27,17 +27,17 @@
<input type="text" class="form-control" id="skuInput" />
</div>
<div class="panel-col">
<input type="button" class="btn" value="搜索" id="searchSku" />
<input type="button" class="btn btn-info" value="搜索" id="searchSku" />
</div>
</div>
</div>
</div>
<div id="add-list">
<div id="add-list" hidden>
<input type="hidden" id="noMeasureIds" for="checkbox">
<div id="add-head"></div>
<div id="content-list"></div>
<div id="add-saveArea" hidden="hidden">
<input type="button" class="btn" value="保存" id="add-saveBtn" />
<div id="add-saveArea">
<input type="button" class="btn btn-primary" value="保存" id="add-saveBtn" />
</div>
</div>
</div>
... ...