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/plaDetl.js |  896 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 849 insertions(+), 47 deletions(-)

diff --git a/src/main/webapp/static/js/pla/plaDetl.js b/src/main/webapp/static/js/pla/plaDetl.js
index 6569d16..f8e03f1 100644
--- a/src/main/webapp/static/js/pla/plaDetl.js
+++ b/src/main/webapp/static/js/pla/plaDetl.js
@@ -5,87 +5,176 @@
 var matCodeLayerIdx;
 var data = [];
 var checkStatus = [];
+var dataCheck = [];
+var admin;
+var printData = [];
+var layDate;
 function getCol() {
     var cols = [
         {field: 'id', title: 'id', align: 'center',hide:true}
-        ,{type: 'checkbox'}
-        ,{field: 'pakinTime', title: '鍏ュ簱鏃堕棿', align: 'center'}
-        ,{field: 'batch', align: 'center',title: '鎵瑰彿'}
-        ,{field: 'packageNo', align: 'center',title: '鍖呭彿'}
-        ,{field: 'brand', align: 'center',title: '鐗屽彿'}
-        ,{field: 'weight', align: 'center',title: '閲嶉噺锛圞G锛�', hide:true}
-        ,{field: 'workshop', align: 'center',title: '鐢熶骇杞﹂棿', hide:true}
-        ,{field: 'line', align: 'center',title: '鐢熶骇绾�', hide:true}
-        ,{field: 'packageType', align: 'center',title: '鍖呰绫诲瀷', hide:true}
-        ,{field: 'zpalletType', align: 'center',title: '鎵樼洏绫诲瀷', hide:true}
-        ,{field: 'fingerMelting', align: 'center',title: '鐔旀寚锛坓/10min锛�'}
-        ,{field: 'fusingPoint', align: 'center',title: '鐔旂偣锛堚剝锛�'}
-        ,{field: 'vadf1', align: 'center',title: '鎸ュ彂浠�1锛�%锛�', hide:true}
-        ,{field: 'vadf2', align: 'center',title: '鎸ュ彂浠�2锛�%锛�', hide:true}
-        ,{field: 'yellowness', align: 'center',title: '榛勫害',  hide:true}
-        ,{field: 'opacity', align: 'center',title: '涓嶉�忔槑搴︼紙0-100%锛�', hide:true}
-        ,{field: 'water', align: 'center',title: '姘村垎锛坧pm锛�', hide:true}
-        ,{field: 'l', align: 'center',title: 'l鍊�', edit: true}
-        ,{field: 'a', align: 'center',title: 'a鍊�', edit: true}
-        ,{field: 'b', align: 'center',title: 'b鍊�', edit: true}
-        ,{field: 'fillIn', align: 'center',title: '濉厖(%)', edit: true}
-        ,{field: 'massState', align: 'center',title: '璐ㄩ噺鐘舵��', hide:true}
-        ,{field: 'problem', align: 'center',title: '璐ㄩ噺闂', hide:true}
-        ,{field: 'stash', align: 'center',title: '浠撳簱', edit:true}
-        ,{field: 'locNo', align: 'center',title: '搴撲綅', edit:true}
-        ,{field: 'weightAnfme', align: 'center',title: '鍓╀綑閲嶉噺锛圞G锛�', edit:true}
-        ,{field: 'status', align: 'center',title: '鐘舵��', edit:true}
-        ,{field: 'createUser', align: 'center',title: '鍗曞彿', edit:true}
-        ,{field: 'createUser', align: 'center',title: '鍑哄簱鏃堕棿', edit:true}
-        ,{field: 'createUser', align: 'center',title: '閲嶉噺', edit:true}
-        ,{field: 'createUser', align: 'center',title: '缁忓姙浜�', edit:true}
-        ,{field: 'createUser', align: 'center',title: '娴佽浆褰㈠紡', edit:true}
-        ,{field: 'createUser', align: 'center',title: '瀹㈡埛鍚嶇О', edit:true}
-        ,{field: 'createUser', align: 'center',title: '璋冩嫧鍒�', edit:true}
-        ,{field: 'createUser', align: 'center',title: '澶囨敞', edit:true}
+        ,{type: 'checkbox',totalRow:true}
+        ,{field:'id', width:80, title: '', sort: true, totalRowText: '鍚堣锛�',hide: true}
+        ,{field: 'pakinTime$', title: '鍏ュ簱鏃堕棿', align: 'center' , sort:true}
+        ,{field: 'matnr', align: 'center',title: '瀛樿揣缂栫爜',hide:true,edit:true}
+        ,{field: 'brand', align: 'center',title: '鐗屽彿',edit:true}
+        ,{field: 'batch', align: 'center',title: '鎵瑰彿',edit:true, width: 150, sort:true}
+        ,{field: 'packageNo', align: 'center',title: '鍖呰鍙�',edit:true, sort:true}
+        ,{field: 'proDate', align: 'center',title: '鐢熶骇鏃ユ湡',edit:true, width: 100}
+        ,{field: 'weight', align: 'center',title: '閲嶉噺KG',edit:true,totalRow:true}
+        ,{field: 'filmWrap', align: 'center',title: '缂犺啘',edit:true,hide:true}
+        ,{field: 'fingerMelting', align: 'center',title: '鐔旀寚锛実/10min',edit:true}
+        ,{field: 'water', align: 'center',title: '姘村垎锛宲pm', hide:true,edit:true}
+        ,{field: 'fusingPoint', align: 'center',title: '鐔旂偣锛屸剝',edit:true}
+        ,{field: 'vadf1', align: 'center',title: '鎸ュ彂娈碉紝%', hide:true,edit:true}
+        ,{field: 'vadf2', align: 'center',title: '鍒嗚В娈碉紝%', hide:true,edit:true}
+        ,{field: 'yellowness', align: 'center',title: '榛勫害',edit:true}
+        ,{field: 'opacity', align: 'center',title: '涓嶉�忔槑搴︼紝%',edit:true}
+        ,{field: 'l', align: 'center',title: 'L*', hide:true,edit:true}
+        ,{field: 'a', align: 'center',title: 'a*', hide:true,edit:true}
+        ,{field: 'b', align: 'center',title: 'b*', hide:true,edit:true}
+        ,{field: 'fillIn', align: 'center',title: '濉厖锛�%',hide:true,edit:true}
+        ,{field: 'str1', align: 'center',title: '鎷変几寮哄害锛孧Pa',hide:true,edit:true}
+        ,{field: 'str2', align: 'center',title: '鏂浼搁暱鐜囷紝%',hide:true,edit:true}
+        ,{field: 'str3', align: 'center',title: '缂哄彛鍐插嚮锛孠J/m2',hide:true,edit:true}
+        ,{field: 'str4', align: 'center',title: '缁村崱锛屸剝',hide:true,edit:true}
+        ,{field: 'str5', align: 'center',title: '鍗婄粨鏅舵椂闂达紝min',hide:true,edit:true}
+        ,{field: 'str6', align: 'center',title: '缁撴櫠搴︼紝%',hide:true,edit:true}
+        ,{field: 'packageType', align: 'center',title: '鍖呰绫诲瀷',edit:true}
+        ,{field: 'zpalletType', align: 'center',title: '鎵樼洏绫诲瀷',edit:true}
+        ,{field: 'massState', align: 'center',title: '璐ㄩ噺鐘舵��',edit:true}
+        ,{field: 'problem', align: 'center',title: '澶囨敞',edit:true,hide:true}
+        ,{field: 'direction', align: 'center',title: '搴旂敤鏂瑰悜',edit:true,hide:true}
+        ,{field: 'position', align: 'center',title: '瀛樻斁浣嶇疆',edit:true,hide:true}
+        ,{field: 'stash', align: 'center',title: '浠撳簱',edit:true,hide:true}
+        ,{field: 'locNo', align: 'center',title: '搴撲綅',edit:true}
+        ,{field: 'owner', align: 'center',title: '涓讳綋',edit:true}
+        ,{field: 'type', align: 'center',title: '鐗╄祫绫诲埆',hide:true,edit:true}
+        ,{field: 'proOrderNo', align: 'center',title: '鐢熶骇璁㈠崟缂栧彿',hide:true,edit:true}
+        ,{field: 'workshop', align: 'center',title: '鐢熶骇杞﹂棿',hide:true,edit:true}
+        ,{field: 'line', align: 'center',title: '鐢熶骇绾�',hide:true,edit:true}
+        ,{field: 'weightAnfme', align: 'center',title: '鍓╀綑閲嶉噺锛圞G锛�',edit:true,totalRow:true}
+        ,{field: 'qtyAnfme', align: 'center',title: '寰呭嚭搴撻噸閲忥紙KG锛�',hide:true,edit:true}
+        ,{field: 'status', align: 'center',title: '鐘舵��', templet: setState ,edit:true}
+        ,{field: 'stockFreeze', align: 'center',title: '搴撳瓨鍐荤粨', templet: '#stockFreezeTpl'}
+        ,{field: 'stockFreezeBy', align: 'center',title: '鎿嶄綔浜哄憳',hide:true}
+        ,{field: 'stockFreezeDate$', align: 'center',title: '鎿嶄綔鏃ユ湡',hide:true}
+        ,{align: 'center', title: '娴佽浆鏄庣粏', toolbar: '#tbLook'}
+        ,{field: 'createTime$', title: '鍒涘缓鏃堕棿', align: 'center' , sort:true}
+        ,{field: 'newBrand', align: 'center',title: '鍏宠仈鐗屽彿',edit:true}
+        ,{field: 'newBatch', align: 'center',title: '鍏宠仈鎵瑰彿',edit:true, width: 150, sort:true}
+        ,{field: 'newPackageNo', align: 'center',title: '鍏宠仈鍖呰鍙�',edit:true, sort:true}
+        // ,{field: 'orderNo', align: 'center',title: '鍗曞彿', hide:true}
+        // ,{field: 'pakoutTime', align: 'center',title: '鍑哄簱鏃堕棿', hide:true}
+        // ,{field: 'orderWeight', align: 'center',title: '閲嶉噺', hide:true}
+        // ,{field: 'handlerBy', align: 'center',title: '缁忓姙浜�', hide:true}
+        // ,{field: 'transfer', align: 'center',title: '娴佽浆褰㈠紡', hide:true}
+        // ,{field: 'customer', align: 'center',title: '瀹㈡埛鍚嶇О', hide:true}
+        // ,{field: 'allocate', align: 'center',title: '璋冩嫧鍒�', hide:true}
+        // ,{field: 'memo', align: 'center',title: '澶囨敞', hide:true}
     ];
     return cols;
 }
 
