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

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

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

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

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

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

/** 同步导入 */
export const importExcelApiUrl = '/ModelOutPut/sui/ModelOutPut/ModelOutPut/ModelOutPutImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/ModelOutPut/sui/ModelOutPut/ModelOutPut/ModelOutPutImportAsyncExcel';

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

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

