Skip to content

Commit

Permalink
fix(测试跟踪): 用例自定义字段筛选
Browse files Browse the repository at this point in the history
--bug=1026039 --user=宋昌昌 【测试跟踪】github#24275,【模板设置】用例模板中自定义字段,勾选条件进行筛选,没有筛选想要的数据 https://www.tapd.cn/55049933/s/1370144
  • Loading branch information
song-cc-rock authored and liuruibin committed May 10, 2023
1 parent dd9c9a9 commit d382533
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 === '用例等级'">
Expand Down Expand Up @@ -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") : {};
Expand Down Expand Up @@ -347,6 +349,7 @@ export default {
filters: {}
},
versionFilters: [],
userFilters: [],
graphData: {},
priorityFilters: [
{text: 'P0', value: 'P0'},
Expand Down Expand Up @@ -574,6 +577,7 @@ export default {
});
}
this.getVersionOptions();
this.getUserOptions();
},
watch: {
'$route'(to) {
Expand Down Expand Up @@ -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;
},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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>
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/common/js/custom_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
3 changes: 3 additions & 0 deletions frontend/src/common/js/tableUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d382533

Please sign in to comment.