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

feat: 数据源增加搜索功能

上级 3e0933d8
...@@ -2,19 +2,31 @@ ...@@ -2,19 +2,31 @@
<el-col style="padding: 0 5px 0 5px;"> <el-col style="padding: 0 5px 0 5px;">
<el-col> <el-col>
<el-row> <el-row>
<span class="header-title"> <span v-show="!showSearchInput" class="header-title">
{{ $t('commons.datasource') }} <div class="de-input" style="margin-top: 7px !important;">
<el-button style="float: right;padding-right: 7px;margin-top: -8px" icon="el-icon-plus" type="text" @click="addFolder" /> {{ $t('commons.datasource') }}
<el-button style="float: right;padding-right: 7px;margin-top: -8px" icon="el-icon-plus" type="text" @click="addFolder" />
<el-button style="float: right;padding-right: 15px;margin-top: -8px" icon="el-icon-search" type="text" @click="showSearchWidget" />
</div>
</span>
<span v-show="showSearchInput" class="header-title">
<div class="de-input" style="margin-top: 0px !important;margin-bottom: 12px !important">
<el-input v-model="key">
<el-button slot="append" icon="el-icon-close" @click="closeSearchWidget" />
</el-input>
</div>
</span> </span>
</el-row> </el-row>
<el-col class="custom-tree-container"> <el-col class="custom-tree-container">
<div class="block"> <div class="block">
<el-tree <el-tree
ref="panel_list_tree" ref="myDsTree"
:default-expanded-keys="expandedArray" :default-expanded-keys="expandedArray"
:data="tData" :data="tData"
node-key="id" node-key="id"
default-expand-all
:expand-on-click-node="true" :expand-on-click-node="true"
:filter-node-method="filterNode"
@node-click="nodeClick" @node-click="nodeClick"
> >
<span slot-scope="{ node, data }" class="custom-tree-node-list father"> <span slot-scope="{ node, data }" class="custom-tree-node-list father">
...@@ -74,13 +86,31 @@ export default { ...@@ -74,13 +86,31 @@ export default {
data() { data() {
return { return {
expandedArray: [], expandedArray: [],
tData: [] tData: [],
showSearchInput: false,
key: ''
}
},
watch: {
key(val) {
this.$refs.myDsTree.filter(val)
} }
}, },
mounted() { mounted() {
this.queryTreeDatas() this.queryTreeDatas()
}, },
methods: { methods: {
filterNode(value, data) {
if (!value) return true
return data.name.indexOf(value) !== -1
},
showSearchWidget() {
this.showSearchInput = true
},
closeSearchWidget() {
this.key = ''
this.showSearchInput = false
},
queryTreeDatas() { queryTreeDatas() {
listDatasource().then(res => { listDatasource().then(res => {
this.tData = this.buildTree(res.data) this.tData = this.buildTree(res.data)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论