|  |  |  | 
|---|
|  |  |  | default: false | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 需被排除的部门ID | 
|---|
|  |  |  | excludeId: {} | 
|---|
|  |  |  | excludeId: {}, | 
|---|
|  |  |  | topMenuId: {} | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | data () { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | watch: { | 
|---|
|  |  |  | excludeId () { | 
|---|
|  |  |  | this.fetchData() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | topMenuId () { | 
|---|
|  |  |  | this.fetchData() | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | fetchTree() | 
|---|
|  |  |  | .then(records => { | 
|---|
|  |  |  | this.data = [] | 
|---|
|  |  |  | this.__fillData(this.data, records) | 
|---|
|  |  |  | var res = []; | 
|---|
|  |  |  | if(this.topMenuId){ | 
|---|
|  |  |  | records.forEach(item => { | 
|---|
|  |  |  | if(item.id == this.topMenuId){ | 
|---|
|  |  |  | res = item.children | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | res = records | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.__fillData(this.data, res) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | .catch(e => { | 
|---|
|  |  |  | this.$tip.apiFailed(e) | 
|---|
|  |  |  | 
|---|
|  |  |  | // 填充菜单树 | 
|---|
|  |  |  | __fillData (list, pool) { | 
|---|
|  |  |  | for (const menu of pool) { | 
|---|
|  |  |  | if (menu.id === this.excludeId) { | 
|---|
|  |  |  | if (menu.id === this.excludeId || menu.linkType ===1) { | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const menuNode = { | 
|---|