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

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

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

/** 删除 */
export const delRepStoreApi = (modelCode?: string, beginDate?: string, endDate?: string, ruleId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepStore/spi/dataset/RepStore/RepStoreDelete', data: { modelCode, beginDate, endDate, ruleId } });
};

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

/** 查询单条数据 */
export const queryRepStoreApi = (modelCode?: string, beginDate?: string, endDate?: string, ruleId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepStore/spi/dataset/RepStore/RepStoreQueryOne', data: { modelCode, beginDate, endDate, ruleId } });
};

/** 同步导入 */
export const importExcelApiUrl = '/RepStore/sui/dataset/RepStore/RepStoreImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepStore/sui/dataset/RepStore/RepStoreImportAsyncExcel';

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

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

