import request from '@/utils/request';
import type { EmsActionResponse, EmsDetailResponse, BaseWorkUnitVO, EmsId, EmsIdParam, EmsListResponse, EmsQuery, EmsTreeNode } from '../types';

// 查询统计单元信息列表
export function listBaseWorkUnit(query?: EmsQuery): Promise<EmsListResponse<BaseWorkUnitVO>> {
  return request({
    url: '/ems/base/baseWorkUnit/list',
    method: 'get',
    params: query
  });
}

// 查询统计单元信息详细
export function getBaseWorkUnit(objId: EmsId): Promise<EmsDetailResponse<BaseWorkUnitVO>> {
  return request({
    url: '/ems/base/baseWorkUnit/' + objId,
    method: 'get'
  });
}

// 新增统计单元信息
export function addBaseWorkUnit(data: BaseWorkUnitVO): Promise<EmsActionResponse<BaseWorkUnitVO>> {
  return request({
    url: '/ems/base/baseWorkUnit',
    method: 'post',
    data: data
  });
}

// 修改统计单元信息
export function updateBaseWorkUnit(data: BaseWorkUnitVO): Promise<EmsActionResponse<BaseWorkUnitVO>> {
  return request({
    url: '/ems/base/baseWorkUnit',
    method: 'put',
    data: data
  });
}

// 删除统计单元信息
export function delBaseWorkUnit(objId: EmsIdParam): Promise<EmsActionResponse> {
  return request({
    url: '/ems/base/baseWorkUnit/' + objId,
    method: 'delete'
  });
}

//查询统计单元信息信息下拉结构
export function getWorkUnitTrees(): Promise<EmsDetailResponse<EmsTreeNode[]>> {
  return request({
    url: '/ems/base/baseWorkUnit/workUnitTree',
    method: 'post'
  });
}
