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

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

/** 批量删除 */
export const delCsckModelDetailListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      systemCode,
      systemVersion,
      modelId: v,
    };
  });
  return request.postJson({
    url: '/csck/spi/csck/CsckModelDetail/CsckModelDetailBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delCsckModelDetailApi = (systemCode, systemVersion, modelId: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckModelDetail/CsckModelDetailDelete', data: { systemCode, systemVersion, modelId } });
};

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

/** 查询单条数据 */
export const queryCsckModelDetailApi = (systemCode, systemVersion, modelId: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/csck/spi/csck/CsckModelDetail/CsckModelDetailQueryOne', data: { systemCode, systemVersion, modelId } });
};

/** 导入 */
export const importExcelApiUrl = '/csck/sui/csck/CsckModelDetail/CsckModelDetailImportExcel';

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