no message
This commit is contained in:
parent
a00af5b380
commit
b132b49ef2
@ -8,8 +8,8 @@
|
||||
</el-badge>
|
||||
<div class="right-panel-search" v-if="filter.length>0">
|
||||
<el-form :inline="true" :model="data">
|
||||
<el-form-item style="margin-bottom:0px;margin-right: 6px;" v-for="(i,index) in filter" :key="index">
|
||||
<x-item :item="i.field" v-model="data"></x-item>
|
||||
<el-form-item style="margin-bottom:0px;margin-right: 6px;" v-for="(i,index) in fieldTop" :key="index">
|
||||
<x-item :item="i" v-model="data"></x-item>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-bottom:0px;margin-right: 6px;">
|
||||
<el-button type="primary" @click="ok">查询</el-button>
|
||||
@ -37,7 +37,7 @@
|
||||
<el-tag :disable-transitions="true">{{index+1}}</el-tag>
|
||||
</td>
|
||||
<td>
|
||||
<el-icon class="del" @click="delFilter(index)" style="border: 1px solid #e6e6e6;">
|
||||
<el-icon v-if="!item.field.selected" class="del" @click="delFilter(index, item)" style="border: 1px solid #e6e6e6;">
|
||||
<el-icon-delete />
|
||||
</el-icon>
|
||||
</td>
|
||||
@ -46,13 +46,10 @@
|
||||
</py-select>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<x-item v-model="data" :item="item.field"></x-item>
|
||||
|
||||
|
||||
</td>
|
||||
<td v-if="item.field.operators">
|
||||
<el-select v-model="item.operator" placeholder="运算符">
|
||||
<el-select v-model="item.field.operator" placeholder="运算符">
|
||||
<el-option v-for="ope in item.field.operators || operator" :key="ope.value" v-bind="ope"></el-option>
|
||||
</el-select>
|
||||
</td>
|
||||
@ -69,7 +66,7 @@
|
||||
<el-button @click="clear">清空过滤</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@ -135,6 +132,7 @@
|
||||
fields: this.options,
|
||||
filter: [],
|
||||
myFilter: [],
|
||||
fieldTop: [],
|
||||
defaultValue: Object.assign({}, this.modelValue),
|
||||
filterObjLength: 0,
|
||||
saveLoading: false,
|
||||
@ -150,30 +148,24 @@
|
||||
filterObj(){
|
||||
const obj = {}
|
||||
this.filter.forEach((item) => {
|
||||
|
||||
if (!this.data[item.field.name] || this.data[item.field.name] === '') {
|
||||
if (!this.data[item.field.name] || this.data[item.field.name] == '') {
|
||||
return; // 跳过当前迭代,继续下一次迭代
|
||||
}
|
||||
|
||||
obj[item.field.name] = item.operator ? this.data[item.field.name]+`${config.separator}${item.operator}` : this.data[item.field.name]
|
||||
|
||||
obj[item.field.name] = item.field.operator ? this.data[item.field.name]+`${config.separator}${item.field.operator}` : this.data[item.field.name]
|
||||
})
|
||||
|
||||
console.log(obj, this.filter)
|
||||
console.log(obj, this.defaultValue, this.data)
|
||||
|
||||
return obj
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
|
||||
|
||||
//默认显示的过滤项
|
||||
this.fields.forEach((item) => {
|
||||
if(item.selected){
|
||||
this.fieldTop.push(item)
|
||||
this.filter.push({
|
||||
field: item,
|
||||
operator: item.operator,
|
||||
value: ''
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -194,61 +186,30 @@
|
||||
const filterNum = filterArr[0]
|
||||
this.filter.push({
|
||||
field: filterNum,
|
||||
operator: filterNum.operator,
|
||||
value: ''
|
||||
})
|
||||
},
|
||||
//删除过滤项
|
||||
delFilter(index){
|
||||
delFilter(index, o){
|
||||
this.filter.splice(index, 1)
|
||||
this.data[o.field.name] = '';
|
||||
},
|
||||
//过滤项字段变更事件
|
||||
fieldChange(tr){
|
||||
let oldType = tr.field.type
|
||||
tr.field.type = ''
|
||||
this.$nextTick(() => {
|
||||
tr.field.type = oldType
|
||||
})
|
||||
tr.operator = tr.field.operator
|
||||
tr.value = ''
|
||||
console.log(tr)
|
||||
},
|
||||
//下拉框得到数据后回调
|
||||
selectChange(o){
|
||||
const foundItem = o.field.options.items.find(item => item.value === o.value);
|
||||
if (foundItem?.operator) {
|
||||
o.operator = foundItem.operator;
|
||||
}
|
||||
//立即过滤
|
||||
ok(){
|
||||
this.filterObjLength = Object.keys(this.filterObj).length
|
||||
this.$emit('filterChange',this.filterObj)
|
||||
this.dialog = false
|
||||
},
|
||||
//下拉框显示事件处理异步
|
||||
async visibleChange(isopen, item){
|
||||
if(isopen && item.field.options.request && !item.field.options.remote){
|
||||
item.selectLoading = true;
|
||||
try {
|
||||
var data = await item.field.options.request()
|
||||
}catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
item.field.options.data = data;
|
||||
item.selectLoading = false;
|
||||
}
|
||||
},
|
||||
//下拉框显示事件处理异步搜索
|
||||
async remoteMethod(query, item){
|
||||
if(!item.field.options.request) {
|
||||
return false;
|
||||
}
|
||||
if(query !== ''){
|
||||
item.selectLoading = true;
|
||||
try {
|
||||
var data = await item.field.options.request(query);
|
||||
}catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
item.field.options.data = data;
|
||||
item.selectLoading = false;
|
||||
}else{
|
||||
item.field.options.data = [];
|
||||
}
|
||||
//清空过滤
|
||||
clear(){
|
||||
Object.keys(this.data).forEach(key => {
|
||||
this.data[key] = this.data[key] === this.defaultValue[key] ? this.defaultValue[key] : '';
|
||||
});
|
||||
this.filterObjLength = 0
|
||||
this.$emit('filterChange',this.filterObj)
|
||||
},
|
||||
//选择常用过滤
|
||||
selectMyfilter(item){
|
||||
@ -259,9 +220,9 @@
|
||||
if(filterValue){
|
||||
var operator = filterValue.split("|")[1]
|
||||
var value = filterValue.split("|")[0]
|
||||
if(field.type=='select' && field.options.multiple){
|
||||
if(field.component=='select' && field.options.multiple){
|
||||
value = value.split(",")
|
||||
}else if(field.type=='daterange'){
|
||||
}else if(field.component=='daterange'){
|
||||
value = value.split(",")
|
||||
}
|
||||
this.filter.push({
|
||||
@ -275,12 +236,6 @@
|
||||
this.$emit('filterChange',item.filterObj)
|
||||
this.dialog = false
|
||||
},
|
||||
//立即过滤
|
||||
ok(){
|
||||
this.filterObjLength = Object.keys(this.filterObj).length
|
||||
this.$emit('filterChange',this.filterObj)
|
||||
this.dialog = false
|
||||
},
|
||||
//保存常用
|
||||
saveMy(){
|
||||
this.$prompt('常用过滤名称', '另存为常用', {
|
||||
@ -313,21 +268,6 @@
|
||||
//
|
||||
})
|
||||
},
|
||||
//清空过滤
|
||||
clear(){
|
||||
|
||||
Object.keys(this.data).forEach(key => {
|
||||
if (this.data[key] === this.defaultValue[key]) {
|
||||
this.data[key] = this.defaultValue[key];
|
||||
} else {
|
||||
this.data[key] = '';
|
||||
}
|
||||
});
|
||||
|
||||
// this.filter = []
|
||||
this.filterObjLength = 0
|
||||
this.$emit('filterChange',this.filterObj)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -4,7 +4,7 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<el-select ref="select" v-bind="$attrs" :filter-method="filterMethod" @visible-change="visibleChange">
|
||||
<el-select ref="select" v-bind="$attrs" :filter-method="filterMethod" @visible-change="visibleChange" :disabled="$attrs.modelValue.selected">
|
||||
<el-option v-for="field in optionsList" :key="field.name" :label="field" :value="field" :disabled="isDisabled(field.name)"> </el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
@ -26,7 +26,6 @@
|
||||
mounted() {
|
||||
this.optionsList = this.options
|
||||
this.optionsList_ = [...this.options]
|
||||
this.$refs.select.selectedLabel = 'vdssavasdva'
|
||||
},
|
||||
methods: {
|
||||
filterMethod(keyword){
|
||||
|
@ -58,7 +58,8 @@ axios.interceptors.response.use(
|
||||
}
|
||||
}).then(() => {
|
||||
router.replace({
|
||||
path: '/login'
|
||||
path: '/login',
|
||||
query: { redirect: router.currentRoute.fullPath }
|
||||
});
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
@ -38,14 +38,11 @@
|
||||
|
||||
<script>
|
||||
|
||||
import XItem from '@/components/scForm/item'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
data: { type: Object, default: () => ({}) }
|
||||
},
|
||||
components: {
|
||||
XItem,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user