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

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

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

/** 删除 */
export const delLevelMaintainApi = (subNo?: string): Promise<IResponse> => {
  return request.postJson({ url: '/LevelMaintain/spi/LevelMaintain/LevelMaintain/LevelMaintainDelete', data: { subNo } });
};

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

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

/** 同步导入 */
export const importExcelApiUrl = '/LevelMaintain/sui/LevelMaintain/LevelMaintain/LevelMaintainImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/LevelMaintain/sui/LevelMaintain/LevelMaintain/LevelMaintainImportAsyncExcel';

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

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

