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

/** 获取表格数据 */
export const getRepSetRuleListApi = (data: any) => {
  return request.postJson({ url: '/RepSetRule/spi/dataset/RepSetRule/RepSetRuleQueryPage', data });
};

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

/** 删除 */
export const delRepSetRuleApi = (ruleCode?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepSetRule/spi/dataset/RepSetRule/RepSetRuleDelete', data: { ruleCode } });
};

/** 保存 */
export const saveRepSetRuleApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/RepSetRule/spi/dataset/RepSetRule/RepSetRuleSave', data });
};

/** 查询单条数据 */
export const queryRepSetRuleApi = (ruleCode?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepSetRule/spi/dataset/RepSetRule/RepSetRuleQueryOne', data: { ruleCode } });
};

/** 同步导入 */
export const importExcelApiUrl = '/RepSetRule/sui/dataset/RepSetRule/RepSetRuleImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepSetRule/sui/dataset/RepSetRule/RepSetRuleImportAsyncExcel';

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

/** 获取某个字典 */
export const getCsckCheckType = ({ paramName, systemCode }): Promise<IResponse> => {
  return request.postJson({
    url: '/param/spi/param/systemparam',
    data: {
      paramName: paramName,
      systemCode: systemCode,
    },
  });
};

