import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkSlipTypeVO, WorkSlipTypeForm, WorkSlipTypeQuery } from '@/api/order/workSlipType/types';

/**
 * 查询工单类型列表
 * @param query
 * @returns {*}
 */

export const listWorkSlipType = (query?: WorkSlipTypeQuery): AxiosPromise<WorkSlipTypeVO[]> => {
  return request({
    url: '/system/workSlipType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工单类型详细
 * @param id
 */
export const getWorkSlipType = (id: string | number): AxiosPromise<WorkSlipTypeVO> => {
  return request({
    url: '/system/workSlipType/' + id,
    method: 'get'
  });
};

/**
 * 新增工单类型
 * @param data
 */
export const addWorkSlipType = (data: WorkSlipTypeForm) => {
  return request({
    url: '/system/workSlipType',
    method: 'post',
    data: data
  });
};

/**
 * 修改工单类型
 * @param data
 */
export const updateWorkSlipType = (data: WorkSlipTypeForm) => {
  return request({
    url: '/system/workSlipType',
    method: 'put',
    data: data
  });
};

/**
 * 删除工单类型
 * @param id
 */
export const delWorkSlipType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/workSlipType/' + id,
    method: 'delete'
  });
};
export function changeStatus(id: string | number, isShow: string) {
  const data = {
    id,
    isShow
  };
  return request({
    url: '/system/workSlipType/changeStatus',
    method: 'put',
    data: data
  });
}
