fix(高级搜索): 自定义字段显示问题

story 1004114
This commit is contained in:
shiziyuan9527 2022-05-20 18:49:41 +08:00 committed by shiziyuan9527
parent 1c4966ce74
commit 77ecb3dee5
10 changed files with 41 additions and 19 deletions
backend/src/main/java/io/metersphere/base/mapper/ext
frontend/src

View File

@ -82,10 +82,16 @@
<foreach collection="${condition}.customs" item="custom" separator="" open="" close=""> <foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
and test_case.id in ( and test_case.id in (
select resource_id from custom_field_test_case where field_id = #{custom.id} select resource_id from custom_field_test_case where field_id = #{custom.id}
and trim(both '"' from value) <if test="custom.type == 'multipleMember'">
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> and `value` = #{custom.value}
<property name="object" value="custom"/> </if>
</include>) <if test="custom.type != 'multipleMember'">
and trim(both '"' from value)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="custom"/>
</include>
</if>
)
</foreach> </foreach>
</if> </if>
</sql> </sql>

View File

@ -75,11 +75,11 @@ export default {
} }
if (this.condition.custom) { if (this.condition.custom) {
let components = []; let components = [];
this.systemFiled = config.components.filter(co => co.custom === undefined || false); this.systemFiled = config.components.filter(co => co.custom === undefined || co.custom === false);
this.customFiled = config.components.filter(co => co.custom === true); this.customFiled = config.components.filter(co => co.custom === true);
// //
this.$set(components, 0, {label: "系统字段", child: this.systemFiled}); this.$set(components, 0, {label: this.$t('custom_field.system_field'), child: this.systemFiled});
this.$set(components, 1, {label: "自定义字段", child: this.customFiled}); this.$set(components, 1, {label: this.$t('custom_field.name'), child: this.customFiled});
this.$set(config, "components", components); this.$set(config, "components", components);
} }
return config; return config;
@ -120,7 +120,8 @@ export default {
condition['customs'].push({ condition['customs'].push({
id: component.key, id: component.key,
operator: component.operator.value, operator: component.operator.value,
value: component.value value: component.type === "multipleMember" ? JSON.stringify(component.value) : component.value,
type: component.type
}); });
} }

View File

