fix(测试跟踪): 功能用例-筛选弹框页是空白
--bug=1026912 --user=白奇 【测试跟踪】功能用例-筛选弹框页是空白 https://www.tapd.cn/55049933/s/1381797
This commit is contained in:
parent
7cfee34209
commit
40daae08df
|
@ -1,28 +1,56 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="adv-search-bar">
|
<span class="adv-search-bar">
|
||||||
<el-link type="primary" @click="open" v-if="showLink">{{ $t('commons.adv_search.title') }}</el-link>
|
<el-link type="primary" @click="open" v-if="showLink">{{
|
||||||
<el-dialog :title="$t('commons.adv_search.title')" :visible.sync="visible"
|
$t("commons.adv_search.title")
|
||||||
custom-class="adv-dialog" :append-to-body="true">
|
}}</el-link>
|
||||||
|
<el-dialog
|
||||||
|
:title="$t('commons.adv_search.title')"
|
||||||
|
:visible.sync="visible"
|
||||||
|
custom-class="adv-dialog"
|
||||||
|
:append-to-body="true"
|
||||||
|
>
|
||||||
<div class="search-items">
|
<div class="search-items">
|
||||||
<div class="search-item" v-for="(component) in optional.components" :key="component.key">
|
<div
|
||||||
|
class="search-item"
|
||||||
|
v-for="component in optional.components"
|
||||||
|
:key="component.key"
|
||||||
|
>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="22">
|
<el-col :span="22">
|
||||||
<component :is="component.name" :component="component" :components.sync="config.components"
|
<component
|
||||||
@updateKey="changeSearchItemKey" :custom="condition.custom"/>
|
:is="component.name"
|
||||||
|
:component="component"
|
||||||
|
:components.sync="config.components"
|
||||||
|
@updateKey="changeSearchItemKey"
|
||||||
|
:custom="condition.custom"
|
||||||
|
/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="2">
|
<el-col :span="2">
|
||||||
<i class="el-icon-close delete-icon" @click="remove(component)"
|
<i
|
||||||
v-if="optional.components.length !==1"></i>
|
class="el-icon-close delete-icon"
|
||||||
|
@click="remove(component)"
|
||||||
|
v-if="optional.components.length !== 1"
|
||||||
|
></i>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<el-link type="primary" icon="el-icon-plus" v-if="showAddFilterLink"
|
<el-link
|
||||||
class="add-filter-link" @click="addFilter">{{ $t('commons.adv_search.add_filter_link') }}</el-link>
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
v-if="showAddFilterLink"
|
||||||
|
class="add-filter-link"
|
||||||
|
@click="addFilter"
|
||||||
|
>{{ $t("commons.adv_search.add_filter_link") }}</el-link
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="reset">{{ $t('commons.adv_search.reset') }}</el-button>
|
<el-button @click="reset">{{
|
||||||
<el-button type="primary" @click="search">{{ $t('commons.adv_search.search') }}</el-button>
|
$t("commons.adv_search.reset")
|
||||||
|
}}</el-button>
|
||||||
|
<el-button type="primary" @click="search">{{
|
||||||
|
$t("commons.adv_search.search")
|
||||||
|
}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
@ -31,11 +59,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import components from "./search-components";
|
import components from "./search-components";
|
||||||
import {cloneDeep, concat, slice} from "lodash-es";
|
import { cloneDeep, concat, slice } from "lodash-es";
|
||||||
import {_findByKey, _findIndexByKey} from "./custom-component";
|
import { _findByKey, _findIndexByKey } from "./custom-component";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {...components},
|
components: { ...components },
|
||||||
name: "MsTableAdvSearchBar",
|
name: "MsTableAdvSearchBar",
|
||||||
props: {
|
props: {
|
||||||
condition: Object,
|
condition: Object,
|
||||||
|
@ -47,47 +75,58 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default() {
|
default() {
|
||||||
return 4; // 默认展示的搜索条件数量
|
return 4; // 默认展示的搜索条件数量
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
config: {
|
config: {
|
||||||
components: []
|
components: [],
|
||||||
},
|
},
|
||||||
optional: {
|
optional: {
|
||||||
components: []
|
components: [],
|
||||||
},
|
},
|
||||||
showAddFilterLink: true,
|
showAddFilterLink: true,
|
||||||
nullFilterKey: '',
|
nullFilterKey: "",
|
||||||
isInit: false,
|
isInit: false,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
doInit(handleCustom) {
|
doInit(handleCustom) {
|
||||||
let config = cloneDeep(this.condition);
|
let config = cloneDeep(this.condition);
|
||||||
config.components.forEach(component => {
|
config.components.forEach((component) => {
|
||||||
let operator = component.operator.value;
|
let operator = component.operator.value;
|
||||||
component.operator.value = operator === undefined ? component.operator.options[0].value : operator;
|
component.operator.value =
|
||||||
})
|
operator === undefined
|
||||||
|
? component.operator.options[0].value
|
||||||
|
: operator;
|
||||||
|
});
|
||||||
if (!handleCustom) {
|
if (!handleCustom) {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
if (this.condition.custom) {
|
if (this.condition.custom) {
|
||||||
let components = [];
|
let components = [];
|
||||||
this.systemFiled = config.components.filter(co => co.custom === undefined || co.custom === false);
|
this.systemFiled = config.components.filter(
|
||||||
this.customFiled = config.components.filter(co => co.custom === true);
|
(co) => co.custom === undefined || co.custom === false
|
||||||
|
);
|
||||||
|
this.customFiled = config.components.filter((co) => co.custom === true);
|
||||||
// 选项分组
|
// 选项分组
|
||||||
this.$set(components, 0, {label: this.$t('custom_field.system_field'), child: this.systemFiled});
|
components.push({
|
||||||
this.$set(components, 1, {label: this.$t('custom_field.name'), child: this.customFiled});
|
label: this.$t("custom_field.system_field"),
|
||||||
|
child: this.systemFiled,
|
||||||
|
});
|
||||||
|
components.push({
|
||||||
|
label: this.$t("custom_field.name"),
|
||||||
|
child: this.customFiled,
|
||||||
|
});
|
||||||
this.$set(config, "components", components);
|
this.$set(config, "components", components);
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
search() {
|
search() {
|
||||||
let condition = {}
|
let condition = {};
|
||||||
this.optional.components.forEach(component => {
|
this.optional.components.forEach((component) => {
|
||||||
let value = component.value;
|
let value = component.value;
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
if (value.length > 0) {
|
if (value.length > 0) {
|
||||||
|
@ -104,42 +143,60 @@ export default {
|
||||||
if (this.condition.name) this.condition.name = undefined;
|
if (this.condition.name) this.condition.name = undefined;
|
||||||
// 添加组合条件
|
// 添加组合条件
|
||||||
this.condition.combine = condition;
|
this.condition.combine = condition;
|
||||||
this.$emit('update:condition', this.condition);
|
this.$emit("update:condition", this.condition);
|
||||||
this.$emit('search', condition);
|
this.$emit("search", condition);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
},
|
},
|
||||||
setCondition(condition, component) {
|
setCondition(condition, component) {
|
||||||
// 某些字段储存在自定义表但是其 custom 的值是 false
|
// 某些字段储存在自定义表但是其 custom 的值是 false
|
||||||
// 因为需求要把这些字段在有选项分类时归为 系统字段 ?
|
// 因为需求要把这些字段在有选项分类时归为 系统字段 ?
|
||||||
if (component.custom || ['严重程度', '处理人', '状态', '用例状态', '责任人', '用例等级'].indexOf(component.label) > -1) {
|
if (
|
||||||
|
component.custom ||
|
||||||
|
[
|
||||||
|
"严重程度",
|
||||||
|
"处理人",
|
||||||
|
"状态",
|
||||||
|
"用例状态",
|
||||||
|
"责任人",
|
||||||
|
"用例等级",
|
||||||
|
].indexOf(component.label) > -1
|
||||||
|
) {
|
||||||
this.handleCustomField(condition, component);
|
this.handleCustomField(condition, component);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
condition[component.key] = {
|
condition[component.key] = {
|
||||||
operator: component.operator.value,
|
operator: component.operator.value,
|
||||||
value: component.value
|
value: component.value,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleCustomField(condition, component) {
|
handleCustomField(condition, component) {
|
||||||
if (!condition.customs) {
|
if (!condition.customs) {
|
||||||
condition['customs'] = [];
|
condition["customs"] = [];
|
||||||
}
|
}
|
||||||
let value = component.value;
|
let value = component.value;
|
||||||
if (component.label === '用例状态' && value.length === 1 && value.indexOf('Trash') > -1) {
|
if (
|
||||||
|
component.label === "用例状态" &&
|
||||||
|
value.length === 1 &&
|
||||||
|
value.indexOf("Trash") > -1
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (component.type === "multipleMember" || component.type === "checkbox" || component.type === "multipleSelect") {
|
if (
|
||||||
|
component.type === "multipleMember" ||
|
||||||
|
component.type === "checkbox" ||
|
||||||
|
component.type === "multipleSelect"
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
value = JSON.stringify(component.value);
|
value = JSON.stringify(component.value);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
condition['customs'].push({
|
condition["customs"].push({
|
||||||
id: component.key,
|
id: component.key,
|
||||||
operator: component.operator.value,
|
operator: component.operator.value,
|
||||||
value: value,
|
value: value,
|
||||||
type: component.type
|
type: component.type,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -147,7 +204,10 @@ export default {
|
||||||
this.optional.components.forEach((component, index) => {
|
this.optional.components.forEach((component, index) => {
|
||||||
if (component.operator.value !== undefined) {
|
if (component.operator.value !== undefined) {
|
||||||
let operator = _findByKey(source, component.key).operator.value;
|
let operator = _findByKey(source, component.key).operator.value;
|
||||||
component.operator.value = operator === undefined ? component.operator.options[0].value : operator;
|
component.operator.value =
|
||||||
|
operator === undefined
|
||||||
|
? component.operator.options[0].value
|
||||||
|
: operator;
|
||||||
}
|
}
|
||||||
if (component.value !== undefined) {
|
if (component.value !== undefined) {
|
||||||
component.value = source[index].value;
|
component.value = source[index].value;
|
||||||
|
@ -155,24 +215,37 @@ export default {
|
||||||
if (component.reset && component.reset instanceof Function) {
|
if (component.reset && component.reset instanceof Function) {
|
||||||
component.reset();
|
component.reset();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
this.condition.combine = undefined;
|
this.condition.combine = undefined;
|
||||||
this.$emit('update:condition', this.condition);
|
this.$emit("update:condition", this.condition);
|
||||||
this.$emit('search');
|
this.$emit("search");
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.config = this.doInit(true);
|
this.config = this.doInit(true);
|
||||||
this.optional = this.doInit();
|
this.optional = this.doInit();
|
||||||
if (this.optional.components.length && this.optional.components.length <= this.showItemSize) {
|
if (
|
||||||
|
this.optional.components.length &&
|
||||||
|
this.optional.components.length <= this.showItemSize
|
||||||
|
) {
|
||||||
this.showAddFilterLink = false;
|
this.showAddFilterLink = false;
|
||||||
}
|
}
|
||||||
// 默认显示几个搜索条件
|
// 默认显示几个搜索条件
|
||||||
this.optional.components = slice(this.optional.components, 0, this.showItemSize);
|
this.optional.components = slice(
|
||||||
let allComponent = this.condition.custom ?
|
this.optional.components,
|
||||||
concat(this.config.components[0].child, this.config.components[1].child) : this.config.components;
|
0,
|
||||||
|
this.showItemSize
|
||||||
|
);
|
||||||
|
let allComponent = this.condition.custom
|
||||||
|
? concat(
|
||||||
|
this.config.components[0].child,
|
||||||
|
this.config.components[1].child
|
||||||
|
)
|
||||||
|
: this.config.components;
|
||||||
for (let component of allComponent) {
|
for (let component of allComponent) {
|
||||||
let co = _findByKey(this.optional.components, component.key);
|
let co = _findByKey(this.optional.components, component.key);
|
||||||
co ? this.$set(co, 'disable', true) : this.$set(component, 'disable', false);
|
co
|
||||||
|
? this.$set(co, "disable", true)
|
||||||
|
: this.$set(component, "disable", false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
|
@ -188,40 +261,58 @@ export default {
|
||||||
},
|
},
|
||||||
refreshComponentOption() {
|
refreshComponentOption() {
|
||||||
// 当前已存在的搜索子组件中是否有需要进行刷新数据选项的
|
// 当前已存在的搜索子组件中是否有需要进行刷新数据选项的
|
||||||
let comps = this.optional.components.filter(cp => cp.init && cp.init instanceof Function);
|
let comps = this.optional.components.filter(
|
||||||
comps.forEach(comp => comp.init());
|
(cp) => cp.init && cp.init instanceof Function
|
||||||
|
);
|
||||||
|
comps.forEach((comp) => comp.init());
|
||||||
},
|
},
|
||||||
setModulesParam() {
|
setModulesParam() {
|
||||||
let comps = this.optional.components.filter(c => c.key === 'moduleIds' && c.options.type === 'POST');
|
let comps = this.optional.components.filter(
|
||||||
comps.forEach(comp => comp.options.params = {"projectId": this.condition.projectId});
|
(c) => c.key === "moduleIds" && c.options.type === "POST"
|
||||||
|
);
|
||||||
|
comps.forEach(
|
||||||
|
(comp) =>
|
||||||
|
(comp.options.params = { projectId: this.condition.projectId })
|
||||||
|
);
|
||||||
},
|
},
|
||||||
handleCustomComponent() {
|
handleCustomComponent() {
|
||||||
let newConfig = cloneDeep(this.condition);
|
let newConfig = cloneDeep(this.condition);
|
||||||
newConfig.components.forEach(component => {
|
newConfig.components.forEach((component) => {
|
||||||
let operator = component.operator.value;
|
let operator = component.operator.value;
|
||||||
component.operator.value = operator === undefined ? component.operator.options[0].value : operator;
|
component.operator.value =
|
||||||
})
|
operator === undefined
|
||||||
this.newCustomFiled = newConfig.components.filter(co => co.custom);
|
? component.operator.options[0].value
|
||||||
|
: operator;
|
||||||
|
});
|
||||||
|
this.newCustomFiled = newConfig.components.filter((co) => co.custom);
|
||||||
for (let customField of this.newCustomFiled) {
|
for (let customField of this.newCustomFiled) {
|
||||||
let co = _findByKey(this.optional.components, customField.key);
|
let co = _findByKey(this.optional.components, customField.key);
|
||||||
co ? this.$set(co, 'disable', true) : this.$set(customField, 'disable', false);
|
co
|
||||||
|
? this.$set(co, "disable", true)
|
||||||
|
: this.$set(customField, "disable", false);
|
||||||
}
|
}
|
||||||
this.config.components[1] = {label: this.$t('custom_field.name'), child: this.newCustomFiled};
|
this.config.components[1] = {
|
||||||
|
label: this.$t("custom_field.name"),
|
||||||
|
child: this.newCustomFiled,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
addFilter() {
|
addFilter() {
|
||||||
const index = _findIndexByKey(this.optional.components, this.nullFilterKey);
|
const index = _findIndexByKey(
|
||||||
|
this.optional.components,
|
||||||
|
this.nullFilterKey
|
||||||
|
);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.$warning(this.$t('commons.adv_search.add_filter_link_tip'));
|
this.$warning(this.$t("commons.adv_search.add_filter_link_tip"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let data = {
|
let data = {
|
||||||
key: this.nullFilterKey,
|
key: this.nullFilterKey,
|
||||||
name: 'MsTableSearchInput',
|
name: "MsTableSearchInput",
|
||||||
label: '',
|
label: "",
|
||||||
operator: {
|
operator: {
|
||||||
options: []
|
options: [],
|
||||||
},
|
},
|
||||||
disable: false
|
disable: false,
|
||||||
};
|
};
|
||||||
this.optional.components.push(data);
|
this.optional.components.push(data);
|
||||||
},
|
},
|
||||||
|
@ -231,7 +322,10 @@ export default {
|
||||||
this.enableOptional(component, this.config.components);
|
this.enableOptional(component, this.config.components);
|
||||||
} else {
|
} else {
|
||||||
// 系统字段和自定义字段选项合并
|
// 系统字段和自定义字段选项合并
|
||||||
const components = concat(this.config.components[0].child, this.config.components[1].child);
|
const components = concat(
|
||||||
|
this.config.components[0].child,
|
||||||
|
this.config.components[1].child
|
||||||
|
);
|
||||||
this.enableOptional(component, components);
|
this.enableOptional(component, components);
|
||||||
}
|
}
|
||||||
let index = _findIndexByKey(this.optional.components, component.key);
|
let index = _findIndexByKey(this.optional.components, component.key);
|
||||||
|
@ -242,7 +336,7 @@ export default {
|
||||||
enableOptional(component, components) {
|
enableOptional(component, components) {
|
||||||
let data = _findByKey(components, component.key);
|
let data = _findByKey(components, component.key);
|
||||||
if (data) {
|
if (data) {
|
||||||
this.$set(data, 'disable', false);
|
this.$set(data, "disable", false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 搜索组件的字段变换时触发
|
// 搜索组件的字段变换时触发
|
||||||
|
@ -255,7 +349,10 @@ export default {
|
||||||
if (!this.condition.custom) {
|
if (!this.condition.custom) {
|
||||||
components = this.config.components;
|
components = this.config.components;
|
||||||
} else {
|
} else {
|
||||||
components = concat(this.config.components[0].child, this.config.components[1].child);
|
components = concat(
|
||||||
|
this.config.components[0].child,
|
||||||
|
this.config.components[1].child
|
||||||
|
);
|
||||||
}
|
}
|
||||||
for (let op of components) {
|
for (let op of components) {
|
||||||
if (op.disable !== undefined && op.disable === false) {
|
if (op.disable !== undefined && op.disable === false) {
|
||||||
|
@ -263,9 +360,9 @@ export default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -296,7 +393,6 @@ export default {
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.dialog-footer {
|
.dialog-footer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue