Browse Source

搜索菜单默认展开第一层

V1.0
mk 3 years ago
parent
commit
2b9dda7e97
  1. 7
      src/views/modules/base/community/community.vue

7
src/views/modules/base/community/community.vue

@ -19,6 +19,7 @@
:filter-node-method="filterNode" :filter-node-method="filterNode"
@node-click="handleNodeClick" @node-click="handleNodeClick"
lazy lazy
:default-expanded-keys="autoOpenArr"
:load="lazyLoadTree"> :load="lazyLoadTree">
<span slot-scope="{ node, data }" <span slot-scope="{ node, data }"
@ -303,7 +304,6 @@ import { Loading } from 'element-ui' // 引入Loading服务
import nextTick from 'dai-js/tools/nextTick' import nextTick from 'dai-js/tools/nextTick'
import debounce from "lodash/debounce"; import debounce from "lodash/debounce";
import deepClone from "@/utils/deepClone.js"; import deepClone from "@/utils/deepClone.js";
let loading // let loading //
export default { export default {
data () { data () {
@ -322,6 +322,7 @@ export default {
return time.getTime() > nowData return time.getTime() > nowData
} }
return { return {
autoOpenArr:[],
boxHeight: true, boxHeight: true,
searchHeight: 190, searchHeight: 190,
filterText: '', filterText: '',
@ -538,15 +539,17 @@ export default {
this.startLoading() this.startLoading()
this.$refs.ref_tree.$data.store.lazy = !this.filterText this.$refs.ref_tree.$data.store.lazy = !this.filterText
if(this.filterText.length > 0 && this.filterText!=''){ if(this.filterText.length > 0 && this.filterText!=''){
const url = `/actual/base/communityBuilding/tree/search?keyword=${this.filterText}` const url = `/actual/base/communityBuilding/tree/search?keyword=${this.filterText}`
const {data,code,msg} = await requestGet(url) const {data,code,msg} = await requestGet(url)
if(data[0].children.length>0){ if(data[0].children.length>0){
this.treeData = data this.treeData = data
this.autoOpenArr.push(this.treeData[0].id);
}else{ }else{
this.treeData = [] this.treeData = []
setTimeout(() => { setTimeout(() => {
this.loadTree() this.loadTree()
}, 5) }, 5)
this.$message.error('暂未找到!') this.$message.error('暂未找到!')
} }
}else { }else {

Loading…
Cancel
Save