diff --git a/package.json b/package.json
index e2fe74cd1..2e2eb6e88 100644
--- a/package.json
+++ b/package.json
@@ -60,6 +60,7 @@
"vue-types": "^5.1.1",
"vuedraggable": "^4.1.0",
"web-storage-cache": "^1.1.1",
+ "xlsx": "^0.18.5",
"xml-js": "^1.6.11"
},
"devDependencies": {
diff --git a/src/components/ImportForm/src/ImportFormStep.vue b/src/components/ImportForm/src/ImportFormStep.vue
index 616527ac4..832e09cee 100644
--- a/src/components/ImportForm/src/ImportFormStep.vue
+++ b/src/components/ImportForm/src/ImportFormStep.vue
@@ -82,7 +82,7 @@
{{ t('ts.下载模板') }}
-
+
{{ t('ts.下载差异数据') }}
@@ -101,6 +101,7 @@ import download from '@/utils/download'
import { getBaseUrl } from '@/utils/systemParam'
import { UploadFilled, List, CircleCheckFilled,WarningFilled } from '@element-plus/icons-vue'
import { waitForDebugger } from 'node:inspector/promises'
+import * as XLSX from 'xlsx';
defineOptions({ name: 'ImportForm' })
@@ -432,6 +433,37 @@ const importTemplate = () => {
const res = importTemplateData.value.templateUrl
download.excel(res, importTemplateData.value.templateTitle)
}
+
+const downloadDifferenceData = () => {
+ if (props.tableObject.tableList.length === 0) {
+ message.warning('没有可下载的差异数据');
+ return;
+ }
+
+ // 获取当前使用的列定义
+ const columns = currentColumns.value;
+
+ // 创建工作簿和工作表,使用原始数据
+ const wb = XLSX.utils.book_new();
+ const ws = XLSX.utils.json_to_sheet(props.tableObject.tableList);
+
+ // 替换表头为中文;
+ columns.forEach((col, index) => {
+ const cellAddress = XLSX.utils.encode_cell({ r: 0, c: index });
+ if (ws[cellAddress]) {
+ ws[cellAddress].v = col.label;
+ }
+ });
+
+ // 设置列宽(可选)
+ const colWidth = columns.map(() => ({ wch: 20 }));
+ ws['!cols'] = colWidth;
+
+ // 添加工作表到工作簿并下载
+ XLSX.utils.book_append_sheet(wb, ws, "差异数据");
+ const timestamp = new Date().getTime();
+ XLSX.writeFile(wb, `差异数据_${timestamp}.xlsx`);
+}