import{be as t,bf as e,bg as i,bh as r,bi as s,bj as a,bk as n,bl as o,bm as h}from"./index-DL8B2Mxu.js";const l=t({id:" app-base",state:()=>({dictionaryList:[],organizeTree:[],departmentTree:[],positionTree:[],groupTree:[],roleTree:[],userTree:[],userList:[],relationData:{}}),getters:{getDictionaryList(){return this.dictionaryList},getRelationData(){return this.relationData}},actions:{setDictionaryList(t){this.dictionaryList=t||[]},setOrganizeTree(t){this.organizeTree=t},setDepartmentTree(t){this.departmentTree=t},setPositionTree(t){this.positionTree=t},setGroupTree(t){this.groupTree=t},setRoleTree(t){this.roleTree=t},setUserTree(t){this.userTree=t},setUserList(t){this.userList=t},updateRelationData(t){this.relationData=t},getDictionaryDataAll(){return new Promise(((t,i)=>{this.dictionaryList.length?t(this.dictionaryList):e().then((e=>{this.setDictionaryList(e.data.list),t(e.data.list)})).catch((t=>{i(t)}))}))},getDictionaryData(t){return new Promise((async e=>{let i=[],r=[],s=[];if(i=this.dictionaryList.length?this.dictionaryList:await this.getDictionaryDataAll(),t.sort)if(r=i.filter((e=>e.enCode===t.sort))[0],t.id){let e=[];if(r.isTree){const i=r=>{for(let s=0;s<r.length;s++){const a=r[s];if(a.id==t.id){e[0]=a;break}a.children&&a.children.length&&i(a.children)}};i(r.dictionaryList)}else e=r.dictionaryList.fliter((e=>e.id==t.id));s=e.length?e[0]:{id:"",fullName:""}}else s=(null==r?void 0:r.dictionaryList)||[];e(s)}))},getDicDataSelector(t,e="id"){return new Promise((async i=>{let r=[],s={},a=[];if(r=this.dictionaryList.length?this.dictionaryList:await this.getDictionaryDataAll(),!t)return i([]);let n=r.filter((i=>i[e]===t));if(!n.length)return i([]);s=n[0],a=s.dictionaryList,i(a)}))},getOrganizeTree(){return new Promise(((t,e)=>{this.organizeTree.length?t(this.organizeTree):i().then((e=>{this.setOrganizeTree(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getDepartmentTree(){return new Promise(((t,e)=>{this.departmentTree.length?t(this.departmentTree):r().then((e=>{this.setDepartmentTree(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getPositionTree(){return new Promise(((t,e)=>{this.positionTree.length?t(this.positionTree):s().then((e=>{this.setPositionTree(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getGroupTree(){return new Promise(((t,e)=>{this.groupTree.length?t(this.groupTree):a().then((e=>{this.setGroupTree(e.data),t(e.data)})).catch((t=>{e(t)}))}))},getRoleTree(){return new Promise(((t,e)=>{this.roleTree.length?t(this.roleTree):n().then((e=>{this.setRoleTree(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getUserTree(){return new Promise(((t,e)=>{this.userTree.length?t(this.userTree):o().then((e=>{this.setUserTree(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getUserList(){return new Promise(((t,e)=>{this.userList.length?t(this.userList):h().then((e=>{this.setUserList(e.data.list),t(e.data.list)})).catch((t=>{e(t)}))}))},getUserInfo(t){return new Promise((async e=>{let i=[];i=this.userList.length?this.userList:await this.getUserList(),e(i.filter((e=>e.id===t))[0]||{})}))}}});export{l as u};
