From cf12fd3b3410d9234ae25a7d3a1812661241006b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 20 六月 2020 16:37:52 +0800
Subject: [PATCH] #
---
src/main/webapp/static/js/pakStore/pakStore.js | 185 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 145 insertions(+), 40 deletions(-)
diff --git a/src/main/webapp/static/js/pakStore/pakStore.js b/src/main/webapp/static/js/pakStore/pakStore.js
index 24ad683..2e2c251 100644
--- a/src/main/webapp/static/js/pakStore/pakStore.js
+++ b/src/main/webapp/static/js/pakStore/pakStore.js
@@ -1,3 +1,7 @@
+
+var initCountVal = 0;
+var matCodeData = [];
+
layui.use(['table','laydate', 'form'], function() {
var table = layui.table;
var $ = layui.jquery;
@@ -13,39 +17,25 @@
cellMinWidth: 50,
toolbar: '#toolbar',
cols: [[
- {type: 'checkbox'},
- {field: 'matNo', align: 'center', title: '鐗╂枡缂栫爜', sort: 'true'},
+ {fixed: 'left', field: 'count', title: '鏁伴噺(蹇呭~)', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'},
+ {field: 'matNo', align: 'center', title: '鐗╂枡缂栫爜'},
{field: 'barcode', align: 'center', title: '鏉$爜'},
{field: 'matName', align: 'center', title: '鐗╂枡鍚嶇О'},
{field: 'str1', align: 'center', title: '鐗╂枡鍗曚綅'},
{field: 'str2', align: 'center', title: '鐗╂枡瑙勬牸'},
- {field: 'count', title: '鏁伴噺', align: 'center', edit:'text', width: 100}
+ {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:80}
]],
done: function (res, curr, count) {
+ $('td[data-field=count] div').html(initCountVal);
+ setMatCodeData(res.data);
+ limit();
+ getInBound();
}
});
- // 鐩戝惉鎺掑簭浜嬩欢
- table.on('sort(chooseData)', function (obj) {
- var searchData = {};
- $.each($('#search-box [name]').serializeArray(), function() {
- searchData[this.name] = this.value;
- });
- searchData['orderByField'] = obj.field;
- searchData['orderByType'] = obj.type;
- matQueryTable.reload({
- where: searchData,
- page: {
- curr: 1
- },
- done: function (res, curr, count) {
- if (res.code === 403) {
- top.location.href = baseUrl+"/";
- }
- pageCurr=curr;
- limit();
- }
- });
+ // 椤甸潰淇敼
+ table.on('edit(chooseData)', function (obj) {
+ updateMatCodeData(obj.data.matNo, Number(obj.value));
});
// 鐩戝惉澶村伐鍏锋爮浜嬩欢
@@ -54,33 +44,127 @@
var data = checkStatus.data;
switch(obj.event) {
case 'comb':
- if (data.length === 0){
- layer.msg('璇烽�夋嫨鏁版嵁');
- } else {
- layer.open({
- type: 1,
- title: '缁勭洏',
- maxmin: true,
- shadeClose: true,
- content: $('#combDiv'),
- success: function (layero, index) {
-
- }
- })
+ // 鍒ゆ柇鏄惁瀛樺湪鐗╂枡
+ if (matCodeData.length === 0) {
+ layer.msg("璇峰厛娣诲姞鐗╂枡");
+ return;
}
+ // 鍒ゆ柇鐗╂枡鏁伴噺鏄惁瀛樺湪寮傚父
+ for (var i=0;i<matCodeData.length;i++){
+ if (isNaN(matCodeData[i].count)) {
+ layer.msg("璇疯緭鍏ユ暟瀛�");
+ return;
+ }
+ if (matCodeData[i].count === 0){
+ layer.msg("鏁伴噺涓嶈兘涓洪浂");
+ return;
+ }
+ }
+ $.ajax({
+ url: baseUrl+"/full/store/put/start",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify({
+ devpNo: $('#putSiteSelect').val(),
+ list: matCodeData
+ }),
+ contentType:'application/json;charset=UTF-8',
+ method: 'POST',
+ async: false,
+ success: function (res) {
+ if (res.code === 200){
+ layer.msg("鍏ュ簱鍚姩鎴愬姛锛岀洰鏍囧簱浣嶏細" + res.data);
+ matCodeData = [];
+ tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound();}});
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ }else {
+ layer.msg(res.msg)
+ }
+ }
+ })
break;
}
});
-});
+ // 鐩戝惉琛屽伐鍏蜂簨浠�
+ table.on('tool(chooseData)', function(obj){
+ var data = obj.data;
+ switch (obj.event) {
+ case 'remove':
+ for (var i = matCodeData.length - 1; i >= 0; i--) {
+ if (matCodeData[i].matNo === data.matNo) {
+ matCodeData.splice(i, 1);
+ }
+ }
+ tableIns.reload({data: matCodeData,done:function (res) {
+ limit();
+ getInBound();
+ // 瑕嗙洊render鏂规硶鐨刣one
+ }});
+ break;
+ }
+ });
+
+ function setMatCodeData(data) {
+ matCodeData = data;
+ for (var i=0;i<matCodeData.length;i++){
+ matCodeData[i]["count"] = initCountVal;
+ }
+ }
+
+ function updateMatCodeData(matNo, count) {
+ if (isNaN(count)) {
+ layer.msg("璇疯緭鍏ユ暟瀛�");
+ } else {
+ if (count > 0) {
+ for (var i=0;i<matCodeData.length;i++){
+ if (matCodeData[i]["matNo"] === matNo){
+ matCodeData[i]["count"] = count;
+ }
+ }
+ } else {
+ layer.msg("鏁伴噺蹇呴』澶т簬闆�");
+ }
+ }
+
+ tableIns.reload({data: matCodeData,done:function (res) {
+ limit();
+ getInBound();
+ // 瑕嗙洊render鏂规硶鐨刣one
+ }});
+ }
+
+ // 鑾峰彇鍙敤鍏ュ簱绔欑偣
+ function getInBound() {
+ $.ajax({
+ url: baseUrl + "/available/put/site",
+ headers: {'token': localStorage.getItem('token')},
+ method: 'POST',
+ success: function (res) {
+ if (res.code === 200) {
+ var tpl = $("#putSiteSelectTemplate").html();
+ var template = Handlebars.compile(tpl);
+ var html = template(res);
+ $('#putSiteSelect').append(html);
+ form.render('select');
+ } else if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ } else {
+ layer.msg(res.msg)
+ }
+ }
+ })
+ }
+
+
+});
// 鎻愬彇鐗╂枡
var matCodeLayerIdx;
function getMat() {
- tableIns.reload({data: []});
matCodeLayerIdx = layer.open({
type: 2,
- title: '搴撲綅鐗╂枡',
+ title: '鎻愬彇鐗╂枡',
maxmin: true,
area: [top.detailWidth, top.detailHeight],
shadeClose: true,
@@ -88,4 +172,25 @@
success: function(layero, index){
}
});
+}
+
+// 娣诲姞琛ㄦ牸鏁版嵁
+function addTableData(data) {
+ for (var i=0;i<data.length;i++){
+ let pass = false;
+ for (var j=0;j<matCodeData.length;j++){
+ if (data[i].matNo === matCodeData[j].matNo) {
+ pass = true;
+ break;
+ }
+ }
+ if (pass) {
+ data.splice(i--, 1);
+ } else {
+ data[i]["count"] = initCountVal;
+ }
+ }
+ matCodeData.push.apply(matCodeData, data);
+ tableIns.reload({data: matCodeData});
+ layer.close(matCodeLayerIdx);
}
\ No newline at end of file
--
Gitblit v1.9.1