From b7e08df5a07b3fa832a46ecc31983e16f2bccc8c Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 24 七月 2023 14:56:01 +0800
Subject: [PATCH] # 出库作业,和库存明细管理 排序

---
 src/main/webapp/static/js/pakStore/pakStore.js |  256 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 199 insertions(+), 57 deletions(-)

diff --git a/src/main/webapp/static/js/pakStore/pakStore.js b/src/main/webapp/static/js/pakStore/pakStore.js
index a5b3b4f..5afb458 100644
--- a/src/main/webapp/static/js/pakStore/pakStore.js
+++ b/src/main/webapp/static/js/pakStore/pakStore.js
@@ -1,6 +1,22 @@
 
 var initCountVal = 0;
 var matCodeData = [];
+function getCol() {
+    var cols = [
+        {fixed: 'left', field: 'count', title: '鏁伴噺(蹇呭~)', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'},
+        {field: 'supplier', title: '鎵瑰彿', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'},
+        {field: 'source', title: '鏉ユ簮', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'},
+        {field: 'vendor', title: '渚涘簲鍟�', align: 'center', edit:'text', width: 120,  style:'color: blue;font-weight: bold'}
+        // {field: 'allqty', title: '鎬绘暟閲�', align: 'center'},
+        // {field: 'allweight', title: '鎬婚噸閲�', align: 'center'}
+    ];
+    cols.push.apply(cols, matCols);
+    cols.push(
+        {field: 'memo', title:'鐢熶骇鏃ユ湡', align: 'center'},
+        {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
+        )
+    return cols;
+}
 
 layui.use(['table','laydate', 'form'], function() {
     var table = layui.table;
@@ -9,8 +25,6 @@
     var layDate = layui.laydate;
     var form = layui.form;
 
-
-
     tableIns = table.render({
         elem: '#chooseData',
         data: [],
@@ -18,35 +32,70 @@
         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);
             setMatCodeData(res.data);
             limit();
+            getInBound();
         }
     });
 
-
-
     // 椤甸潰淇敼
     table.on('edit(chooseData)', function (obj) {
-        if (!isNaN(obj.value)) {
-            updateMatCodeData(obj.data.matNo, Number(obj.value));
-            tableIns.reload({data: matCodeData,done:function (res) {
-                    limit();
-                    // 瑕嗙洊render鏂规硶鐨刣one
-                }});
-        } else {
-            layer.msg("璇疯緭鍏ユ暟瀛�");
+        // var index  = ;
+        // console.log(obj.tr.parents('tr'))
+        // console.log($('obj').othis)
+        // console.log(obj.parents('tr').attr("data-index"));
+        switch (obj.field) {
+            case 'count':
+                updateMatCodeData(obj.data.matNo, obj.data.supplier, Number(obj.value));
+                break
+            case 'supplier':
+                // updateMatCodeSupplier(obj.data.matNo, obj.value);
+                for (var i=0;i<matCodeData.length;i++){
+                    if (matCodeData[i]["matNo"] === obj.data.matNo){
+                        matCodeData[i]["supplier"] = obj.data.supplier;
+                    }
+                }
+                // tableIns.reload({data: matCodeData,done:function (res) {
+                //         limit();
+                //         // getInBound();
+                //         // 瑕嗙洊render鏂规硶鐨刣one
+                //     }});
+                break
+            case 'source':
+                for (var i=0;i<matCodeData.length;i++){
+                    if (matCodeData[i]["matNo"] === obj.data.matNo
+                        && (matCodeData[i]["supplier"] === obj.data.supplier || matCodeData[i]["supplier"]==='')){
+                        matCodeData[i]["source"] = obj.data.source;
+                    }
+                }
+                break;
+            case 'vendor':
+                for (var i=0;i<matCodeData.length;i++){
+                    if (matCodeData[i]["matNo"] === obj.data.matNo
+                        && (matCodeData[i]["supplier"] === obj.data.supplier || matCodeData[i]["supplier"]==='')){
+                        matCodeData[i]["vendor"] = obj.data.vendor;
+                    }
+                }
+                break;
+
+            // case 'memo':
+            //     for (var i=0;i<matCodeData.length;i++){
+            //         if (matCodeData[i]["matNo"] === obj.data.matNo
+            //             && (matCodeData[i]["supplier"] === obj.data.supplier || matCodeData[i]["supplier"]==='')){
+            //             matCodeData[i]["memo"] = obj.data.memo;
+            //         }
+            //     }
+            //     break;
         }
+        tableIns.reload({data: matCodeData,done:function (res) {
+                limit();
+                getInBound();
+                // 瑕嗙洊render鏂规硶鐨刣one
+            }});
+
     });
 
     // 鐩戝惉澶村伐鍏锋爮浜嬩欢
@@ -55,12 +104,12 @@
         var data = checkStatus.data;
         switch(obj.event) {
             case 'comb':
-                // 鍒ゆ柇鏄惁瀛樺湪鐗╂枡
+                // 鍒ゆ柇鏄惁瀛樺湪浜у搧
                 if (matCodeData.length === 0) {
-                    layer.msg("璇峰厛娣诲姞鐗╂枡");
+                    layer.msg("璇峰厛娣诲姞浜у搧");
                     return;
                 }
-                // 鍒ゆ柇鐗╂枡鏁伴噺鏄惁瀛樺湪寮傚父
+                // 鍒ゆ柇浜у搧鏁伴噺鏄惁瀛樺湪寮傚父
                 for (var i=0;i<matCodeData.length;i++){
                     if (isNaN(matCodeData[i].count)) {
                         layer.msg("璇疯緭鍏ユ暟瀛�");
@@ -71,14 +120,27 @@
                         return;
                     }
                 }
-                layer.open({
-                    type: 1,
-                    title: '閫夋嫨鍏ュ簱绔�',
-                    maxmin: true,
-                    shadeClose: true,
-                    content: $('#combDiv'),
-                    success: function (layero, index) {
-
+                console.log(matCodeData);
+                $.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 = [];
+                            tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound();}});
+                        } else if (res.code === 403){
+                            top.location.href = baseUrl+"/";
+                        }else {
+                            layer.msg(res.msg)
+                        }
                     }
                 })
                 break;
@@ -87,19 +149,49 @@
 
     // 鐩戝惉琛屽伐鍏蜂簨浠�
     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) {
+                    if (matCodeData[i].matNo === obj.data.matNo) {
                         matCodeData.splice(i, 1);
                     }
                 }
                 tableIns.reload({data: matCodeData,done:function (res) {
                         limit();
+                        getInBound();
                         // 瑕嗙洊render鏂规硶鐨刣one
                     }});
+                break;
+            case 'memo':
+               var memoLayer = layer.open({
+                    type: 2,
+                    title: '澶囨敞',
+                    maxmin: true,
+                    area: ['400px', '215px'],
+                    shadeClose: false,
+                    content: 'matMemo.html',
+                    btn: ['淇濆瓨', '鍙栨秷'],
+                    style: 'text-algin: center',
+                    yes:  function(index, layero){
+                        var memo = layer.getChildFrame('body', index).find("#memo")[0].value;
+                        matCodeData.map(function (item) {
+                            if (item.matNo === obj.data.matNo && item.supplier === obj.data.supplier) {
+                                item.memo = memo;
+                            }
+                        });
+                        // 閲嶇疆琛ㄦ牸鏁版嵁
+                        tableIns.reload({data: matCodeData,done:function (res) {
+                            limit();
+                            getInBound();
+                            layer.close(memoLayer);
+                        }});
+                    },
+                    success: function(layero, index){
+                        var iframeWin = window[layero.find('iframe')[0]['name']];//寰楀埌iframe椤电殑绐楀彛瀵硅薄
+                        iframeWin.setMatMemo(data.memo);
+                    }
+                });
                 break;
         }
     });
