From 0406c675e143bbb08284fd55381261afcc587afc Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期日, 18 一月 2026 15:51:36 +0800
Subject: [PATCH] 月结增加明细
---
src/main/webapp/static/js/monthlySettle/monthlySettle.js | 170 ++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 133 insertions(+), 37 deletions(-)
diff --git a/src/main/webapp/static/js/monthlySettle/monthlySettle.js b/src/main/webapp/static/js/monthlySettle/monthlySettle.js
index 87b7958..740f243 100644
--- a/src/main/webapp/static/js/monthlySettle/monthlySettle.js
+++ b/src/main/webapp/static/js/monthlySettle/monthlySettle.js
@@ -1,7 +1,7 @@
var pageCurr;
layui.config({
base: baseUrl + "/static/layui/lay/modules/"
-}).use(['layer', 'form', 'table', 'util', 'admin', 'laydate', 'laytpl'], function () {
+}).use(['layer', 'form', 'table', 'util', 'admin', 'laydate', 'laytpl', 'element'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var form = layui.form;
@@ -10,6 +10,7 @@
var admin = layui.admin;
var layDate = layui.laydate;
var laytpl = layui.laytpl;
+ var element = layui.element;
// 娓叉煋琛ㄦ牸
tableIns = table.render({
@@ -52,6 +53,7 @@
}
pageCurr = curr;
// 寤惰繜璋冪敤鏉冮檺鎺у埗锛岀‘淇濊〃鏍兼搷浣滃垪鐨勬寜閽凡缁忔覆鏌撳畬鎴�
+ // 鏀逛负寮傛璇锋眰锛岄伩鍏嶉樆濉為〉闈㈡覆鏌�
setTimeout(function() {
var param = window.location.href.split("?")[1];
if (null != param) {
@@ -60,7 +62,7 @@
url: baseUrl+"/power/menu/"+resourceId+"/auth",
headers: {'token': localStorage.getItem('token')},
method: 'GET',
- async: false,
+ async: true, // 鏀逛负寮傛锛屼笉闃诲椤甸潰娓叉煋
success: function (res) {
if (res.code === 200){
for(var i = 0, len = res.data.length; i < len; i++) {
@@ -412,7 +414,8 @@
layer.closeAll('loading');
if (res.code === 200) {
var settle = res.data.settle;
- var details = res.data.details;
+ var details = res.data.details || [];
+ var detailFlows = res.data.detailFlows || [];
// 鍏堟覆鏌撴ā鏉�
var template = $('#detailDialog').html();
@@ -424,7 +427,41 @@
content: html,
area: ['90%', '80%'],
success: function (layero, dIndex) {
- // 娓叉煋鏄庣粏琛ㄦ牸锛堝璐﹀崟鏍煎紡锛�
+ // 鍒濆鍖杢ab缁勪欢锛屼娇鍏跺彲浠ュ垏鎹�
+ element.render('tab', 'monthlySettleDetailTab');
+
+ // 娓叉煋鏄庣粏娴佹按琛ㄦ牸锛堢涓�椤碉級
+ table.render({
+ elem: '#detailFlowTable',
+ data: detailFlows,
+ page: true,
+ cellMinWidth: 100,
+ width: '100%',
+ cols: [[
+ {type: 'numbers', title: '搴忓彿', width: 60, align: 'center'},
+ {field: 'orderNo', title: '璁㈠崟缂栧彿', width: 150},
+ {field: 'orderTime', title: '涓氬姟鏃堕棿', width: 180},
+ {field: 'pakinPakoutStatusName', title: '绫诲瀷', width: 80, align: 'center'},
+ {field: 'matnr', title: '鐗╂枡缂栫爜', width: 150},
+ {field: 'maktx', title: '鐗╂枡鍚嶇О', width: 200},
+ {field: 'batch', title: '鎵规', width: 120},
+ {field: 'brand', title: '鍝佺墝', width: 120},
+ {field: 'specs', title: '瑙勬牸', width: 120},
+ {
+ field: 'qty',
+ align: 'right',
+ title: '鏁伴噺',
+ width: 120,
+ templet: function (d) {
+ var qty = parseFloat(d.qty || 0);
+ return qty.toFixed(2);
+ }
+ },
+ {field: 'unit', title: '鍗曚綅', width: 80}
+ ]]
+ });
+
+ // 娓叉煋姹囨�昏〃鏍硷紙绗簩椤碉級
table.render({
elem: '#detailTable',
data: details,
@@ -506,6 +543,46 @@
});
}
+ // 鍔ㄦ�佸姞杞� xlsx.js 搴�
+ function loadXLSXLibrary(callback) {
+ // 濡傛灉宸茬粡鍔犺浇锛岀洿鎺ユ墽琛屽洖璋�
+ if (typeof XLSX !== 'undefined') {
+ callback();
+ return;
+ }
+
+ // 妫�鏌ユ槸鍚︽鍦ㄥ姞杞�
+ if (window._xlsxLoading) {
+ // 濡傛灉姝e湪鍔犺浇锛岀瓑寰呭姞杞藉畬鎴�
+ var checkInterval = setInterval(function() {
+ if (typeof XLSX !== 'undefined') {
+ clearInterval(checkInterval);
+ callback();
+ }
+ }, 100);
+ return;
+ }
+
+ // 寮�濮嬪姞杞�
+ window._xlsxLoading = true;
+ layer.load(2, {content: '姝e湪鍔犺浇瀵煎嚭搴�...'});
+
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = 'https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js';
+ script.onload = function() {
+ window._xlsxLoading = false;
+ layer.closeAll('loading');
+ callback();
+ };
+ script.onerror = function() {
+ window._xlsxLoading = false;
+ layer.closeAll('loading');
+ layer.msg('鍔犺浇瀵煎嚭搴撳け璐ワ紝璇锋鏌ョ綉缁滆繛鎺�', {icon: 2});
+ };
+ document.head.appendChild(script);
+ }
+
// 瀵煎嚭鏈堢粨鏄庣粏
function exportDetail(data) {
layer.confirm('纭畾瀵煎嚭鏈堢粨鏄庣粏 "' + data.settleNo + '" 鍚楋紵', {
@@ -513,39 +590,57 @@
skin: 'layui-layer-admin'
}, function (i) {
layer.close(i);
- layer.load(2);
- $.ajax({
- url: baseUrl + '/monthlySettle/detail/export/' + data.id + '/auth',
- headers: {'token': localStorage.getItem('token')},
- method: 'POST',
- success: function (res) {
- layer.closeAll('loading');
- if (res.code === 200) {
- // 瀹氫箟琛ㄥご
- var titles = [
- '鐗╂枡缂栫爜',
- '鐗╂枡鍚嶇О',
- '鎵规',
- '鍝佺墝',
- '鏈熷垵搴撳瓨',
- '鏈熸湯搴撳瓨',
- '宸紓鏁伴噺',
- '鏈湡鍏ュ簱',
- '鏈湡鍑哄簱'
- ];
- // 浣跨敤 table.exportFile 瀵煎嚭
- table.exportFile(titles, res.data, 'xls');
- layer.msg('瀵煎嚭鎴愬姛', {icon: 1});
- } else if (res.code === 403) {
- top.location.href = baseUrl + "/";
- } else {
- layer.msg(res.msg || '瀵煎嚭澶辫触', {icon: 2});
+
+ // 鍏堝姞杞� xlsx.js 搴擄紝鐒跺悗鍐嶆墽琛屽鍑�
+ loadXLSXLibrary(function() {
+ layer.load(2);
+ $.ajax({
+ url: baseUrl + '/monthlySettle/detail/export/' + data.id + '/auth',
+ headers: {'token': localStorage.getItem('token')},
+ method: 'POST',
+ success: function (res) {
+ layer.closeAll('loading');
+ if (res.code === 200) {
+ var exportData = res.data;
+ // 绗竴椤碉細鏄庣粏娴佹按
+ var flowTitles = exportData.flowTitles || ['璁㈠崟缂栧彿', '涓氬姟鏃堕棿', '绫诲瀷', '鐗╂枡缂栫爜', '鐗╂枡鍚嶇О', '鎵规', '鍝佺墝', '瑙勬牸', '鏁伴噺', '鍗曚綅'];
+ var flowData = exportData.detailFlows || [];
+ // 绗簩椤碉細姹囨��
+ var summaryTitles = exportData.summaryTitles || ['鐗╂枡缂栫爜', '鐗╂枡鍚嶇О', '鎵规', '鍝佺墝', '鏈熷垵搴撳瓨', '鏈熸湯搴撳瓨', '宸紓鏁伴噺', '鏈湡鍏ュ簱', '鏈湡鍑哄簱'];
+ var summaryData = exportData.details || [];
+
+ try {
+ // 浣跨敤 xlsx.js 鍒涘缓鍖呭惈涓や釜sheet鐨凟xcel鏂囦欢
+ var wb = XLSX.utils.book_new();
+
+ // 鍒涘缓鏄庣粏娴佹按sheet
+ var flowWS = XLSX.utils.aoa_to_sheet([flowTitles].concat(flowData));
+ XLSX.utils.book_append_sheet(wb, flowWS, "鏄庣粏娴佹按");
+
+ // 鍒涘缓姹囨�籹heet
+ var summaryWS = XLSX.utils.aoa_to_sheet([summaryTitles].concat(summaryData));
+ XLSX.utils.book_append_sheet(wb, summaryWS, "姹囨��");
+
+ // 瀵煎嚭Excel鏂囦欢
+ var fileName = '鏈堢粨鏄庣粏_' + data.settleNo + '.xlsx';
+ XLSX.writeFile(wb, fileName);
+
+ layer.msg('瀵煎嚭鎴愬姛', {icon: 1, time: 2000});
+ } catch (e) {
+ console.error('瀵煎嚭澶辫触:', e);
+ layer.msg('瀵煎嚭澶辫触锛�' + (e.message || '鏈煡閿欒'), {icon: 2});
+ }
+ } else if (res.code === 403) {
+ top.location.href = baseUrl + "/";
+ } else {
+ layer.msg(res.msg || '瀵煎嚭澶辫触', {icon: 2});
+ }
+ },
+ error: function() {
+ layer.closeAll('loading');
+ layer.msg('瀵煎嚭澶辫触', {icon: 2});
}
- },
- error: function() {
- layer.closeAll('loading');
- layer.msg('瀵煎嚭澶辫触', {icon: 2});
- }
+ });
});
});
}
@@ -663,6 +758,7 @@
}
pageCurr=curr;
// 寤惰繜璋冪敤鏉冮檺鎺у埗锛岀‘淇濊〃鏍兼搷浣滃垪鐨勬寜閽凡缁忔覆鏌撳畬鎴�
+ // 鏀逛负寮傛璇锋眰锛岄伩鍏嶉樆濉為〉闈㈡覆鏌�
setTimeout(function() {
var param = window.location.href.split("?")[1];
if (null != param) {
@@ -671,7 +767,7 @@
url: baseUrl+"/power/menu/"+resourceId+"/auth",
headers: {'token': localStorage.getItem('token')},
method: 'GET',
- async: false,
+ async: true, // 鏀逛负寮傛锛屼笉闃诲椤甸潰娓叉煋
success: function (res) {
if (res.code === 200){
for(var i = 0, len = res.data.length; i < len; i++) {
--
Gitblit v1.9.1