数通互联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

3 months ago
import { defineStore } from 'pinia'
import { ref} from 'vue';
import request from "@/utils/request";
import { id } from 'element-plus/es/locale';
3 months ago
export const useOrgMemberStore = defineStore('orgMember', () => {
interface OrgMemberItem {
id: string;
name: string;
child?:OrgMemberItem[];
3 months ago
}
3 months ago
const listMap = ref<Record<string, string>>({})
const dataTree = ref<OrgMemberItem>({ id: '', name: '', child: [] })
3 months ago
async function init() {
3 months ago
await request({
url: "/systemapi/app/get_org_everyone_people",//"172.20.2.87:39168",
3 months ago
method: "post",
data:{id:"313",all: 1}
3 months ago
}).then((response) => {
// assuming response.data is an array of OrgMemberItem
dataTree.value={id:"313",name:"集团公司",child:response.data}
handleChildren(response.data)
3 months ago
});
}
function handleChildren(childs:any[]){
childs.forEach(item => {
listMap.value[item.id] = item.name;
if(item.child){
handleChildren(item.child)
3 months ago
}
});
}
init()
return { listMap,dataTree }
})