+function setState(data){
+    if(data.status === "寰呭叆搴�"){
+        return  "<span style='color: orange'>寰呭叆搴�</span>"
+    }else if(data.status === "宸插叆搴�"){
+        return  "<span style='color: blue'>宸插叆搴�</span>"
+    }else if(data.status === "寰呭嚭搴�"){
+        return  "<span style='color: red'>寰呭嚭搴�</span>"
+    }else if(data.status === "閮ㄥ垎鍑哄簱"){
+        return  "<span style='color: black'>閮ㄥ垎鍑哄簱</span>"
+    }else if(data.status === "鍏ㄩ儴鍑哄簱"){
+        return  "<span style='color: gray'>鍏ㄩ儴鍑哄簱</span>"
+    }else if(data.status === "鏆傚叆搴�"){
+        return  "<span style='color: purple'>鏆傚叆搴�</span>"
+    }
+}
+
 layui.config({
     base: baseUrl + "/static/layui/lay/modules/"
-}).use(['table','laydate', 'form', 'admin'], function() {
+}).use(['table','laydate', 'form', 'admin', 'xmSelect', 'dropdown'], function() {
+    var dropdown = layui.dropdown;
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
-    var layDate = layui.laydate;
+    laydate = layui.laydate;
     var form = layui.form;
-    var admin = layui.admin;
+    admin = layui.admin;
+
+    // 鏃ユ湡鏃堕棿鑼冨洿
+    laydate.render({
+        elem: '#ID-laydate-range-datetime',
+        type: 'datetime',
+        range: true
+    });
+
 
     // 鏁版嵁娓叉煋
     tableIns = table.render({
         elem: '#plaDetl',
         headers: {token: localStorage.getItem('token')},
-        url: baseUrl+'/pla/list/auth?step=3',
+        url: baseUrl+'/pla/list/auth?step=2',
         page: true,
+        totalRow: true, // 寮�鍚悎璁¤
+        height: function(){
+            var otherHeight = $('.function-area').outerHeight() + $('#search-box').outerHeight(); // 鑷畾涔夊叾浠栧尯鍩熺殑楂樺害
+            console.log($(window).height() - otherHeight);
+            return $(window).height() - otherHeight - 100; // 杩斿洖 number 绫诲瀷
+        },
+        //height: 'full',
         limit: 16,
-        limits: [16, 30, 50, 100, 200, 500],
+        limits: [16, 50, 100, 200, 500,2000,5000,10000],
         even: true,
         toolbar: '#toolbar',
         cellMinWidth: 50,
-        cols: [getCol()],
+        cols: [function(){
+            var arr = getCol();
+
+            // 鍒濆鍖栫瓫閫夌姸鎬�
+            var local = layui.data('table-filter-test'); // 鑾峰彇瀵瑰簲鐨勬湰鍦拌褰�
+            layui.each(arr, function(index, item){
+                if(item.field in local){
+                    item.hide = local[item.field];
+                }
+            });
+            return arr;
+        }() ],
+        where:{
+            type: function() {
+                const tabPosition = JSON.parse(sessionStorage.getItem('easyweb-iframe_tempData')).tabPosition
+                return tabPosition.match(/\d+$/)[0] === '90646' ? '鏀规�ф爲鑴�' :
+                    (tabPosition.match(/\d+$/)[0] === '90657' ? '绾爲鑴�' : '')
+                 }
+            },
         request: {
             pageName: 'curr',
             pageSize: 'limit'
         },
         parseData: function (res) {
-            console.log(res)
             return {
                 'code': res.code,
                 'msg': res.msg,
                 'count': res.data.total,
-                'data': res.data.records
+                'data': res.data.records,
             }
         },
         response: {
             statusCode: 200
         },
         done: function(res, curr, count) {
+            // 璁板綍绛涢�夌姸鎬�
+            var that = this;
+            that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function(){
+                var input = $(this).prev()[0];
+                // 姝ゅ琛ㄥ悕鍙换鎰忓畾涔�
+                layui.data('table-filter-test', {
+                    key: input.name
+                    ,value: input.checked
+                })
+            });
+
+            //$(".lavui-table-grid-down").hide();
             if (res.code === 403) {
                 top.location.href = baseUrl+"/";
             }
@@ -101,12 +190,381 @@
                     res.data[_index][data.value] = 'N';
                 }
             });
+            let headerTop = $('.layui-table-header').offset().top; //鑾峰彇琛ㄦ牸澶村埌鏂囨。椤堕儴鐨勮窛绂�
+            let headerPage = $('.layui-table-page').offset().top; //鑾峰彇琛ㄦ牸搴曢儴鏂囨。椤堕儴鐨勮窛绂�
+            $(window).scroll(function () {
+                if ((headerTop - $(window).scrollTop()) < 0) { //瓒呰繃浜�
+                    $('.layui-table-header').addClass('table-header-fixed'); //娣诲姞鏍峰紡锛屽浐瀹氫綇琛ㄥご
+                } else { //娌¤秴杩�
+                    $('.layui-table-header').removeClass('table-header-fixed'); //绉婚櫎鏍峰紡
+                }
+            });
         }
     });
 