@ -1,12 +1,16 @@
import {OPERATORS} from "@/business/components/common/components/search/search-components"; import {OPERATORS} from "@/business/components/common/components/search/search-components";
export function getAdvSearchCustomField(componentArr, fields) { export function getAdvSearchCustomField(condition, fields) {
let componentArr = condition.components;
const components = []; const components = [];
for (let field of fields) { for (let field of fields) {
let index = componentArr.findIndex(a => a.key === field.id); let index = componentArr.findIndex(a => a.key === field.id);
if (index > -1) { if (index > -1) {
continue; continue;
} }
if (field.id === 'platformStatus') {
continue;
}
const componentType = getComponentName(field.type); const componentType = getComponentName(field.type);
let component = { let component = {
key: field.id, key: field.id,
@ -14,7 +18,12 @@ export function getAdvSearchCustomField(componentArr, fields) {
label: field.name, label: field.name,
operator: getComponentOperator(componentType, field.type, false), // 自定义字段可以异步获取选项? operator: getComponentOperator(componentType, field.type, false), // 自定义字段可以异步获取选项?
options: getComponentOptions(field), options: getComponentOptions(field),
custom: true, custom: !field.system,
type: field.type
}
// 自定义字段中有"系统字段"属性为否的,记录为含有自定义字段
if (!field.system && !condition.custom) {
condition.custom = true;
} }
// 作为搜索条件时,可以多选 // 作为搜索条件时,可以多选
if (componentType === 'MsTableSearchSelect') { if (componentType === 'MsTableSearchSelect') {
@ -22,6 +31,12 @@ export function getAdvSearchCustomField(componentArr, fields) {
multiple: true multiple: true
} }
} }
//
if (component.type === 'member' || component.type === 'multipleMember') {
component['isShow']= operator => {
return operator !== OPERATORS.CURRENT_USER.value;
}
}
components.push(component); components.push(component);
} }
return components; return components;

View File

@ -601,7 +601,7 @@ export const REPORT_CASE_CONFIGS = [NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_
export const UI_REPORT_CONFIGS = [NAME, TEST_NAME, CREATE_TIME, UI_REPORT_STATUS, CREATOR, TRIGGER_MODE]; export const UI_REPORT_CONFIGS = [NAME, TEST_NAME, CREATE_TIME, UI_REPORT_STATUS, CREATOR, TRIGGER_MODE];
export const TEST_CASE_CONFIGS = [NAME, API_TAGS, MODULE, PRIORITY, CREATE_TIME, UPDATE_TIME, CREATOR, CASE_REVIEW_STATUS]; export const TEST_CASE_CONFIGS = [NAME, API_TAGS, MODULE, CREATE_TIME, UPDATE_TIME, CREATOR, CASE_REVIEW_STATUS];
export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE]; export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE];

View File

@ -333,7 +333,7 @@ export default {
condition: { condition: {
components: TEST_CASE_CONFIGS, components: TEST_CASE_CONFIGS,
filters: {}, filters: {},
custom: true, custom: false,
}, },
versionFilters: [], versionFilters: [],
graphData: {}, graphData: {},
@ -633,7 +633,7 @@ export default {
this.testCaseTemplate = template; this.testCaseTemplate = template;
this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields, this.members); this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields, this.members);
// todo // todo
let comp = getAdvSearchCustomField(this.condition.components, this.testCaseTemplate.customFields); let comp = getAdvSearchCustomField(this.condition, this.testCaseTemplate.customFields);
this.condition.components.push(...comp); this.condition.components.push(...comp);
this.setTestCaseDefaultValue(template); this.setTestCaseDefaultValue(template);
this.typeArr = []; this.typeArr = [];

View File

@ -198,7 +198,7 @@ export default {
return { return {
page: getPageInfo({ page: getPageInfo({
components: TEST_TRACK_ISSUE_LIST, components: TEST_TRACK_ISSUE_LIST,
custom: true, custom: false,
}), }),
fields: [], fields: [],
tableHeaderKey:"ISSUE_LIST", tableHeaderKey:"ISSUE_LIST",
@ -293,7 +293,7 @@ export default {
} }
// //
this.page.condition.components = this.page.condition.components.filter(item => item.custom !== true); this.page.condition.components = this.page.condition.components.filter(item => item.custom !== true);
let comp = getAdvSearchCustomField(this.page.condition.components, this.issueTemplate.customFields); let comp = getAdvSearchCustomField(this.page.condition, this.issueTemplate.customFields);
this.page.condition.components.push(...comp); this.page.condition.components.push(...comp);
if (this.$refs.table) this.$refs.table.reloadTable(); if (this.$refs.table) this.$refs.table.reloadTable();
}, },

View File

@ -308,7 +308,7 @@ export function getTableHeaderWithCustomFields(key, customFields, projectMembers
isCustom: true isCustom: true
} }
fieldSetting.push(field); fieldSetting.push(field);
if (item.type === 'member' && projectMembers && projectMembers.length > 0) { if ((item.type === 'member' || item.type === 'multipleMember' ) && projectMembers && projectMembers.length > 0) {
item.options = projectMembers; item.options = projectMembers;
} }
}); });

View File

@ -527,7 +527,7 @@ export default {
issue_severity: 'Severity', issue_severity: 'Severity',
create: 'Create Field', create: 'Create Field',
update: 'Update Field', update: 'Update Field',
name: 'Custom Field', name: 'Template Field',
system_field: 'System Field', system_field: 'System Field',
scene: 'Use Scene', scene: 'Use Scene',
attribute_type: 'Attribute Type', attribute_type: 'Attribute Type',

View File

@ -529,7 +529,7 @@ export default {
issue_severity: '严重程度', issue_severity: '严重程度',
create: '创建字段', create: '创建字段',
update: '更新字段', update: '更新字段',
name: '自定义字段', name: '模版字段',
system_field: '系统字段', system_field: '系统字段',
scene: '使用场景', scene: '使用场景',
attribute_type: '属性类型', attribute_type: '属性类型',

View File

@ -529,7 +529,7 @@ export default {
issue_severity: '嚴重程度', issue_severity: '嚴重程度',
create: '創建字段', create: '創建字段',
update: '更新字段', update: '更新字段',
name: '自定義字段', name: '模版字段',
system_field: '系統字段', system_field: '系統字段',
scene: '使用場景', scene: '使用場景',
attribute_type: '屬性類型', attribute_type: '屬性類型',