提交 9647c791 编写于 作者: RedPig97's avatar RedPig97

update: 搜索栏更新

上级 7c25628b
<template>
<div class="app-searchbar">
<div class="app-searchbar-group" v-for="(item,index) in condItems">
<div class="app-searchbar-group" v-for="(item,index) in items">
<el-select size="small" class="app-searchbar-field app-searchbar-item" v-model="item.field" clearable :placeholder="$t('components.filterTree.placeholder')">
<el-option
v-for="field in fieldItems"
......@@ -16,7 +16,7 @@
<slot :data="item"></slot>
</div>
<div class="app-searchbar-action">
<img v-if="index === condItems.length - 1" src="assets/img/ic_add_circle.svg" @click="onAddItem()">
<img v-if="index === items.length - 1" src="assets/img/ic_add_circle.svg" @click="onAddItem()">
<img v-else src="assets/img/remove_circle.svg" @click="onRemoveItem(index)">
</div>
</div>
......@@ -51,20 +51,6 @@ export default class AppSearchbar extends Vue {
*/
@Prop() fields: any;
@Watch("items", {immediate: true})
onItemsChange(newItems: any[]) {
this.condItems = [];
if (newItems && newItems.length > 0) {
this.condItems.push(...newItems);
} else {
this.condItems.push({
field: null,
mode: null,
editor: null
});
}
}
/**
* 属性项集合
*
......@@ -73,14 +59,6 @@ export default class AppSearchbar extends Vue {
*/
protected fieldItems: any[] = [];
/**
* 条件项集合
*
* @type {*}
* @memberof AppSearchbar
*/
protected condItems: any[] = [];
/**
* 生命周期
*
......@@ -91,6 +69,13 @@ export default class AppSearchbar extends Vue {
if(!this.fields) {
return;
}
if (this.items.length == 0) {
this.items.push({
field: null,
mode: null,
editor: null
})
}
this.fields.forEach((field: any) => {
let index: number = this.fieldItems.findIndex((item: any) => Object.is(item.value, field.prop));
if(index < 0) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册