fix(测试跟踪): 测试计划关联功能用例高级搜索有两个用例状态

--bug=1019819 --user=陈建星 【测试跟踪】测试计划-关联功能用例-高级搜索-显示两个用例状态 https://www.tapd.cn/55049933/s/1300002
This commit is contained in:
chenjianxing 2022-11-22 11:55:05 +08:00 committed by jianxing
parent e83d4e0f54
commit 0947e6d8d7
3 changed files with 49 additions and 50 deletions

View File

@ -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 = {};

View File

@ -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;
}

View File

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