import { get, post, parmasPost, put } from '@/http/index'

// 单位机构树列表
export const unitorganizationtree = async () => {
  return await get('/system/organization/treeSelect')
}

// 新增
export const newlyaddedlnterface = async (formData) => {
  return await post('/system/organization/addChild', formData)
}

// 根据树节点ID查询子级详细信息
export const queryChilddata = async (formData) => {
  return await post('/system/organization/queryChildById', formData)
}

// 查询所有子单位和部门信息
export const queryByCondition = async (query) => {
  let queryStr = 'pageNum=' + query.pageNum + '&pageSize=' + query.pageSize + '&unitName=' + query.unitName + '&childId=' + query.childId + '&childType=' + query.childType + ''
  return await get('/system/organization/likeQuery?' + queryStr)
}

// 单一删除和批量删除
export const deleteChildById = async (formData) => {
  return await post('/system/organization/deleteChildById', formData)
}

// 单一修改和批量修改子级状态-启用
export const bachUpdateChildStatusById = async (formData) => {
  return await post('/system/organization/bachEnable', formData)
}

// 单一修改和批量修改子级状态-禁用
export const disablebachUpdateChildStatusById = async (formData) => {
  return await post('/system/organization/batchDisable', formData)
}

// 移动的单位机构树列表
export const usertreeSelect = async () => {
  return await get('/system/organization/deptTreeSelect')
}

// 批量移动
export const batchMoveChildDeptByParentId = async (formData) => {
  return await post('/system/organization/batchMoveChildDeptByParentId', formData)
}

// 修改子单位或部门
export const updateChildById = async (formData) => {
  return await put('/system/organization/updateChildById', formData)
}

// 查询单位涉及的装备专业
export const queryUnitEquipmentProfession = async (unitId) => {
  return await get('/system/equipmentProfession/getSubordinateUnitEquipmentProfession/' + unitId)
}

// 修改装备专业与单位关联
export const updateEquipmentProfessionUnit = async (formData) => {
  return await post('/system/equipmentProfession/updateEquipmentProfessionUnit', formData)
}

// 下发
export const downFile = (userId) => {
  window.location.href = process.env.VUE_APP_BASE_API_target + `/org/orgSend?userId=${userId}`
}
