import { addTreeitem, axios, delTreeitem, editTreeitem, getTreeselect, } from "@/request"; export enum DeptType { corps = 1, detachment = 2, brigade = 3, } export type Organization = { ancestors: string; children?: Organization[]; deptType: DeptType; id: string; leader: string; level: number; name: string; parentId: string; parentName: string; phone: string; remark: string; }; export const getOrganizationTree = async (type?: string) => (await axios.get(getTreeselect, { headers: { share: 1 }, params: { type, ingoreRes: true, share: 1, } })).data; export const addOrganization = async ( dept: Omit, deptIds: string[] ) => { await axios.post(addTreeitem, { superior: "sheq", ...dept, deptIdList: deptIds.join(","), }); }; export const setOrganization = async ( dept: Organization, deptIds: string[] ) => { await axios.post(editTreeitem, { superior: "sheq", ...dept, deptIdList: deptIds.join(","), }); }; export const delOrganization = async (deptId: string) => axios.post(delTreeitem + deptId);