新功能:
1.部门显示组件
This commit is contained in:
30
web/src/stores/modules/dept.ts
Normal file
30
web/src/stores/modules/dept.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {request} from "/@/utils/service";
|
||||
import XEUtils from "xe-utils";
|
||||
import {toRaw} from 'vue'
|
||||
export const useDeptInfoStore = defineStore('deptInfo', {
|
||||
state:()=>(
|
||||
{
|
||||
list:[],
|
||||
tree:[],
|
||||
}
|
||||
),
|
||||
actions:{
|
||||
async requestDeptInfo() {
|
||||
// 请求部门信息
|
||||
const ret = await request({
|
||||
url: '/api/system/dept/all_dept/'
|
||||
})
|
||||
this.list = ret.data
|
||||
this.tree = XEUtils.toArrayTree(ret.data,{parentKey:'parent',strict:true})
|
||||
},
|
||||
async getDeptById(id:any){
|
||||
|
||||
},
|
||||
async getParentDeptById(id: any){
|
||||
const tree = toRaw(this.tree)
|
||||
const obj = XEUtils.findTree(tree, item => item.id == id)
|
||||
return obj
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user