import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsRepairInstanceActivityVO, DmsRepairInstanceActivityForm, DmsRepairInstanceActivityQuery } from '@/api/dms/dmsRepairInstanceActivity/types';

/**
 * 查询检修工单实例节点;最后一步作为检修记录列表
 * @param query
 * @returns {*}
 */

export const listDmsRepairInstanceActivity = (query?: DmsRepairInstanceActivityQuery): AxiosPromise<DmsRepairInstanceActivityVO[]> => {
  return request({
    url: '/dms/dmsRepairInstanceActivity/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询检修工单实例节点;最后一步作为检修记录详细
 * @param instanceActivityId
 */
export const getDmsRepairInstanceActivity = (instanceActivityId: string | number): AxiosPromise<DmsRepairInstanceActivityVO> => {
  return request({
    url: '/dms/dmsRepairInstanceActivity/' + instanceActivityId,
    method: 'get'
  });
};

/**
 * 新增检修工单实例节点;最后一步作为检修记录
 * @param data
 */
export const addDmsRepairInstanceActivity = (data: DmsRepairInstanceActivityForm) => {
  return request({
    url: '/dms/dmsRepairInstanceActivity',
    method: 'post',
    data: data
  });
};

/**
 * 修改检修工单实例节点;最后一步作为检修记录
 * @param data
 */
export const updateDmsRepairInstanceActivity = (data: DmsRepairInstanceActivityForm) => {
  return request({
    url: '/dms/dmsRepairInstanceActivity',
    method: 'put',
    data: data
  });
};

/**
 * 删除检修工单实例节点;最后一步作为检修记录
 * @param instanceActivityId
 */
export const delDmsRepairInstanceActivity = (instanceActivityId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsRepairInstanceActivity/' + instanceActivityId,
    method: 'delete'
  });
};


/**
 * 下拉框查询检修工单实例节点;最后一步作为检修记录列表
 * @param query
 * @returns {*}
 */
export function getDmsRepairInstanceActivityList (query) {
    return request({
        url: '/dms/dmsRepairInstanceActivity/getDmsRepairInstanceActivityList',
        method: 'get',
        params: query
    });
};
