import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ArStepVO, ArStepForm, ArStepQuery } from '@/api/inspection/step/types';

/**
 * 查询巡检步骤列表
 * @param query
 * @returns {*}
 */
export const listArStep = (query?: ArStepQuery): AxiosPromise<ArStepVO[]> => {
  return request({
    url: '/inspection/step/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询任务的步骤树形结构
 * @param taskId
 * @returns {*}
 */
export const getArStepTree = (taskId: string | number): AxiosPromise<ArStepVO[]> => {
  return request({
    url: '/inspection/step/tree/' + taskId,
    method: 'get'
  });
};

/**
 * 查询巡检步骤详细
 * @param id
 */
export const getArStep = (id: string | number): AxiosPromise<ArStepVO> => {
  return request({
    url: '/inspection/step/' + id,
    method: 'get'
  });
};

/**
 * 新增巡检步骤
 * @param data
 */
export const addArStep = (data: ArStepForm) => {
  return request({
    url: '/inspection/step',
    method: 'post',
    data: data
  });
};

/**
 * 修改巡检步骤
 * @param data
 */
export const updateArStep = (data: ArStepForm) => {
  return request({
    url: '/inspection/step',
    method: 'put',
    data: data
  });
};

/**
 * 删除巡检步骤(级联删除子步骤)
 * @param id
 */
export const delArStep = (id: string | number | Array<string | number>) => {
  return request({
    url: '/inspection/step/' + id,
    method: 'delete'
  });
};
