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

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

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

/** 删除 */
export const delRepStoreMappingApi = (modelCode?: string, ruleId?: string, srcCol?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepStoreMapping/spi/dataset/RepStoreMapping/RepStoreMappingDelete', data: { modelCode, ruleId, srcCol } });
};

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

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

/** 同步导入 */
export const importExcelApiUrl = '/RepStoreMapping/sui/dataset/RepStoreMapping/RepStoreMappingImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepStoreMapping/sui/dataset/RepStoreMapping/RepStoreMappingImportAsyncExcel';

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

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

