import settings from '@/settings'
import request from '@/utils/request'
const systemPrefix = settings.systemPrefix

/**
 * 获取机构树
 * @param data 请求参数
 */
export function getDepartmentTree(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/getDepartmentTree`,
    method: 'post',
    requestType: 'json',
    data,
  })
}
export function ComDepartSobTreeController(param){
    return request({
        url: `${systemPrefix}/im/dhc/zz/automake/zzmanage/accounting_manager/generalAccount_manager/ComDepartSobTreeController.do`,
        data:{
            tree_type:param,
            isParentType:"&&",
            isAsync:"true",
            isUseSts:"false",
            searchFlag:"02",
            optType:'modify'
        },
        method:'post',
    })
}

/**
 * 查询下级机构
 * @param data 请求参数
 */
export function querySubDepartments(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/queryLowerDepartments`,
    method: 'post',
    requestType: 'json',
    data,
  })
}
/**机构新增*/
export function addDepartment(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/addDepartment`,
    method: 'post',
    requestType: 'json',
    data,
  })
}
/**
 * 机构修改
 * @param data
 * @returns
 */
export function updateDepartment(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/updateDepartment`,
    method: 'post',
    requestType: 'json',
    data,
  })
}
/**机构删除，同时会将该机构下所有正常状态的用户一并删除 */
export function deleteDepAndUser(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/deleteDepAndUser`,
    method: 'post',
    requestType: 'json',
    params:data,
  })
}
/**通过机构编号获取部门信息 */
export function getDepartmentByNo(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/getDepartmentByNo`,
    method: 'post',
    data,
  })
}
/**机构启用停用 */
export function changeUseSts(data) {
  return request({
    url: `${systemPrefix}/sys/deparment/changeUseSts`,
    method: 'post',
    data,
  })
}

/**机构恢复*/
export function restoreDep(params) {
  return request({
    url: `${systemPrefix}/sys/deparment/restoreDep`,
    method: 'post',
    params,
  })
}
