import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsBillsLubeInstanceVO, DmsBillsLubeInstanceForm, DmsBillsLubeInstanceQuery } from '@/api/dms/dmsBillsLubeInstance/types';

/**
 * 查询润滑工单列表
 * @param query
 * @returns {*}
 */

export const listDmsBillsLubeInstance = (query?: DmsBillsLubeInstanceQuery): AxiosPromise<DmsBillsLubeInstanceVO[]> => {
  return request({
    url: '/dms/dmsBillsLubeInstance/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询润滑工单详细
 * @param lubeInstanceId
 */
export const getDmsBillsLubeInstance = (lubeInstanceId: string | number): AxiosPromise<DmsBillsLubeInstanceVO> => {
  return request({
    url: '/dms/dmsBillsLubeInstance/' + lubeInstanceId,
    method: 'get'
  });
};

/**
 * 新增润滑工单
 * @param data
 */
export const addDmsBillsLubeInstance = (data: DmsBillsLubeInstanceForm) => {
  return request({
    url: '/dms/dmsBillsLubeInstance',
    method: 'post',
    data: data
  });
};

/**
 * 修改润滑工单
 * @param data
 */
export const updateDmsBillsLubeInstance = (data: DmsBillsLubeInstanceForm) => {
  return request({
    url: '/dms/dmsBillsLubeInstance',
    method: 'put',
    data: data
  });
};

/**
 * 删除润滑工单
 * @param lubeInstanceId
 */
export const delDmsBillsLubeInstance = (lubeInstanceId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsBillsLubeInstance/' + lubeInstanceId,
    method: 'delete'
  });
};


/**
 * 下拉框查询润滑工单列表
 * @param query
 * @returns {*}
 */
export function getDmsBillsLubeInstanceList (query) {
    return request({
        url: '/dms/dmsBillsLubeInstance/getDmsBillsLubeInstanceList',
        method: 'get',
        params: query
    });
};

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