fix(测试跟踪): 功能用例-筛选弹框页是空白

--bug=1026912 --user=白奇 【测试跟踪】功能用例-筛选弹框页是空白 https://www.tapd.cn/55049933/s/1381797
This commit is contained in:
baiqi 2023-06-20 14:50:23 +08:00 committed by 刘瑞斌
parent ae5b9aa55a
commit 1d655abff1
2 changed files with 388 additions and 194 deletions

View File

@ -1,33 +1,65 @@
<template> <template>
<span class="adv-search-bar"> <span class="adv-search-bar">
<el-button size="mini" @click="open" ref="filter-btn"> <el-button size="mini" @click="open" ref="filter-btn">
<svg-icon :icon-class="conditionNum == 0 ? 'icon-filter' : 'icon-filter-actived'"/> <svg-icon
<span class="condition-num">{{conditionNum == 0 ? "" : "(" + conditionNum + ")" }}</span> :icon-class="conditionNum == 0 ? 'icon-filter' : 'icon-filter-actived'"
/>
<span class="condition-num">{{
conditionNum == 0 ? "" : "(" + conditionNum + ")"
}}</span>
</el-button> </el-button>
<el-dialog :title="$t('commons.adv_search.new_title')" :visible.sync="visible" <el-dialog
custom-class="adv-dialog" :append-to-body="true" width="60%"> :title="$t('commons.adv_search.new_title')"
:visible.sync="visible"
custom-class="adv-dialog"
:append-to-body="true"
width="60%"
>
<div class="search-items" style="height: 300px"> <div class="search-items" style="height: 300px">
<el-scrollbar style="height: 100%" ref="scrollbar"> <el-scrollbar style="height: 100%" ref="scrollbar">
<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="23"> <el-col :span="23">
<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="1"> <el-col :span="1">
<i class="el-icon-delete delete-icon" @click="remove(component)" v-if="optional.components.length !==1"></i> <i
class="el-icon-delete delete-icon"
@click="remove(component)"
v-if="optional.components.length !== 1"
></i>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</el-scrollbar> </el-scrollbar>
<el-link type="primary" icon="el-icon-plus" v-if="showAddFilterLink" :underline="false" <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"
:underline="false"
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 size="small" @click="reset">{{ $t('commons.adv_search.reset') }}</el-button> <el-button size="small" @click="reset">{{
<el-button size="small" type="primary" @click="search">{{ $t('commons.adv_search.search') }}</el-button> $t("commons.adv_search.reset")
}}</el-button>
<el-button size="small" type="primary" @click="search">{{
$t("commons.adv_search.search")
}}</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@ -52,23 +84,23 @@ export default {
type: Number, type: Number,
default() { default() {
return 6; // return 6; //
} },
} },
}, },
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,
conditionNum: 0, conditionNum: 0,
} };
}, },
updated() { updated() {
this.setScrollToBottom(); this.setScrollToBottom();
@ -76,28 +108,39 @@ export default {
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() {
this.conditionNum = 0 this.conditionNum = 0;
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) {
@ -114,10 +157,10 @@ export default {
if (this.conditionNum > 0) { if (this.conditionNum > 0) {
this.$refs["filter-btn"].$el.focus(); this.$refs["filter-btn"].$el.focus();
this.$refs["filter-btn"].$el.style.width = 'auto'; this.$refs["filter-btn"].$el.style.width = "auto";
} else { } else {
this.$refs["filter-btn"].$el.blur(); this.$refs["filter-btn"].$el.blur();
this.$refs["filter-btn"].$el.style.width = '32px'; this.$refs["filter-btn"].$el.style.width = "32px";
} }
// name // name
@ -126,53 +169,74 @@ export default {
} }
// //
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() {
this.conditionNum = 0; this.conditionNum = 0;
this.$refs["filter-btn"].$el.blur(); this.$refs["filter-btn"].$el.blur();
this.$refs["filter-btn"].$el.style.width = '32px'; this.$refs["filter-btn"].$el.style.width = "32px";
let source = this.condition.components; let source = this.condition.components;
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;
@ -180,24 +244,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() {
@ -212,27 +289,37 @@ 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 })
);
}, },
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);
}, },
@ -242,7 +329,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);
@ -253,7 +343,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);
} }
}, },
// //
@ -266,7 +356,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) {
@ -276,16 +369,16 @@ export default {
} }
}, },
setScrollToBottom() { setScrollToBottom() {
this.$refs['scrollbar'].wrap.scrollTop = this.$refs['scrollbar'].wrap.scrollHeight; this.$refs["scrollbar"].wrap.scrollTop =
} this.$refs["scrollbar"].wrap.scrollHeight;
} },
, },
computed: { computed: {
isAuto() { isAuto() {
return this.conditionNum > 0 return this.conditionNum > 0;
} },
} },
} };
</script> </script>
<style> <style>
@ -316,7 +409,6 @@ export default {
</style> </style>
<style scoped> <style scoped>
.dialog-footer { .dialog-footer {
text-align: right; text-align: right;
} }
@ -406,7 +498,7 @@ export default {
span.condition-num { span.condition-num {
width: 18px; width: 18px;
height: 22px; height: 22px;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
@ -416,7 +508,7 @@ span.condition-num {
flex: none; flex: none;
order: 1; order: 1;
flex-grow: 0; flex-grow: 0;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
line-height: 22px; line-height: 22px;
display: flex; display: flex;
@ -452,12 +544,12 @@ span.condition-num {
flex: none; flex: none;
flex-grow: 0; flex-grow: 0;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep(i.el-tag__close.el-icon-close) { :deep(i.el-tag__close.el-icon-close) {
@ -467,30 +559,30 @@ span.condition-num {
} }
.adv-search-bar { .adv-search-bar {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep(input.el-input__inner) { :deep(input.el-input__inner) {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep (.el-button--mini, .el-button--small) { :deep (.el-button--mini, .el-button--small) {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
text-align: center; text-align: center;
color: #1F2329; color: #1f2329;
} }
</style> </style>

View File

@ -1,32 +1,74 @@
<template> <template>
<span class="adv-search-bar"> <span class="adv-search-bar">
<el-button size="mini" @click="open" ref="filter-btn" :class="conditionNum === 0 ? '' : 'btn-active'"> <el-button
<svg-icon :icon-class="conditionNum === 0 ? 'icon-filter' : 'icon-filter-active'"/> size="mini"
<span class="condition-num">{{conditionNum === 0 ? "" : "(" + conditionNum + ")" }}</span> @click="open"
ref="filter-btn"
:class="conditionNum === 0 ? '' : 'btn-active'"
>
<svg-icon
:icon-class="conditionNum === 0 ? 'icon-filter' : 'icon-filter-active'"
/>
<span class="condition-num">{{
conditionNum === 0 ? "" : "(" + conditionNum + ")"
}}</span>
</el-button> </el-button>
<el-dialog :title="$t('commons.adv_search.new_title')" :visible.sync="visible" <el-dialog
custom-class="adv-dialog" :append-to-body="true" width="60%"> :title="$t('commons.adv_search.new_title')"
:visible.sync="visible"
custom-class="adv-dialog"
:append-to-body="true"
width="60%"
>
<div class="search-items" style="height: 275px"> <div class="search-items" style="height: 275px">
<el-scrollbar style="height: 100%" ref="scrollbar"> <el-scrollbar style="height: 100%" ref="scrollbar">
<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="23"> <el-col :span="23">
<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="1"> <el-col :span="1">
<i class="el-icon-delete delete-icon" @click="remove(component)" v-if="optional.components.length !==1"></i> <i
class="el-icon-delete delete-icon"
@click="remove(component)"
v-if="optional.components.length !== 1"
></i>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</el-scrollbar> </el-scrollbar>
<el-link type="primary" icon="el-icon-plus" v-if="showAddFilterLink" :underline="false" <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"
:underline="false"
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" style="margin-top: 30px"> <div class="dialog-footer" style="margin-top: 30px">
<el-button size="small" @click="reset">{{ $t('commons.adv_search.reset') }}</el-button> <el-button size="small" @click="reset">{{
<el-button size="small" type="primary" @click="search" class="custom-btn">{{ $t('commons.adv_search.search') }}</el-button> $t("commons.adv_search.reset")
}}</el-button>
<el-button
size="small"
type="primary"
@click="search"
class="custom-btn"
>{{ $t("commons.adv_search.search") }}</el-button
>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@ -51,23 +93,23 @@ export default {
type: Number, type: Number,
default() { default() {
return 6; // return 6; //
} },
} },
}, },
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,
conditionNum: 0, conditionNum: 0,
} };
}, },
updated() { updated() {
this.setScrollToBottom(); this.setScrollToBottom();
@ -75,28 +117,39 @@ export default {
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() {
this.conditionNum = 0 this.conditionNum = 0;
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) {
@ -113,10 +166,10 @@ export default {
if (this.conditionNum > 0) { if (this.conditionNum > 0) {
this.$refs["filter-btn"].$el.focus(); this.$refs["filter-btn"].$el.focus();
this.$refs["filter-btn"].$el.style.width = 'auto'; this.$refs["filter-btn"].$el.style.width = "auto";
} else { } else {
this.$refs["filter-btn"].$el.blur(); this.$refs["filter-btn"].$el.blur();
this.$refs["filter-btn"].$el.style.width = '32px'; this.$refs["filter-btn"].$el.style.width = "32px";
} }
// name // name
@ -125,53 +178,74 @@ export default {
} }
// //
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() {
this.conditionNum = 0; this.conditionNum = 0;
this.$refs["filter-btn"].$el.blur(); this.$refs["filter-btn"].$el.blur();
this.$refs["filter-btn"].$el.style.width = '32px'; this.$refs["filter-btn"].$el.style.width = "32px";
let source = this.condition.components; let source = this.condition.components;
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;
@ -179,24 +253,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() {
@ -211,27 +298,37 @@ 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 })
);
}, },
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'), false); this.$warning(this.$t("commons.adv_search.add_filter_link_tip"), false);
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);
}, },
@ -241,7 +338,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);
@ -252,7 +352,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);
} }
}, },
// //
@ -265,7 +365,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) {
@ -275,18 +378,18 @@ export default {
} }
}, },
setScrollToBottom() { setScrollToBottom() {
if (this.$refs['scrollbar']) { if (this.$refs["scrollbar"]) {
this.$refs['scrollbar'].wrap.scrollTop = this.$refs['scrollbar'].wrap.scrollHeight; this.$refs["scrollbar"].wrap.scrollTop =
this.$refs["scrollbar"].wrap.scrollHeight;
} }
} },
} },
,
computed: { computed: {
isAuto() { isAuto() {
return this.conditionNum > 0 return this.conditionNum > 0;
} },
} },
} };
</script> </script>
<style> <style>
@ -325,12 +428,11 @@ export default {
text-align: left !important; text-align: left !important;
} }
button.el-button.custom-btn.el-button--primary.el-button--small { button.el-button.custom-btn.el-button--primary.el-button--small {
color: #FFFFFF!important; color: #ffffff !important;
} }
} }
</style> </style>
<style scoped> <style scoped>
.dialog-footer { .dialog-footer {
text-align: right; text-align: right;
} }
@ -410,7 +512,7 @@ export default {
span.condition-num { span.condition-num {
width: 18px; width: 18px;
height: 10px; height: 10px;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
@ -420,7 +522,7 @@ span.condition-num {
flex: none; flex: none;
order: 1; order: 1;
flex-grow: 0; flex-grow: 0;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
line-height: 22px; line-height: 22px;
display: flex; display: flex;
@ -456,12 +558,12 @@ span.condition-num {
flex: none; flex: none;
flex-grow: 0; flex-grow: 0;
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep(i.el-tag__close.el-icon-close) { :deep(i.el-tag__close.el-icon-close) {
@ -471,25 +573,25 @@ span.condition-num {
} }
.adv-search-bar { .adv-search-bar {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep(input.el-input__inner) { :deep(input.el-input__inner) {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: #1F2329; color: #1f2329;
} }
:deep (.el-button--mini, .el-button--small) { :deep (.el-button--mini, .el-button--small) {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
@ -498,7 +600,7 @@ span.condition-num {
} }
:deep(.el-button--small span) { :deep(.el-button--small span) {
font-family: 'PingFang SC'; font-family: "PingFang SC";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;