+    // 娓叉煋鐗╂枡閫夋嫨
+    var matXmSelect = xmSelect.render({
+        el: '#mat',
+        style: {
+            width: '270px',
+        },
+        autoRow: true,
+        toolbar: { show: true },
+        filterable: true,
+        remoteSearch: true,
+        remoteMethod: function(val, cb, show){
+            $.ajax({
+                url: baseUrl+"/pla/batch/all/get/kv",
+                headers: {'token': localStorage.getItem('token')},
+                data: {
+                    condition: val
+                },
+                method: 'POST',
+                success: function (res) {
+                    if (res.code === 200){
+                        cb(res.data)
+                    } else {
+                        cb([]);
+                        layer.msg(res.msg, {icon: 2});
+                    }
+                }
+            });
+        }
+    })
 
+    // 澶嶉�夋浜嬩欢
+    table.on('checkbox(plaDetl)', function(obj){
+        // console.log(obj); // 鏌ョ湅瀵硅薄鎵�鏈夋垚鍛�
+        // console.log(obj.checked); // 褰撳墠鏄惁閫変腑鐘舵��
+        // console.log(obj.data); // 閫変腑琛岀殑鐩稿叧鏁版嵁
+        // console.log(obj.type); // 鑻ヨЕ鍙戠殑鏄叏閫夛紝鍒欎负锛歛ll锛涜嫢瑙﹀彂鐨勬槸鍗曢�夛紝鍒欎负锛歰ne
+        var checkStatus = table.checkStatus(obj.config.id)
+        var selectedNum = checkStatus.data.length;
+        var weightAll = 0;
+        var weightAnfmeAll = 0;
+
+        for (var i in checkStatus.data){
+            weightAll += checkStatus.data[i].weight;
+            weightAnfmeAll += checkStatus.data[i].weightAnfme;
+        }
+
+        $('.layui-table-total').find('.laytable-cell-1-0-1').text(selectedNum);
+        $('.layui-table-total').find('.laytable-cell-1-0-9').text(weightAll);
+        $('.layui-table-total').find('.laytable-cell-1-0-41').text(weightAnfmeAll);
+
+    });
+
+    // 琛屽崟鍑讳簨浠�( 鍙屽嚮浜嬩欢涓�: rowDouble )
+    table.on('row(plaDetl)', function(obj){
+
+    });
+
+    table.on('tool(plaDetl)', function (obj) {
+        var data = obj.data;
+        var layEvent = obj.event;
+        if (layEvent === 'look') {
+            var $a = $(obj.tr).find('a[lay-event="look"]');
+            var offset = $a.offset();
+            var top = offset.top;
+            var left = offset.left;
+            layer.open({
+                type: 1,
+                title: false,
+                area: '1200px',
+                offset: ['600px', (left - 1200 + $a.outerWidth()) + 'px'],
+                shade: .01,
+                shadeClose: true,
+                fixed: false,
+                content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
+                success: function (layero) {
+                    table.render({
+                        elem: '#lookSSXMTable',
+                        headers: {token: localStorage.getItem('token')},
+                        url: baseUrl+'/plaQty/list/auth',
+                        where: {
+                            brand: data.brand,
+                            batch: data.batch,
+                            package_no: data.packageNo
+                        },
+                        page: true,
+                        cellMinWidth: 100,
+                        cols: [[
+                            {type: 'numbers'},
+                            {field: 'orderNo', title: '鍗曞彿'},
+                            {field: 'pakoutTime', title: '鍑哄簱鏃堕棿'},
+                            {field: 'orderWeight', title: '閲嶉噺'},
+                            {field: 'handlerBy', title: '缁忓姙浜�'},
+                            {field: 'transfer', title: '娴佽浆褰㈠紡'},
+                            {field: 'customer', title: '瀹㈡埛鍚嶇О'},
+                            {field: 'allocate', title: '璋冩嫧鍒�'},
+                            {field: 'memo', title: '澶囨敞'},
+                        ]],
+                        request: {
+                            pageName: 'curr',
+                            pageSize: 'limit'
+                        },
+                        parseData: function (res) {
+                            return {
+                                'code': res.code,
+                                'msg': res.msg,
+                                'count': res.data.total,
+                                'data': res.data.records
+                            }
+                        },
+                        response: {
+                            statusCode: 200
+                        },
+                        done: function () {
+                            $(layero).find('.layui-table-view').css('margin', '0');
+                        },
+                        size: ''
+                    });
+                }
+            });
+        }
+
+    })
+
+    // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+    table.on('toolbar(plaDetl)', function (obj) {
+        var checkStatus = table.checkStatus(obj.config.id)
+        printData = checkStatus;
+        switch(obj.event) {
+            case 'updateData':
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鏁版嵁');
+                } else {
+                    layer.confirm('纭畾淇敼'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+                        $.ajax({
+                            url: baseUrl+"/pla/update/auth",
+                            headers: {'token': localStorage.getItem('token')},
+                            data: JSON.stringify(data),
+                            contentType:'application/json;charset=UTF-8',
+                            method: 'POST',
+                            traditional:true,
+                            success: function (res) {
+                                if (res.code === 200){
+                                    layer.closeAll();
+                                    tableReload(false);
+                                } else if (res.code === 403){
+                                    top.location.href = baseUrl+"/";
+                                } else {
+                                    layer.msg(res.msg)
+                                }
+                            }
+                        })
+                    });
+                }
+                break;
+            case "deleteData":
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鏁版嵁');
+                } else {
+                    layer.confirm('纭畾鍒犻櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+                        $.ajax({
+                            url: baseUrl+"/pla/delete/auth",
+                            headers: {'token': localStorage.getItem('token')},
+                            data: JSON.stringify(data),
+                            contentType:'application/json;charset=UTF-8',
+                            method: 'POST',
+                            traditional:true,
+                            success: function (res) {
+                                if (res.code === 200){
+                                    layer.closeAll();
+                                    tableReload(false);
+                                } else if (res.code === 403){
+                                    top.location.href = baseUrl+"/";
+                                } else {
+                                    layer.msg(res.msg)
+                                }
+                            }
+                        })
+                    });
+                }
+                break;
+            case "viladate":
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鏁版嵁');
+                } else {
+                    layer.confirm('纭畾鏍¢獙'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+                        $.ajax({
+                            url: baseUrl+"/pla/viladate/auth",
+                            headers: {'token': localStorage.getItem('token')},
+                            data: JSON.stringify(data),
+                            contentType:'application/json;charset=UTF-8',
+                            method: 'POST',
+                            traditional:true,
+                            success: function (res) {
+                                if (res.code === 200){
+                                    layer.closeAll();
+                                    tableReload(false);
+                                } else if (res.code === 403){
+                                    top.location.href = baseUrl+"/";
+                                } else {
+                                    layer.msg(res.msg)
+                                }
+                            }
+                        })
+                    });
+                }
+                break;
+            case 'freezeData':
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鏁版嵁');
+                } else {
+                    layer.confirm('纭畾鍐荤粨'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+                        $.ajax({
+                            url: baseUrl+"/pla/updateStockFreeze",
+                            headers: {'token': localStorage.getItem('token')},
+                            data: JSON.stringify(data),
+                            contentType:'application/json;charset=UTF-8',
+                            method: 'POST',
+                            traditional:true,
+                            success: function (res) {
+                                if (res.code === 200){
+                                    layer.closeAll();
+                                    tableReload(false);
+                                    layer.msg(res.msg,{icon:1})
+                                } else if (res.code === 403){
+                                    top.location.href = baseUrl+"/";
+                                } else {
+                                    layer.msg(res.msg,{icon:2})
+                                }
+                            }
+                        })
+                    });
+                }
+                break;
+            case 'disFreezeData':
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鏁版嵁');
+                } else {
+                    layer.confirm('纭畾瑙i櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹殑鍐荤粨鍚�', function(){
+                        $.ajax({
+                            url: baseUrl+"/pla/updateStockDisFreeze",
+                            headers: {'token': localStorage.getItem('token')},
+                            data: JSON.stringify(data),
+                            contentType:'application/json;charset=UTF-8',
+                            method: 'POST',
+                            traditional:true,
+                            success: function (res) {
+                                if (res.code === 200){
+                                    layer.closeAll();
+                                    tableReload(false);
+                                    layer.msg(res.msg,{icon:1})
+                                } else if (res.code === 403){
+                                    top.location.href = baseUrl+"/";
+                                } else {
+                                    layer.msg(res.msg,{icon:2})
+                                }
+                            }
+                        })
+                    });
+                }
+                break;
+            // 鎵归噺鎵撳嵃
+            case "btnPrintBatch":
+                printMatCodeNos = [];
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鎵撳嵃鏁版嵁');
+                } else {
+                    layer.open({
+                        type: 1,
+                        area: ['600px', '750px'],
+                        title: '鎵归噺鎵撳嵃 [鏁伴噺'+ data.length +']',
+                        shadeClose: true,
+                        content: $('#printDataDiv'),
+                        success: function(layero, index){
+                            for (var i = 0; i<data.length;i++) {
+                                printMatCodeNos.push(data[i].matnr);
+                            }
+                        },
+                        end: function () {
+                        }
+                    });
+                }
+                break;
+        }
+    })
+
+    // 妯℃澘閫夋嫨
+    form.on('radio(selectTemplateRadio)', function (data) {
+        $('.template-preview').hide();
+        $('#template-preview-'+data.value).show();
+    });
+
+    // 寮�濮嬫墦鍗�
+    form.on('submit(doPrint)', function (data) {
+        var templateNo = data.field.selectTemplate;
+        var templateDom = $("#templatePreview"+templateNo);
+        var className = templateDom.attr("class");
+        layer.closeAll();
+        for (let i=0;i<printData.data.length;i++){
+            if (className === 'template-barcode') {
+                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1&param="+(printData.data[i].brand+";"+printData.data[i].batch+";"+printData.data[i].packageNo+";"+printData.data[i].line)
+            } else {
+                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+(printData.data[i].brand+";"+printData.data[i].batch+";"+printData.data[i].packageNo+";"+printData.data[i].line)
+            }
+        }
+        var tpl = templateDom.html();
+        var template = Handlebars.compile(tpl);
+        var html = template(printData);
+        var box = $("#box");
+        box.html(html);box.show();
+        box.print({mediaPrint:true});
+        box.hide();
+        // $.ajax({
+        //     url: baseUrl+"/pla/print/auth",
+        //     headers: {'token': localStorage.getItem('token')},
+        //     data: JSON.stringify(printData.data),
+        //     contentType:'application/json;charset=UTF-8',
+        //     method: 'POST',
+        //     async: false,
+        //     success: function (res) {
+        //         if (res.code === 200){
+        //             layer.closeAll();
+        //             for (let i=0;i<res.data.length;i++){
+        //                 var templateDom = $("#templatePreview"+templateNo);
+        //                 var className = templateDom.attr("class");
+        //                 if (className === 'template-barcode') {
+        //                     res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1&param="+res.data[i].matnr;
+        //                 } else {
+        //                     res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+res.data[i].matnr;
+        //                 }
+        //             }
+        //             var tpl = templateDom.html();
+        //             var template = Handlebars.compile(tpl);
+        //             var html = template(res);
+        //             var box = $("#box");
+        //             box.html(html);box.show();
+        //             box.print({mediaPrint:true});
+        //             box.hide();
+        //         } else if (res.code === 403){
+        //             top.location.href = baseUrl+"/";
+        //         }else {
+        //             layer.msg(res.msg)
+        //         }
+        //     }
+        // })
+    });
+
+    // 鎼滅储鏍忔悳绱簨浠�
+    form.on('submit(search)', function (data) {
+        pageCurr = 1;
+        tableReload(false);
+    });
+
+    // 鐢ㄦ潵鏍囪瘑鎼滅储閲嶇疆鏃讹紝鏀规�ф爲鑴傚拰绾爲鑴備粠鐐瑰嚮浜嬩欢浼犺繃鏉ュ悕绉帮紝杩涜鐗╄川绫诲埆闄愬畾
+    let customValue = undefined
     // 閲嶇疆浜嬩欢
     form.on('submit(reset)', function (data) {
+        customValue = $(this).attr('data-value');
         reset();
     });
 
