From 0670ffb1086287ad7dc5f98466f02075ba6350e0 Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Wed, 15 Jan 2025 09:37:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cpts/excel-template-confirmation.vue | 2 +- .../base/smartExcel/cpts/excel-view.vue | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue index c7b92527e..1824f1da2 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue @@ -2,7 +2,7 @@
-
+
取 消 确 定 diff --git a/src/views/modules/base/smartExcel/cpts/excel-view.vue b/src/views/modules/base/smartExcel/cpts/excel-view.vue index c083f9b35..8802b18a6 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -53,6 +53,7 @@ export default { ], menuActive: 0, socket: null, + currentTable:'' }; }, props: { @@ -143,15 +144,23 @@ export default { }, getAllTables() { let list = luckysheet.getAllSheets() - let currentTable = list.filter(item => item.status == '1') - const findFirstAllNullIndex = (arr) => { - return arr.findIndex(subArray => Array.isArray(subArray) && subArray.every(item => item === null)); + this.currentTable = list.filter(item => item.status == '1') + + const findLastNonNullIndex = (arr) => { + for (let i = arr.length - 1; i >= 0; i--) { + const subArray = arr[i]; + // 判断:是数组,且至少有一个不为 null 的元素 + if (Array.isArray(subArray) && subArray.some(item => item !== null && item.v && item.v !== null&& item.v !== '')) { + return i; // 返回下标 + } + } + return -1; // 如果没有符合条件的,返回 -1 }; - this.sheetR = findFirstAllNullIndex(currentTable[0].data) + this.sheetR = findLastNonNullIndex(this.currentTable[0].data) + console.log(this.sheetR); if(this.sheetR != -1){ + luckysheet.insertRow(this.currentTable[0].data.length,5) this.updataSheet() - }else{ - luckysheet.insertRow(currentTable[0].data.length,5) } }, updataSheet() { @@ -196,9 +205,9 @@ export default { } ] arr.forEach((item, index) => { + luckysheet.insertRow(this.currentTable[0].data.length,1) for (let k in item) { - // index +1 + this.sheetR(当前表最后一个有数据的行) - luckysheet.setCellValue(index+this.sheetR, k - 1, item[k]) + luckysheet.setCellValue(index+this.sheetR + 1, k - 1, item[k]) } }) }, From fa3e51f8095de6c1df1c61f73405053b6aeb9bea Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Wed, 15 Jan 2025 10:12:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E5=AE=B9=E5=99=A8Id=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cpts/excel-template-confirmation.vue | 15 +++------------ .../modules/base/smartExcel/cpts/excel-view.vue | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue index 1824f1da2..e94650193 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue @@ -2,7 +2,7 @@
-
+
取 消 确 定 @@ -53,6 +53,7 @@ export default { that.exportJson = exportJson if (exportJson.sheets == null || exportJson.sheets.length == 0) return alert('读取excel文件内容失败, 目前不支持XLS文件!'); window.luckysheet.destroy(); + options.container = 'luckysheet1' window.luckysheet.create({ ...options, data: exportJson.sheets, @@ -71,16 +72,6 @@ export default { mounted() { console.log(this.fileUrl, 'fileUrl==='); this.urlToFile('http://localhost:9001/epmet-work-pc/test1.xlsx',this.fileName) - this.$nextTick(() => { - window.luckysheet.destroy(); - options.title = '模板确认' - window.luckysheet.create({ - ...options, - hook: { - cellEditBefore: this.handleCellEditBefore, - }, - }); - }) }, props: { @@ -104,7 +95,7 @@ export default { \ No newline at end of file diff --git a/src/views/modules/base/smartExcel/cpts/excel-view.vue b/src/views/modules/base/smartExcel/cpts/excel-view.vue index bca103f7f..959192b86 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -96,6 +96,7 @@ export default { const { id } = this.$store.state.user; options.gridKey = this.workbookId; options.allowUpdate = true; + options.container = 'luckysheet' options.loadUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/load?workbookId=${this.workbookId}` options.updateUrl = `ws://219.146.91.110:30801/api/actual/base/ws/luckysheet/${this.workbookId}/${id}` options.loadSheetUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/loadSheets?workbookId=${this.workbookId}`