fix: 增加excel字段重复错误提示

This commit is contained in:
junjie 2021-06-28 13:50:53 +08:00
parent a9aab687d3
commit 9f8ef33647
2 changed files with 29 additions and 0 deletions

View File

@ -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;
}
}
}

View File

@ -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',