From fdeb135f7f6ba6b9fc33aa150fb98f5a3dabc7b9 Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Tue, 14 Jan 2025 18:01:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E9=A1=BA=E5=BA=8F=E6=89=BE=E5=88=B0?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E5=81=9A=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/smartExcel/cpts/excel-view.vue | 171 +++++++++--------- 1 file changed, 89 insertions(+), 82 deletions(-) diff --git a/src/views/modules/base/smartExcel/cpts/excel-view.vue b/src/views/modules/base/smartExcel/cpts/excel-view.vue index da32ed948..c083f9b35 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -1,26 +1,26 @@ @@ -73,26 +73,26 @@ export default { }, watch: {}, mounted() { - this.$nextTick(()=>{ + this.$nextTick(() => { this.loadWorkBook() }) }, methods: { - loadWorkBook() { - window.luckysheet.destroy(); - const {id} = this.$store.state.user; - options.gridKey = this.workbookId; - options.allowUpdate = true; - 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}` - window.luckysheet.create({ - ...options, - hook: { - cellEditBefore: this.handleCellEditBefore, - sheetCreateAfter: this.handleSheetCreateAfter, - }, - }); + loadWorkBook() { + window.luckysheet.destroy(); + const { id } = this.$store.state.user; + options.gridKey = this.workbookId; + options.allowUpdate = true; + 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}` + window.luckysheet.create({ + ...options, + hook: { + cellEditBefore: this.handleCellEditBefore, + sheetCreateAfter: this.handleSheetCreateAfter, + }, + }); }, handleSheetCreateAfter(e) { console.log('setsheet', e); @@ -141,60 +141,66 @@ export default { handelClickBack() { this.$emit('close') }, - getAllTables(){ - console.log(luckysheet.getAllSheets()); - let currentTable = luckysheet.getAllSheets().filter(item=>item.status === '1') - + 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.sheetR = findFirstAllNullIndex(currentTable[0].data) + if(this.sheetR != -1){ + this.updataSheet() + }else{ + luckysheet.insertRow(currentTable[0].data.length,5) + } + }, + updataSheet() { let arr = [ { - 1:'张三1', - 2:'证件类型1', - 3:'1234', - 4:'456', - 5:'国籍', - 6:'性别', - 7:'出生日期', - 8:'所属社区', - 9:'所属网格', - 10:'所属小区', - 11:'楼栋名称', - 12:'单元号', - 13:'门牌号', - 14:'人房关系', - 15:'人户状况', - 16:'与户主关系', - 17:'民族' + 1: '张三1', + 2: '证件类型1', + 3: '1234', + 4: '456', + 5: '国籍', + 6: '性别', + 7: '出生日期', + 8: '所属社区', + 9: '所属网格', + 10: '所属小区', + 11: '楼栋名称', + 12: '单元号', + 13: '门牌号', + 14: '人房关系', + 15: '人户状况', + 16: '与户主关系', + 17: '民族' }, { - 1:'张三12', - 2:'证件类型12', - 3:'12342', - 4:'4562', - 5:'国籍2', - 6:'性别2', - 7:'出生日期2', - 8:'所属社区2', - 9:'所属网格2', - 10:'所属小区2', - 11:'楼栋名称2', - 12:'单元号2', - 13:'门牌号2', - 14:'人房关系2', - 15:'人户状况2', - 16:'与户主关系2', - 17:'民族' + 1: '张三12', + 2: '证件类型12', + 3: '12342', + 4: '4562', + 5: '国籍2', + 6: '性别2', + 7: '出生日期2', + 8: '所属社区2', + 9: '所属网格2', + 10: '所属小区2', + 11: '楼栋名称2', + 12: '单元号2', + 13: '门牌号2', + 14: '人房关系2', + 15: '人户状况2', + 16: '与户主关系2', + 17: '民族' } ] - arr.forEach((item,index)=>{ - for(let k in item){ + arr.forEach((item, index) => { + for (let k in item) { // index +1 + this.sheetR(当前表最后一个有数据的行) - luckysheet.setCellValue(index+1, k - 1, item[k]) + luckysheet.setCellValue(index+this.sheetR, k - 1, item[k]) } }) - // 17列 - }, - updataSheet(){ - }, }, beforeDestroy() { @@ -208,11 +214,12 @@ export default {