@@ -111,48 +203,77 @@
         }
     }
 
-    function updateMatCodeData(matNo, count) {
+    function updateMatCodeData(matNo, supplier, 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]["supplier"] === supplier){
+                        matCodeData[i]["count"] = count;
+                        // matCodeData[i]["supplier"] = supplier;
+                    }
+                }
+            } else {
+                layer.msg("鏁伴噺蹇呴』澶т簬闆�");
+            }
+        }
+
+        tableIns.reload({data: matCodeData,done:function (res) {
+                limit();
+                getInBound();
+                // 瑕嗙洊render鏂规硶鐨刣one
+            }});
+    }
+
+
+    function updateMatCodeSupplier(matNo, supplier) {
+        console.log('-')
+        debugger
         for (var i=0;i<matCodeData.length;i++){
             if (matCodeData[i]["matNo"] === matNo){
-                matCodeData[i]["count"] = count;
+                if (matCodeData[i]["supplier"] === supplier) {
+                    console.log(supplier);
+                    console.log(matCodeData[i]["supplier"])
+                    layer.msg("鎵瑰彿宸插瓨鍦�", {icon: 2});
+                } else {
+                    matCodeData[i]["supplier"] = supplier;
+                }
             }
         }
     }
 
-    // 琛ㄥ崟 --- 鍚姩鍏ュ簱
-    form.on('submit(combDo)', function (data) {
+    // 鑾峰彇鍙敤鍏ュ簱绔欑偣
+    function getInBound() {
         $.ajax({
-            url: baseUrl+"/full/store/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.msg);
-                    matCodeData = [];
-                    tableIns.reload({data: matCodeData,done:function (res) { limit();}});
-                } else if (res.code === 403){
-                    top.location.href = baseUrl+"/";
-                }else {
+                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() {
     matCodeLayerIdx = layer.open({
         type: 2,
-        title: '鎻愬彇鐗╂枡',
+        title: '鎻愬彇浜у搧',
         maxmin: true,
         area: [top.detailWidth, top.detailHeight],
         shadeClose: true,
@@ -161,3 +282,24 @@
         }
     });
 }
+
+// 娣诲姞琛ㄦ牸鏁版嵁
+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