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..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 98e592dcb..959192b86 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -59,6 +59,7 @@ export default { ], menuActive: 0, socket: null, + currentTable:'' }; }, props: { @@ -95,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}` @@ -155,15 +157,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() { @@ -208,9 +218,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]) } }) },