no message

This commit is contained in:
小陌 2023-07-03 15:55:57 +08:00
parent a00af5b380
commit b132b49ef2
4 changed files with 30 additions and 93 deletions

View File

@ -8,8 +8,8 @@
</el-badge> </el-badge>
<div class="right-panel-search" v-if="filter.length>0"> <div class="right-panel-search" v-if="filter.length>0">
<el-form :inline="true" :model="data"> <el-form :inline="true" :model="data">
<el-form-item style="margin-bottom:0px;margin-right: 6px;" v-for="(i,index) in filter" :key="index"> <el-form-item style="margin-bottom:0px;margin-right: 6px;" v-for="(i,index) in fieldTop" :key="index">
<x-item :item="i.field" v-model="data"></x-item> <x-item :item="i" v-model="data"></x-item>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom:0px;margin-right: 6px;"> <el-form-item style="margin-bottom:0px;margin-right: 6px;">
<el-button type="primary" @click="ok">查询</el-button> <el-button type="primary" @click="ok">查询</el-button>
@ -37,7 +37,7 @@
<el-tag :disable-transitions="true">{{index+1}}</el-tag> <el-tag :disable-transitions="true">{{index+1}}</el-tag>
</td> </td>
<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-delete />
</el-icon> </el-icon>
</td> </td>
@ -46,13 +46,10 @@
</py-select> </py-select>
</td> </td>
<td> <td>
<x-item v-model="data" :item="item.field"></x-item> <x-item v-model="data" :item="item.field"></x-item>
</td> </td>
<td v-if="item.field.operators"> <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-option v-for="ope in item.field.operators || operator" :key="ope.value" v-bind="ope"></el-option>
</el-select> </el-select>
</td> </td>
@ -135,6 +132,7 @@
fields: this.options, fields: this.options,
filter: [], filter: [],
myFilter: [], myFilter: [],
fieldTop: [],
defaultValue: Object.assign({}, this.modelValue), defaultValue: Object.assign({}, this.modelValue),
filterObjLength: 0, filterObjLength: 0,
saveLoading: false, saveLoading: false,
@ -150,30 +148,24 @@
filterObj(){ filterObj(){
const obj = {} const obj = {}
this.filter.forEach((item) => { 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; // return; //
} }
obj[item.field.name] = item.field.operator ? this.data[item.field.name]+`${config.separator}${item.field.operator}` : this.data[item.field.name]
obj[item.field.name] = item.operator ? this.data[item.field.name]+`${config.separator}${item.operator}` : this.data[item.field.name]
}) })
console.log(obj, this.filter) console.log(obj, this.defaultValue, this.data)
return obj return obj
} }
}, },
mounted(){ mounted(){
// //
this.fields.forEach((item) => { this.fields.forEach((item) => {
if(item.selected){ if(item.selected){
this.fieldTop.push(item)
this.filter.push({ this.filter.push({
field: item, field: item,
operator: item.operator,
value: ''
}) })
} }
}) })
@ -194,61 +186,30 @@
const filterNum = filterArr[0] const filterNum = filterArr[0]
this.filter.push({ this.filter.push({
field: filterNum, field: filterNum,
operator: filterNum.operator,
value: ''
}) })
}, },
// //
delFilter(index){ delFilter(index, o){
this.filter.splice(index, 1) this.filter.splice(index, 1)
this.data[o.field.name] = '';
}, },
// //
fieldChange(tr){ fieldChange(tr){
let oldType = tr.field.type console.log(tr)
tr.field.type = ''
this.$nextTick(() => {
tr.field.type = oldType
})
tr.operator = tr.field.operator
tr.value = ''
}, },
// //
selectChange(o){ ok(){
const foundItem = o.field.options.items.find(item => item.value === o.value); this.filterObjLength = Object.keys(this.filterObj).length
if (foundItem?.operator) { this.$emit('filterChange',this.filterObj)
o.operator = foundItem.operator; this.dialog = false
}
}, },
// //
async visibleChange(isopen, item){ clear(){
if(isopen && item.field.options.request && !item.field.options.remote){ Object.keys(this.data).forEach(key => {
item.selectLoading = true; this.data[key] = this.data[key] === this.defaultValue[key] ? this.defaultValue[key] : '';
try { });
var data = await item.field.options.request() this.filterObjLength = 0
}catch (error) { this.$emit('filterChange',this.filterObj)
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 = [];
}
}, },
// //
selectMyfilter(item){ selectMyfilter(item){
@ -259,9 +220,9 @@
if(filterValue){ if(filterValue){
var operator = filterValue.split("|")[1] var operator = filterValue.split("|")[1]
var value = filterValue.split("|")[0] var value = filterValue.split("|")[0]
if(field.type=='select' && field.options.multiple){ if(field.component=='select' && field.options.multiple){
value = value.split(",") value = value.split(",")
}else if(field.type=='daterange'){ }else if(field.component=='daterange'){
value = value.split(",") value = value.split(",")
} }
this.filter.push({ this.filter.push({
@ -275,12 +236,6 @@
this.$emit('filterChange',item.filterObj) this.$emit('filterChange',item.filterObj)
this.dialog = false this.dialog = false
}, },
//
ok(){
this.filterObjLength = Object.keys(this.filterObj).length
this.$emit('filterChange',this.filterObj)
this.dialog = false
},
// //
saveMy(){ saveMy(){
this.$prompt('常用过滤名称', '另存为常用', { 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> </script>

View File

@ -4,7 +4,7 @@
--> -->
<template> <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-option v-for="field in optionsList" :key="field.name" :label="field" :value="field" :disabled="isDisabled(field.name)"> </el-option>
</el-select> </el-select>
</template> </template>
@ -26,7 +26,6 @@
mounted() { mounted() {
this.optionsList = this.options this.optionsList = this.options
this.optionsList_ = [...this.options] this.optionsList_ = [...this.options]
this.$refs.select.selectedLabel = 'vdssavasdva'
}, },
methods: { methods: {
filterMethod(keyword){ filterMethod(keyword){

View File

@ -58,7 +58,8 @@ axios.interceptors.response.use(
} }
}).then(() => { }).then(() => {
router.replace({ router.replace({
path: '/login' path: '/login',
query: { redirect: router.currentRoute.fullPath }
}); });
}).catch(() => {}) }).catch(() => {})
} }

View File

@ -38,14 +38,11 @@
<script> <script>
import XItem from '@/components/scForm/item'
export default { export default {
props: { props: {
data: { type: Object, default: () => ({}) } data: { type: Object, default: () => ({}) }
}, },
components: { components: {
XItem,
}, },
data() { data() {
return { return {