From e28269e80c3d8cdd4b77566263f684532436b489 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期五, 21 二月 2025 09:13:53 +0800
Subject: [PATCH] 拣货单管理多选,全选excel导出

---
 src/main/webapp/static/js/picking/picking.js |   85 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/src/main/webapp/static/js/picking/picking.js b/src/main/webapp/static/js/picking/picking.js
index cfac7df..13e3129 100644
--- a/src/main/webapp/static/js/picking/picking.js
+++ b/src/main/webapp/static/js/picking/picking.js
@@ -2,6 +2,8 @@
 var printMatCodeNos = [];
 var ordernoo = "123";
 var insTbCount = 0;
+var selectedData = [];
+var selectType = 'one';
 layui.config({
     base: baseUrl + "/static/layui/lay/modules/"
 }).use(['table','laydate', 'form', 'admin', 'layer'], function(){
@@ -27,11 +29,11 @@
         limit: 15,
         limits: [15, 30, 50, 100, 200, 500],
         // toolbar: '#toolbar',
-        cellMinWidth: 50,
+        // cellMinWidth: 50,
         height: 'full-120',
         cols: [[
-            // {type: 'checkbox'}
-            {type: 'numbers'}
+            {type: 'checkbox'}
+            ,{type: 'numbers', title: '搴忓彿'}
             ,{field: 'wrkNo', align: 'center',title: 'id', hide:true}
             ,{field: 'doc_num',title: '鎷h揣鍗曞彿' }
             ,{align: 'center', title: '浜岀淮鐮�', toolbar: '#operate', width: 200 , hide:true}
@@ -40,7 +42,7 @@
             ,{field: 'custName', align: 'center',title: '瀹㈡埛鍚嶇О', width: 160}
             ,{field: 'createTime$', align: 'center',title: '鍒涘缓鏃堕棿'}
             ,{field: 'updateTime$', align: 'center',title: '鍑哄簱鏃堕棿'}
-            ,{align: 'center', title: '鎿嶄綔', toolbar: '#operate'}
+            ,{align: 'center', title: '鎿嶄綔', toolbar: '#operate',width: 300}
 
         ]],
         request: {
@@ -48,7 +50,6 @@
             pageSize: 'limit'
         },
         parseData: function (res) {
-            console.log(res);
             return {
                 'code': res.code,
                 'msg': res.msg,
@@ -72,6 +73,19 @@
                 if ($(this).text() === '鏈嚭搴�') {
                     $('tr').eq(index).css("color", 'red');
                 }
+            });
+
+            // 閲嶆柊鍕鹃��
+            var selectedOrderNos = selectedData.map(item => item.doc_num);
+            var indexArr = []
+            res.data.forEach(function (item,index) {
+                if (selectedOrderNos.includes(item.doc_num)) {
+                    indexArr.push(index)
+                }
+            })
+
+            table.setRowChecked('saasLog',{
+                index: indexArr
             });
         }
     });
@@ -233,13 +247,74 @@
         tableReload(false);
     });
 
+    // 澶嶉�夋鍕鹃�変簨浠�
+    table.on('checkbox(saasLog)', function (obj) {
+        if (obj.type === 'all' && obj.checked) {
+            selectType = 'all'
+        } else if (obj.type === 'one' && obj.checked) {
+            selectType = 'one'
+            selectedData.push(obj.data); // 閫変腑鏃朵繚瀛樻暟鎹�
+        } else if (obj.type === 'one' && !obj.checked && obj.index !== undefined) {
+            selectType = 'one'
+            selectedData = selectedData.filter(item => item.doc_num !== obj.data.doc_num); // 鍙栨秷鏃剁Щ闄ゆ暟鎹�
+        } else if (obj.type === 'all' && !obj.checked && obj.index === undefined) {
+            selectType = 'one'
+            selectedData = [];
+        }
+    });
+
     // 閲嶇疆
     form.on('submit(reset)', function (data) {
         pageCurr = 1;
+        selectedData = []
+        selectType = 'one'
         clearFormVal($('#search-box'));
         tableReload(false);
     });
 
+    // 瀵煎嚭
+    form.on('submit(exportExcel)', function (data) {
+        layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function () {
+            layer.closeAll();
+            layer.load(1, {shade: [0.1, '#fff']});
+            var reqData = {};
+            reqData.type = selectType;
+            if (reqData.type === 'one') {
+                if (selectedData.length === 0) {
+                    layer.msg('璇峰厛鍕鹃�夋暟鎹�')
+                    layer.closeAll('loading');
+                    return
+                }
+                reqData.docNumList = selectedData.map(item => item.doc_num);
+            } else {
+                var searchData = {};
+                $.each($('#search-box [name]').serializeArray(), function() {
+                    searchData[this.name] = this.value;
+                });
+                reqData.queryWhere = searchData
+            }
+            $.ajax({
+                url: baseUrl + "/pakOut/excelExport3/auth",
+                headers: {'token': localStorage.getItem('token')},
+                data: JSON.stringify(reqData),
+                contentType: 'application/json;charset=UTF-8',
+                method: 'POST',
+                xhrFields: {
+                    responseType: 'blob'  // 澶勭悊杩斿洖鐨勬枃浠舵祦
+                },
+                success: function (res) {
+                    var link = document.createElement('a');
+                    link.href = URL.createObjectURL(res);  // 浣跨敤 Blob 瀵硅薄鐢熸垚涓存椂 URL
+                    link.download = new Date().getTime() + '.xlsx';  // 璁剧疆涓嬭浇鐨勬枃浠跺悕
+                    document.body.appendChild(link);
+                    link.click();  // 瑙﹀彂涓嬭浇
+                    document.body.removeChild(link);
+                }
+            });
+            layer.closeAll('loading');
+        });
+    });
+
     // 鏃堕棿閫夋嫨鍣�
     function layDateRender(data) {
         setTimeout(function () {

--
Gitblit v1.9.1