import request from '@/config/axios';
import type { TableData } from './types';

/** 获取表格数据 */
export const getSrdbKxqRuleListApi = (data: any) => {
  return request.postJson({ url: '/srdb/spi/srdb/SrdbKxqRule/SrdbKxqRuleQueryPage', data });
};

/** 批量删除 */
export const delSrdbKxqRuleListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      ruleCode: v,
    };
  });
  return request.postJson({
    url: '/srdb/spi/srdb/SrdbKxqRule/SrdbKxqRuleBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delSrdbKxqRuleApi = (ruleCode: string | number): Promise<IResponse> => {
  return request.postJson({
    url: '/srdb/spi/srdb/SrdbKxqRule/SrdbKxqRuleDelete',
    data: { ruleCode },
  });
};

/** 保存 */
export const saveSrdbKxqRuleApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/srdb/spi/srdb/SrdbKxqRule/SrdbKxqRuleSave', data });
};

/** 查询单条数据 */
export const querySrdbKxqRuleApi = (ruleCode: string | number): Promise<IResponse> => {
  return request.postJson({
    url: '/srdb/spi/srdb/SrdbKxqRule/SrdbKxqRuleQueryOne',
    data: { ruleCode },
  });
};

/** 导入 */
export const importExcelApiUrl = '/srdb/sui/srdb/SrdbKxqRule/SrdbKxqRuleImpFileLoop';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/srdb/sdi/srdb/SrdbKxqRule/SrdbKxqRuleExportXls', params });
};
