From 6f237f7f4c8020e049c319faa2747bb0fbc0faa9 Mon Sep 17 00:00:00 2001 From: pengjun <158915633@qq.com> Date: Tue, 15 Aug 2023 12:45:15 +0800 Subject: [PATCH] import --- src/views/doctorCheck/personnelBatch.vue | 52 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/src/views/doctorCheck/personnelBatch.vue b/src/views/doctorCheck/personnelBatch.vue index 115dcb0..98a9293 100644 --- a/src/views/doctorCheck/personnelBatch.vue +++ b/src/views/doctorCheck/personnelBatch.vue @@ -51,8 +51,8 @@ 上一步 - 确 定分析确 定 @@ -69,6 +69,12 @@ export default { dialogVisible1: true, dialogVisible2: false, dialogVisible3: false, + + startRow:2, //数据开始行,标题行为 startRow - 1 ; + importData:[], //导入原始数据 + tableDataCol:{}, //导入原始数据 分析后 字段 key-value:key 为excel字段标题,value 为数据库中后台字段 + tableData:[], //导入原始数据 分析后 表格数据 + }; }, methods: { @@ -101,13 +107,53 @@ export default { // 处理Excel文件内容 worksheet.eachRow((row, rowNumber) => { console.log(row.values); - // this.importData.push(row.values); + this.importData.push(row.values); // console.log(`第${row.rowNumber}行的数据:${row.rowData}`); }); }); }; reader.readAsArrayBuffer(file); }, + + //导入后数据分析 + parseImportData(startRow){ + if(!this.importData || this.importData.length == 0) return; + let cols = []; + let record = {}; + this.importData.forEach((item,index) =>{ + console.log(index,item); + if(index == startRow - 2){ + item.forEach((e,i) =>{ + console.log('e',i,e); + if(i>0){ + if(e){ + this.tableDataCol[e] = e; + cols.push(e); + }else{ + this.tableDataCol[`第${Number(i)+1}列`] = `第${Number(i)+1}列`; + cols.push(`第${Number(i)+1}列`); + } + } + }); + }else if(index > startRow - 2){ + for(let i=0;i0){ + console.log('cols[i]',i,cols[i-1]); + if(item[i]){ + record[cols[i-1]] = item[i]; + }else{ + record[cols[i-1]] = null; + } + } + } + this.tableData.push({...record}); + } + }); + + console.log('tableDataCol',this.tableDataCol); + console.log('tableData',this.tableData); + }, + nextTick() { if (this.radio == 1) { this.dialogVisible1 = false;