Merge pull request #6618 from dataease/pr@dev@fixds

feat: Excel数据集上传文件后,可以支持删除上传文件
This commit is contained in:
taojinlong 2023-11-09 02:25:40 -06:00 committed by GitHub
commit 0b213f36d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 25 deletions

View File

@ -218,9 +218,7 @@ public class DataSetTableService {
excelSheetDataList.forEach(excelSheetData -> {
String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getFieldName)
.toArray(String[]::new);
if (checkIsRepeat(fieldArray)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
}
checkIsRepeat(fieldArray);
excelSheetData.setData(null);
excelSheetData.setJsonArray(null);
});
@ -254,9 +252,7 @@ public class DataSetTableService {
for (ExcelSheetData sheet : datasetTable.getSheets()) {
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName)
.toArray(String[]::new);
if (checkIsRepeat(fieldArray)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
}
checkIsRepeat(fieldArray);
}
for (ExcelSheetData sheet : datasetTable.getSheets()) {
@ -304,9 +300,7 @@ public class DataSetTableService {
}
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName).toArray(String[]::new);
if (checkIsRepeat(fieldArray)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
}
checkIsRepeat(fieldArray);
sheet.setData(null);
sheet.setJsonArray(null);
excelSheetDataList.add(sheet);
@ -1221,9 +1215,7 @@ public class DataSetTableService {
List<String[]> data = result.get("dataList");
List<TableField> fields = result.get("fieldList");
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
if (checkIsRepeat(fieldArray)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
}
checkIsRepeat(fieldArray);
List<Map<String, Object>> jsonArray = new ArrayList<>();
if (CollectionUtils.isNotEmpty(data)) {
jsonArray = data.stream().map(ele -> {
@ -1305,9 +1297,7 @@ public class DataSetTableService {
List<String[]> data = result.get("dataList");
List<TableField> fields = result.get("fieldList");
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
if (checkIsRepeat(fieldArray)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
}
checkIsRepeat(fieldArray);
List<Map<String, Object>> jsonArray = new ArrayList<>();
if (CollectionUtils.isNotEmpty(data)) {
jsonArray = data.stream().map(ele -> {
@ -2755,15 +2745,22 @@ public class DataSetTableService {
/*
* 判断数组中是否有重复的值
*/
public static boolean checkIsRepeat(String[] array) {
public static void checkIsRepeat(String[] array) {
HashSet<String> hashSet = new HashSet<>();
HashSet<String> repeat = new HashSet<>();
for (String s : array) {
if (StringUtils.isEmpty(s)) {
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
}
hashSet.add(s);
if(hashSet.contains(s)){
repeat.add(s);
}else {
hashSet.add(s);
}
}
if(CollectionUtils.isNotEmpty(repeat)){
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat") + ": " + String.valueOf(repeat));
}
return hashSet.size() != array.length;
}
public DatasetTable syncDatasetTableField(String id) throws Exception {

View File

@ -92,7 +92,7 @@ i18n_sql_add_not_matching=The data column of incremental SQL does not match the
i18n_sql_delete_not_matching=The data column of incremental delete SQL does not match the dataset,
i18n_cst_ds_tb_or_field_deleted=Custom dataset union data is deleted or field changed,can not display
i18n_no_all_delete_privilege_folder=This folder have sources which have no manage or view privilege,Can Not Be Deleted.
i18n_excel_field_repeat=Duplicate fields exist, please modify and try again.
i18n_excel_field_repeat=Duplicate fields exist:
i18n_schema_is_empty=Database schema is empty
\u7AD9\u5185\u6D88\u606F=Messages Center
\u6240\u6709\u6D88\u606F=All Messages

View File

@ -92,7 +92,7 @@ i18n_sql_add_not_matching=\u589E\u91CF\u6DFB\u52A0 SQL \u7684\u6570\u636E\u5217\
i18n_sql_delete_not_matching=\u589E\u91CF\u5220\u9664 SQL \u7684\u6570\u636E\u5217\u4E0E\u6570\u636E\u96C6\u4E0D\u5339\u914D,
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u4E49\u6570\u636E\u96C6\u6240\u5173\u8054\u6570\u636E\u88AB\u5220\u9664\u6216\u5B57\u6BB5\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u6B63\u5E38\u663E\u793A
i18n_no_all_delete_privilege_folder=\u8BE5\u76EE\u5F55\u4E0B\u5B58\u5728\u6CA1\u6709\u7BA1\u7406\u6743\u9650\u6216\u67E5\u770B\u6743\u9650\u7684\u8D44\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u590D\u5B57\u6BB5\uFF0C\u8BF7\u4FEE\u6539\u540E\u91CD\u8BD5
i18n_excel_field_repeat=\u5b58\u5728\u91cd\u590d\u5b57\u6bb5\uff1a
i18n_schema_is_empty=\u6570\u636E\u5E93 Schema \u4E3A\u7A7A
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F

View File

@ -92,7 +92,7 @@ i18n_sql_add_not_matching=\u589E\u91CF\u6DFB\u52A0 sql \u7684\u6578\u64DA\u5217\
i18n_sql_delete_not_matching=\u589E\u91CF\u522A\u9664 sql \u7684\u6578\u64DA\u5217\u8207\u6578\u64DA\u96C6\u4E0D\u5339\u914D,
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u7FA9\u6578\u64DA\u96C6\u6240\u95DC\u806F\u6578\u64DA\u88AB\u522A\u9664\u6216\u5B57\u6BB5\u767C\u751F\u8B8A\u5316\uFF0C\u7121\u6CD5\u6B63\u5E38\u986F\u793A
i18n_no_all_delete_privilege_folder=\u8A72\u76EE\u9304\u4E0B\u5B58\u5728\u6C92\u6709\u7BA1\u7406\u6B0A\u9650\u6216\u67E5\u770B\u6B0A\u9650\u7684\u8CC7\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u5FA9\u5B57\u6BB5\uFF0C\u8ACB\u4FEE\u6539\u5F8C\u91CD\u8BD5
i18n_excel_field_repeat=\u5b58\u5728\u91cd\u5fa9\u5b57\u6bb5\uff1a
i18n_schema_is_empty=\u6578\u64DA\u5EAB Schema \u70BA\u7A7A
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F

View File

@ -68,10 +68,9 @@
@node-click="handleNodeClick"
@check-change="handleCheckChange"
>
<span
slot-scope="{ data }"
<span class="custom-tree-node"
slot-scope="{ node, data}"
:title="data.excelLabel"
class="custom-tree-node"
>
<span class="label">{{ data.excelLabel }}</span>
<span
@ -87,6 +86,16 @@
class="ds-icon-scene"
/>
</span>
<span>
<el-button
v-show="!data.sheet"
type="text"
size="mini"
@click="() => remove(node, data)">
{{ $t('dataset.delete') }}
</el-button>
</span>
</span>
</el-tree>
</div>
@ -465,7 +474,12 @@ export default {
store.dispatch('user/refreshToken', refreshToken)
}
},
remove(node, data) {
const parent = node.parent;
const children = parent.data.children || parent.data;
const index = children.findIndex(d => d.id === data.id);
children.splice(index, 1);
},
save() {
var validate = true
var selectedSheet = []