import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ErpDeptVO, ErpDeptForm, ErpDeptQuery } from '@/api/erpData/erpDept/types';

/**
 * 查询erp部门列表
 * @param query
 * @returns {*}
 */

export const listErpDept = (query?: ErpDeptQuery): AxiosPromise<ErpDeptVO[]> => {
  return request({
    url: '/system/erpDept/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询erp部门详细
 * @param deptId
 */
export const getErpDept = (deptId: string | number): AxiosPromise<ErpDeptVO> => {
  return request({
    url: '/system/erpDept/' + deptId,
    method: 'get'
  });
};

// 查询部门列表（排除节点）
export const listErpDeptExcludeChild = (deptId: string | number): AxiosPromise<ErpDeptVO[]> => {
  return request({
    url: '/system/erpDept/list/exclude/' + deptId,
    method: 'get'
  });
};

/**
 * 新增erp部门
 * @param data
 */
export const addErpDept = (data: ErpDeptForm) => {
  return request({
    url: '/system/erpDept',
    method: 'post',
    data: data
  });
};

/**
 * 修改erp部门
 * @param data
 */
export const updateErpDept = (data: ErpDeptForm) => {
  return request({
    url: '/system/erpDept',
    method: 'put',
    data: data
  });
};

/**
 * 删除erp部门
 * @param deptId
 */
export const delErpDept = (deptId: string | number | Array<string | number>) => {
  return request({
    url: '/system/erpDept/' + deptId,
    method: 'delete'
  });
};
