import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsBillsInspectInstanceVO, DmsBillsInspectInstanceForm, DmsBillsInspectInstanceQuery } from '@/api/dms/dmsBillsInspectInstance/types';

/**
 * 查询点巡检工单列表
 * @param query
 * @returns {*}
 */

export const listDmsBillsInspectInstance = (query?: DmsBillsInspectInstanceQuery): AxiosPromise<DmsBillsInspectInstanceVO[]> => {
  return request({
    url: '/dms/dmsBillsInspectInstance/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询点巡检工单详细
 * @param inspectInstanceId
 */
export const getDmsBillsInspectInstance = (inspectInstanceId: string | number): AxiosPromise<DmsBillsInspectInstanceVO> => {
  return request({
    url: '/dms/dmsBillsInspectInstance/' + inspectInstanceId,
    method: 'get'
  });
};

/**
 * 新增点巡检工单
 * @param data
 */
export const addDmsBillsInspectInstance = (data: DmsBillsInspectInstanceForm) => {
  return request({
    url: '/dms/dmsBillsInspectInstance',
    method: 'post',
    data: data
  });
};

/**
 * 修改点巡检工单
 * @param data
 */
export const updateDmsBillsInspectInstance = (data: DmsBillsInspectInstanceForm) => {
  return request({
    url: '/dms/dmsBillsInspectInstance',
    method: 'put',
    data: data
  });
};

/**
 * 删除点巡检工单
 * @param inspectInstanceId
 */
export const delDmsBillsInspectInstance = (inspectInstanceId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsBillsInspectInstance/' + inspectInstanceId,
    method: 'delete'
  });
};

/**
 * Get inspect instance count
 * @returns
 */
export const getInspectInstanceCount = (params: any): AxiosPromise<number> => {
  return request({
    url: '/dms/dmsBillsInspectInstance/count',
    method: 'get',
    params
  });
};


/**
 * 下拉框查询点巡检工单列表
 * @param query
 * @returns {*}
 */
export function getDmsBillsInspectInstanceList (query) {
    return request({
        url: '/dms/dmsBillsInspectInstance/getDmsBillsInspectInstanceList',
        method: 'get',
        params: query
    });
};

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

