import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderInfoVO, OrderInfoForm, OrderInfoQuery } from '@/api/mes/orderInfo/types';

/**
 * 查询生产订单信息列表
 * @param query
 * @returns {*}
 */

export const listOrderInfo = (query?: OrderInfoQuery): AxiosPromise<OrderInfoVO[]> => {
  return request({
    url: '/mes/orderInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询生产订单信息详细
 * @param productOrderId
 */
export const getOrderInfo = (productOrderId: string | number): AxiosPromise<OrderInfoVO> => {
  return request({
    url: '/mes/orderInfo/' + productOrderId,
    method: 'get'
  });
};

/**
 * 新增生产订单信息
 * @param data
 */
export const addOrderInfo = (data: OrderInfoForm) => {
  return request({
    url: '/mes/orderInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改生产订单信息
 * @param data
 */
export const updateOrderInfo = (data: OrderInfoForm) => {
  return request({
    url: '/mes/orderInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除生产订单信息
 * @param productOrderId
 */
export const delOrderInfo = (productOrderId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/orderInfo/' + productOrderId,
    method: 'delete'
  });
};


/**
 * 下拉框查询生产订单信息列表
 * @param query
 * @returns {*}
 */
export function getOrderInfoList(query) {
  return request({
    url: '/mes/orderInfo/getOrderInfoList',
    method: 'get',
    params: query
  });
};
