import { addTreeitem, axios, delTreeitem, editTreeitem, getTreeselect, } from "@/request"; const request = axios.create({ baseURL: 'https://xj-mix3d.4dkankan.com/fusion-xj', timeout: 1000, headers: { share: 1, 'Content-Type': 'application/json' }, }); 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 request.get('/web/department/treeselect', { 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);