@@ -114,13 +572,58 @@
         clearFormVal($('#search-box'));
         matCodeData = [];
         tableReload();
-        locTips(false);
+
+        // locTips(false);
     }
 
     // 閲嶈浇琛ㄦ牸
-    function tableReload() {
-        tableIns.reload({data: matCodeData});
+    // function tableReload() {
+    //     tableIns.reload({data: matCodeData});
+    // }
+    function tableReload(child) {
+        var searchData = {
+        };
+        $.each($('#search-box [name]').serializeArray(), function() {
+            searchData[this.name] = this.value;
+        });
+        if(customValue !== undefined){
+            searchData['type'] = customValue
+        }
+        if(searchData.select){
+            searchData.batch = searchData.select;
+            searchData.select = null;
+        }
+        (child ? parent.tableIns : tableIns).reload({
+            where: searchData,
+            page: {
+                curr: pageCurr
+            },
+            done: function (res, curr, count) {
+                if (res.code === 403) {
+                    top.location.href = baseUrl+"/";
+                }
+                pageCurr=curr;
+                if (res.data.length === 0 && count !== 0) {
+                    tableIns.reload({
+                        where: searchData,
+                        page: {
+                            curr: pageCurr-1
+                        }
+                    });
+                    pageCurr -= 1;
+                }
+                limit(child);
+            }
+        });
     }
+
+    $(document).on('click','#updateZpallet',function (){
+        debugger;
+    })
+    $("[name='layTableCheckbox']").click(function(){ // 閫氳繃name灞炴�ч�夊彇鍏冪礌锛屽苟娣诲姞鐐瑰嚮浜嬩欢
+        alert("Hello World!"); // 鍦ㄦ帶鍒跺彴杈撳嚭鎻愮ず淇℃伅
+        debugger
+    });
 
 
 
@@ -157,7 +660,6 @@
                     layer.msg("鏈夋湭濉啓瀛楁");
                     return;
                 }
