fix(测试跟踪): 用例自定义字段筛选

--bug=1026039 --user=宋昌昌 【测试跟踪】github#24275,【模板设置】用例模板中自定义字段,勾选条件进行筛选,没有筛选想要的数据 https://www.tapd.cn/55049933/s/1370144
This commit is contained in:
song-cc-rock 2023-05-09 15:06:20 +08:00 committed by 刘瑞斌
parent dd9c9a9568
commit d38253365a
4 changed files with 38 additions and 6 deletions

View File

@ -509,6 +509,12 @@
#{value}
</foreach>
</when>
<when test="key=='maintainer'">
and test_case.maintainer in
<foreach collection="values" open="(" close=")" separator="," item="value">
#{value}
</foreach>
</when>
</choose>
</if>
<if test="key=='status' and (values == null || values.size() == 0)">

View File

@ -11,7 +11,7 @@
<ms-table
v-loading="page.result.loading"
:data="page.data"
:condition="condition"
:condition.sync="condition"
:total="page.total"
:page-size.sync="page.pageSize"
:operators="operators"
@ -201,6 +201,7 @@
:fields-width="fieldsWidth"
:label="field.system ? $t(systemFiledMap[field.name]) :field.name"
:min-width="120"
:column-key="field.columnKey"
:prop="field.name">
<template v-slot="scope">
<span v-if="field.name === '用例等级'">
@ -297,6 +298,7 @@ import {editTestCaseOrder} from "@/network/testCase";
import {getGraphByCondition} from "@/network/graph";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import ListItemDeleteConfirm from "@/business/components/common/components/ListItemDeleteConfirm";
import {generateColumnKey} from "@/common/js/custom_field"
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const relationshipGraphDrawer = requireComponent.keys().length > 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {};
@ -347,6 +349,7 @@ export default {
filters: {}
},
versionFilters: [],
userFilters: [],
graphData: {},
priorityFilters: [
{text: 'P0', value: 'P0'},
@ -574,6 +577,7 @@ export default {
});
}
this.getVersionOptions();
this.getUserOptions();
},
watch: {
'$route'(to) {
@ -695,15 +699,16 @@ export default {
field.options.forEach(option => {
option.text = this.$t(option.text)
})
return field.options;
}
if (field.name === '用例等级') {
return this.priorityFilters;
return field.options && field.options.length > 0 ? field.options : this.priorityFilters;
} else if (field.name === '用例状态') {
if (this.trashEnable) {
return null;
}
return this.statusFilters;
return field.options && field.options.length > 0 ? field.options : this.statusFilters;
} else if (field.name === '责任人') {
return this.userFilters;
}
return null;
},
@ -792,8 +797,6 @@ export default {
this.condition.filters.review_status = [this.selectDataRange];
break;
}
this.condition.filters.priority = this.condition.filters['用例等级'];
this.condition.filters.status = this.condition.filters['用例状态'];
if (this.trashEnable) {
//
let versionIds = this.condition.filters.version_id;
@ -1225,6 +1228,13 @@ export default {
});
}
},
getUserOptions() {
this.$get('/user/project/member/list', response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
},
}
};
</script>

View File

@ -162,3 +162,16 @@ export function buildTestCaseOldFields(testCase) {
oldFields.set('用例等级', testCase.priority);
return oldFields;
}
export function generateColumnKey(name) {
// 只处理系统自定义字段
if (name === '用例等级') {
return 'priority';
} else if (name === '责任人') {
return 'maintainer';
} else if (name === '用例状态') {
return 'status';
} else {
return name;
}
}

View File

@ -4,6 +4,7 @@ import {updateCustomFieldTemplate} from "@/network/custom-field-template";
import i18n from "@/i18n/i18n";
import Sortable from 'sortablejs'
import {timestampFormatDate} from "@/common/js/filter";
import {generateColumnKey} from "@/common/js/custom_field";
export function _handleSelectAll(component, selection, tableData, selectRows, condition) {
if (selection.length > 0) {
@ -289,6 +290,8 @@ export function getTableHeaderWithCustomFields(key, customFields) {
translateLabel(fieldSetting);
let keys = getCustomFieldsKeys(customFields);
customFields.forEach(item => {
// 设置系统自定义字段columnKey
item.columnKey = generateColumnKey(item.name);
if (!item.key) {
// 兼容旧版更新key
item.key = generateTableHeaderKey(keys, customFields);