|
|
@ -51,8 +51,8 @@ |
|
|
</div> |
|
|
</div> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<el-button @click="back3">上一步</el-button> |
|
|
<el-button @click="back3">上一步</el-button> |
|
|
<el-button type="primary" @click="dialogVisible3 = false" |
|
|
|
|
|
>确 定</el-button |
|
|
|
|
|
|
|
|
<el-button type="primary" @click="parseImportData(startRow)">分析</el-button |
|
|
|
|
|
<el-button type="primary" @click="">确 定</el-button |
|
|
> |
|
|
> |
|
|
</span> |
|
|
</span> |
|
|
</el-dialog> |
|
|
</el-dialog> |
|
|
@ -69,6 +69,12 @@ export default { |
|
|
dialogVisible1: true, |
|
|
dialogVisible1: true, |
|
|
dialogVisible2: false, |
|
|
dialogVisible2: false, |
|
|
dialogVisible3: false, |
|
|
dialogVisible3: false, |
|
|
|
|
|
|
|
|
|
|
|
startRow:2, //数据开始行,标题行为 startRow - 1 ; |
|
|
|
|
|
importData:[], //导入原始数据 |
|
|
|
|
|
tableDataCol:{}, //导入原始数据 分析后 字段 key-value:key 为excel字段标题,value 为数据库中后台字段 |
|
|
|
|
|
tableData:[], //导入原始数据 分析后 表格数据 |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
@ -101,13 +107,53 @@ export default { |
|
|
// 处理Excel文件内容 |
|
|
// 处理Excel文件内容 |
|
|
worksheet.eachRow((row, rowNumber) => { |
|
|
worksheet.eachRow((row, rowNumber) => { |
|
|
console.log(row.values); |
|
|
console.log(row.values); |
|
|
// this.importData.push(row.values); |
|
|
|
|
|
|
|
|
this.importData.push(row.values); |
|
|
// console.log(`第${row.rowNumber}行的数据:${row.rowData}`); |
|
|
// console.log(`第${row.rowNumber}行的数据:${row.rowData}`); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
reader.readAsArrayBuffer(file); |
|
|
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;i<item.length;i++){ |
|
|
|
|
|
if(i>0){ |
|
|
|
|
|
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() { |
|
|
nextTick() { |
|
|
if (this.radio == 1) { |
|
|
if (this.radio == 1) { |
|
|
this.dialogVisible1 = false; |
|
|
this.dialogVisible1 = false; |
|
|
|