/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-12-20 13:57:54
 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { Key } from 'react';
import { request } from 'umi';

//获取table列表数据

export type EquipTableDataType = {};

export const getStandItemList = (params?: any) => {
  return request<{
    current: number;
    list: EquipTableDataType[];
    pageSize: number;
    totalCount: number;
    totalPage: number;
  }>('/costAccount/setting/getStandItemList', {
    method: 'GET',
    params: { ...params },
  });
};
//获取康程分类
export const getKcClassDicData = () => {
  return request('/costAccount/setting/getKcClassDict', {
    method: 'GET',
  });
};

//获取会计科目
export const getCostAccountingDict = (params?: any) => {
  return request('/costAccount/setting/getCostAccountingDict', {
    method: 'GET',
    params: { ...params },
  });
};

//新增
export type AddTableDataType = {
  code: string;
  name: string;
  nationalCode: string;
  kcClassCode: string; //康程分类代码（小类）
  kcClassName: string; //康程分类名称
  kcClassPath: string; //康程分类路径
  executeTime: number; //执行时间（m）
  riskDegree: number;
  technicalDifficulty: number;
};

export const addData = (data: AddTableDataType) => {
  return request('/costAccount/setting/addStandItem', {
    method: 'POST',
    data,
  });
};

//导入数据
export const importDataPost = (data: any) => {
  return request('/costAccount/setting/importStandItem', {
    method: 'POST',
    data,
  });
};

//编辑表格数据

export type TableRowEditType = {
  id: number;
} & AddTableDataType;

export const editData = (data: any) => {
  return request('/costAccount/setting/editStandItem', {
    method: 'POST',
    data,
  });
};

//删除表格操作
export const delData = (id: string) => {
  return request('/costAccount/setting/deleteStandItem', {
    method: 'POST',
    params: { id },
  });
};

//获取对照人员列表
export const getStandItemEmpMap = (standCode: string) => {
  return request('/costAccount/setting/getStandItemEmpMap', {
    method: 'GET',
    params: { standCode },
  });
};

//获取对照设备列表
export const getStandItemEquipmentMap = (standCode: string) => {
  return request('/costAccount/setting/getStandItemEquipmentMap', {
    method: 'GET',
    params: { standCode },
  });
};

//获取对照空间列表
export const getStandItemSpaceMap = (standCode: string) => {
  return request('/costAccount/setting/getStandItemSpaceMap', {
    method: 'GET',
    params: { standCode },
  });
};

//添加抽屉表格数据

export const addDrawerTableData = (data: any, tabKey: number) => {
  let url: string = '';
  if (tabKey == 1) {
    url = '/costAccount/setting/addStandItemEmpMap';
  }
  if (tabKey == 2) {
    url = '/costAccount/setting/addStandItemEquipmentMap';
  }
  if (tabKey == 3) {
    url = '/costAccount/setting/addStandItemSpaceMap';
  }

  return request(url, {
    method: 'POST',
    data,
  });
};

//编辑抽屉表格数据

export const editDrawerTableData = (data: any, tabKey: number) => {
  let url: string = '';
  if (tabKey == 1) {
    url = '/costAccount/setting/editStandItemEmpMap';
  }
  if (tabKey == 2) {
    url = '/costAccount/setting/editStandItemEquipmentMap';
  }
  if (tabKey == 3) {
    url = '/costAccount/setting/editStandItemSpaceMap';
  }

  return request(url, {
    method: 'POST',
    data,
  });
};

//shanchu抽屉表格数据

export const delDrawerTableData = (id: Key, tabKey: number) => {
  let url: string = '';
  if (tabKey == 1) {
    url = '/costAccount/setting/deleteStandItemEmpMap';
  }
  if (tabKey == 2) {
    url = '/costAccount/setting/deleteStandItemEquipmentMap';
  }
  if (tabKey == 3) {
    url = '/costAccount/setting/deleteStandItemSpaceMap';
  }

  return request(url, {
    method: 'POST',
    params: { id },
  });
};
