import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsMaintInstanceActivityVO, DmsMaintInstanceActivityForm, DmsMaintInstanceActivityQuery } from '@/api/dms/dmsMaintInstanceActivity/types';

/**
 * 查询保养工单实例节点;弃用列表
 * @param query
 * @returns {*}
 */

export const listDmsMaintInstanceActivity = (query?: DmsMaintInstanceActivityQuery): AxiosPromise<DmsMaintInstanceActivityVO[]> => {
  return request({
    url: '/dms/dmsMaintInstanceActivity/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询保养工单实例节点;弃用详细
 * @param instanceActivityId
 */
export const getDmsMaintInstanceActivity = (instanceActivityId: string | number): AxiosPromise<DmsMaintInstanceActivityVO> => {
  return request({
    url: '/dms/dmsMaintInstanceActivity/' + instanceActivityId,
    method: 'get'
  });
};

/**
 * 新增保养工单实例节点;弃用
 * @param data
 */
export const addDmsMaintInstanceActivity = (data: DmsMaintInstanceActivityForm) => {
  return request({
    url: '/dms/dmsMaintInstanceActivity',
    method: 'post',
    data: data
  });
};

/**
 * 修改保养工单实例节点;弃用
 * @param data
 */
export const updateDmsMaintInstanceActivity = (data: DmsMaintInstanceActivityForm) => {
  return request({
    url: '/dms/dmsMaintInstanceActivity',
    method: 'put',
    data: data
  });
};

/**
 * 删除保养工单实例节点;弃用
 * @param instanceActivityId
 */
export const delDmsMaintInstanceActivity = (instanceActivityId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsMaintInstanceActivity/' + instanceActivityId,
    method: 'delete'
  });
};


/**
 * 下拉框查询保养工单实例节点;弃用列表
 * @param query
 * @returns {*}
 */
export function getDmsMaintInstanceActivityList (query) {
    return request({
        url: '/dms/dmsMaintInstanceActivity/getDmsMaintInstanceActivityList',
        method: 'get',
        params: query
    });
};

/**
 * 更新保养工单实例节点的工作流定义ID
 * @param maintInstanceId 保养工单实例的ID
 * @param wfDefinitionId 工作流定义的ID
 * @return 如果更新成功返回true，否则返回false
 */
export function updateWfDefinitionIdById (maintInstanceId: string | number, wfDefinitionId: string | number) {
  return request({
      url: '/dms/dmsMaintInstanceActivity/updateWfDefinitionIdById',
      method: 'post',
      params: {
          maintInstanceId,
          wfDefinitionId
      }
  });
};