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>
<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>

View File

@ -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){

View File

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

View File

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