import BasicService from "./BasicService";

/**
 * @desc 全局服务
 */
class CalculateService extends BasicService {
  constructor() {
    super();
  }

  //获取人员确认列表信息
  getPCDataList = async ({ url, queryParams }: any) => {
    const { departmentIds = "", positionIds = "", subcompanyIds = "", statuses, ...extraParams } = queryParams || {};
    queryParams = {
      ...extraParams,
      departmentIds: departmentIds ? departmentIds.split(",") : undefined,
      positionIds: positionIds ? positionIds.split(",") : undefined,
      subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : undefined,
      statuses: statuses ? statuses.split(",") : []
    };
    for (let key in queryParams) {
      if (queryParams[key] === "" || queryParams[key] === "0") {
        delete queryParams[key];
      }
    }
    return this.post(
      url,
      queryParams
    );
  };
  //获取系统配置项
  getSysconfcode = async ({ code }: any) => {
    return this.get(`/api/bs/hrmsalary/sys/conf/code?code=${code}`);
  };
  //获取职级信息
  getRankInfo = async () => {
    return this.get(`/api/ais/tupu/getRankInfo`);
  };
  //获取社保福利台账-正常缴纳合计行数据
  siaccountDetailCommonListSum = async (data: any) => {
    return this.post(`/api/bs/hrmsalary/siaccount/detail/common/list/sum`, data);
  };
  //获取社保福利台账-正常缴纳合计行数据
  siaccountDetailSupplementaryListSum = async (data: any) => {
    return this.post(`/api/bs/hrmsalary/siaccount/detail/supplementary/list/sum`, data);
  };
  //获取社保福利台账-社保福利台账退差合计接口
  siaccountDetailRecessionListSum = async (data: any) => {
    return this.post(`/api/bs/hrmsalary/siaccount/detail/recession/list/sum`, data);
  };
  //获取社保福利台账-社保福利台账补差合计接口
  siaccountDetailBalanceListSum = async (data: any) => {
    return this.post(`/api/bs/hrmsalary/siaccount/detail/balance/list/sum`, data);
  };
  //工资单发放-查看详情页面列表合计行数据
  salaryBillSendSum = async (data: any) => {
    return this.post(`/api/bs/hrmsalary/salaryBill/send/sum`, data);
  };
  //合计行
  getAcctresultsum = async (params: any) => {
    const { departmentIds = "", positionIds = "", subcompanyIds = "", ...extraParams } = params || {};
    let queryParams = {
      ...extraParams,
      departmentIds: departmentIds ? departmentIds.split(",") : undefined,
      positionIds: positionIds ? positionIds.split(",") : undefined,
      subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : undefined
    };
    for (let key in queryParams) {
      if (queryParams[key] === "" || queryParams[key] === "0") {
        delete queryParams[key];
      }
    }
    return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, queryParams);
  };
  //合计行
  getAcctResultsum = async (url: string, params: any) => (this.post(url, params));
  //社保合计行
  getSyMixSum = async (params: any) => {
    return this.post(`/api/bs/hrmsalary/siaccount/detail/list/syMixSum`, params);
  };
  //薪资项目拓扑图
  getSalarysobItemTopology = async (params: any) => {
    return this.post(`/api/bs/hrmsalary/salarysob/item/topology`, params);
  };
}

const calculateService = new CalculateService();

export default calculateService;
