fix(仪表板-下拉框过滤器): 拖入多个字段排序字段无法展示

This commit is contained in:
fit2cloud-chenyw 2022-08-31 13:11:22 +08:00
parent 765909db1d
commit 2ea8a41d75
2 changed files with 27 additions and 14 deletions

View File

@ -181,7 +181,7 @@
<de-main-container class="ms-main-container">
<div v-if="currentElement.options && currentElement.options.attrs">
<filter-head :element="currentElement" :table-fields-map="tableFieldsMap" :widget="widget" />
<filter-head :element="currentElement" :widget="widget" />
<filter-control :element="currentElement" :widget="widget" :control-attrs="myAttrs" :child-views="childViews" />
@ -297,7 +297,6 @@ export default {
datasetParams: []
},
currentElement: null,
tableFieldsMap: {},
tempTreeDatas: null,
showTips: false
}
@ -632,7 +631,6 @@ export default {
loadField(tableId) {
fieldListWithPermission(tableId).then(res => {
let datas = res.data
this.$set(this.tableFieldsMap, tableId, JSON.parse(JSON.stringify(datas)))
if (this.widget && this.widget.filterFieldMethod) {
datas = this.widget.filterFieldMethod(datas)
}
@ -643,7 +641,6 @@ export default {
comLoadField(tableId) {
fieldListWithPermission(tableId).then(res => {
let datas = res.data
this.$set(this.tableFieldsMap, tableId, JSON.parse(JSON.stringify(datas)))
if (this.widget && this.widget.filterFieldMethod) {
datas = this.widget.filterFieldMethod(datas)
}

View File

@ -18,7 +18,7 @@
>
<v-flex v-for="(item,index) in element.options.attrs.dragItems" :key="item.id">
<drag-item :key="item.id" :is-sort-widget="isSortWidget" :item="item" :index="index" :sort="element.options.attrs.sort" :all-fields="index ? [] : fieldsMap[item.tableId]" @closeItem="closeItem" @sort-change="sortChange" />
<drag-item :key="item.id" :is-sort-widget="isSortWidget" :item="item" :index="index" :sort="element.options.attrs.sort" :all-fields="index ? [] : tableFields" @closeItem="closeItem" @sort-change="sortChange" />
</v-flex>
<span solt="footer">{{ $t('panel.drag_here') }}</span>
@ -34,6 +34,8 @@
<script>
import draggable from 'vuedraggable'
import DragItem from '@/components/DragItem'
import { fieldListWithPermission } from '@/api/dataset/dataset'
export default {
name: 'FilterHead',
components: {
@ -45,10 +47,7 @@ export default {
type: Object,
default: () => {}
},
tableFieldsMap: {
type: Object,
default: () => {}
},
widget: {
type: Object,
default: null
@ -56,25 +55,42 @@ export default {
},
data() {
return {
targets: []
targets: [],
tableFields: []
}
},
computed: {
isSortWidget() {
return this.widget && this.widget.isSortWidget && this.widget.isSortWidget()
},
fieldsMap() {
return JSON.parse(JSON.stringify(this.tableFieldsMap))
firstTableId() {
if (!this.isSortWidget) return null
if (this.element.options.attrs.dragItems && this.element.options.attrs.dragItems.length) {
return this.element.options.attrs.dragItems[0].tableId
}
return null
}
},
watch: {
firstTableId(val, old) {
if (val !== old) {
this.loadFields()
}
}
},
created() {
if (this.isSortWidget && this.element.options.attrs.dragItems && this.element.options.attrs.dragItems.length) {
this.loadFields()
}
},
methods: {
loadFields() {
fieldListWithPermission(this.firstTableId).then(res => {
this.tableFields = JSON.parse(JSON.stringify(res.data))
})
},
onMove(e, originalEvent) {
return true
},