From 539d9ffc477d28a23a923b41fdeabc8c37c99ce6 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 23 九月 2024 14:43:31 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/pla/productionInfo.js |  234 ++++++++++++++++++++++++---------------------------------
 1 files changed, 99 insertions(+), 135 deletions(-)

diff --git a/src/main/webapp/static/js/pla/productionInfo.js b/src/main/webapp/static/js/pla/productionInfo.js
index 8143808..960585d 100644
--- a/src/main/webapp/static/js/pla/productionInfo.js
+++ b/src/main/webapp/static/js/pla/productionInfo.js
@@ -4,11 +4,12 @@
 var currLocNo;
 var matCodeLayerIdx;
 var data = [];
+var checkStatus = [];
 function getCol() {
     var cols = [
         {field: 'id', title: 'id', align: 'center',hide:true}
         ,{type: 'checkbox'}
-        ,{field: 'ioTime', title: '鍏ュ簱鏃堕棿', align: 'center'}
+        ,{field: 'pakinTime', title: '鍏ュ簱鏃堕棿', align: 'center'}
         ,{field: 'batch', align: 'center',title: '鎵瑰彿', edit: true}
         ,{field: 'packageNo', align: 'center',title: '鍖呭彿', edit: true}
         ,{field: 'brand', align: 'center',title: '鐗屽彿', edit: true}
@@ -17,6 +18,7 @@
         ,{field: 'line', align: 'center',title: '鐢熶骇绾�', edit: true}
         ,{field: 'packageType', align: 'center',title: '鍖呰绫诲瀷', edit: true}
         ,{field: 'zpalletType', align: 'center',title: '鎵樼洏绫诲瀷', edit: true}
+        ,{field: 'filmWrap', align: 'center',title: '缂犺啘', edit: true}
     ];
     return cols;
 }
@@ -31,6 +33,8 @@
     var form = layui.form;
     var admin = layui.admin;
 
+    initSelector();
+
     tableIns = table.render({
         elem: '#productionInfoTable',
         data: [],
@@ -44,118 +48,51 @@
         }
     });
 
-    // 椤甸潰淇敼
-    table.on('edit(chooseData)', function (obj) {
-        let index = obj.tr.attr("data-index");
-        let data = matCodeData[index];
-        let modify = true;
-        if (obj.field === 'count'){
-            let vle = Number(obj.value);
-            if (isNaN(vle)) {
-                layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
-                modify = false;
-            } else {
-                if (vle <= 0) {
-                    layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2});
-                    modify = false;
+
+    function initSelector(){
+        $('#package').append('<option value="value">Text</option>');
+
+        var selectDom = $('#package');
+        $.ajax({
+            url: baseUrl+"/configTypeQuery/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: {condition: ',packageType'},
+            method: 'POST',
+            traditional:true,
+            success: function (res) {
+                if (res.code === 200){
+                    var list = res.data;
+                    for (var i=0;i<list.length;i++){
+                        var option = new Option(list[i].value, i);
+                        selectDom.append($("<option></option>").attr("value",option["value"]));
+                    }
+
+                } else if (res.code === 403){
+
+                }else {
+                    layer.msg(res.msg, {icon: 2})
                 }
             }
-        }
-        if (modify) {
-            data[obj.field] = obj.value;
-        }
-        tableIns.reload({data: matCodeData});
-    });
+        })
+        $('#packageCheck').val();
+    }
 
