提交 6aab3097 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 查询条件绑定视图

上级 3d7a65aa
<template> <template>
<el-select v-if="options!== null && options.attrs!==null" v-model="options.value" clearable :multiple="options.attrs.multiple" :placeholder="options.attrs.placeholder" @change="changeValue"> <el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :clearable="!options.attrs.multiple" :multiple="options.attrs.multiple" :placeholder="options.attrs.placeholder" @change="changeValue">
<el-option <el-option
v-for="item in options.attrs.datas" v-for="item in options.attrs.datas"
:key="item[options.attrs.key]" :key="item[options.attrs.key]"
...@@ -28,10 +28,15 @@ export default { ...@@ -28,10 +28,15 @@ export default {
data() { data() {
return { return {
options: null, options: null,
operator: 'eq', // operator: 'eq',
values: null values: null
} }
}, },
computed: {
operator() {
return this.options.attrs.multiple ? 'in' : 'eq'
}
},
watch: { watch: {
'options.attrs.multiple': function(value) { 'options.attrs.multiple': function(value) {
if (value) { if (value) {
...@@ -41,7 +46,6 @@ export default { ...@@ -41,7 +46,6 @@ export default {
} }
} }
}, },
created() { created() {
this.options = this.element.options this.options = this.element.options
this.setCondition() this.setCondition()
...@@ -54,11 +58,16 @@ export default { ...@@ -54,11 +58,16 @@ export default {
methods: { methods: {
changeValue(value) { changeValue(value) {
this.setCondition() this.setCondition()
this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator }) // this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator })
}, },
setCondition() { setCondition() {
this.inDraw && this.$store.dispatch('conditions/add', { component: this.element, value: [this.options.value], operator: this.operator }) const param = {
component: this.element,
value: Array.isArray(this.options.value) ? this.options.value : [this.options.value],
operator: this.operator
}
this.inDraw && this.$store.dispatch('conditions/add', param)
} }
} }
} }
......
...@@ -157,16 +157,16 @@ ...@@ -157,16 +157,16 @@
</div> </div>
</el-col> </el-col>
<el-col :span="16"><div class="filter-options-right"> <el-col :span="16"><div class="filter-options-right">
<el-checkbox v-model="customRange"><span> {{ $t('panel.custom_scope') }} </span> </el-checkbox> <el-checkbox v-model="componentInfo.options.attrs.enableRange" @change="enableRangeChange"><span> {{ $t('panel.custom_scope') }} </span> </el-checkbox>
<el-popover <el-popover
v-model="popovervisible" v-model="popovervisible"
placement="bottom-end" placement="bottom-end"
:disabled="!customRange" :disabled="!componentInfo.options.attrs.enableRange"
width="200" width="200"
> >
<div class="view-container-class"> <div class="view-container-class">
<el-checkbox-group v-model="checkedViews" @change="checkedViewsChange"> <el-checkbox-group v-model="componentInfo.options.attrs.viewIds" @change="checkedViewsChange">
<el-checkbox v-for="(item ) in viewInfos" :key="item.id" :label="item.id"> <el-checkbox v-for="(item ) in viewInfos" :key="item.id" :label="item.id">
<span> <span>
<svg-icon :icon-class="item.type" class="chart-icon" /> <svg-icon :icon-class="item.type" class="chart-icon" />
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</el-checkbox-group> </el-checkbox-group>
</div> </div>
<i slot="reference" :class="{'i-filter-active': customRange, 'i-filter-inactive': !customRange}" class="el-icon-setting i-filter" /> <i slot="reference" :class="{'i-filter-active': componentInfo.options.attrs.enableRange, 'i-filter-inactive': !componentInfo.options.attrs.enableRange}" class="el-icon-setting i-filter" />
</el-popover> </el-popover>
<!-- <el-checkbox disabled>备选项</el-checkbox> --> <!-- <el-checkbox disabled>备选项</el-checkbox> -->
</div> </div>
...@@ -257,10 +257,8 @@ export default { ...@@ -257,10 +257,8 @@ export default {
selectField: [], selectField: [],
widget: null, widget: null,
fieldValues: [], fieldValues: [],
customRange: false,
popovervisible: false, popovervisible: false,
viewInfos: [], viewInfos: []
checkedViews: []
} }
}, },
computed: { computed: {
...@@ -478,7 +476,14 @@ export default { ...@@ -478,7 +476,14 @@ export default {
}, },
checkedViewsChange(values) { checkedViewsChange(values) {
this.componentInfo.options.attrs.viewIds = values // this.componentInfo.options.attrs.viewIds = values
this.$emit('re-fresh-component', this.componentInfo)
},
enableRangeChange(value) {
if (!value) {
this.componentInfo.options.attrs.viewIds = []
}
// this.componentInfo.options.attrs.enableRange = value
this.$emit('re-fresh-component', this.componentInfo) this.$emit('re-fresh-component', this.componentInfo)
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论