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

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

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

/** 删除 */
export const delRepDataModelApi = (modelCode?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepDataModel/spi/dataset/RepDataModel/RepDataModelDelete', data: { modelCode } });
};

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

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

/** 同步导入 */
export const importExcelApiUrl = '/RepDataModel/sui/dataset/RepDataModel/RepDataModelImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepDataModel/sui/dataset/RepDataModel/RepDataModelImportAsyncExcel';

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

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