-                data[i].step = 3;
                 dataSave.push(data[i]);
             }else {
                 dataOld.push(data[i]);
@@ -185,5 +687,305 @@
         })
     })
 
+    $(document).on('click','#rework', function () {
+        let data = table.cache.plaDetl;
+        let dataSave = [];
+        let dataOld = [];
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夛紝璇峰厛鍕鹃�夐渶瑕侀噸鍋氱殑搴撳瓨");
+            return;
+        }
+
+        layer.confirm('纭畾閲嶅仛閫変腑鐨勫簱瀛樺悧锛�', {
+            shade: .1,
+            skin: 'layui-layer-admin'
+        }, function (i) {
+            layer.close(i);
+            $.ajax({
+                url: baseUrl+"/pla/rework/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})
+                    }
+                }
+            })
+        })
+    })
+
+    $(document).on('click','#updateZpallet', function () {
+        let data = table.cache.plaDetl;
+        let dataSave = [];
+        let dataOld = [];
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                data[i].step = 1;
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+        dataCheck = dataSave;
+
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夛紝璇峰厛鍕鹃�夐渶瑕佹洿鏀圭殑搴撳瓨");
+            return;
+        }
+
+        layer.open({
+            type: 2,
+            title: '鎹㈠寘瑁�/鎵樼洏/缂犺啘',
+            maxmin: true,
+            area: ['500px', top.detailHeight],
+            shadeClose: false,
+            content: 'update.html',
+            success: function(layero, index){
+                layer.getChildFrame('#data-detail-submit-edit', index).hide();
+                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
+                layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+
+                var iframe = window['layui-layer-iframe' + index];
+                iframe.child(dataSave)
+            }
+        });
+    })
+
+    $(document).on('click','#sellout', function () {
+
+        var data = table.cache.plaDetl;
+        var dataSave = [];
+        var dataOld = [];
+        var brand;
+
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                if(data[i].status === "鏆傚叆搴�" || data[i].status === "寰呭叆搴�" || data[i].status === "鍏ㄩ儴鍑哄簱"|| data[i].weightAnfme < data[i].qtyAnfme){
+                    layer.msg("閫変腑鐨勬槑缁嗚繕鏈叆搴撴垨鑰呭凡鍏ㄩ儴鍑哄簱鎴栬�呮病鏈夊墿浣欏彲鍑洪噸閲忥紝璇烽噸鏂伴�夋嫨");
+                    return;
+                }
+
+                brand = brand ? brand : data[i].brand;
+
+                if(brand != data[i].brand){
+                    layer.msg("閫変腑鐨勬槑缁嗕腑鍚湁澶氱鐗屽彿锛岃閲嶆柊閫夋嫨");
+                    return;
+                }
+                if (data[i].zpalletType == null && data[i].packageType == null && data[i].massState == null) {
+                    layer.msg("璐ㄩ噺鎸囨爣鏈笂浼�");
+                    return;
+                }
+                // if(data[i].stockFreeze === 0){
+                //     layer.msg("閫変腑鐨勬槑缁嗕腑鍚湁鍐荤粨鐨勫簱瀛橈紝璇疯В鍐诲悗鎿嶄綔");
+                //     return;
+                // }
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+        dataCheck = dataSave;
+
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夛紝璇峰厛鍕鹃�夐渶瑕佹洿鏀圭殑搴撳瓨");
+            return;
+        }
+
+        layer.open({
+            type: 2,
+            title: '鍑哄簱',
+            maxmin: true,
+            area: ['800px', top.detailHeight],
+            shadeClose: false,
+            content: 'sellout.html',
+            success: function(layero, index){
+                //layer.getChildFrame('#data-detail-submit-edit', index).hide();
+                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
+                layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+
+                var iframe = window['layui-layer-iframe' + index];
+                iframe.child(dataSave)
+            }
+        });
+    })
+
+    $(document).on('click','#pickup', function () {
+
+        let data = table.cache.plaDetl;
+        let dataSave = [];
+        let dataOld = [];
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                if(data[i].status === "鏆傚叆搴�" || data[i].status === "寰呭叆搴�" || data[i].status === "鍏ㄩ儴鍑哄簱"){
+                    layer.msg("閫変腑鐨勬槑缁嗚繕鏈叆搴撴垨鑰呭凡鍏ㄩ儴鍑哄簱锛岃閲嶆柊閫夋嫨");
+                    return;
+                }
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+        dataCheck = dataSave;
+
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夛紝璇峰厛鍕鹃�夐渶瑕佹洿鏀圭殑搴撳瓨");
+            return;
+        }
+        if(dataSave.length > 1){
+            layer.msg("璇峰嬀閫変竴鏉″簱瀛樻槑缁�");
+            return;
+        }
+
+        layer.open({
+            type: 2,
+            title: '鍗栧嚭',
+            maxmin: true,
+            area: ['800px', top.detailHeight],
+            shadeClose: false,
+            content: 'pickup.html',
+            success: function(layero, index){
+                //layer.getChildFrame('#data-detail-submit-edit', index).hide();
+                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
+                layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+
+                var iframe = window['layui-layer-iframe' + index];
+                iframe.child(dataSave)
+            }
+        });
+    })
+
+    $(document).on('click','#returned', function () {
+
+        layer.open({
+            type: 2,
+            title: '閫�鍥�',
+            maxmin: true,
+            area: ['800px', '800px'],
+            shadeClose: false,
+            content: 'returned.html',
+            success: function(layero, index){
+                layer.getChildFrame('#data-detail-submit-edit', index).hide();
+                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
+
+            }
+        });
+    })
+    $(document).on('click','#updateOwner', function () {
+        let data = table.cache.plaDetl;
+        let dataSave = [];
+        let dataOld = [];
+        for(var i=0; i<data.length; i++){
+            if(data[i].LAY_CHECKED){
+                data[i].step = 1;
+                dataSave.push(data[i]);
+            }else {
+                dataOld.push(data[i]);
+            }
+        }
+        dataCheck = dataSave;
+
+        if(!dataSave || dataSave.length < 1){
+            layer.msg("鏈嬀閫夛紝璇峰厛鍕鹃�夐渶瑕佹洿鏀圭殑搴撳瓨");
+            return;
+        }
+
+        layer.open({
+            type: 2,
+            title: '鍙樻洿涓讳綋',
+            maxmin: true,
+            area: ['500px', top.detailHeight],
+            shadeClose: false,
+            content: 'updateOwner.html',
+            success: function(layero, index){
+                layer.getChildFrame('#data-detail-submit-edit', index).hide();
+                top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
+                layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+
+                var iframe = window['layui-layer-iframe' + index];
+                iframe.child(dataSave)
+            }
+        });
+    })
+
 })
 