-    // 鐩戝惉澶村伐鍏锋爮浜嬩欢
-    table.on('toolbar(chooseData)', function (obj) {
-        switch(obj.event) {
-            case 'adjust':
-                if (isEmpty(currLocNo)) {
-                    layer.msg("璇峰厛妫�绱㈠簱浣�", {icon: 2})
-                    inputTip($("#searchLocNo"));
-                    return;
-                }
-                if (matCodeData.length === 0) {
-                    layer.msg("璇峰厛娣诲姞鏄庣粏", {icon: 2});
-                    return;
-                }
-                for (var i=0;i<matCodeData.length;i++){
-                    if (isNaN(matCodeData[i].count)) {
-                        layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
-                        return;
-                    }
-                    if (matCodeData[i].count < 0){
-                        layer.msg("鏁伴噺涓嶈兘灏忎簬闆�", {icon: 2});
-                        return;
-                    }
-                }
-                layer.confirm('纭畾璋冩暣'+currLocNo+'搴撲綅鐨勬槑缁嗗悧锛�', {shadeClose: true}, function(){
-                    $.ajax({
-                        url: baseUrl+"/manLocDetl/adjust/start",
-                        headers: {'token': localStorage.getItem('token')},
-                        data: JSON.stringify({
-                            locNo: currLocNo,
-                            list: matCodeData
-                        }),
-                        contentType:'application/json;charset=UTF-8',
-                        method: 'POST',
-                        async: false,
-                        success: function (res) {
-                            if (res.code === 200){
-                                layer.msg(currLocNo + res.msg, {icon: 1});
-                                init(currLocNo)
-                            } else if (res.code === 403){
-                                top.location.href = baseUrl+"/";
-                            }else {
-                                layer.msg(res.msg, {icon: 2})
-                            }
-                        }
-                    })
-                });
-                break;
-        }
-    });
-
-    // 鐩戝惉琛屽伐鍏蜂簨浠�
-    table.on('tool(chooseData)', function(obj){
-        var data = obj.data;
-        switch (obj.event) {
-            case 'remove':
-                let index = obj.tr.attr("data-index");
-                matCodeData.splice(index, 1);
-                tableIns.reload({data: matCodeData});
-                break;
-        }
-    });
-
-    // 妫�绱簨浠�
-    form.on('submit(search)', function (data) {
-        let loc_no = data.field.loc_no;
-        if (loc_no === "") {
-            inputTip($("#searchLocNo"));
-            layer.msg("璇疯緭鍏ュ簱浣嶅彿");
-            return;
-        }
-        init(loc_no);
+    form.on('select(selectDemo1)', function (data) {
+        debugger
+        console.log(data.elem);
+        var elem = $(data.elem);
+        var trElem = elem.parents('tr');
+        console.log(trElem);
+        var tableData = table.cache.productionInfoTable; // 涓簍able id
+        console.log(tableData);
+        // 鏇存柊鍒拌〃鏍肩殑缂撳瓨鏁版嵁涓紝鎵嶈兘鍦ㄨ幏寰楅�変腑琛岀瓑绛夊叾浠栫殑鏂规硶涓緱鍒版洿鏂颁箣鍚庣殑鍊�
+        tableData[trElem.data('index')][elem.attr('name')] = data.value;
     });
 
     // 閲嶇疆浜嬩欢
     form.on('submit(reset)', function (data) {
         reset();
     });
-
-    function init(locNo) {
-        http.post(baseUrl + "/manLocDetl/list", {loc_no: locNo,limit: 1000}, function (res) {
-            matCodeData = [];
-            matCodeData = res.data.records;
-            for (var i = 0; i<matCodeData.length; i++) {
-                matCodeData[i]["count"] = matCodeData[i]["anfme"];
-            }
-            locTips(true, locNo);
-            tableReload();
-        })
-    }
 
     function reset() {
         clearFormVal($('#search-box'));
@@ -169,44 +106,71 @@
         tableIns.reload({data: matCodeData});
     }
 
-    // 搴撲綅鎻愮ず妗�
-    function locTips(retrieve, locNo) {
-        if (retrieve) {
-            http.post(baseUrl+"/node/select/"+locNo+"/auth", null, function (res) {
-                console.log(res);
-                let data = res.data;
-                if (data != null) {
-                    $(".retrieve").show();
-                    // $("#locMsg").html(locNo + "&nbsp;,搴撲綅鐘舵�侊細" + data.locSts$);
-                    $("#locMsg").html(locNo + "&nbsp;");
-                    $('.not-retrieve').hide();
-                    currLocNo = locNo;
-                } else {
-                    layer.msg("璇疯緭鍏ユ湁鏁堝簱浣嶅彿", {icon: 2});
-                    $('.not-retrieve').show();
-                    $("#locMsg").html("");
-                    $(".retrieve").hide();
-                    currLocNo = null;
-                    inputTip($("#searchLocNo"));
-                }
-            })
-        } else {
-            $('.not-retrieve').show();
-            $("#locMsg").html("");
-            $(".retrieve").hide();
-            currLocNo = null;
-        }
-    }
 
     $(document).on('click','#add', function () {
-        var strTime = "20"
-        var now = new Date(year,month,date,hrs,min,sec);
-        var newRow = {ioTime : now};
+        var now = dateToStr(new Date())
+        var newRow = {pakinTime : now};
+        data = table.cache.productionInfoTable;
         data.push(newRow);
         table.reload('productionInfoTable',{
             data: data
         })
     })
 
+    $(document).on('click','#delete', function () {
+        let dataNew = [];
+        let data = table.cache.productionInfoTable;
+        for(var i=0; i<data.length; i++){
+            if(!data[i].LAY_CHECKED){
+                dataNew.push(data[i]);
+            }
+        }
+        table.reload('productionInfoTable',{
+            data: dataNew
+        })
+    })
+
+    $(document).on('click','#submit', function () {
+        let data = table.cache.productionInfoTable;
+        let dataSave = [];
+        let dataOld = [];
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                if(!data[i].batch || !data[i].packageNo || !data[i].brand || !data[i].weight || !data[i].workshop || !data[i].line || !data[i].packageType || !data[i].zpalletType){
+                    layer.msg("鏈夋湭濉啓瀛楁");
+                    return;
+                }
+                data[i].step = 1;
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夋彁浜ら」锛屾棤娉曟彁浜�");
+            return;
+        }
+        $.ajax({
+            url: baseUrl+"/pla/add/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: JSON.stringify(dataSave),
+            contentType:'application/json;charset=UTF-8',
+            method: 'POST',
+            async: false,
+            success: function (res) {
+                if (res.code === 200){
+                    layer.msg("鎻愪氦鎴愬姛");
+                    table.reload('productionInfoTable',{
+                        data: dataOld
+                    })
+                } else if (res.code === 403){
+
+                }else {
+                    layer.msg(res.msg, {icon: 2})
+                }
+            }
+        })
+    })
+
 })
 

--
Gitblit v1.9.1