From a451e2d9e1abcae3286dfcfec4103aad1ee64085 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期二, 08 四月 2025 15:08:54 +0800
Subject: [PATCH] *

---
 src/main/webapp/views/taskWrkLog/taskWrkLog.html |  120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 120 insertions(+), 0 deletions(-)

diff --git a/src/main/webapp/views/taskWrkLog/taskWrkLog.html b/src/main/webapp/views/taskWrkLog/taskWrkLog.html
index 8152575..d593008 100644
--- a/src/main/webapp/views/taskWrkLog/taskWrkLog.html
+++ b/src/main/webapp/views/taskWrkLog/taskWrkLog.html
@@ -10,6 +10,8 @@
 		<script type="text/javascript" src="../../static/wcs/js/common.js"></script>
 		<script type="text/javascript" src="../../static/wcs/js/vue.min.js"></script>
 		<script type="text/javascript" src="../../static/wcs/js/element.js"></script>
+		<script type="text/javascript" src="../../static/wcs/js/xlsx.full.min.js"></script>
+		<script type="text/javascript" src="../../static/wcs/js/FileSaver.min.js"></script>
 	</head>
 
 	<body>
@@ -26,6 +28,8 @@
 						<el-form-item>
 							<el-button type="primary" @click="getTableData">鏌ヨ</el-button>
 							<el-button type="primary" @click="resetParam">閲嶇疆</el-button>
+							<el-button type="primary" @click="exportTable">瀵煎嚭褰撳墠椤甸潰鏁版嵁</el-button>
+							<el-button type="primary" @click="exportTableAll">瀵煎嚭鎵�鏈�</el-button>
 						</el-form-item>
 					</el-form>
 					<el-table ref="singleTable" :data="tableData" style="width: 100%;">
@@ -93,6 +97,7 @@
 				el: '#app',
 				data: {
 					tableData: [],
+					tableDataAll: [],
 					currentPage: 1,
 					pageSizes: [16, 30, 50, 100, 150, 200],
 					pageSize: 16,
@@ -148,6 +153,115 @@
 							}
 						});
 					},
+					executeExportTable() {
+						// 1. 杩囨护鎿嶄綔鍒�
+						const exportData = this.tableData.map(item => {
+							const cloned = { ...item }
+							delete cloned.operation // 绉婚櫎鎿嶄綔鍒楀叧鑱斿瓧娈�
+							return cloned
+						})
+
+						// 2. 瀹屾暣瀛楁鏄犲皠
+						const headerMap = {
+							taskNo: '浠诲姟鍙�',
+							status$: '浠诲姟鐘舵��',
+							wrkNo: '宸ヤ綔鍙�',
+							createTime$: '鐢熸垚鏃堕棿',
+							modiTime$: '鏇存柊鏃堕棿',
+							assignTime$: '娲惧彂鏃堕棿',
+							executeTime$: '鎵ц鏃堕棿',
+							completeTime$: '瀹岀粨鏃堕棿',
+							cancelTime$: '鍙栨秷鏃堕棿',
+							durationTime: '鎸佺画鏃堕暱',
+							ioType$: '浠诲姟绫诲瀷',
+							startPoint: '璧风偣浣嶇疆',
+							targetPoint: '缁堢偣浣嶇疆',
+							wrkSts$: '宸ヤ綔鐘舵��',
+							crnNo: '鍫嗗灈鏈哄彿',
+							barcode: '鏉$爜',
+							memo: '澶囨敞'
+						}
+
+						// 3. 鍒涘缓宸ヤ綔琛�
+						const worksheet = XLSX.utils.json_to_sheet(exportData)
+
+						// 4. 鏇挎崲琛ㄥご涓轰腑鏂�
+						XLSX.utils.sheet_add_aoa(worksheet, [Object.values(headerMap)], { origin: 'A1' })
+
+						// 5. 鐢熸垚鏂囦欢鍚嶏紙甯︽棩鏈燂級
+						const fileName = `浠诲姟鍒楄〃_${new Date().toLocaleDateString().replace(/\//g, '-')}.xlsx`
+
+						// 6. 瀵煎嚭鏂囦欢
+						const workbook = XLSX.utils.book_new()
+						XLSX.utils.book_append_sheet(workbook, worksheet, '浠诲姟鏁版嵁')
+						XLSX.writeFile(workbook, fileName)
+					},
+					executeExportTableAll() {
+						let that = this;
+
+						$.ajax({
+							url: baseUrl + "/taskWrkLog/export/all/auth",
+							headers: {
+								'token': localStorage.getItem('token')
+							},
+							dataType: 'json',
+							contentType: 'application/json;charset=UTF-8',
+							method: 'GET',
+							success: function(res) {
+								if (res.code == 200) {
+									that.tableDataAll = res.data.records
+									// 1. 杩囨护鎿嶄綔鍒�
+									const exportData = that.tableDataAll.map(item => {
+										const cloned = { ...item }
+										delete cloned.operation // 绉婚櫎鎿嶄綔鍒楀叧鑱斿瓧娈�
+										return cloned
+									})
+
+									// 2. 瀹屾暣瀛楁鏄犲皠
+									const headerMap = {
+										taskNo: '浠诲姟鍙�',
+										status$: '浠诲姟鐘舵��',
+										wrkNo: '宸ヤ綔鍙�',
+										createTime$: '鐢熸垚鏃堕棿',
+										modiTime$: '鏇存柊鏃堕棿',
+										assignTime$: '娲惧彂鏃堕棿',
+										executeTime$: '鎵ц鏃堕棿',
+										completeTime$: '瀹岀粨鏃堕棿',
+										cancelTime$: '鍙栨秷鏃堕棿',
+										durationTime: '鎸佺画鏃堕暱',
+										ioType$: '浠诲姟绫诲瀷',
+										startPoint: '璧风偣浣嶇疆',
+										targetPoint: '缁堢偣浣嶇疆',
+										wrkSts$: '宸ヤ綔鐘舵��',
+										crnNo: '鍫嗗灈鏈哄彿',
+										barcode: '鏉$爜',
+										memo: '澶囨敞'
+									}
+
+									// 3. 鍒涘缓宸ヤ綔琛�
+									const worksheet = XLSX.utils.json_to_sheet(exportData)
+
+									// 4. 鏇挎崲琛ㄥご涓轰腑鏂�
+									XLSX.utils.sheet_add_aoa(worksheet, [Object.values(headerMap)], { origin: 'A1' })
+
+									// 5. 鐢熸垚鏂囦欢鍚嶏紙甯︽棩鏈燂級
+									const fileName = `浠诲姟鍒楄〃_${new Date().toLocaleDateString().replace(/\//g, '-')}.xlsx`
+
+									// 6. 瀵煎嚭鏂囦欢
+									const workbook = XLSX.utils.book_new()
+									XLSX.utils.book_append_sheet(workbook, worksheet, '浠诲姟鏁版嵁')
+									XLSX.writeFile(workbook, fileName)
+								} else if (res.code === 403) {
+									top.location.href = baseUrl + "/";
+								} else {
+									that.$message({
+										message: res.msg,
+										type: 'error'
+									});
+								}
+							}
+						});
+					},
 					handleSizeChange(val) {
 						console.log(`姣忛〉 ${val} 鏉);
 						this.pageSize = val
@@ -166,6 +280,12 @@
 						}
 						this.getTableData()
 					},
+					exportTable() {
+						this.executeExportTable()
+					},
+					exportTableAll() {
+						this.executeExportTableAll()
+					},
 					handleCommand(command, row) {
 						switch (command) {
 							case "showCommand":

--
Gitblit v1.9.1