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); }); }, }