From f68db688939b4ff75c4d5b7ad12e0acfa56d5c98 Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期三, 08 一月 2025 13:15:51 +0800
Subject: [PATCH] 订单历史档

---
 src/main/webapp/static/js/orderLog/order.js |  308 +++++++++++++++++++
 src/main/webapp/static/js/orderLog/out.js   |  631 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 939 insertions(+), 0 deletions(-)

diff --git a/src/main/webapp/static/js/orderLog/order.js b/src/main/webapp/static/js/orderLog/order.js
new file mode 100644
index 0000000..93da4c4
--- /dev/null
+++ b/src/main/webapp/static/js/orderLog/order.js
@@ -0,0 +1,308 @@
+var insTbCount = 0;
+var admin;
+var insTb
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate'], function () {
+    var $ = layui.jquery;
+    var layer = layui.layer;
+    var form = layui.form;
+    var table = layui.table;
+    var util = layui.util;
+    admin = layui.admin;
+    var xmSelect = layui.xmSelect;
+    var layDate = layui.laydate;
+    var laytpl = layui.laytpl;
+
+    // 娓叉煋鎼滅储妯℃澘
+    $.ajax({
+        url: baseUrl+"/docType/list/auth",
+        headers: {'token': localStorage.getItem('token')},
+        data: {
+            limit: 9999
+        },
+        method: 'POST',
+        success: function (res) {
+            if (res.code === 200){
+                let template = Handlebars.compile($('#docTypeTpl').html());
+                $('#docType-query').html(template(res.data));
+                layui.form.render('select');
+            } else if (res.code === 403){
+                top.location.href = baseUrl+"/";
+            } else {
+                layer.msg(res.msg, {icon: 2})
+            }
+        }
+    })
+
+    // 娓叉煋琛ㄦ牸
+    insTb = table.render({
+        elem: '#order',
+        url: baseUrl+'/orderLog/head/page/auth',
+        headers: {token: localStorage.getItem('token')},
+        page: true,
+        cellMinWidth: 100,
+        cols: [[
+            {type: 'numbers'},
+            {field: 'defNumber', align: 'center', title: '鎿嶄綔绯荤粺鍙�', hide: false, width: 120},
+            {field: '鎿嶄綔鍗曟嵁', align: 'center', title: '鎿嶄綔鍗曟嵁', hide: true},
+            {field: '鎿嶄綔绫诲瀷', align: 'center', title: '鎿嶄綔绫诲瀷', hide: true},
+            {field: 'orderNo', title: '鍗曟嵁缂栧彿', templet: '#orderNoTpl'},
+            //{field: 'itemName', align: 'center', title: '鏍哥畻涓讳綋'},
+            {field: 'docType$', align: 'center', title: '鍗曟嵁绫诲瀷'},
+            //{field: 'defNumber', align: 'center', title: '涓氬姟绫诲瀷'},
+            //{field: 'postFee', align: 'center', title: '鎬绘暟閲�',  minWidth: 130, width: 130},
+            {align: 'center', title: '鏄庣粏', toolbar: '#tbLook', minWidth: 160, width: 160},
+            {field: 'createTime$', title: '鍒涘缓鏃堕棿', hide: true},
+            {field: 'createBy$', title: '鍒涘缓浜�'},
+            {field: 'orderTime', align: 'center',title: '鍗曟嵁鏃ユ湡'},
+            //{field: 'shipCode', align: 'center',title: '鍒跺崟浜�', hide: false},
+            {field: 'settle$', align: 'center', title: '鐘舵��', templet: '#settleTpl',  minWidth: 160, width: 160},
+            {field: 'memo', align: 'center',title: '澶囨敞', hide: true},
+            {field: 'cstmrName', align: 'center',title: '渚涘簲鍟�/瀹㈡埛缂栫爜', hide: true},
+            {field: 'tel', align: 'center',title: '浠撳簱', hide: true},
+            {field: 'operMemb', align: 'center',title: '鍑哄叆搴撶被鍒�', hide: true},
+            {field: 'salesman', align: 'center',title: '閮ㄩ棬', hide: true},
+        ]],
+        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 (res, curr, count) {
+            limit();
+            if (res.code === 403) {
+                top.location.href = baseUrl+"/";
+            }
+            insTbCount = count;
+        }
+    });
+
+    // 鎼滅储
+    form.on('submit(tbSearch)', function (data) {
+        insTb.reload({where: data.field, page: {curr: 1}});
+    });
+
+    // 娣诲姞
+    $("#orderAddBtn").click(function () {
+        showEditModel();
+    });
+
+    // 瀵煎叆閿�鍞崟
+    $("#importOrder").click(function () {
+        $("#importExcel").trigger("click");
+    });
+
+    // 宸ュ叿鏉$偣鍑讳簨浠�
+    table.on('tool(order)', function (obj) {
+        var data = obj.data;
+        var layEvent = obj.event;
+        if (layEvent === 'edit') {
+            showEditModel(data);
+        } else if (layEvent === 'wrkTrace') {
+            showWrkTrace(data.id);
+        } else if (layEvent === 'del') {
+            doDel(data.id);
+        } else if (layEvent === 'complete') {
+            doModify(data.id, 4);
+        } else if (layEvent === 'report'){
+            doReport(data.id);
+        } else 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: '1460px',
+                offset: [top + 'px', (left - 900 + $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+'/orderDetlLog/list/auth',
+                        where: {
+                            order_id: data.id
+                        },
+                        page: true,
+                        cellMinWidth: 100,
+                        cols: [[
+                            //{type: 'numbers'},
+                            {field: 'matnr', title: '鍟嗗搧缂栫爜', width: 140},
+                            {field: 'maktx', title: '鍟嗗搧鍚嶇О', width: 150},
+                            {field: 'batch', title: '鎵瑰彿'},
+                            {field: 'anfme', title: '鏁伴噺'},
+                            {field: 'qty', title: '浣滀笟鏁伴噺', style: 'font-weight: bold'},
+                            // {field: 'unit', title: '鍗曚綅'},
+                            // {
+                            //     field: 'createTime$', title: '鍒涘缓鏃堕棿', sort: true, templet: function (d) {
+                            //         return util.toDateString(d.createTime);
+                            //     },  width: 180
+                            // },
+                            // {field: 'inQty', title: '宸插叆搴撻噺'},
+                            // {field: 'color', title: '棰滆壊'},
+                            //{field: 'specs', title: '瑙勬牸鍨嬪彿'},
+                            {field: 'unit', title: '璁¢噺鍗曚綅'},
+                            //{field: 'manu', title: '琛屽彿'},
+                            {field: 'threeCode', title: '閿�鍞崟鍙�'},
+                            //{field: 'deadTime', title: '鑷敱椤�'},
+                            {field: 'processSts$', title: '宸ュ簭'},
+                            //{field: 'specs', title: '瑙勬牸'},
+                            {field: 'reportQty', title: '涓婃姤鏁伴噺'},
+                            //{field: 'itemNum', 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: ''
+                    });
+                }
+            });
+        }
+    });
+
+
+
+    // 浠诲姟杩芥函
+    function showWrkTrace(orderId) {
+        let loadIndex = layer.msg('璇锋眰涓�...', {icon: 16, shade: 0.01, time: false});
+        $.ajax({
+            url: baseUrl+"/orderLog/wrk/trace/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: {
+                orderId: orderId
+            },
+            method: 'POST',
+            success: function (res) {
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    laytpl(wrkTraceDialog.innerHTML).render(res.data, function (html) {
+                        admin.open({
+                            type: 1,
+                            title: '浠诲姟杩芥函',
+                            area: ['800px', '450px'],
+                            shadeClose: true,
+                            content: html,
+                            success: function (layero, dIndex) {
+                                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                                /** 缁熻鍥捐〃 */
+                                var traceCharts = echarts.init(document.getElementById('wrkTraceCharts'));
+                                var traceOptions = {
+                                    title: {
+                                        text: '浣滀笟/鎬婚噺', x: 'center', y: '38%',
+                                        textStyle: {fontSize: 18, color: '#262626', fontWeight: 'normal'},
+                                        subtextStyle: {fontSize: 36, color: '#10B4E8'},
+                                        itemGap: 20
+                                    },
+                                    color: ['#10B4E8', '#E0E0E0', '#FF0000'],
+                                    tooltip: {trigger: 'item'},
+                                    series: [{name: '鏁伴噺', type: 'pie', radius: ['75%', '80%'], label: {normal: {show: false}}}]
+                                };
+                                traceCharts.setOption(traceOptions);
+                                // 璧嬪��
+                                traceCharts.setOption({
+                                    title: {
+                                        subtext: res.data.wrkQty+"/"+res.data.totalQty
+                                    },
+                                    series: [
+                                        {
+                                            data: [
+                                                {name: '宸蹭綔涓�', value: res.data.wrkQty},
+                                                {name: '鏈綔涓�', value: res.data.totalQty-res.data.wrkQty-res.data.lackQty},
+                                                {name: '搴撳瓨涓嶈冻', value: res.data.lackQty},
+                                            ]
+                                        }
+                                    ]
+                                });
+                            }
+                        });
+                    });
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                }else {
+                    layer.msg(res.msg, {icon: 2});
+                }
+            }
+        })
+    }
+
+
+    layDate.render({
+        elem: '.layui-laydate-range'
+        ,type: 'datetime'
+        ,range: true
+    });
+});
+
+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 + "/orderLog/excel/import/auth";
+        var form = new FormData();
+        form.append("file", file);
+        let xhr = new XMLHttpRequest();
+        xhr.open("post", url, true);
+        xhr.setRequestHeader('token', localStorage.getItem('token'));
+        xhr.onload = uploadComplete;
+        xhr.onerror =  uploadFailed;
+        xhr.onloadend = function () {
+            layer.closeAll('loading');
+        };
+        // xhr.upload.onprogress = progressFunction;
+        xhr.upload.onloadstart = function(){
+            ot = new Date().getTime();
+            oloaded = 0;
+        };
+        xhr.send(form);
+    }, function(index){
+    });
+}
+function uploadComplete(evt) {
+    let res = JSON.parse(evt.target.responseText);
+    if(res.code === 200) {
+        layer.msg(res.msg, {icon: 1});
+        insTb.reload({page: {curr: 1}});
+    } else {
+        alert(res.msg);
+        // layer.msg(res.msg, {icon: 2});
+    }
+}
+function uploadFailed(evt) {
+    let res = JSON.parse(evt.target.responseText);
+    alert(res.msg);
+    // layer.msg(res.msg, {icon: 2});
+}
diff --git a/src/main/webapp/static/js/orderLog/out.js b/src/main/webapp/static/js/orderLog/out.js
new file mode 100644
index 0000000..ac322ac
--- /dev/null
+++ b/src/main/webapp/static/js/orderLog/out.js
@@ -0,0 +1,631 @@
+var pageCurr;
+var insTb2;
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).extend({
+    notice: 'notice/notice',
+}).use(['table','laydate', 'form', 'util', 'admin', 'notice', 'treeTable', 'xmSelect', 'tableMerge', 'tableX'], function(){
+    var table = layui.table;
+    var $ = layui.jquery;
+    var layer = layui.layer;
+    var layDate = layui.laydate;
+    var form = layui.form;
+    var admin = layui.admin;
+    var util = layui.util;
+    var notice = layui.notice;
+    var treeTable = layui.treeTable;
+    var xmSelect = layui.xmSelect;
+    var tableMerge = layui.tableMerge;
+    var tableX = layui.tableX;
+
+    insTb2 = table.render({
+        elem: '#orderDetlTable',
+        headers: {token: localStorage.getItem('token')},
+        url: baseUrl+'/orderDetl/pakout/list/auth',
+        page: true,
+        limit: 15,
+        limits: [15, 30, 50, 100, 200, 500],
+        toolbar: '#orderDetToolbar',
+        height: 'full-120',
+        where: {order_id: 9999999999},
+        cols: [[
+            {type: 'checkbox'}
+            ,{type: 'numbers', title: '#'}
+            ,{field: 'orderNo', align: 'center',title: '鍗曟嵁缂栧彿', templet: '#orderNoTpl', width: 160}
+            ,{field: 'matnr', align: 'center',title: '鐗╂枡鍙�', width: 160}
+            ,{field: 'maktx', align: 'center',title: '鐗╂枡鍚嶇О', width: 200}
+            ,{field: 'batch', align: 'center',title: '搴忓垪鐮�'}
+            ,{field: 'specs', align: 'center',title: '瑙勬牸'}
+            // ,{field: 'anfme', align: 'center',title: '鏁伴噺'}
+            // ,{field: 'qty', align: 'center',title: '浣滀笟鏁伴噺', style: 'font-weight: bold'}
+            ,{field: 'enableQty', align: 'center',title: '寰呭嚭鏁伴噺', style: 'font-weight: bold'}
+            ,{field: 'color', align: 'center',title: '閿�鍞鍗曞彿'}
+            ,{field: 'origin', align: 'center',title: '閿�鍞鍗曡鍙�'}
+            // ,{field: 'name', align: 'center',title: '鍚嶇О'}
+            // ,{field: 'model', align: 'center',title: '閫氱敤鍨嬪彿'}
+            ,{field: 'unit', align: 'center',title: '鍗曚綅', hide: true}
+            ,{field: 'barcode', align: 'center',title: '鍟嗗搧鏉$爜', hide: true}
+            // ,{field: 'supplier', align: 'center',title: '渚涘簲鍟�'}
+            // ,{field: 'unitPrice', align: 'center',title: '鍗曚环'}
+            // ,{field: 'itemNum', align: 'center',title: '鍝侀」鏁�'}
+            // ,{field: 'count', align: 'center',title: '鏁伴噺'}
+            // ,{field: 'weight', align: 'center',title: '閲嶉噺'}
+            // ,{field: 'status$', align: 'center',title: '鐘舵��'}
+            // ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'}
+            // ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
+            // ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳'}
+            // ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
+            // ,{field: 'memo', align: 'center',title: '澶囨敞'}
+            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width: 160}
+        ]],
+        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(res, curr, count) {
+            if (res.code === 403) {
+                top.location.href = baseUrl+"/";
+            }
+            pageCurr=curr;
+            limit();
+        }
+    });
+
+    /* 琛ㄦ牸2鎼滅储 */
+    form.on('submit(sensorTbSearch)', function (data) {
+        insTb2.reload({where: data.field, page: {curr: 1}});
+        return false;
+    });
+
+    /* 琛ㄦ牸2澶村伐鍏锋爮鐐瑰嚮浜嬩欢 */
+    table.on('toolbar(orderDetlTable)', function (obj) {
+        var checkStatus = table.checkStatus(obj.config.id).data;
+        if (obj.event === 'pakoutPreview') { // 娣诲姞
+            if (checkStatus.length === 0) {
+                layer.msg('璇烽�夋嫨鑷冲皯涓�鏉″嚭搴撴槑缁�', {icon: 2});
+                return;
+            }
+            pakoutPreview(checkStatus.map(function (d) {
+                return d.id;
+            }));
+        } else if (obj.event === 'del') { // 鍒犻櫎
+            var checkRows = table.checkStatus('sensorTable');
+            if (checkRows.data.length === 0) {
+                layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
+                return;
+            }
+            var ids = checkRows.data.map(function (d) {
+                return d.id;
+            });
+            doDelSensor({ids: ids});
+        }
+    });
+
+    /* 琛ㄦ牸2宸ュ叿鏉$偣鍑讳簨浠� */
+    table.on('tool(orderDetlTable)', function (obj) {
+        var data = obj.data;
+        switch (obj.event) {
+            // 鍑哄簱
+            case 'pakoutPreview':
+                pakoutPreview([data.id])
+                break;
+        }
+    });
+
+    function pakoutPreview(ids) {
+        let loadIndex = layer.load(2);
+        $.ajax({
+            url: baseUrl + "/out/pakout/preview/auth",
+            headers: {'token': localStorage.getItem('token')},
+            contentType: 'application/json;charset=UTF-8',
+            data: JSON.stringify(ids),
+            method: 'POST',
+            success: function (res) {
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    pakoutPreviewDialog(res.data)
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    layer.msg(res.msg, {icon: 2})
+                }
+            }
+        })
+    }
+
+    function pakoutPreviewDialog(data) {
+        for(var i=0; i<data.length; i++){
+            if(!data[i].staNos){
+                data[i].staNos = data[i].agvStaNos;
+                data[i].staNo = data[i].agvStaNo;
+            }
+        }
+        var tableCache;
+        layer.open({
+            type: 1
+            ,title: false
+            ,closeBtn: false
+            ,offset: '50px'
+            ,area: ['1200px', '700px']
+            ,shade: 0.5
+            ,shadeClose: false
+            ,btn: ['绔嬪嵆鍑哄簱', '绋嶅悗澶勭悊']
+            ,btnAlign: 'c'
+            ,moveType: 1 //鎷栨嫿妯″紡锛�0鎴栬��1
+            ,content: $('#pakoutPreviewBox').html()
+            ,success: function(layero, index){
+                stoPreTabIdx = table.render({
+                    elem: '#stoPreTab',
+                    data: data,
+                    height: 520,
+                    page: false,
+                    limit: Number.MAX_VALUE,
+                    cellMinWidth: 100,
+                    cols: [[
+                        // {type: 'checkbox', merge: ['orderNo']},
+                        {field: 'orderNo', title: '鍗曟嵁缂栧彿', merge: true, align: 'center'},
+                        {field: 'title', title: '鍟嗗搧', merge: true, align: 'center', width: 350},
+                        {field: 'batch', title: '搴忓垪鐮�', align: 'center'},
+                        {field: 'anfme', title: '鏁伴噺', align: 'center', width: 90, style: 'font-weight: bold'},
+                        {field: 'locNo', title: '璐т綅', align: 'center', templet: '#locNoTpl'},
+                        {field: 'staNos', align: 'center', title: '鍑哄簱绔�', merge: ['locNo'], templet: '#tbBasicTbStaNos'},
+                        // {type: 'checkbox', merge: ['locNo']},
+                    ]],
+                    //cols: getCol(data),
+                    done: function (res) {
+                        tableMerge.render(this);
+                        $('.layui-table-body.layui-table-main').css("overflow", "auto");
+                        tableCache = tableData = table.cache.stoPreTab;
+                    }
+                });
+                // 淇敼鍑哄簱绔�
+                form.on('select(tbBasicTbStaNos)', function (obj) {
+                    let index  = obj.othis.parents('tr').attr("data-index");
+                    let data = tableCache[index];
+                    for (let i = 0; i<tableCache.length; i++) {
+                        if (tableCache[i].locNo === data.locNo) {
+                            //tableCache[i]['staNo'] = Number(obj.elem.value);
+                            tableCache[i]['staNo'] = obj.elem.value;
+                        }
+                    }
+                    obj.othis.children().find("input").css("color", "blue");
+                    return false;
+                });
+                // 鎵归噺淇敼鍑哄簱绔�
+                form.on('submit(batchModifySta)', function () {
+                    modifySta();
+                });
+                // 鎵归噺淇敼鍑哄簱绔� - 绔欑偣閫夋嫨
+                function modifySta() {
+                    // 鍑哄簱绔欏彇浜ら泦
+                    let staBatchSelectVal = [];
+                    for(let i = 0; i<tableCache.length; i++) {
+                        let staNos = tableCache[i].staNos;
+                        if (staNos !== null) {
+                            if (staBatchSelectVal.length === 0) {
+                                staBatchSelectVal = staNos;
+                            } else {
+                                staBatchSelectVal = staBatchSelectVal.filter(val =>
+                                    {
+                                        return new Set(staNos).has(val)
+                                    }
+                                )
+                            }
+                        }
+                    }
+                    if (staBatchSelectVal.length === 0) {
+                        layer.msg("鍑哄簱绔欐病鏈変氦闆嗭紝鏃犳硶鎵归噺淇敼", {icon: 2});
+                        return;
+                    }
+                    admin.open({
+                        type: 1,
+                        area: '300px',
+                        offset: 'auto',
+                        title: '璇烽�夋嫨绔欑偣',
+                        content: $('#staBatchSelectDialog').html(),
+                        success: function (layero, ddIndex) {
+                            // 娓叉煋涓嬫媺妗�
+                            let template = Handlebars.compile($('#batchStaSelectTpl').html());
+                            $('#batchSelectStaBox').html(template({list: staBatchSelectVal}));
+                            // 纭
+                            form.on('submit(staBatchSelectConfirm)', function (obj) {
+                                let loadIdx = layer.load(2);
+                                //let batchSta = Number(obj.field.batchSta);
+                                let batchSta = obj.field.batchSta;
+                                let arr = [];
+                                for (let i = 0; i<tableCache.length; i++) {
+                                    tableCache[i]['staNo'] = batchSta;
+                                    arr.push(i);
+                                }
+                                stoPreTabIdx.reload({data: tableCache});
+                                arr.forEach(item => {
+                                    $('div[lay-id=stoPreTab] tr[data-index="' + item + '"] .order-sta-select').val(batchSta);
+                                });
+                                layui.form.render('select');
+                                arr.forEach(item => {
+                                    $('div[lay-id=stoPreTab] tr[data-index="' + item + '"] .layui-select-title').find("input").css("color", "blue");
+                                });
+                                layer.close(loadIdx); layer.close(ddIndex);
+                                return false;
+                            });
+                            // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+                            $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                            layui.form.render('select');
+                        },
+                    })
+                }
+
+            }
+            ,yes: function(index, layero){
+                //鎸夐挳銆愮珛鍗冲嚭搴撱�戠殑鍥炶皟
+                pakout(tableCache, index);
+            }
+            ,btn2: function(index, layero){
+                //鎸夐挳銆愮◢鍚庡鐞嗐�戠殑鍥炶皟
+                layer.close(index)
+                //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
+            }
+        });
+    }
+
+    function pakout(tableCache, layerIndex) {
+        // let loadIndex = layer.load(2);
+        for(var i=0; i<tableCache.length; i++){
+            if(tableCache[i].agvStaNos){
+                tableCache[i].agvStaNo = tableCache[i].staNo;
+                tableCache[i].staNos = null;
+                tableCache[i].staNo = null;
+            }
+        }
+        notice.msg('姝e湪鐢熸垚鍑哄簱浠诲姟......', {icon: 4});
+        $.ajax({
+            url: baseUrl + "/out/pakout/auth",
+            headers: {'token': localStorage.getItem('token')},
+            contentType: 'application/json;charset=UTF-8',
+            data: JSON.stringify(tableCache),
+            method: 'POST',
+            success: function (res) {
+                notice.destroy();
+                if (res.code === 200) {
+                    layer.close(layerIndex);
+                    layer.msg(res.msg, {icon: 1});
+                    insTb.reload({where: null});
+                    insTb2.reload({where: null, page: {curr: 1}});
+                } else if (res.code === 403) {
+                    top.location.href = baseUrl + "/";
+                } else {
+                    layer.msg(res.msg, {icon: 2})
+                }
+            }
+        });
+    }
+
+
+
+    /* 鍒犻櫎璁㈠崟 */
+    function doDelSensor(obj) {
+        layer.confirm('纭畾瑕佸垹闄ら�変腑鏁版嵁鍚楋紵', {
+            skin: 'layui-layer-admin',
+            shade: .1
+        }, function (i) {
+            layer.close(i);
+            var loadIndex = layer.load(2);
+            $.ajax({
+                url: baseUrl+"/sensor/delete/auth",
+                headers: {'token': localStorage.getItem('token')},
+                data: {ids: obj.ids},
+                method: 'POST',
+                success: function (res) {
+                    layer.close(loadIndex);
+                    if (res.code === 200){
+                        layer.msg(res.msg, {icon: 1});
+                        $(".layui-laypage-btn")[0].click();
+                    } else if (res.code === 403){
+                        top.location.href = baseUrl+"/";
+                    }else {
+                        layer.msg(res.msg, {icon: 2});
+                    }
+                }
+            })
+
+        });
+    }
+
+    // 淇敼鐘舵��
+    form.on('switch(statusSwitch)', function (obj) {
+        var index  = obj.othis.parents('tr').attr("data-index");
+        var data = tableData[index];
+        data[this.name] = obj.elem.checked?1:0;
+        http.post(baseUrl+"/sensor/edit/auth", {id: data.id, status: data[this.name]}, function (res) {
+            layer.msg(res.msg, {icon: 1});
+        })
+    })
+
+    window.pakoutPreview = pakoutPreview;
+
+    // ----------------------------------------------------------------------------------------------------------------------------------
+
+    // 鍚堝苟鍑哄簱
+    form.on('submit(mergeOut)', function (data) {
+        let checkStatus = layui.table.checkStatus('originTable').data;
+        if (checkStatus.length < 2) {
+            layer.msg("璇疯嚦灏戦�夋嫨涓ゆ潯浠ヤ笂鍚堝苟鏁版嵁", {icon: 7});
+            return false;
+        }
+        showMerge(checkStatus.map(function (d) {
+            return d.id;
+        }));
+    });
+
+    // 璁㈠崟鍚堝苟绐楀彛
+    function showMerge(orderIds) {
+        let loadIndex = layer.load(2);
+        $.ajax({
+            url: baseUrl+"/order/merge/preview/auth",
+            headers: {'token': localStorage.getItem('token')},
+            method: 'GET',
+            data: {
+                orderIds: orderIds
+            },
+            success: function (res) {
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    layer.open({
+                        type: 1
+                        , title: false
+                        , closeBtn: false
+                        , offset: '50px'
+                        , area: ['1200px', '700px']
+                        , shade: 0.5
+                        , shadeClose: false
+                        , btn: ['纭畾', '鍙栨秷']
+                        , btnAlign: 'c'
+                        , moveType: 1 //鎷栨嫿妯″紡锛�0鎴栬��1
+                        , content: $('#mergeDialog').html()
+                        , success: function (layero, index) {
+                            orderMergeTabIdx = table.render({
+                                elem: '#orderMergeTab',
+                                data: res.data,
+                                height: 550,
+                                page: false,
+                                limit: Number.MAX_VALUE,
+                                cellMinWidth: 100,
+                                cols: [[
+                                    {type: 'checkbox'},
+                                    {field: 'matnr', title: '鐗╂枡鍙�', align: 'center', width: 350},
+                                    {field: 'maktx', title: '鐗╂枡鍚嶇О', align: 'center'},
+                                    {field: 'specs', title: '瑙勬牸', align: 'center'},
+                                    {field: 'batch', title: '鎵瑰彿', align: 'center'},
+                                    {field: 'anfme', title: '鏁伴噺', align: 'center', width: 90, style: 'font-weight: bold'},
+                                ]],
+                                done: function (res) {
+                                    $('.layui-table-body.layui-table-main').css("overflow", "auto");
+                                }
+                            });
+                        }
+                        , yes: function (index, layero) {
+                            //鎸夐挳銆愮‘瀹氥�戠殑鍥炶皟
+                            let checkStatus = layui.table.checkStatus('orderMergeTab').data;
+                            if (checkStatus.length < 1) {
+                                layer.msg("璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�", {icon: 7});
+                                return false;
+                            }
+                            let loadIndex = layer.load(2);
+                            $.ajax({
+                                url: baseUrl + "/out/pakout/preview/merge/auth",
+                                headers: {'token': localStorage.getItem('token')},
+                                contentType: 'application/json;charset=UTF-8',
+                                data: JSON.stringify(checkStatus),
+                                method: 'POST',
+                                success: function (res) {
+                                    layer.close(loadIndex);
+                                    if (res.code === 200){
+                                        layer.close(index)
+                                        pakoutPreviewMergeDialog(res.data)
+                                    } else if (res.code === 403){
+                                        top.location.href = baseUrl+"/";
+                                    } else {
+                                        layer.msg(res.msg, {icon: 2})
+                                    }
+                                }
+                            })
+                        }
+                        , btn2: function (index, layero) {
+                            //鎸夐挳銆愬彇娑堛�戠殑鍥炶皟
+                            layer.close(index)
+                            //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
+                        }
+                    })
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    layer.msg(res.msg, {icon: 2})
+                }
+            }
+        })
+    }
+
+    function pakoutPreviewMergeDialog(data) {
+        for(var i=0; i<data.length; i++){
+            if(!data[i].staNos){
+                data[i].staNos = data[i].agvStaNos;
+                data[i].staNo = data[i].agvStaNo;
+            }
+        }
+        var mergeTabCache;
+        layer.open({
+            type: 1
+            ,title: false
+            ,closeBtn: false
+            ,offset: '50px'
+            ,area: ['1200px', '700px']
+            ,shade: 0.5
+            ,shadeClose: false
+            ,btn: ['绔嬪嵆鍑哄簱', '绋嶅悗澶勭悊']
+            ,btnAlign: 'c'
+            ,moveType: 1 //鎷栨嫿妯″紡锛�0鎴栬��1
+            ,content: $('#pakoutPreviewMergeBox').html()
+            ,success: function(layero, index){
+                stoPreTabMergeIdx = table.render({
+                    elem: '#stoPreTabMerge',
+                    data: data,
+                    height: 520,
+                    page: false,
+                    limit: Number.MAX_VALUE,
+                    cellMinWidth: 100,
+                    cols: [[
+                        // {type: 'checkbox', merge: ['orderNo']},
+                        {field: 'title', title: '鍟嗗搧', merge: true, align: 'center', width: 350},
+                        {field: 'specs', title: '瑙勬牸', align: 'center'},
+                        {field: 'batch', title: '搴忓垪鐮�', align: 'center'},
+                        {field: 'anfme', title: '鏁伴噺', align: 'center', width: 90, style: 'font-weight: bold'},
+                        {field: 'locNo', title: '璐т綅', align: 'center', templet: '#locNoTpl'},
+                        {field: 'staNos', align: 'center', title: '鍑哄簱绔�', merge: ['locNo'], templet: '#tbBasicTbStaNos'},
+                        // {type: 'checkbox', merge: ['locNo']},
+                    ]],
+                    done: function (res) {
+                        tableMerge.render(this);
+                        $('.layui-table-body.layui-table-main').css("overflow", "auto");
+                        mergeTabCache = table.cache.stoPreTabMerge;
+                    }
+                });
+                // 淇敼鍑哄簱绔�
+                form.on('select(tbBasicTbStaNos)', function (obj) {
+                    let index  = obj.othis.parents('tr').attr("data-index");
+                    let data = mergeTabCache[index];
+                    for (let i = 0; i<mergeTabCache.length; i++) {
+                        if (mergeTabCache[i].locNo === data.locNo) {
+                            //mergeTabCache[i]['staNo'] = Number(obj.elem.value);
+                            mergeTabCache[i]['staNo'] = obj.elem.value;
+                        }
+                    }
+                    obj.othis.children().find("input").css("color", "blue");
+                    return false;
+                });
+                // 鎵归噺淇敼鍑哄簱绔�
+                form.on('submit(batchModifySta)', function () {
+                    modifySta();
+                });
+                // 鎵归噺淇敼鍑哄簱绔� - 绔欑偣閫夋嫨
+                function modifySta() {
+                    // 鍑哄簱绔欏彇浜ら泦
+                    let staBatchSelectVal = [];
+                    for(let i = 0; i<mergeTabCache.length; i++) {
+                        let staNos = mergeTabCache[i].staNos;
+                        if (staNos !== null) {
+                            if (staBatchSelectVal.length === 0) {
+                                staBatchSelectVal = staNos;
+                            } else {
+                                staBatchSelectVal = staBatchSelectVal.filter(val =>
+                                    {
+                                        return new Set(staNos).has(val)
+                                    }
+                                )
+                            }
+                        }
+                    }
+                    if (staBatchSelectVal.length === 0) {
+                        layer.msg("鍑哄簱绔欐病鏈変氦闆嗭紝鏃犳硶鎵归噺淇敼", {icon: 2});
+                        return;
+                    }
+                    admin.open({
+                        type: 1,
+                        area: '300px',
+                        offset: 'auto',
+                        title: '璇烽�夋嫨绔欑偣',
+                        content: $('#staBatchSelectDialog').html(),
+                        success: function (layero, ddIndex) {
+                            // 娓叉煋涓嬫媺妗�
+                            let template = Handlebars.compile($('#batchStaSelectTpl').html());
+                            $('#batchSelectStaBox').html(template({list: staBatchSelectVal}));
+                            // 纭
+                            form.on('submit(staBatchSelectConfirm)', function (obj) {
+                                let loadIdx = layer.load(2);
+                                //let batchSta = Number(obj.field.batchSta);
+                                let batchSta = obj.field.batchSta;
+                                let arr = [];
+                                for (let i = 0; i<mergeTabCache.length; i++) {
+                                    mergeTabCache[i]['staNo'] = batchSta;
+                                    arr.push(i);
+                                }
+                                console.log(mergeTabCache)
+                                stoPreTabMergeIdx.reload({data: mergeTabCache});
+                                arr.forEach(item => {
+                                    $('div[lay-id=stoPreTabMerge] tr[data-index="' + item + '"] .order-sta-select').val(batchSta);
+                                });
+                                layui.form.render('select');
+                                arr.forEach(item => {
+                                    $('div[lay-id=stoPreTabMerge] tr[data-index="' + item + '"] .layui-select-title').find("input").css("color", "blue");
+                                });
+                                layer.close(loadIdx); layer.close(ddIndex);
+                                return false;
+                            });
+                            // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+                            $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                            layui.form.render('select');
+                        },
+                    })
+                }
+
+            }
+            ,yes: function(index, layero){
+                //鎸夐挳銆愮珛鍗冲嚭搴撱�戠殑鍥炶皟
+                pakout(mergeTabCache, index);
+            }
+            ,btn2: function(index, layero){
+                //鎸夐挳銆愮◢鍚庡鐞嗐�戠殑鍥炶皟
+                layer.close(index)
+                //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
+            }
+        });
+    }
+
+
+});
+
+function tableReload(child) {
+    var searchData = {};
+    $.each($('#search-box [name]').serializeArray(), function() {
+        searchData[this.name] = this.value;
+    });
+    (child ? parent.tableIns : tableIns).reload({
+        where: searchData,
+        page: {
+            curr: pageCurr
+        }
+    });
+}
+
+/**
+ * 涓�閿嚭搴�
+ */
+function autoOut(orderId) {
+    let loadIndex = layer.msg('璇锋眰涓�...', {icon: 16, shade: 0.01, time: false});
+    $.ajax({
+        url: baseUrl + "/out/pakout/orderDetlIds/auth",
+        headers: {'token': localStorage.getItem('token')},
+        data: { orderId : orderId },
+        method: 'POST',
+        success: function (res) {
+            layer.close(loadIndex);
+            if (res.code === 200){
+                pakoutPreview(res.data);
+            } else if (res.code === 403){
+                top.location.href = baseUrl+"/";
+            } else {
+                layer.msg(res.msg, {icon: 2});
+            }
+        }
+    })
+}

--
Gitblit v1.9.1