From b3a8446156d7178acb8265cb6d49cb022acaae65 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 8 Nov 2023 15:33:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20Excel=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=AD=97=E6=AE=B5=E6=8F=90=E7=A4=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 33 +++++++++---------- .../resources/i18n/messages_en_US.properties | 2 +- .../resources/i18n/messages_zh_CN.properties | 2 +- .../resources/i18n/messages_zh_TW.properties | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 83e209f781..19586b83dc 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -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 data = result.get("dataList"); List 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> jsonArray = new ArrayList<>(); if (CollectionUtils.isNotEmpty(data)) { jsonArray = data.stream().map(ele -> { @@ -1305,9 +1297,7 @@ public class DataSetTableService { List data = result.get("dataList"); List 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> 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 hashSet = new HashSet<>(); + HashSet 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 { diff --git a/core/backend/src/main/resources/i18n/messages_en_US.properties b/core/backend/src/main/resources/i18n/messages_en_US.properties index 2aaf7f0b7e..0d5b36e213 100644 --- a/core/backend/src/main/resources/i18n/messages_en_US.properties +++ b/core/backend/src/main/resources/i18n/messages_en_US.properties @@ -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 diff --git a/core/backend/src/main/resources/i18n/messages_zh_CN.properties b/core/backend/src/main/resources/i18n/messages_zh_CN.properties index b27d1036df..a31e8745dc 100644 --- a/core/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/core/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -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 diff --git a/core/backend/src/main/resources/i18n/messages_zh_TW.properties b/core/backend/src/main/resources/i18n/messages_zh_TW.properties index 969fd1440a..e5b121220c 100644 --- a/core/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/core/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -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 From 6cdf45fc2763a3d3e694b586fede7fb6d3411bf9 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 9 Nov 2023 16:21:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20Excel=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E5=90=8E=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E5=88=A0=E9=99=A4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/dataset/add/AddExcel.vue | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/core/frontend/src/views/dataset/add/AddExcel.vue b/core/frontend/src/views/dataset/add/AddExcel.vue index ba068a6ef8..a0e4f28425 100644 --- a/core/frontend/src/views/dataset/add/AddExcel.vue +++ b/core/frontend/src/views/dataset/add/AddExcel.vue @@ -68,10 +68,9 @@ @node-click="handleNodeClick" @check-change="handleCheckChange" > - {{ data.excelLabel }} + + + {{ $t('dataset.delete') }} + + + @@ -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 = []