import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PurchaseOrderItemVO, PurchaseOrderItemForm, PurchaseOrderItemQuery } from '@/api/amz/purchaseOrderItem/types';

/**
 * 查询供应商订单产品明细列表
 * @param query
 * @returns {*}
 */

export const listPurchaseOrderItem = (query?: PurchaseOrderItemQuery): AxiosPromise<PurchaseOrderItemVO[]> => {
  return request({
    url: '/amz/purchaseOrderItem/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商订单产品明细详细
 * @param id
 */
export const getPurchaseOrderItem = (id: string | number): AxiosPromise<PurchaseOrderItemVO> => {
  return request({
    url: '/amz/purchaseOrderItem/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商订单产品明细
 * @param data
 */
export const addPurchaseOrderItem = (data: PurchaseOrderItemForm) => {
  return request({
    url: '/amz/purchaseOrderItem',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商订单产品明细
 * @param data
 */
export const updatePurchaseOrderItem = (data: PurchaseOrderItemForm) => {
  return request({
    url: '/amz/purchaseOrderItem',
    method: 'put',
    data: data
  });
};

export const updateOrderItemDetail = (data: any) => {
  return request({
    url: '/amz/purchaseOrderItem',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商订单产品明细
 * @param id
 */
export const delPurchaseOrderItem = (id: string | number | Array<string | number>) => {
  return request({
    url: '/amz/purchaseOrderItem/' + id,
    method: 'delete'
  });
};
