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 @Data
public class ExcelFileData { public class ExcelFileData {
@ApiModelProperty("excelID") @ApiModelProperty("excelID")
private String excelId; private String id;
@ApiModelProperty("excel标签") @ApiModelProperty("excel标签")
private String excelLable; private String excelLable;
@ApiModelProperty("sheets") @ApiModelProperty("sheets")

View File

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

View File

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

View File

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