import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseWorkshopInfoVO, BaseWorkshopInfoForm, BaseWorkshopInfoQuery } from '@/api/mes/baseWorkshopInfo/types';

/**
 * 查询车间信息列表
 * @param query
 * @returns {*}
 */
export const listBaseWorkshopInfo = (query?: BaseWorkshopInfoQuery): AxiosPromise<BaseWorkshopInfoVO[]> => {
  return request({
    url: '/mes/baseWorkshopInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询车间信息详细
 * @param workshopId
 */
export const getBaseWorkshopInfo = (workshopId: string | number): AxiosPromise<BaseWorkshopInfoVO> => {
  return request({
    url: '/mes/baseWorkshopInfo/' + workshopId,
    method: 'get'
  });
};

/**
 * 新增车间信息
 * @param data
 */
export const addBaseWorkshopInfo = (data: BaseWorkshopInfoForm) => {
  return request({
    url: '/mes/baseWorkshopInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改车间信息
 * @param data
 */
export const updateBaseWorkshopInfo = (data: BaseWorkshopInfoForm) => {
  return request({
    url: '/mes/baseWorkshopInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除车间信息
 * @param workshopId
 */
export const delBaseWorkshopInfo = (workshopId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseWorkshopInfo/' + workshopId,
    method: 'delete'
  });
};

/**
 * 查询车间信息下拉框列表
 * @param query
 * @returns {*}
 */
export function getWorkshopList(query) {
  return request({
    url: '/mes/baseWorkshopInfo/getWorkshopList',
    method: 'get',
    params: query
  });
};
