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

/** 获取表格数据 */
export const getCsckDataCheckResultListApi = (data: any) => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckResultQueryPage', data });
};

/** 批量删除 */
export const delCsckDataCheckResultListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      pkid: v,
    };
  });
  return request.postJson({
    url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckResultBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delCsckDataCheckResultApi = (pkid: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckResultDelete', data: { pkid } });
};

/** 保存 */
export const saveCsckDataCheckResultApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckResultSave', data });
};

/** 查询单条数据 */
export const queryCsckDataCheckResultApi = (pkid: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckResultQueryOne', data: { pkid } });
};

/** 导入 */
export const importExcelApiUrl = '/csck/sui/csck/CsckDataCheckResult/CsckDataCheckResultImportExcel';

/** 导出 */
export const exportExcelApi = (data: any) => {
  return request.doExport({ url: '/csck/sdi/csck/CsckDataCheckResult/CsckDataCheckResultExportXls', data });
};
/** 单独导出 */
export const exportAloneExcelApi = (data: any) => {
  return request.doExport({ url: '/csck/sdi/csck/CsckDataCheckResult/CsckDataCheckRuleDataExportXls', data });
};
export const checkAllRuleApi = (data: { orgCodes?: string; dataDate?: string; pkid?: string,createUser?: string;systemGroupCode?: string }): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataForRuleChecks', data });
};

export const batchCheckRuleApi = (data: { list: { orgCodes?: string; dataDate?: string; pkid?: string;systemGroupName?:string }[] }): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataForResultChecks', data });
};

/** 获取表格数据 */
export const getCsckDataCheckDataApi = (data: any): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataCheckResult/CsckDataCheckData', data });
};

export const csckDataRetrievalApi = (data: { dbList: { orgCode?: string; dataDate?: string; pkid?: string;systemGroupName?:string}[],createUser?: string } ): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckDataRetrieval/CsckDataRetrieval', data });
};
