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

/** 获取表格数据 */
export const getRepDataProblemListApi = (data: any) => {
  return request.postJson({ url: '/RepDataProblem/spi/reporting/RepDataProblem/RepDataProblemQueryPage', data });
};

/** 批量删除 */
export const delRepDataProblemListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      pId: v.pId,
    };
  });
  return request.postJson({
    url: '/RepDataProblem/spi/reporting/RepDataProblem/RepDataProblemBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delRepDataProblemApi = (pId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepDataProblem/spi/reporting/RepDataProblem/RepDataProblemDelete', data: { pId } });
};

/** 保存 */
export const saveRepDataProblemApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.doImport({ url: '/RepDataProblem/spi/reporting/RepDataProblem/RepDataProblemSave', data });
};

/** 查询单条数据 */
export const queryRepDataProblemApi = (pId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepDataProblem/spi/reporting/RepDataProblem/RepDataProblemQueryOne', data: { pId } });
};

/** 同步导入 */
export const importExcelApiUrl = '/RepDataProblem/sui/reporting/RepDataProblem/RepDataProblemImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepDataProblem/sui/reporting/RepDataProblem/RepDataProblemImportAsyncExcel';

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

/** 生成WordBytes */
export const saveWordBytes = (tId?: string, organCode?: string, dataDate?: string) : Promise<IResponse> => {
  return request.postJson({ url: '/RepDataProblem/sdi/reporting/RepDataProblem/RepDataProblemSaveWordBytes', data:{tId,organCode,dataDate}});
};

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

