fix: 仪表板>过滤器 选择“字段枚举值”后,再次打开下拉框没有数据

This commit is contained in:
ulleo 2023-09-06 16:29:55 +08:00
parent 3ba69be557
commit f1124fad3f
5 changed files with 231 additions and 124 deletions

View File

@ -275,6 +275,11 @@ export default {
this.logic = this.item.logic
this.filterType = this.item.filterType
this.enumCheckField = this.item.enumCheckField
// init enum option
if (this.item.filterType === 'enum' && this.needRequestEnum) {
this.initEnumOptions()
}
},
initEnumOptions() {
//

View File

@ -1,24 +1,65 @@
<template>
<span style="position: relative;display: inline-block;">
<i class="el-icon-arrow-down el-icon-delete" style="position: absolute;top: 6px;right: 24px;color: #878d9f;cursor: pointer;z-index: 1;" @click="removeItem" />
<el-dropdown trigger="click" size="mini" @command="clickItem">
<i
class="el-icon-arrow-down el-icon-delete"
style="position: absolute;top: 6px;right: 24px;color: #878d9f;cursor: pointer;z-index: 1;"
@click="removeItem"
/>
<el-dropdown
trigger="click"
size="mini"
@command="clickItem"
>
<span class="el-dropdown-link">
<el-tag size="small" class="item-axis" :type="tagType">
<el-tag
size="small"
class="item-axis"
:type="tagType"
>
<span style="float: left">
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
<svg-icon v-if="item.deType === 5" icon-class="field_location" class="field-icon-location" />
<svg-icon
v-if="item.deType === 0"
icon-class="field_text"
class="field-icon-text"
/>
<svg-icon
v-if="item.deType === 1"
icon-class="field_time"
class="field-icon-time"
/>
<svg-icon
v-if="item.deType === 2 || item.deType === 3"
icon-class="field_value"
class="field-icon-value"
/>
<svg-icon
v-if="item.deType === 5"
icon-class="field_location"
class="field-icon-location"
/>
</span>
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
<field-error-tips v-if="tagType === 'danger'" />
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
<span
class="item-span-style"
:title="item.name"
>{{ item.name }}</span>
<field-error-tips v-if="tagType === 'danger'"/>
<i
class="el-icon-arrow-down el-icon--right"
style="position: absolute;top: 6px;right: 10px;"
/>
</el-tag>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')">
<el-dropdown-item
icon="el-icon-files"
:command="beforeClickItem('filter')"
>
<span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" divided :command="beforeClickItem('remove')">
<el-dropdown-item
icon="el-icon-delete"
divided
:command="beforeClickItem('remove')"
>
<span>{{ $t('chart.delete') }}</span>
</el-dropdown-item>
</el-dropdown-menu>
@ -28,11 +69,12 @@
</template>
<script>
import { getItemType } from './utils'
import {getItemType} from './utils'
import FieldErrorTips from './FieldErrorTips'
export default {
name: 'FilterItem',
components: { FieldErrorTips },
components: {FieldErrorTips},
props: {
param: {
type: Object,
@ -53,25 +95,34 @@ export default {
quotaData: {
type: Array,
required: true
}
},
bus: {
type: Object,
required: false,
default: null
},
},
data() {
return {
tagType: 'success'
tagType: 'success'
}
},
watch: {
dimensionData: function() {
dimensionData: function () {
this.getItemTagType()
},
quotaData: function() {
quotaData: function () {
this.getItemTagType()
},
item: function() {
item: function () {
this.getItemTagType()
}
},
mounted() {
this.bus.$on('reset-change-table', this.getItemTagType)
},
beforeDestroy() {
this.bus.$off('reset-change-table', this.getItemTagType)
},
methods: {
clickItem(param) {
@ -110,45 +161,45 @@ export default {
</script>
<style scoped>
.item-axis {
padding: 1px 6px;
margin: 0 3px 2px 3px;
text-align: left;
height: 24px;
line-height: 22px;
display: flex;
border-radius: 4px;
box-sizing: border-box;
white-space: nowrap;
width: 159px;
}
.item-axis {
padding: 1px 6px;
margin: 0 3px 2px 3px;
text-align: left;
height: 24px;
line-height: 22px;
display: flex;
border-radius: 4px;
box-sizing: border-box;
white-space: nowrap;
width: 159px;
}
.item-axis:hover {
background-color: #fdfdfd;
cursor: pointer;
}
.item-axis:hover {
background-color: #fdfdfd;
cursor: pointer;
}
span {
font-size: 12px;
}
span {
font-size: 12px;
}
.summary-span{
margin-left: 4px;
color: #878d9f;;
}
.summary-span {
margin-left: 4px;
color: #878d9f;;
}
.inner-dropdown-menu{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%
}
.inner-dropdown-menu {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%
}
.item-span-style{
display: inline-block;
width: 100px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.item-span-style {
display: inline-block;
width: 115px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
</style>

View File

@ -9,18 +9,18 @@
@add="addXaxis" @update="calcData(true)">
<transition-group class="draggable-group">
<dimension-item v-for="(item,index) in view.xaxis" :key="index"
:param="param"
:index="0"
:item="item"
:dimension-data="dimension"
:quota-data="quotaData"
:chart="chart"
@onDimensionItemChange="dimensionItemChange"
@onDimensionItemRemove="dimensionItemRemove"
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
dimension-name="dimension"
:bus="bus"
:param="param"
:index="0"
:item="item"
:dimension-data="dimension"
:quota-data="quotaData"
:chart="chart"
@onDimensionItemChange="dimensionItemChange"
@onDimensionItemRemove="dimensionItemRemove"
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
dimension-name="dimension"
:bus="bus"
/>
</transition-group>
</draggable>
@ -84,7 +84,7 @@
@add="addCustomFilter" @update="calcData(true)">
<transition-group class="draggable-group">
<filter-item v-for="(item,index) in view.customFilter" :key="item.id" :param="param" :index="index"
:item="item" :dimension-data="dimension" :quota-data="quota"
:item="item" :dimension-data="dimension" :quota-data="quota" :bus="bus"
@onFilterItemRemove="filterItemRemove"
@editItemFilter="showEditFilter"/>
</transition-group>

View File

@ -1,24 +1,65 @@
<template>
<span style="position: relative;display: inline-block;">
<i class="el-icon-arrow-down el-icon-delete" style="position: absolute;top: 6px;right: 24px;color: #878d9f;cursor: pointer;z-index: 1;" @click="removeItem" />
<el-dropdown trigger="click" size="mini" @command="clickItem">
<i
class="el-icon-arrow-down el-icon-delete"
style="position: absolute;top: 6px;right: 24px;color: #878d9f;cursor: pointer;z-index: 1;"
@click="removeItem"
/>
<el-dropdown
trigger="click"
size="mini"
@command="clickItem"
>
<span class="el-dropdown-link">
<el-tag size="small" class="item-axis" :type="tagType">
<el-tag
size="small"
class="item-axis"
:type="tagType"
>
<span style="float: left">
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
<svg-icon v-if="item.deType === 5" icon-class="field_location" class="field-icon-location" />
<svg-icon
v-if="item.deType === 0"
icon-class="field_text"
class="field-icon-text"
/>
<svg-icon
v-if="item.deType === 1"
icon-class="field_time"
class="field-icon-time"
/>
<svg-icon
v-if="item.deType === 2 || item.deType === 3"
icon-class="field_value"
class="field-icon-value"
/>
<svg-icon
v-if="item.deType === 5"
icon-class="field_location"
class="field-icon-location"
/>
</span>
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
<field-error-tips v-if="tagType === 'danger'" />
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
<span
class="item-span-style"
:title="item.name"
>{{ item.name }}</span>
<field-error-tips v-if="tagType === 'danger'"/>
<i
class="el-icon-arrow-down el-icon--right"
style="position: absolute;top: 6px;right: 10px;"
/>
</el-tag>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')">
<el-dropdown-item
icon="el-icon-files"
:command="beforeClickItem('filter')"
>
<span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item>
<el-dropdown-item icon="el-icon-delete" divided :command="beforeClickItem('remove')">
<el-dropdown-item
icon="el-icon-delete"
divided
:command="beforeClickItem('remove')"
>
<span>{{ $t('chart.delete') }}</span>
</el-dropdown-item>
</el-dropdown-menu>
@ -28,11 +69,12 @@
</template>
<script>
import { getItemType } from './utils'
import {getItemType} from './utils'
import FieldErrorTips from './FieldErrorTips'
export default {
name: 'FilterItem',
components: { FieldErrorTips },
components: {FieldErrorTips},
props: {
param: {
type: Object,
@ -53,25 +95,34 @@ export default {
quotaData: {
type: Array,
required: true
}
},
bus: {
type: Object,
required: false,
default: null
},
},
data() {
return {
tagType: 'success'
tagType: 'success'
}
},
watch: {
dimensionData: function() {
dimensionData: function () {
this.getItemTagType()
},
quotaData: function() {
quotaData: function () {
this.getItemTagType()
},
item: function() {
item: function () {
this.getItemTagType()
}
},
mounted() {
this.bus.$on('reset-change-table', this.getItemTagType)
},
beforeDestroy() {
this.bus.$off('reset-change-table', this.getItemTagType)
},
methods: {
clickItem(param) {
@ -110,45 +161,45 @@ export default {
</script>
<style scoped>
.item-axis {
padding: 1px 6px;
margin: 0 3px 2px 3px;
text-align: left;
height: 24px;
line-height: 22px;
display: flex;
border-radius: 4px;
box-sizing: border-box;
white-space: nowrap;
width: 159px;
}
.item-axis {
padding: 1px 6px;
margin: 0 3px 2px 3px;
text-align: left;
height: 24px;
line-height: 22px;
display: flex;
border-radius: 4px;
box-sizing: border-box;
white-space: nowrap;
width: 159px;
}
.item-axis:hover {
background-color: #fdfdfd;
cursor: pointer;
}
.item-axis:hover {
background-color: #fdfdfd;
cursor: pointer;
}
span {
font-size: 12px;
}
span {
font-size: 12px;
}
.summary-span{
margin-left: 4px;
color: #878d9f;;
}
.summary-span {
margin-left: 4px;
color: #878d9f;;
}
.inner-dropdown-menu{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%
}
.inner-dropdown-menu {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%
}
.item-span-style{
display: inline-block;
width: 100px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.item-span-style {
display: inline-block;
width: 115px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
</style>

View File

@ -97,7 +97,7 @@
@add="addCustomFilter" @update="calcData(true)">
<transition-group class="draggable-group">
<filter-item v-for="(item,index) in view.customFilter" :key="item.id" :param="param" :index="index"
:item="item" :dimension-data="dimension" :quota-data="quota"
:item="item" :dimension-data="dimension" :quota-data="quota" :bus="bus"
@onFilterItemRemove="filterItemRemove"
@editItemFilter="showEditFilter"/>
</transition-group>