import { WeaTools } from "ecCom";
import { postExportFetch, postFetch } from "../util/request";

// 薪资项目-获取列表
export const getItemList = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/list", params);
};

//数据源列表字典项
export const formulaDatasourceList = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/formula/datasource/list", "GET", params);
};

//薪资项目-系统薪资项目列表
export const getSysItemList = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/sysList", params);
};

//薪资项目-批量删除薪资项目
export const deleteItem = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/delete", params);
};

//薪资项目-批量删除列表
export const deleteItemList = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/listCanDelete", params);
};

//薪资项目-新增薪资项目
export const saveItem = params => {
  delete params.formulaContent;
  return postFetch("/api/bs/hrmsalary/salaryitem/save", params);
};

//薪资项目-薪资项目详情
export const getItemForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryitem/getSalaryForm", "GET", params);
};

//薪资项目-添加系统薪资项目
export const saveSysItem = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/saveSys", params);
};

//获取公式描述
export const getFormulaDes = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/formula/des", "GET", params);
};

// 获取公式变量类型
export const formualSearchGroup = params => {
  return postFetch("/api/bs/hrmsalary/formula/search/group", params);
};

//获取公式变量字段
export const formualSearchField = params => {
  return postFetch("/api/bs/hrmsalary/formula/search/field", params);
};

// 保存公式
export const saveFormual = params => {
  return postFetch("/api/bs/hrmsalary/formula/save", params);
};
// 公式测试
export const testFormual = params => {
  return postFetch("/api/bs/hrmsalary/formula/mock", params);
};

// 根据id获取formual
export const detailFormual = params => {
  return postFetch("/api/bs/hrmsalary/formula/detail", params);
};

// 列出可以删除的薪资项目
export const listCanDelete = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/listCanDelete", params);
};

//获取哪些账套中使用了该薪资项目
export const getSalarySobBySalaryItem = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryitem/getSalarySobBySalaryItem", "GET", params);
};
// 同步到薪资账套
export const syncSalaryItemToSalarySobItem = params => {
  return postFetch("/api/bs/hrmsalary/salaryitem/syncSalaryItemToSalarySobItem", params);
};

// 导出薪资项目
export const exportSalaryitem = (params) => {
  return postExportFetch("/api/bs/hrmsalary/salaryitem/export", params);
};
// 下载模板
export const downloadTemplate = (params) => {
  return postExportFetch("/api/bs/hrmsalary/salaryitem/downloadTemplate", params);
};

// 导入薪资项目
export const importSalaryitem = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryitem/import", params);
};


