import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinancialConfigVO, FinancialConfigForm, FinancialConfigQuery } from '@/api/bfs/financialConfig/types';
import { RulesCodeMappingForm } from '@/api/financial/financialConfig/types';

/**
 * 查询清单配置列表
 * @param query
 * @returns {*}
 */

export const listFinancialConfig = (query?: FinancialConfigQuery): AxiosPromise<FinancialConfigVO[]> => {
  return request({
    url: '/bfs/financialConfigMain/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询清单配置详细
 * @param id
 */
export const getFinancialConfig = (id: string | number): AxiosPromise<FinancialConfigVO> => {
  return request({
    url: '/bfs/financialConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增清单配置
 * @param data
 */
export const addFinancialConfig = (data: FinancialConfigForm) => {
  return request({
    url: '/bfs/financialConfigMain/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改清单配置
 * @param data
 */
export const updateFinancialConfig = (data: FinancialConfigForm) => {
  return request({
    url: '/bfs/financialConfig/edit',
    method: 'post',
    data: data
  });
};

/**
 * 审核通过
 * @param data
 */
export const auditPass = (data: FinancialConfigForm) => {
  return request({
    url: '/bfs/financialConfig/auditPass',
    method: 'post',
    data: data
  });
};

/**
 * 审核不通过
 * @param data
 */
export const auditFail = (data: FinancialConfigForm) => {
  return request({
    url: '/bfs/financialConfig/auditFail',
    method: 'post',
    data: data
  });
};

/**
 * 删除清单配置
 * @param id
 */
export const delFinancialConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bfs/financialConfig/' + id,
    method: 'delete'
  });
};

/**
 * 查询清单配置列表
 * @param query
 * @returns {*}
 */

export const listRulesCodeMapping = (data: RulesCodeMappingForm) => {
  return request({
    url: '/bfs/financialConfig/ruleCode',
    method: 'post',
    data: data
  });
};

/**
 * 停用规则
 * @param data
 */
export const changeRuleStatus = (data: FinancialConfigVO) => {
  return request({
    url: '/bfs/financialConfig/changeStatus',
    method: 'post',
    data: data
  });
};
