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

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

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

/** 删除 */
export const delCodeRepTargetApi = (crtid?: string): Promise<IResponse> => {
  return request.postJson({ url: '/CodeRepTarget/spi/dataset/CodeRepTarget/CodeRepTargetDelete', data: { crtid } });
};

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

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

/** 同步导入 */
export const importExcelApiUrl = '/CodeRepTarget/sui/dataset/CodeRepTarget/CodeRepTargetImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/CodeRepTarget/sui/dataset/CodeRepTarget/CodeRepTargetImportAsyncExcel';

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

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

