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

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

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

/** 删除 */
export const delFieldMaintenanceApi = (id?: string): Promise<IResponse> => {
  return request.postJson({ url: '/srdb/spi/srdb/FieldMaintenance/FieldMaintenanceDelete', data: { id } });
};

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

/** 查询单条数据 */
export const queryFieldMaintenanceApi = (id?: string): Promise<IResponse> => {
  return request.postJson({ url: '/srdb/spi/srdb/FieldMaintenance/FieldMaintenanceQueryOne', data: { id } });
};

/** 同步导入 */
export const importExcelApiUrl = '/srdb/sui/srdb/FieldMaintenance/FieldMaintenanceImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/srdb/sui/srdb/FieldMaintenance/FieldMaintenanceImportAsyncExcel';

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

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

