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

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

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

/** 删除 */
export const delRepStoreParameterApi = (modelCode?: string, ruleId?: string, field?: string): Promise<IResponse> => {
  return request.postJson({ url: '/RepStoreParameter/spi/dataset/RepStoreParameter/RepStoreParameterDelete', data: { modelCode, ruleId, field } });
};

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

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

/** 同步导入 */
export const importExcelApiUrl = '/RepStoreParameter/sui/dataset/RepStoreParameter/RepStoreParameterImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/RepStoreParameter/sui/dataset/RepStoreParameter/RepStoreParameterImportAsyncExcel';

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

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

