import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductPlanDetailVO, ProductPlanDetailForm, ProductPlanDetailQuery } from '@/api/mes/productPlanDetail/types';

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

export const listProductPlanDetail = (query?: ProductPlanDetailQuery): AxiosPromise<ProductPlanDetailVO[]> => {
  return request({
    url: '/mes/productPlanDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询生产信息详细
 * @param planDetailId
 */
export const getProductPlanDetail = (planDetailId: string | number, workshopId: string | number): AxiosPromise<ProductPlanDetailVO> => {
  return request({
    url: '/mes/productPlanDetail/' + planDetailId + '/' + workshopId,
    method: 'get'
  });
};

/**
 * 新增生产信息
 * @param data
 */
export const addProductPlanDetail = (data: ProductPlanDetailForm) => {
  return request({
    url: '/mes/productPlanDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改生产信息
 * @param data
 */
export const updateProductPlanDetail = (data: ProductPlanDetailForm) => {
  return request({
    url: '/mes/productPlanDetail',
    method: 'put',
    data: data
  });
};

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


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