From c56c5744f2fec4de83c88c2597566c1f5235bba0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 17 十月 2022 15:10:23 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/orderTable.js |    2 
 src/main/webapp/static/js/order/out.js  |  140 ++++++++++++++++++++++++++++++++++++++++++++++
 src/main/webapp/views/order/out.html    |    7 +
 3 files changed, 146 insertions(+), 3 deletions(-)

diff --git a/src/main/webapp/static/js/order/out.js b/src/main/webapp/static/js/order/out.js
index 4889cf0..832b4dc 100644
--- a/src/main/webapp/static/js/order/out.js
+++ b/src/main/webapp/static/js/order/out.js
@@ -333,6 +333,146 @@
 
     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+"/delivery/merge/preview/auth",
+            headers: {'token': localStorage.getItem('token')},
+            method: 'GET',
+            data: {
+                orderIds: orderIds
+            },
+            success: function (res) {
+                layer.close(loadIndex);
+                if (res.code === 200){
+                    admin.open({
+                        type: 1,
+                        title: '璁㈠崟鍚堝苟 銆� 鏁伴噺锛�' + orderIds.length + " 銆�",
+                        content: $('#mergeDialog').html(),
+                        area: '900px',
+                        success: function (layero, dIndex) {
+                            $('#newOrderNo').val(res.data.newOrderNo);
+                            // 娓叉煋瀹㈡埛鍒楄〃
+                            let cstmrVal = xmSelect.render({
+                                el: '#cstmrSelect',
+                                radio: true,
+                                clickClose: true,
+                                filterable: true,
+                                create: function(val, arr){
+                                    if(arr.length === 0){
+                                        return {
+                                            name:  val,
+                                            value: val
+                                        }
+                                    }
+                                },
+                                model: {
+                                    icon: 'hidden',
+                                    label: {
+                                        type: 'text',
+                                    }
+                                },
+                                data: res.data.cstmrs
+                            })
+                            // 娓叉煋鏄庣粏
+                            let xxDataList = res.data.orderDetls;
+                            let tbOptions = {
+                                elem: '#mergeTable',
+                                headers: {token: localStorage.getItem('token')},
+                                data: xxDataList,
+                                limit: 9999,
+                                height: '350px;',
+                                cellMinWidth: 100,
+                                cols: [[
+                                    {type: 'numbers', title: '#'},
+                                    {field: 'matnr', title: '鍟嗗搧缂栫爜', minWidth: 170},
+                                    {field: 'maktx', title: '鍟嗗搧鍚嶇О'},
+                                    {field: 'batch', title: '鎵瑰彿'},
+                                    {field: 'anfme', title: '鏁伴噺', minWidth: 80, width: 80},
+                                    {field: 'unitPrice', title: '鍗曚环(淇敼)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 120, width: 120, fixed: 'right'},
+                                    // {align: 'center', title: '鎿嶄綔', toolbar: '#formSSXMTableBar', minWidth: 80, width: 80}
+                                ]],
+                                done: function (res) {
+                                    $(layero).find('.layui-table-view').css('margin', '0');
+                                }
+                            };
+                            let insMergeTb = table.render(tbOptions);
+                            // 浠锋牸淇敼
+                            table.on('edit(mergeTable)', function (obj) {
+                                let unitPrice = Number(obj.value);
+                                if (isNaN(unitPrice)) {
+                                    layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
+                                } else {
+                                    if (unitPrice > 0) {
+                                        for (let i=0;i<xxDataList.length;i++){
+                                            if (xxDataList[i]["matnr"] === obj.data.matnr && xxDataList[i]["batch"] === obj.data.batch){
+                                                xxDataList[i]["unitPrice"] = unitPrice;
+                                                break;
+                                            }
+                                        }
+                                    } else {
+                                        layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2});
+                                    }
+                                }
+                                insMergeTb.reload({data: xxDataList});
+                            });
+                            // 鍚堝苟琛ㄥ崟鎻愪氦浜嬩欢
+                            form.on('submit(mergeSubmit)', function (data) {
+                                let nList = admin.util.deepClone(xxDataList);
+                                data.field.cstmr = cstmrVal.getValue()[0] ? cstmrVal.getValue()[0].name : null;
+                                layer.load(2);
+                                $.ajax({
+                                    url: baseUrl+"/delivery/merge/auth",
+                                    headers: {'token': localStorage.getItem('token')},
+                                    data: JSON.stringify({
+                                        oldOrderIds: orderIds,
+                                        orderNo: data.field.newOrderNo,
+                                        cstmr: data.field.cstmr,
+                                        orderDetls: nList
+                                    }),
+                                    contentType:'application/json;charset=UTF-8',
+                                    method: 'POST',
+                                    success: function (res) {
+                                        layer.closeAll('loading');
+                                        if (res.code === 200){
+                                            layer.close(dIndex);
+                                            $(".layui-laypage-btn")[0].click();
+                                            layer.msg(res.msg, {icon: 1});
+                                        } else if (res.code === 403){
+                                            top.location.href = baseUrl+"/";
+                                        }else {
+                                            layer.msg(res.msg, {icon: 2});
+                                        }
+                                    }
+                                })
+                                return false;
+                            });
+                            $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                        }
+                    });
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    layer.msg(res.msg, {icon: 2})
+                }
+            }
+        })
+    }
+
+
 });
 
 function tableReload(child) {
diff --git a/src/main/webapp/static/js/orderTable.js b/src/main/webapp/static/js/orderTable.js
index 72f9075..450fd13 100644
--- a/src/main/webapp/static/js/orderTable.js
+++ b/src/main/webapp/static/js/orderTable.js
@@ -39,7 +39,7 @@
         //     '</p>'].join(''),
         defaultToolbar: [],
         cols: [[
-            // {type: 'numbers', title: '#'},
+            {type: 'checkbox'},
             {field: 'orderTime', title: '鏃ユ湡'},
             {field: 'orderNo', title: '鍗曟嵁缂栧彿', align: 'center'}
         ]],
diff --git a/src/main/webapp/views/order/out.html b/src/main/webapp/views/order/out.html
index 5e9532d..08c97ce 100644
--- a/src/main/webapp/views/order/out.html
+++ b/src/main/webapp/views/order/out.html
@@ -71,10 +71,10 @@
                 <div class="layui-card-body" style="padding: 10px;">
                     <form class="layui-form toolbar">
                         <div class="layui-form-item">
-                            <div class="layui-inline" style="max-width: 300px;">
+                            <div class="layui-inline" style="max-width: 300px;margin-bottom: 5px">
                                 <input name="orderNo" class="layui-input" placeholder="杈撳叆鍗曟嵁缂栧彿" autocomplete="off"/>
                             </div>
-                            <div class="layui-inline">
+                            <div class="layui-inline" style="margin-bottom: 5px">
                                 <button class="layui-btn icon-btn" lay-filter="originTableSearch" lay-submit>
                                     <i class="layui-icon">&#xe615;</i>鎼滅储
                                 </button>
@@ -84,6 +84,9 @@
                             </div>
                         </div>
                     </form>
+                    <button style="margin-bottom: 5px" class="layui-btn icon-btn layui-btn-danger" lay-filter="mergeOut" lay-submit>
+                        <i class="layui-icon">&#xe656;</i>&nbsp;鍚堝苟鍑哄簱
+                    </button>
                     <table id="originTable" lay-filter="originTable"></table>
                 </div>
             </div>

--
Gitblit v1.9.1