forked from github/dataease
fix: 增加excel字段重复错误提示
This commit is contained in:
parent
a9aab687d3
commit
9f8ef33647
@ -946,6 +946,12 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
String[] fieldArray = fields.stream().map(TableFiled::getFieldName).toArray(String[]::new);
|
||||
|
||||
// 校验excel字段是否重名
|
||||
if (checkIsRepeat(fieldArray)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(data)) {
|
||||
jsonArray = data.stream().map(ele -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@ -1087,4 +1093,19 @@ public class DataSetTableService {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断数组中是否有重复的值
|
||||
*/
|
||||
public static boolean checkIsRepeat(String[] array) {
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
hashSet.add(array[i]);
|
||||
}
|
||||
if (hashSet.size() == array.length) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,14 @@ export default {
|
||||
this.uploading = true
|
||||
},
|
||||
uploadFail(response, file, fileList) {
|
||||
this.path = ''
|
||||
this.fields = []
|
||||
this.sheets = []
|
||||
this.data = []
|
||||
const datas = this.data
|
||||
this.$refs.plxTable.reloadData(datas)
|
||||
this.name = ''
|
||||
this.fileList = []
|
||||
this.uploading = false
|
||||
this.$message({
|
||||
type: 'error',
|
||||
|
Loading…
Reference in New Issue
Block a user