diff --git a/src/main/resources/templates/pages/application/application_multi.html b/src/main/resources/templates/pages/application/application_multi.html index a6882dd6..f417fe14 100644 --- a/src/main/resources/templates/pages/application/application_multi.html +++ b/src/main/resources/templates/pages/application/application_multi.html @@ -17,6 +17,7 @@ margin-top: -10px; margin-left: -15px; } + /* .laytable-cell-1-0-7 { overflow: visible !important; } @@ -24,35 +25,38 @@ */ - -
-
@@ -82,10 +86,10 @@ }, response: { statusName: 'status' //规定数据状态的字段名称,默认:code - ,statusCode: 200 //规定成功的状态码,默认:0 - ,msgName: 'message' //规定状态信息的字段名称,默认:msg - ,countName: 'count' //规定数据总数的字段名称,默认:count - ,dataName: 'data' //规定数据列表的字段名称,默认:data + , statusCode: 200 //规定成功的状态码,默认:0 + , msgName: 'message' //规定状态信息的字段名称,默认:msg + , countName: 'count' //规定数据总数的字段名称,默认:count + , dataName: 'data' //规定数据列表的字段名称,默认:data }, height: 'full-255',//固定高度-即固定表头固定第一行首行 toolbar: '#toolbarDemo', @@ -94,16 +98,16 @@ {type: "checkbox", width: 50}, {field: 'mname', width: 150, title: '物料名称'}, {field: 'version', width: 150, title: '规格型号'}, - {field: 'code',width: 200,title: '存货编码',sort: true}, + {field: 'code', width: 200, title: '存货编码', sort: true}, {title: '所处位置', width: 200, templet: '#selectLocation', align: "center"}, {field: 'depositoryName', width: 150, title: '仓库名称'}, {title: '计量单位', width: 200, templet: '#changeUnit', align: "center"}, - {field: 'quantity', width: 150, title: '数量',edit:'quantity'}, - {field: 'applyRemark', width: 150, title: '备注说明',edit:'applyRemark'}, + {field: 'quantity', width: 150, title: '数量', edit: 'quantity'}, + {field: 'applyRemark', width: 150, title: '备注说明', edit: 'applyRemark'}, {title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"} ] ], - limits: [10, 15, 20, 25, 50,100], + limits: [10, 15, 20, 25, 50, 100], limit: 10, page: true, skin: 'line', @@ -118,8 +122,21 @@ // console.log(obj) }); - table.on('edit(currentTableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" + table.on('edit(currentTableFilter)', function (obj) { //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" // console.log(obj.data); //所在行的所有相关数据 + let data = obj.data; + let quantity = data.quantity; + let mcode = data.code; + let unit = data.unit; + let depositoryId = data.depositoryId; + let req = {}; + req.mcode = mcode; + req.quantity = quantity; + req.unit = unit; + req.placeId = -1; + req.depositoryId = depositoryId; + MaterialQuantityIsTrue(req,obj); + }); /** @@ -147,11 +164,11 @@ req.units[i] = data[i].unit; } - if(obj.event==='delete'){ - if(req.mids.length > 0) { + if (obj.event === 'delete') { + if (req.mids.length > 0) { layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { for (i = 0, len = data.length; i < len; i++) { - req.placeCodes[i] = data[i].placeCodes.toString().replace(","," ") + req.placeCodes[i] = data[i].placeCodes.toString().replace(",", " ") } $.ajax({ url: "/depositoryRecord/deleteApplicationToRedis", @@ -178,18 +195,16 @@ }) }) - } - else{ + } else { layer.msg("未选中记录,请确认!"); return false; } - } - else if(obj.event === 'applicationIn'){ + } else if (obj.event === 'applicationIn') { req.type = 'in'; $.ajax({ - url:"/depositoryRecord/createMultiApplications", - type:"post", - data:JSON.stringify(req), + url: "/depositoryRecord/createMultiApplications", + type: "post", + data: JSON.stringify(req), dataType: "json", contentType: "application/json;charset=utf-8", success: function (d) { @@ -202,38 +217,37 @@ icon: 6,//成功的表情 time: 1000 }, //1秒关闭(如果不配置,默认是3秒) - function(){ + function () { //do something - window.location="/application_multi" + window.location = "/application_multi" }); } } }); return false; - } - else if(obj.event === 'applicationOut'){ + } else if (obj.event === 'applicationOut') { req.type = 'out'; $.ajax({ - url:"/depositoryRecord/createMultiApplications", - type:"post", - data:JSON.stringify(req), + url: "/depositoryRecord/createMultiApplications", + type: "post", + data: JSON.stringify(req), dataType: "json", contentType: "application/json;charset=utf-8", success: function (d) { layer.close(this.layerIndex); if (d.status >= 300) { - layer.msg(d.statusInfo.detail,{ - icon:0, - time:1000 - },function () { - obj.update({quantity:1}) + layer.msg(d.statusInfo.detail, { + icon: 0, + time: 1000 + }, function () { + obj.update({quantity: 1}) });//失败的表情 return; - }else if(d.status === 1234){ - layer.msg(d.data,{ - icon:0, - time:1000 - },function () { + } else if (d.status === 1234) { + layer.msg(d.data, { + icon: 0, + time: 1000 + }, function () { table.reload('currentTableId', { url: '/depositoryRecord/applicant_multi_create', page: { @@ -242,13 +256,12 @@ }); }); return - } - else { + } else { layer.msg("申请成功!", { icon: 6,//成功的表情 time: 1000 }, //1秒关闭(如果不配置,默认是3秒) - function() { + function () { //do something table.reload('currentTableId', { url: '/depositoryRecord/applicant_multi_create', @@ -269,60 +282,59 @@ let data = obj.data; if (obj.event === 'applicationIn') { // 入库申请 - var req = data; - req.type = "in"; - $.ajax({ - url:"/depositoryRecord/createMultiApplication", - type:"post", - data:JSON.stringify(req), - dataType: "json", - contentType: "application/json;charset=utf-8", - success: function (d) { - layer.close(this.layerIndex); - if (d.status >= 300) { - layer.msg(d.statusInfo.message);//失败的表情 - return; - } else { - layer.msg("申请成功!", { - icon: 6,//成功的表情 - time: 1000 - }, //1秒关闭(如果不配置,默认是3秒) - function(){ - //do something - window.location="/application_multi" - }); - } - } - }); + var req = data; + req.type = "in"; + $.ajax({ + url: "/depositoryRecord/createMultiApplication", + type: "post", + data: JSON.stringify(req), + dataType: "json", + contentType: "application/json;charset=utf-8", + success: function (d) { + layer.close(this.layerIndex); + if (d.status >= 300) { + layer.msg(d.statusInfo.message);//失败的表情 + return; + } else { + layer.msg("申请成功!", { + icon: 6,//成功的表情 + time: 1000 + }, //1秒关闭(如果不配置,默认是3秒) + function () { + //do something + window.location = "/application_multi" + }); + } + } + }); return false; - } - else if(obj.event === 'applicationOut'){ + } else if (obj.event === 'applicationOut') { // 出库申请 var req = data; req.type = "out"; $.ajax({ - url:"/depositoryRecord/createMultiApplication", - type:"post", - data:JSON.stringify(req), + url: "/depositoryRecord/createMultiApplication", + type: "post", + data: JSON.stringify(req), dataType: "json", contentType: "application/json;charset=utf-8", success: function (d) { layer.close(this.layerIndex); if (d.status >= 300) { - layer.msg(d.statusInfo.detail,{ - icon:0, - time:1000 - },function () { - obj.update({quantity:1}); + layer.msg(d.statusInfo.detail, { + icon: 0, + time: 1000 + }, function () { + obj.update({quantity: 1}); });//失败的表情 } else { layer.msg("申请成功!", { icon: 6,//成功的表情 time: 1000 }, //1秒关闭(如果不配置,默认是3秒) - function(){ + function () { //do something - window.location="/application_multi" + window.location = "/application_multi" }); } } @@ -330,53 +342,74 @@ return false; - } - else if (obj.event === 'changeUnit') { + } else if (obj.event === 'changeUnit') { let splitInfoList = data.splitInfoList; - let btn = $("#btn_unit_"+data.iid); + let btn = $("#btn_unit_" + data.iid); let clickNum = Number(btn.attr("click_num")); - if(splitInfoList.length > 0){ - if(clickNum < splitInfoList.length){ - let newUnit = splitInfoList[clickNum].newUnit; + if (splitInfoList.length > 0) { + if (clickNum < splitInfoList.length) { + let newUnit = splitInfoList[clickNum].newUnit; btn.text(newUnit); clickNum += 1; - btn.attr("click_num",clickNum); - obj.update({unit:newUnit}) - }else{ + btn.attr("click_num", clickNum); + obj.update({unit: newUnit}) + } else { btn.text(data.showUnit); - obj.update({unit:"-1"}); - btn.attr("click_num",0); + obj.update({unit: "-1"}); + btn.attr("click_num", 0); } } - } - else if(obj.event === 'selectLocation'){ - let btn = $("#btn_placeCode_"+data.iid); + } else if (obj.event === 'selectLocation') { + let btn = $("#btn_placeCode_" + data.iid); let placeCodes = data.placeCodes; let clickNum = Number(btn.attr("click_num")); - if(clickNum === 0){ + if (clickNum === 0) { clickNum += 1; } - if(placeCodes.length > 1){ - if(clickNum < placeCodes.length){ + if (placeCodes.length > 1) { + if (clickNum < placeCodes.length) { let placeCode = placeCodes[clickNum]; clickNum += 1; - btn.attr("click_num",clickNum); + btn.attr("click_num", clickNum); btn.text(placeCode); - obj.update({placeCode:placeCode}) - }else{ + obj.update({placeCode: placeCode}) + } else { btn.text(placeCodes[0]); - obj.update({placeCode:placeCodes[0]}); - btn.attr("click_num",0); + obj.update({placeCode: placeCodes[0]}); + btn.attr("click_num", 0); } } } }); - $('body').on('click', '[data-refresh]', function () { - location.reload(); - }) + // 用于判断当前数量是否合法 + MaterialQuantityIsTrue = function (req, obj) { + let loading2 = layer.open({type: 3, shade: [0.25, '#000'], icon: 2, speed: 0}); + $.ajax({ + url: "/material/MaterialQuantityIsTrue", + type: "post", + data: JSON.stringify(req), + dataType: 'json', + contentType: "application/json;charset=utf-8", + success: function (res) { + var flag = res.data; + if (!flag) { // 如果当前数目不合适 + layer.msg("当前单个仓库中物料数量不足", {icon: 0, time: 500}, function () { + layer.close(loading2); + obj.update({quantity: 1}) + }, + ); + } else { + layer.close(loading2) + } + + } + }); + + }; + });