From c86a192ae9022f60b6f03244ee2157ef56e87ed7 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Mon, 27 Nov 2023 14:19:18 +0800 Subject: [PATCH] =?UTF-8?q?style(=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E6=96=B0=E8=AE=BE=E8=AE=A1=E7=A8=BF=E6=A0=B7=E5=BC=8F=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../router/routes/modules/caseManagement.ts | 41 +++++++------- .../components/caseDetail.vue | 8 ++- .../components/caseTable.vue | 54 +++++++++--------- .../components/caseTemplateDetail.vue | 16 +++--- .../components/caseTree.vue | 8 ++- .../components/recycleCaseTable.vue | 55 +++++++------------ .../caseManagementFeature/index.vue | 15 ++--- .../caseManagementFeature/locale/en-US.ts | 5 ++ .../caseManagementFeature/locale/zh-CN.ts | 6 +- 9 files changed, 101 insertions(+), 107 deletions(-) diff --git a/frontend/src/router/routes/modules/caseManagement.ts b/frontend/src/router/routes/modules/caseManagement.ts index 064e894a64..747112aae7 100644 --- a/frontend/src/router/routes/modules/caseManagement.ts +++ b/frontend/src/router/routes/modules/caseManagement.ts @@ -26,6 +26,27 @@ const FeatureTest: AppRouteRecordRaw = { isTopMenu: true, }, }, + // 创建用例&编辑用例 + { + path: 'featureCaseDetail/:mode?', + name: FeatureTestRouteEnum.FEATURE_TEST_CASE_DETAIL, + component: () => import('@/views/case-management/caseManagementFeature/components/caseDetail.vue'), + meta: { + locale: 'menu.featureTest.featureCaseDetail', + roles: ['*'], + breadcrumbs: [ + { + name: FeatureTestRouteEnum.FEATURE_TEST_CASE, + locale: 'menu.featureTest.featureCase', + }, + { + name: FeatureTestRouteEnum.FEATURE_TEST_CASE_DETAIL, + editTag: 'id', + locale: 'menu.featureTest.featureCaseDetail', + }, + ], + }, + }, // 功能用例回收站 { path: 'featureCaseRecycle', @@ -46,26 +67,6 @@ const FeatureTest: AppRouteRecordRaw = { ], }, }, - // 创建用例&编辑用例 - { - path: 'featureCaseDetail', - name: FeatureTestRouteEnum.FEATURE_TEST_CASE_DETAIL, - component: () => import('@/views/case-management/caseManagementFeature/components/caseDetail.vue'), - meta: { - locale: 'menu.featureTest.featureCaseDetail', - roles: ['*'], - breadcrumbs: [ - { - name: FeatureTestRouteEnum.FEATURE_TEST_CASE, - locale: 'menu.featureTest.featureCase', - }, - { - name: FeatureTestRouteEnum.FEATURE_TEST_CASE_DETAIL, - locale: 'menu.featureTest.featureCaseDetail', - }, - ], - }, - }, ], }; diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseDetail.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseDetail.vue index af38b3ca9d..ba723bcd50 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseDetail.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseDetail.vue @@ -60,12 +60,12 @@ async function save() { try { loading.value = true; - if (isEdit.value) { + if (route.params.mode === 'edit') { await updateCaseRequest(caseDetailInfo.value); Message.success(t('featureTest.featureCase.editSuccess')); } else { await createCaseRequest(caseDetailInfo.value); - Message.success(t('common.addSuccess')); + Message.success(route.params.mode === 'copy' ? t('ms.description.copySuccess') : t('common.addSuccess')); } router.push({ name: FeatureTestRouteEnum.FEATURE_TEST_CASE, query: { ...route.query } }); featureCaseStore.setIsAlreadySuccess(true); @@ -99,8 +99,10 @@ } watchEffect(() => { - if (isEdit.value) { + if (route.params.mode === 'edit') { title.value = t('featureTest.featureCase.updateCase'); + } else if (route.params.mode === 'copy') { + title.value = t('featureTest.featureCase.copyCase'); } else { title.value = t('featureTest.featureCase.creatingCase'); } diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue index 2e450a5b70..de0a8054e3 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseTable.vue @@ -1,8 +1,9 @@ + @@ -166,7 +168,7 @@ import useModal from '@/hooks/useModal'; import { useAppStore, useTableStore } from '@/store'; import useFeatureCaseStore from '@/store/modules/case/featureCase'; - import { characterLimit, findNodePathByKey } from '@/utils'; + import { characterLimit, findNodeByKey, findNodePathByKey } from '@/utils'; import type { CaseManagementTable, CaseModuleQueryParams } from '@/models/caseManagement/featureCase'; import type { TableQueryParams } from '@/models/common'; @@ -357,6 +359,17 @@ isTag: true, showDrag: true, }, + { + title: 'featureTest.featureCase.tableColumnUpdateTime', + slotName: 'updateTime', + dataIndex: 'updateTime', + sortable: { + sortDirections: ['ascend', 'descend'], + }, + showInTable: true, + width: 200, + showDrag: true, + }, { title: 'featureTest.featureCase.tableColumnCreateUser', slotName: 'createUser', @@ -375,31 +388,11 @@ width: 200, showDrag: true, }, - { - title: 'featureTest.featureCase.tableColumnUpdateUser', - slotName: 'updateUser', - dataIndex: 'updateUser', - showInTable: true, - width: 200, - showDrag: true, - }, - { - title: 'featureTest.featureCase.tableColumnUpdateTime', - slotName: 'updateTime', - dataIndex: 'updateTime', - sortable: { - sortDirections: ['ascend', 'descend'], - }, - showInTable: true, - width: 200, - showDrag: true, - }, { title: 'featureTest.featureCase.tableColumnActions', slotName: 'operation', dataIndex: 'operation', fixed: 'right', - width: 140, showInTable: true, showDrag: false, }, @@ -558,13 +551,16 @@ emitTableParams(); } - // 编辑 - function editCase(record: CaseManagementTable) { + // 编辑&复制 + function operateCase(record: CaseManagementTable, mode: string) { router.push({ name: FeatureTestRouteEnum.FEATURE_TEST_CASE_DETAIL, query: { id: record.id, }, + params: { + mode, + }, }); } @@ -674,11 +670,15 @@ showBatchMoveDrawer.value = true; } + const moduleNamePath = computed(() => { + return props.activeFolder === 'all' + ? t('featureTest.featureCase.allCase') + : findNodeByKey>(caseTreeData.value, featureCaseStore.moduleId[0], 'id')?.name; + }); // 获取对应模块name function getModules(moduleIds: string) { const modules = findNodePathByKey(caseTreeData.value, moduleIds, undefined, 'id'); const moduleName = (modules || []).treePath.map((item: any) => item.name); - if (moduleName.length === 1) { return moduleName[0]; } diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue index 9e0e5f0373..df4ffb2f73 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseTemplateDetail.vue @@ -524,6 +524,7 @@ break; } }; + // 总自定义字段 const totalTemplateField = ref([]); @@ -589,7 +590,7 @@ } const title = ref(''); - const isEdit = computed(() => !!route.query.id); + const isEditOrCopy = computed(() => !!route.query.id); const attachmentsList = ref([]); // 后台传过来的local文件的item列表 @@ -638,6 +639,7 @@ const { customFields, attachments, steps, tags } = detailResult; form.value = { ...detailResult, + name: route.params.mode === 'copy' ? `${detailResult.name}_copy` : detailResult.name, tags: JSON.parse(tags as string), }; // 处理自定义字段 @@ -655,6 +657,7 @@ }); } attachmentsList.value = attachments; + // 处理文件列表 fileList.value = attachments .map((fileInfo: any) => { @@ -685,12 +688,9 @@ } watchEffect(() => { - if (isEdit.value) { - title.value = t('featureTest.featureCase.updateCase'); - // 调用详情处理字段 + if (route.params.mode === 'edit' || route.params.mode === 'copy') { getCaseInfo(); } else { - title.value = t('featureTest.featureCase.creatingCase'); initDefaultFields(); } }); @@ -709,7 +709,7 @@ if (val) { form.value.relateFileMetaIds = fileList.value.filter((item) => !item.local).map((item) => item.uid); params.value.fileList = fileList.value.filter((item) => item.local && item.status === 'init'); - if (isEdit.value) { + if (isEditOrCopy.value) { getFilesParams(); } } @@ -794,11 +794,11 @@ type: item.type, name: item.id, label: item.name, - value: isEdit.value ? JSON.parse(rule.value) : rule.value, + value: isEditOrCopy.value ? JSON.parse(rule.value) : rule.value, options: optionsItem, required: item.required, props: { - modelValue: isEdit.value ? JSON.parse(rule.value) : rule.value, + modelValue: isEditOrCopy.value ? JSON.parse(rule.value) : rule.value, options: optionsItem, }, }; diff --git a/frontend/src/views/case-management/caseManagementFeature/components/caseTree.vue b/frontend/src/views/case-management/caseManagementFeature/components/caseTree.vue index ba3e4a7a70..8536faf27f 100644 --- a/frontend/src/views/case-management/caseManagementFeature/components/caseTree.vue +++ b/frontend/src/views/case-management/caseManagementFeature/components/caseTree.vue @@ -5,7 +5,7 @@ allow-clear class="mb-[16px]" > - +