+// 鍏抽棴鍔ㄤ綔
+$(document).on('click','#data-detail-close', function () {
+    parent.layer.closeAll();
+});
+
+// excel瀵煎叆妯℃澘涓嬭浇
+function excelMouldDownload(){
+    layer.load(1, {shade: [0.1,'#fff']});
+    location.href = baseUrl + "/pla/excel/import/mould";
+    layer.closeAll('loading');
+}
+
+// excel瀵煎叆
+function importExcel() {
+    $("#importExcel").trigger("click");
+}
+function upload(obj){
+    if(!obj.files) {
+        return;
+    }
+    var file = obj.files[0];
+    admin.confirm('纭鍚屾 [' + file.name +'] 鏂囦欢鍚楋紵', function (index) {
+        layer.load(1, {shade: [0.1,'#fff']});
+        var url = baseUrl + "/pla/excel/import/auth";
+        var form = new FormData();
+        form.append("file", file);
+        xhr = new XMLHttpRequest();
+        xhr.open("post", url, true); //post鏂瑰紡锛寀rl涓烘湇鍔″櫒璇锋眰鍦板潃锛宼rue 璇ュ弬鏁拌瀹氳姹傛槸鍚﹀紓姝ュ鐞嗐��
+        xhr.setRequestHeader('token', localStorage.getItem('token'));
+        xhr.onload = uploadComplete; //璇锋眰瀹屾垚
+        xhr.onerror =  uploadFailed; //璇锋眰澶辫触
+        xhr.onloadend = function () { // // 涓婁紶瀹屾垚閲嶇疆鏂囦欢娴�
+            layer.closeAll('loading');
+            $("#importExcel").val("");
+        };
+        // xhr.upload.onprogress = progressFunction;//銆愪笂浼犺繘搴﹁皟鐢ㄦ柟娉曞疄鐜般��
+        xhr.upload.onloadstart = function(){//涓婁紶寮�濮嬫墽琛屾柟娉�
+            ot = new Date().getTime();   //璁剧疆涓婁紶寮�濮嬫椂闂�
+            oloaded = 0;//璁剧疆涓婁紶寮�濮嬫椂锛屼互涓婁紶鐨勬枃浠跺ぇ灏忎负0
+        };
+        xhr.send(form);
+    }, function(index){
+        $("#importExcel").val("");
+    });
+}
+function uploadComplete(evt) {
+    var res = JSON.parse(evt.target.responseText);
+    if(res.code === 200) {
+        layer.msg(res.msg, {icon: 1});
+        loadTree("");
+    } else {
+        layer.msg(res.msg, {icon: 2});
+    }
+}
+function uploadFailed(evt) {
+    var res = JSON.parse(evt.target.responseText);
+    layer.msg(res.msg, {icon: 2});
+}
+function clearTable(){
+
+}
+

--
Gitblit v1.9.1