fix: excel 多sheets页面

This commit is contained in:
taojinlong 2021-08-25 18:40:42 +08:00
parent 88995675f8
commit 1ba98b57b3
4 changed files with 36 additions and 18 deletions

View File

@ -8,7 +8,7 @@ import java.util.List;
@Data
public class ExcelFileData {
@ApiModelProperty("excelID")
private String excelId;
private String id;
@ApiModelProperty("excel标签")
private String excelLable;
@ApiModelProperty("sheets")

View File

@ -24,7 +24,7 @@ public class ExcelSheetData {
@ApiModelProperty("excelID")
private String sheetExcelId;
@ApiModelProperty("sheetId")
private String sheetId;
private String id;
@ApiModelProperty("路径")
private String path;
@ApiModelProperty("字段MD5")

View File

@ -1214,20 +1214,20 @@ public class DataSetTableService {
String filePath = saveFile(file, excelId);
ExcelFileData excelFileData = new ExcelFileData();
excelFileData.setExcelLable(filename);
excelFileData.setExcelId(excelId);
excelFileData.setId(excelId);
excelFileData.setPath(filePath);
filename = filename.substring(0, filename.lastIndexOf('.'));
if(retrunSheetDataList.size() == 1){
retrunSheetDataList.get(0).setDatasetName(filename);
retrunSheetDataList.get(0).setSheetExcelId(excelId);
retrunSheetDataList.get(0).setSheetId(UUID.randomUUID().toString());
retrunSheetDataList.get(0).setId(UUID.randomUUID().toString());
retrunSheetDataList.get(0).setPath(filePath);
}else {
for (ExcelSheetData excelSheetData : retrunSheetDataList) {
excelSheetData.setDatasetName(filename + "-" + excelSheetData.getExcelLable());
excelSheetData.setSheetExcelId(excelId);
excelSheetData.setSheetId(UUID.randomUUID().toString());
excelSheetData.setId(UUID.randomUUID().toString());
excelSheetData.setPath(filePath);
}
}

View File

@ -50,14 +50,15 @@
<el-tree ref="tree"
:data="excelData"
node-key="excelId"
:props="props"
show-checkbox
highlight-current
@node-click="handleNodeClick"
@check-change="handleCheckChange">
:data="excelData"
:default-expanded-keys=defaultExpandedKeys
:default-checked-keys=defaultCheckedKeys
node-key="id"
:props="props"
show-checkbox
highlight-current
@node-click="handleNodeClick"
@check-change="handleCheckChange">
</el-tree>
@ -186,7 +187,9 @@ export default {
children: 'sheets'
},
count: 1,
excelData: []
excelData: [],
defaultExpandedKeys: [],
defaultCheckedKeys: []
}
},
watch: {
@ -207,6 +210,16 @@ export default {
},
methods: {
handleCheckChange(data, checked, indeterminate) {
if(checked){
this.defaultCheckedKeys.push(data.id)
}else {
var index = this.defaultCheckedKeys.findIndex(id => {
if ( id == data.id) {
return true;
}
})
this.defaultCheckedKeys.splice(index,1)
}
},
handleNodeClick(data) {
if(data.sheet){
@ -258,9 +271,14 @@ export default {
})
},
uploadSuccess(response, file, fileList) {
this.excelData.push(response.data)
this.fileList = fileList
this.uploading = false
this.excelData.push(response.data)
this.defaultExpandedKeys.push(response.data.id)
this.defaultCheckedKeys.push(response.data.sheets[0].id)
this.$nextTick(() => {
this.$refs.tree.setCheckedKeys(this.defaultCheckedKeys);
});
this.fileList = fileList
},
save() {
@ -326,6 +344,7 @@ export default {
}
if(new Set(sheetFileMd5).size !== sheetFileMd5.length && !this.param.tableId){
this.$confirm(this.$t('dataset.merge_msg'), this.$t('dataset.merge_title'), {
distinguishCancelAndClose: true,
confirmButtonText: this.$t('dataset.merge'),
cancelButtonText: this.$t('dataset.no_merge'),
type: 'info'
@ -336,7 +355,7 @@ export default {
this.cancel()
})
}).catch(action => {
if(action == 'cancle'){
if(action === 'close'){
return
}
table.mergeSheet = false
@ -352,7 +371,6 @@ export default {
})
}
},
cancel() {
this.dataReset()
if (this.param.tableId) {