import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsPlanRepairVO, DmsPlanRepairForm, DmsPlanRepairQuery } from '@/api/dms/dmsPlanRepair/types';

/**
 * 查询检修计划信息;人工创建计划，对超期未检修的报警列表
 * @param query
 * @returns {*}
 */

export const listDmsPlanRepair = (query?: DmsPlanRepairQuery): AxiosPromise<DmsPlanRepairVO[]> => {
  return request({
    url: '/dms/dmsPlanRepair/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询检修计划信息;人工创建计划，对超期未检修的报警详细
 * @param planRepairId
 */
export const getDmsPlanRepair = (planRepairId: string | number): AxiosPromise<DmsPlanRepairVO> => {
  return request({
    url: '/dms/dmsPlanRepair/' + planRepairId,
    method: 'get'
  });
};

/**
 * 新增检修计划信息;人工创建计划，对超期未检修的报警
 * @param data
 */
export const addDmsPlanRepair = (data: DmsPlanRepairForm) => {
  return request({
    url: '/dms/dmsPlanRepair',
    method: 'post',
    data: data
  });
};

/**
 * 修改检修计划信息;人工创建计划，对超期未检修的报警
 * @param data
 */
export const updateDmsPlanRepair = (data: DmsPlanRepairForm) => {
  return request({
    url: '/dms/dmsPlanRepair',
    method: 'put',
    data: data
  });
};

/**
 * 删除检修计划信息;人工创建计划，对超期未检修的报警
 * @param planRepairId
 */
export const delDmsPlanRepair = (planRepairId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsPlanRepair/' + planRepairId,
    method: 'delete'
  });
};


/**
 * 下拉框查询检修计划信息;人工创建计划，对超期未检修的报警列表
 * @param query
 * @returns {*}
 */
export function getDmsPlanRepairList (query) {
    return request({
        url: '/dms/dmsPlanRepair/getDmsPlanRepairList',
        method: 'get',
        params: query
    });
};
