From 39589481d07f2a761938f7078a969db96030760d Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 25 Mar 2024 23:54:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E6=A8=A1=E7=89=88=E5=90=8D=E7=A7=B0=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/ExtVisualizationTemplateMapper.java | 2 ++ .../service/TemplateManageService.java | 10 +++++++ .../ExtVisualizationTemplateMapper.xml | 21 +++++++++++++ core/core-frontend/src/api/template.ts | 7 +++++ .../template/component/DeTemplateImport.vue | 30 ++++++++++++------- .../src/views/template/index.vue | 4 +-- .../api/template/TemplateManageApi.java | 4 +++ .../request/TemplateManageRequest.java | 2 ++ 8 files changed, 67 insertions(+), 13 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java b/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java index d7f73f1e30..46e9fe37f1 100644 --- a/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java +++ b/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java @@ -25,6 +25,8 @@ public interface ExtVisualizationTemplateMapper{ Long checkCategoryTemplateName(@Param("templateName") String templateName,@Param("categories") List categories); + Long checkCategoryTemplateBatchNames(@Param("templateNames") List templateNames,@Param("categories") List categories,@Param("templateArray") List templateArray); + List findTemplateCategories(@Param("templateId") String templateId); List findTemplateArrayCategories(@Param("templateArray") List templateArray); diff --git a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java index 6969a32f96..b8de15c4b3 100644 --- a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java +++ b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java @@ -183,6 +183,16 @@ public class TemplateManageService implements TemplateManageApi { } } + @Override + public String checkCategoryTemplateBatchNames(TemplateManageRequest request) { + Long result = extTemplateMapper.checkCategoryTemplateBatchNames(request.getTemplateNames(),request.getCategories(),request.getTemplateArray()); + if (result == 0) { + return CommonConstants.CHECK_RESULT.NONE; + } else { + return CommonConstants.CHECK_RESULT.EXIST_ALL; + } + } + //分类名称检查 public String categoryNameCheck(String optType, String name, String id) { QueryWrapper wrapper = new QueryWrapper<>(); diff --git a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml index 89873f9728..77fda85d80 100644 --- a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml +++ b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml @@ -118,6 +118,27 @@ + + delete from visualization_template_category_map tcm diff --git a/core/core-frontend/src/api/template.ts b/core/core-frontend/src/api/template.ts index 75302e7d32..657591d6ee 100644 --- a/core/core-frontend/src/api/template.ts +++ b/core/core-frontend/src/api/template.ts @@ -62,6 +62,13 @@ export function categoryTemplateNameCheck(data) { }) } +export function checkCategoryTemplateBatchNames(data) { + return request.post({ + url: '/templateManage/categoryTemplateNameCheck', + data: data + }) +} + export function batchDelete(data) { return request.post({ url: '/templateManage/batchDelete', diff --git a/core/core-frontend/src/views/template/component/DeTemplateImport.vue b/core/core-frontend/src/views/template/component/DeTemplateImport.vue index 92948d969d..eebe3fce0b 100644 --- a/core/core-frontend/src/views/template/component/DeTemplateImport.vue +++ b/core/core-frontend/src/views/template/component/DeTemplateImport.vue @@ -122,6 +122,7 @@ const state = reactive({ }, recover: false, templateInfo: { + id: null, level: '1', pid: props.pid, categories: [], @@ -184,17 +185,22 @@ const saveTemplate = () => { const editTemplate = () => { const nameCheckRequest = { pid: state.templateInfo.pid, + id: state.templateInfo.id, name: state.templateInfo.name, categories: state.templateInfo.categories, optType: props.optType } // 全局名称校验 nameCheck(nameCheckRequest).then(response => { - save(state.templateInfo).then(response => { - ElMessage.success(t('编辑成功')) - emits('refresh', getRefreshPInfo()) - emits('closeEditTemplateDialog') - }) + if (response.data.indexOf('exist') > -1) { + ElMessage.warning('当前名称已在模版管理中存在,请修改') + } else { + save(state.templateInfo).then(response => { + ElMessage.success(t('编辑成功')) + emits('refresh', getRefreshPInfo()) + emits('closeEditTemplateDialog') + }) + } }) } @@ -238,11 +244,15 @@ const importTemplate = () => { } else { // 全局名称校验 nameCheck(nameCheckRequest).then(response => { - save(state.templateInfo).then(response => { - ElMessage.success(t('导入成功')) - emits('refresh', getRefreshPInfo()) - emits('closeEditTemplateDialog') - }) + if (response.data.indexOf('exist') > -1) { + ElMessage.warning('当前名称已在模版管理中存在,请修改') + } else { + save(state.templateInfo).then(response => { + ElMessage.success(t('导入成功')) + emits('refresh', getRefreshPInfo()) + emits('closeEditTemplateDialog') + }) + } }) } }) diff --git a/core/core-frontend/src/views/template/index.vue b/core/core-frontend/src/views/template/index.vue index d2643c48ab..5c538019f7 100644 --- a/core/core-frontend/src/views/template/index.vue +++ b/core/core-frontend/src/views/template/index.vue @@ -199,8 +199,6 @@ import DeTemplateList from '@/views/template/component/DeTemplateList.vue' const { t } = useI18n() const templateEditFormRef = ref(null) const templateListRef = ref(null) -import NoneTemplate from '@/assets/svg/dv-empty.svg' -import NoneImage from '@/assets/none.png' import DeTemplateImport from '@/views/template/component/DeTemplateImport.vue' import DeTemplateItem from '@/views/template/component/DeTemplateItem.vue' import DeCategoryChange from '@/views/template/component/DeCategoryChange.vue' @@ -370,7 +368,7 @@ const handleClick = (tab, event) => { const importRefresh = params => { if (params.optType === 'refresh') { - templateListRef.value.nodeClick({ id: params.refreshPid, name: params.refreshPid }) + templateListRef.value.nodeClick({ id: params.refreshPid, name: params.refreshPName }) } else { showTemplateEditDialog('new', null) } diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/template/TemplateManageApi.java b/sdk/api/api-base/src/main/java/io/dataease/api/template/TemplateManageApi.java index eb9ec491a8..d5b45f763c 100644 --- a/sdk/api/api-base/src/main/java/io/dataease/api/template/TemplateManageApi.java +++ b/sdk/api/api-base/src/main/java/io/dataease/api/template/TemplateManageApi.java @@ -53,6 +53,10 @@ public interface TemplateManageApi { @Operation(summary = "分类名称校验") String categoryTemplateNameCheck(@RequestBody TemplateManageRequest request); + @PostMapping("/checkCategoryTemplateBatchNames") + @Operation(summary = "分类名称批量校验") + String checkCategoryTemplateBatchNames(@RequestBody TemplateManageRequest request); + @PostMapping("/batchUpdate") @Operation(summary = "批量更新") void batchUpdate(@RequestBody TemplateManageBatchRequest request); diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/template/request/TemplateManageRequest.java b/sdk/api/api-base/src/main/java/io/dataease/api/template/request/TemplateManageRequest.java index 8bf98f3135..9040090a9e 100644 --- a/sdk/api/api-base/src/main/java/io/dataease/api/template/request/TemplateManageRequest.java +++ b/sdk/api/api-base/src/main/java/io/dataease/api/template/request/TemplateManageRequest.java @@ -26,6 +26,8 @@ public class TemplateManageRequest extends VisualizationTemplateVO { private String categoryId; private List categories; + + private List templateNames; private List templateArray;