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

feat: 仪表板查询组件增加快速检索功能

上级 10544674
...@@ -13,8 +13,25 @@ ...@@ -13,8 +13,25 @@
</el-breadcrumb> </el-breadcrumb>
</div> </div>
<div class="component-result-content filter-common"> <div class="component-result-content filter-common">
<el-col>
<el-row>
<el-form>
<el-form-item class="my-form-item">
<el-input
v-model="keyWord"
size="mini"
:placeholder="$t('dataset.search')"
prefix-icon="el-icon-search"
clearable
/>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-tree <el-tree
v-if="showDomType === 'tree'" v-if="showDomType === 'tree'"
:default-expanded-keys="expandedArray"
node-key="id"
:data="datas" :data="datas"
:props="defaultProps" :props="defaultProps"
lazy lazy
...@@ -39,13 +56,15 @@ ...@@ -39,13 +56,15 @@
@start="start1" @start="start1"
> >
<transition-group> <transition-group>
<div v-for="item in fieldDatas" :key="item.id" class="filter-db-row"> <div v-for="item in fieldDatas.filter(item => !keyWord || (item.name && item.name.toLocaleLowerCase().includes(keyWord)))" :key="item.id" class="filter-db-row">
<i class="el-icon-s-data" /> <i class="el-icon-s-data" />
<span> {{ item.name }}</span> <span> {{ item.name }}</span>
</div> </div>
</transition-group> </transition-group>
</draggable> </draggable>
</div> </div>
</el-row>
</el-col>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :lazy="true" class="de-tab" :label="$t('panel.select_by_module')" name="assembly"> <el-tab-pane :lazy="true" class="de-tab" :label="$t('panel.select_by_module')" name="assembly">
...@@ -59,10 +78,26 @@ ...@@ -59,10 +78,26 @@
</div> </div>
<div class="component-result-content filter-common"> <div class="component-result-content filter-common">
<el-col>
<el-row>
<el-form>
<el-form-item class="my-form-item">
<el-input
v-model="viewKeyWord"
size="mini"
:placeholder="$t('dataset.search')"
prefix-icon="el-icon-search"
clearable
/>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-table <el-table
v-if="comShowDomType === 'view'" v-if="comShowDomType === 'view'"
class="de-filter-data-table" class="de-filter-data-table"
:data="viewInfos" :data="viewInfos.filter(item => !viewKeyWord || item.name.toLocaleLowerCase().includes(viewKeyWord))"
:show-header="false" :show-header="false"
size="mini" size="mini"
:highlight-current-row="true" :highlight-current-row="true"
...@@ -90,13 +125,15 @@ ...@@ -90,13 +125,15 @@
@start="start1" @start="start1"
> >
<transition-group> <transition-group>
<div v-for="item in comFieldDatas" :key="item.id" class="filter-db-row"> <div v-for="item in comFieldDatas.filter(item => !viewKeyWord || item.name.toLocaleLowerCase().includes(viewKeyWord))" :key="item.id" class="filter-db-row">
<i class="el-icon-s-data" /> <i class="el-icon-s-data" />
<span> {{ item.name }}</span> <span> {{ item.name }}</span>
</div> </div>
</transition-group> </transition-group>
</draggable> </draggable>
</div> </div>
</el-row>
</el-col>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -201,6 +238,7 @@ import { mapState } from 'vuex' ...@@ -201,6 +238,7 @@ import { mapState } from 'vuex'
// import { ApplicationContext } from '@/utils/ApplicationContext' // import { ApplicationContext } from '@/utils/ApplicationContext'
import { groupTree, fieldList, fieldValues, post } from '@/api/dataset/dataset' import { groupTree, fieldList, fieldValues, post } from '@/api/dataset/dataset'
import { viewsWithIds } from '@/api/panel/view' import { viewsWithIds } from '@/api/panel/view'
import { authModel } from '@/api/system/sysAuth'
export default { export default {
name: 'FilterDialog', name: 'FilterDialog',
components: { components: {
...@@ -259,7 +297,11 @@ export default { ...@@ -259,7 +297,11 @@ export default {
sort: 'type desc,name asc' sort: 'type desc,name asc'
}, },
isTreeSearch: false, isTreeSearch: false,
defaultDatas: [] defaultDatas: [],
keyWord: '',
timer: null,
expandedArray: [],
viewKeyWord: ''
} }
}, },
computed: { computed: {
...@@ -296,6 +338,18 @@ export default { ...@@ -296,6 +338,18 @@ export default {
this.componentInfo.options.attrs.fieldId = null this.componentInfo.options.attrs.fieldId = null
this.$emit('re-fresh-component', this.componentInfo) this.$emit('re-fresh-component', this.componentInfo)
} }
},
keyWord(val) {
this.expandedArray = []
if (this.showDomType === 'field') {
return
}
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(() => {
this.getTreeData(val)
}, (val && val !== '') ? 1000 : 0)
} }
}, },
created() { created() {
...@@ -310,7 +364,52 @@ export default { ...@@ -310,7 +364,52 @@ export default {
}, },
methods: { methods: {
getTreeData(val) {
if (val) {
this.isTreeSearch = true
this.searchTree(val)
} else {
this.isTreeSearch = false
this.treeNode(this.groupForm)
}
},
searchTree(val) {
this.expandedArray = []
const queryCondition = {
withExtend: 'parent',
modelType: 'dataset',
name: val
}
authModel(queryCondition).then(res => {
this.datas = this.buildTree(res.data)
})
},
buildTree(arrs) {
const idMapping = arrs.reduce((acc, el, i) => {
acc[el[this.defaultProps.id]] = i
return acc
}, {})
const roots = []
arrs.forEach(el => {
// 判断根节点 ###
el.type = el.modelInnerType
el.isLeaf = el.leaf
if (el[this.defaultProps.parentId] === null || el[this.defaultProps.parentId] === 0 || el[this.defaultProps.parentId] === '0') {
roots.push(el)
return
}
// 用映射表找到父元素
const parentEl = arrs[idMapping[el[this.defaultProps.parentId]]]
// 把当前元素添加到父元素的`children`数组中
parentEl.children = [...(parentEl.children || []), el]
// 设置展开节点 如果没有子节点则不进行展开
if (parentEl.children.length > 0) {
this.expandedArray.push(parentEl[this.defaultProps.id])
}
})
return roots
},
loadViews() { loadViews() {
const viewIds = this.componentData const viewIds = this.componentData
.filter(item => item.type === 'view' && item.propValue && item.propValue.viewId) .filter(item => item.type === 'view' && item.propValue && item.propValue.viewId)
...@@ -338,7 +437,7 @@ export default { ...@@ -338,7 +437,7 @@ export default {
} }
} }
} else { } else {
resolve(node.data.children) node.data.children && resolve(node.data.children)
} }
}, },
treeNode(group) { treeNode(group) {
...@@ -400,11 +499,15 @@ export default { ...@@ -400,11 +499,15 @@ export default {
this.removeTail(bread) this.removeTail(bread)
this.$nextTick(() => { this.$nextTick(() => {
this.expandedArray = []
this.keyWord = ''
this.isTreeSearch = false
this.datas = JSON.parse(JSON.stringify(this.defaultDatas)) this.datas = JSON.parse(JSON.stringify(this.defaultDatas))
}) })
}, },
comBackLink(bread) { comBackLink(bread) {
this.comShowDomType = 'view' this.comShowDomType = 'view'
this.viewKeyWord = ''
this.comRemoveTail() this.comRemoveTail()
}, },
// loadTable(sceneId) { // loadTable(sceneId) {
...@@ -435,12 +538,14 @@ export default { ...@@ -435,12 +538,14 @@ export default {
}) })
}, },
showFieldDatas(row) { showFieldDatas(row) {
this.keyWord = ''
this.showDomType = 'field' this.showDomType = 'field'
this.setTailLink(row) this.setTailLink(row)
this.addTail(row) this.addTail(row)
this.loadField(row.id) this.loadField(row.id)
}, },
comShowFieldDatas(row) { comShowFieldDatas(row) {
this.viewKeyWord = ''
this.comShowDomType = 'field' this.comShowDomType = 'field'
this.comSetTailLink(row) this.comSetTailLink(row)
this.comAddTail(row) this.comAddTail(row)
...@@ -511,6 +616,9 @@ export default { ...@@ -511,6 +616,9 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.my-form-item {
cursor: text;
}
.de-dialog-container { .de-dialog-container {
height: 50vh !important; height: 50vh !important;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论