forked from github/dataease
fix(仪表板): 带过滤器的模版过滤器无法切换数据集
This commit is contained in:
parent
32cbe7f1fa
commit
ad26aeea2c
@ -447,12 +447,13 @@ export default {
|
|||||||
this.currentElement = JSON.parse(JSON.stringify(this.element))
|
this.currentElement = JSON.parse(JSON.stringify(this.element))
|
||||||
this.myAttrs = this.currentElement.options.attrs
|
this.myAttrs = this.currentElement.options.attrs
|
||||||
this.treeNode(this.groupForm)
|
this.treeNode(this.groupForm)
|
||||||
|
this.loadViews()
|
||||||
if (this.myAttrs && this.myAttrs.dragItems) {
|
if (this.myAttrs && this.myAttrs.dragItems) {
|
||||||
this.enableSureButton()
|
this.enableSureButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initWithField()
|
this.initWithField()
|
||||||
this.loadViews()
|
|
||||||
this.ProhibitMultiple()
|
this.ProhibitMultiple()
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -462,7 +463,29 @@ export default {
|
|||||||
bus.$off('valid-values-change', this.validateFilterValue)
|
bus.$off('valid-values-change', this.validateFilterValue)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkSuperior(list) {
|
||||||
|
let fieldValid = false
|
||||||
|
const fieldId = this.myAttrs?.fieldId
|
||||||
|
if (fieldId && list?.length) {
|
||||||
|
const stack = [...list]
|
||||||
|
while (stack.length) {
|
||||||
|
const item = stack.pop()
|
||||||
|
if (item.id === fieldId) {
|
||||||
|
fieldValid = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (item.children?.length) {
|
||||||
|
item.children.forEach(kid => stack.push(kid))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!fieldValid) {
|
||||||
|
this.myAttrs.fieldId = null
|
||||||
|
this.myAttrs.dragItems = []
|
||||||
|
this.myAttrs.fieldsParent = null
|
||||||
|
}
|
||||||
|
return fieldValid
|
||||||
|
},
|
||||||
treeNode(cache) {
|
treeNode(cache) {
|
||||||
const modelInfo = localStorage.getItem('dataset-tree')
|
const modelInfo = localStorage.getItem('dataset-tree')
|
||||||
const userCache = (modelInfo && cache)
|
const userCache = (modelInfo && cache)
|
||||||
@ -471,6 +494,7 @@ export default {
|
|||||||
const results = this.buildTree(this.tData)
|
const results = this.buildTree(this.tData)
|
||||||
this.defaultData = JSON.parse(JSON.stringify(results))
|
this.defaultData = JSON.parse(JSON.stringify(results))
|
||||||
this.treeData = JSON.parse(JSON.stringify(results))
|
this.treeData = JSON.parse(JSON.stringify(results))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
queryAuthModel({ modelType: 'dataset' }, !userCache).then(res => {
|
queryAuthModel({ modelType: 'dataset' }, !userCache).then(res => {
|
||||||
localStorage.setItem('dataset-tree', JSON.stringify(res.data))
|
localStorage.setItem('dataset-tree', JSON.stringify(res.data))
|
||||||
@ -488,8 +512,8 @@ export default {
|
|||||||
if (this.myAttrs.fieldsParent) {
|
if (this.myAttrs.fieldsParent) {
|
||||||
this.fieldsParent = this.myAttrs.fieldsParent
|
this.fieldsParent = this.myAttrs.fieldsParent
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.activeName === 'dataset' && this.showFieldData(this.fieldsParent)
|
this.activeName === 'dataset' && this.showFieldData(this.fieldsParent, true)
|
||||||
this.activeName !== 'dataset' && this.comShowFieldData(this.fieldsParent)
|
this.activeName !== 'dataset' && this.comShowFieldData(this.fieldsParent, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,7 +716,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeTail(bread) {
|
removeTail(bread) {
|
||||||
if (!bread.id) {
|
if (!bread?.id) {
|
||||||
this.dataSetBreads = this.dataSetBreads.slice(0, 1)
|
this.dataSetBreads = this.dataSetBreads.slice(0, 1)
|
||||||
this.dataSetBreads[this.dataSetBreads.length - 1]['link'] = false
|
this.dataSetBreads[this.dataSetBreads.length - 1]['link'] = false
|
||||||
return
|
return
|
||||||
@ -718,7 +742,7 @@ export default {
|
|||||||
this.expandedArray = []
|
this.expandedArray = []
|
||||||
this.keyWord = ''
|
this.keyWord = ''
|
||||||
this.isTreeSearch = false
|
this.isTreeSearch = false
|
||||||
if (bread.id) {
|
if (bread?.id) {
|
||||||
const node = this.getNode(bread.id, this.treeData)
|
const node = this.getNode(bread.id, this.treeData)
|
||||||
if (node) {
|
if (node) {
|
||||||
this.tempTreeData = node.children
|
this.tempTreeData = node.children
|
||||||
@ -736,15 +760,17 @@ export default {
|
|||||||
this.comRemoveTail()
|
this.comRemoveTail()
|
||||||
},
|
},
|
||||||
|
|
||||||
loadField(tableId) {
|
async loadField(tableId, init) {
|
||||||
fieldListWithPermission(tableId).then(res => {
|
const res = await fieldListWithPermission(tableId)
|
||||||
let data = res.data
|
let data = res.data || []
|
||||||
if (this.widget && this.widget.filterFieldMethod) {
|
if (init && !this.checkSuperior(data)) {
|
||||||
data = this.widget.filterFieldMethod(data)
|
this.backToLink()
|
||||||
}
|
}
|
||||||
this.originFieldData = data
|
if (this.widget && this.widget.filterFieldMethod) {
|
||||||
this.fieldData = JSON.parse(JSON.stringify(data))
|
data = this.widget.filterFieldMethod(data)
|
||||||
})
|
}
|
||||||
|
this.originFieldData = data
|
||||||
|
this.fieldData = JSON.parse(JSON.stringify(data))
|
||||||
},
|
},
|
||||||
loadDatasetParams(tableId) {
|
loadDatasetParams(tableId) {
|
||||||
var type = 'TEXT'
|
var type = 'TEXT'
|
||||||
@ -758,22 +784,24 @@ export default {
|
|||||||
this.datasetParams = res.data || []
|
this.datasetParams = res.data || []
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
comLoadField(tableId) {
|
async comLoadField(tableId, init) {
|
||||||
fieldListWithPermission(tableId).then(res => {
|
const res = await fieldListWithPermission(tableId)
|
||||||
let data = res.data
|
let data = res.data || []
|
||||||
if (this.widget && this.widget.filterFieldMethod) {
|
if (init && !this.checkSuperior(data)) {
|
||||||
data = this.widget.filterFieldMethod(data)
|
this.comBackLink()
|
||||||
}
|
}
|
||||||
this.originComFieldData = data
|
if (this.widget && this.widget.filterFieldMethod) {
|
||||||
this.comFieldData = JSON.parse(JSON.stringify(data))
|
data = this.widget.filterFieldMethod(data)
|
||||||
})
|
}
|
||||||
|
this.originComFieldData = data
|
||||||
|
this.comFieldData = JSON.parse(JSON.stringify(data))
|
||||||
},
|
},
|
||||||
showFieldData(row) {
|
showFieldData(row, init) {
|
||||||
this.keyWord = ''
|
this.keyWord = ''
|
||||||
this.showDomType = 'field'
|
this.showDomType = 'field'
|
||||||
this.addQueue(row)
|
this.addQueue(row)
|
||||||
this.fieldsParent = row
|
this.fieldsParent = row
|
||||||
this.loadField(row.id)
|
this.loadField(row.id, init)
|
||||||
this.loadDatasetParams(row.id)
|
this.loadDatasetParams(row.id)
|
||||||
},
|
},
|
||||||
showNextGroup(row) {
|
showNextGroup(row) {
|
||||||
@ -782,13 +810,13 @@ export default {
|
|||||||
this.showDomType = 'tree'
|
this.showDomType = 'tree'
|
||||||
this.addQueue(row)
|
this.addQueue(row)
|
||||||
},
|
},
|
||||||
comShowFieldData(row) {
|
comShowFieldData(row, init) {
|
||||||
this.viewKeyWord = ''
|
this.viewKeyWord = ''
|
||||||
this.comShowDomType = 'field'
|
this.comShowDomType = 'field'
|
||||||
this.comSetTailLink(row)
|
this.comSetTailLink(row)
|
||||||
this.comAddTail(row)
|
this.comAddTail(row)
|
||||||
this.fieldsParent = row
|
this.fieldsParent = row
|
||||||
this.comLoadField(row.tableId)
|
this.comLoadField(row.tableId, init)
|
||||||
},
|
},
|
||||||
onMove(e, originalEvent) {
|
onMove(e, originalEvent) {
|
||||||
this.showTips = false
|
this.showTips = false
|
||||||
|
Loading…
Reference in New Issue
Block a user