From f63064b50164522377c5881f97b0e630217e030c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 30 三月 2022 10:39:26 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/pakStore/pakStore.js |  223 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 129 insertions(+), 94 deletions(-)

diff --git a/src/main/webapp/static/js/pakStore/pakStore.js b/src/main/webapp/static/js/pakStore/pakStore.js
index 655e8e8..3b3e666 100644
--- a/src/main/webapp/static/js/pakStore/pakStore.js
+++ b/src/main/webapp/static/js/pakStore/pakStore.js
@@ -1,33 +1,24 @@
-
+var admin;
 var initCountVal = 0;
 var matCodeData = [];
+function getCol() {
+    var cols = [
+        {fixed: 'left', field: 'anfme', title: '鏁伴噺锛堝繀濉級', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'},
+        {field: 'batch', title: '鎵瑰彿锛堥�夊~锛�', align: 'center', edit:'text', width: 200,  style:'color: blue;font-weight: bold'}
+    ];
+    cols.push.apply(cols, matCols);
+    cols.push({fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width: 80})
+    return cols;
+}
 
-layui.use(['table','laydate', 'form'], function() {
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).use(['admin', 'table','laydate', 'form'], function() {
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
-    var layDate = layui.laydate;
     var form = layui.form;
-
-    // 鑾峰彇鍙敤鍏ュ簱绔欑偣
-    $.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)
-            }
-        }
-    })
+    admin = layui.admin;
 
     tableIns = table.render({
         elem: '#chooseData',
@@ -36,29 +27,36 @@
         limit: 500,
         cellMinWidth: 50,
         toolbar: '#toolbar',
-        cols: [[
-            {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: '鐗╂枡瑙勬牸'},
-            {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:80}
-        ]],
+        cols: [getCol()],
         done: function (res, curr, count) {
-            $('td[data-field=count] div').html(initCountVal);
+            $('td[data-field=anfme] div').html(initCountVal);
             setMatCodeData(res.data);
             limit();
+            getInBound();
         }
     });
 
     // 椤甸潰淇敼
     table.on('edit(chooseData)', function (obj) {
-        if (!isNaN(obj.value)) {
-            updateMatCodeData(obj.data.matNo, Number(obj.value));
-        } else {
-            layer.msg("璇疯緭鍏ユ暟瀛�");
+        let index = obj.tr.attr("data-index");
+        let data = matCodeData[index];
+        let modify = true;
+        if (obj.field === 'anfme'){
+            let vle = Number(obj.value);
+            if (isNaN(vle)) {
+                layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
+                modify = false;
+            } else {
+                if (vle <= 0) {
+                    layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2});
+                    modify = false;
+                }
+            }
         }
+        if (modify) {
+            data[obj.field] = obj.value;
+        }
+        tableIns.reload({data: matCodeData});
     });
 
     // 鐩戝惉澶村伐鍏锋爮浜嬩欢
@@ -74,23 +72,37 @@
                 }
                 // 鍒ゆ柇鐗╂枡鏁伴噺鏄惁瀛樺湪寮傚父
                 for (var i=0;i<matCodeData.length;i++){
-                    if (isNaN(matCodeData[i].count)) {
+                    if (isNaN(matCodeData[i].anfme)) {
                         layer.msg("璇疯緭鍏ユ暟瀛�");
                         return;
                     }
-                    if (matCodeData[i].count === 0){
+                    if (matCodeData[i].anfme === 0){
                         layer.msg("鏁伴噺涓嶈兘涓洪浂");
                         return;
                     }
                 }
-                layer.open({
-                    type: 1,
-                    title: '閫夋嫨鍏ュ簱绔�',
-                    maxmin: true,
-                    shadeClose: true,
-                    content: $('#combDiv'),
-                    success: function (layero, index) {
-
+                $.ajax({
+                    url: baseUrl+"/full/store/put/start",
+                    headers: {'token': localStorage.getItem('token')},
+                    data: JSON.stringify({
+                        devpNo: Number($('#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 = [];
+                            $('#focusMatByMat').val("");
+                            tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound();}});
+                            document.getElementById("focusMatByMat").focus();
+                        } else if (res.code === 403){
+                            top.location.href = baseUrl+"/";
+                        }else {
+                            layer.msg(res.msg)
+                        }
                     }
                 })
                 break;
@@ -101,17 +113,13 @@
     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) {
+                for (let i = matCodeData.length - 1; i >= 0; i--) {
+                    if (matCodeData[i].matNo === data.matNo && matCodeData[i].batch === data.batch) {
                         matCodeData.splice(i, 1);
                     }
                 }
-                tableIns.reload({data: matCodeData,done:function (res) {
-                        limit();
-                        // 瑕嗙洊render鏂规硶鐨刣one
-                    }});
+                tableIns.reload({data: matCodeData});
                 break;
         }
     });
@@ -119,65 +127,92 @@
     function setMatCodeData(data) {
         matCodeData = data;
         for (var i=0;i<matCodeData.length;i++){
-            matCodeData[i]["count"] = initCountVal;
+            matCodeData[i]["anfme"] = initCountVal;
         }
     }
 
-    function updateMatCodeData(matNo, count) {
-        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();
-                // 瑕嗙洊render鏂规硶鐨刣one
-            }});
-    }
-
-    // 琛ㄥ崟 --- 鍚姩鍏ュ簱
-    form.on('submit(combDo)', function (data) {
+    // 鑾峰彇鍙敤鍏ュ簱绔欑偣
+    function getInBound() {
         $.ajax({
-            url: baseUrl+"/full/store/put/start",
+            url: baseUrl + "/available/put/site",
             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.closeAll();
-                    layer.msg("鍏ュ簱鍚姩鎴愬姛锛岀洰鏍囧簱浣嶏細" + res.data);
-                    matCodeData = [];
-                    tableIns.reload({data: matCodeData,done:function (res) { limit();}});
-                } else if (res.code === 403){
-                    top.location.href = baseUrl+"/";
-                }else {
-                    layer.msg(res.msg)
+                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, {icon: 2})
                 }
             }
         })
-    });
+    }
+
+
 });
 
 // 鎻愬彇鐗╂枡
 var matCodeLayerIdx;
 function getMat() {
-    matCodeLayerIdx = layer.open({
+    matCodeLayerIdx = admin.open({
         type: 2,
-        title: '鎻愬彇鐗╂枡',
-        maxmin: true,
-        area: [top.detailWidth, top.detailHeight],
+        title: false,
+        closeBtn: false,
+        maxmin: false,
+        area: ['90%', '85%'],
         shadeClose: true,
         content: 'matQuery.html',
         success: function(layero, index){
         }
     });
 }
+
+// 鎵爜
+function focusMat(el) {
+    if (isEmpty(el.value)) {
+        return
+    }
+    $.ajax({
+        url: baseUrl + "/matCode/" + el.value + "/auth",
+        headers: {'token': localStorage.getItem('token')},
+        method: 'GET',
+        success: function (res) {
+            if (res.code === 200) {
+                matCodeData = [];
+                var param = new Array();
+                param[0] = res.data;
+                addTableData(param);
+            } else if (res.code === 403) {
+                top.location.href = baseUrl + "/";
+            } else {
+                layer.msg(res.msg, {icon: 2})
+            }
+        }
+    })
+}
+
+// 娣诲姞琛ㄦ牸鏁版嵁
+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);
+}

--
Gitblit v1.9.1