From 0947e6d8d7ae24ff5008365729e815e5b8408bf8 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 22 Nov 2022 11:55:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=85=B3=E8=81=94=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E4=BE=8B=E9=AB=98=E7=BA=A7=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=9C=89=E4=B8=A4=E4=B8=AA=E7=94=A8=E4=BE=8B=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019819 --user=陈建星 【测试跟踪】测试计划-关联功能用例-高级搜索-显示两个用例状态 https://www.tapd.cn/55049933/s/1300002 --- .../business/case/components/TestCaseList.vue | 40 +---------------- .../frontend/src/business/case/test-case.js | 44 +++++++++++++++++++ .../functional/FunctionalRelevance.vue | 15 ++----- 3 files changed, 49 insertions(+), 50 deletions(-) create mode 100644 test-track/frontend/src/business/case/test-case.js diff --git a/test-track/frontend/src/business/case/components/TestCaseList.vue b/test-track/frontend/src/business/case/components/TestCaseList.vue index 568c80b232..6b1c1630b5 100644 --- a/test-track/frontend/src/business/case/components/TestCaseList.vue +++ b/test-track/frontend/src/business/case/components/TestCaseList.vue @@ -267,10 +267,10 @@ import RelateDemand from "@/business/case/components/RelateDemand"; import TestPlanCaseStatusTableItem from "@/business/common/tableItems/TestPlanCaseStatusTableItem"; import { generateColumnKey, - getAdvSearchCustomField, getCustomFieldValueForTrack, getProjectMemberOption } from "@/business/utils/sdk-utils"; +import {initTestCaseConditionComponents} from "@/business/case/test-case"; export default { @@ -554,43 +554,7 @@ export default { }); }, initConditionComponents() { - this.condition.components = this.condition.components.filter(item => item.custom !== true); - let comp = getAdvSearchCustomField(this.condition, this.testCaseTemplate.customFields); - let statusOption = null; - // 系统字段国际化处理 - comp = comp.filter(element => { - if (element.label === '责任人') { - element.label = this.$t('custom_field.case_maintainer') - } - if (element.label === '用例等级') { - element.label = this.$t('custom_field.case_priority') - } - if (element.label === '用例状态') { - element.label = this.$t('custom_field.case_status') - // 回收站TAB页处理高级搜索用例状态字段 - if (this.trashEnable) { - element.operator.options = [OPERATORS.IN]; - element.options = [{text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'}]; - } else { - element.options.forEach(option => option.text = this.$t(option.text)); - } - statusOption = element.options; - // 用例状态不走自定义字段的搜索,查询status字段 - return false; - } - return true; - }); - if (statusOption) { - this.condition.components.forEach((item) => { - if (item.key === 'status') { - item .options = statusOption; - } - }); - } else { - // statusOption 为空,则去掉状态选项 - this.condition.components = this.condition.components.filter((item) => item.key !== 'status'); - } - this.condition.components.push(...comp); + this.condition.components = initTestCaseConditionComponents(this.condition, this.testCaseTemplate.customFields, this.trashEnable); }, setTestCaseDefaultValue(template) { let testCaseDefaultValue = {}; diff --git a/test-track/frontend/src/business/case/test-case.js b/test-track/frontend/src/business/case/test-case.js new file mode 100644 index 0000000000..d4f84be537 --- /dev/null +++ b/test-track/frontend/src/business/case/test-case.js @@ -0,0 +1,44 @@ +import {getAdvSearchCustomField, OPERATORS} from "@/business/utils/sdk-utils"; +import i18n from "@/i18n"; + +export function initTestCaseConditionComponents(condition, customFields, trashEnable) { + let conditionComponents = condition.components; + conditionComponents = conditionComponents.filter(item => item.custom !== true); + let comp = getAdvSearchCustomField(condition, customFields); + let statusOption = null; + // 系统字段国际化处理 + comp = comp.filter(element => { + if (element.label === '责任人') { + element.label = i18n.t('custom_field.case_maintainer') + } + if (element.label === '用例等级') { + element.label = i18n.t('custom_field.case_priority') + } + if (element.label === '用例状态') { + element.label = i18n.t('custom_field.case_status') + // 回收站TAB页处理高级搜索用例状态字段 + if (trashEnable) { + element.operator.options = [OPERATORS.IN]; + element.options = [{text: i18n.t('test_track.plan.plan_status_trash'), value: 'Trash'}]; + } else { + element.options.forEach(option => option.text = i18n.t(option.text)); + } + statusOption = element.options; + // 用例状态不走自定义字段的搜索,查询status字段 + return false; + } + return true; + }); + if (statusOption) { + conditionComponents.forEach((item) => { + if (item.key === 'status' || item.label === '用例状态') { + item .options = statusOption; + } + }); + } else { + // statusOption 为空,则去掉状态选项 + conditionComponents = conditionComponents.filter(item => item.key !== 'status' && item.label !== '用例状态'); + } + conditionComponents.push(...comp); + return conditionComponents; +} diff --git a/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalRelevance.vue b/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalRelevance.vue index 33ec77c441..d49d94b36b 100644 --- a/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalRelevance.vue +++ b/test-track/frontend/src/business/plan/view/comonents/functional/FunctionalRelevance.vue @@ -121,8 +121,9 @@ import TestPlanCaseStatusTableItem from "@/business/common/tableItems/TestPlanCa import {TEST_CASE_CONFIGS} from "metersphere-frontend/src/components/search/search-components"; import MxVersionSelect from "metersphere-frontend/src/components/version/MxVersionSelect"; import {getProjectApplicationConfig} from "@/api/project-application"; -import {getAdvSearchCustomField, getVersionFilters} from "@/business/utils/sdk-utils"; +import {getVersionFilters} from "@/business/utils/sdk-utils"; import {getTestTemplate} from "@/api/custom-field-template"; +import {initTestCaseConditionComponents} from "@/business/case/test-case"; export default { name: "FunctionalRelevance", @@ -307,17 +308,7 @@ export default { pushCustomFieldToCondition(projectId) { getTestTemplate(projectId).then(data => { this.testCaseTemplate = data; - let comp = getAdvSearchCustomField(this.page.condition, this.testCaseTemplate.customFields); - let caseStatus = comp.find(i => i.label === '用例状态'); - if (caseStatus) { - caseStatus.label = this.$t('custom_field.case_status'); - caseStatus.options.forEach(option => { - option.text = this.$t(option.text); - }); - caseStatus.custom = false; - this.page.condition.custom = false; - this.page.condition.components.push(caseStatus); - } + this.page.condition.components = initTestCaseConditionComponents(this.page.condition, this.testCaseTemplate.customFields); }); }, }