import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractsupplyVO, ContractsupplyForm, ContractsupplyQuery } from '@/api/supplier/contractsupply/types';

/**
 * 查询协议供货列表
 * @param query
 * @returns {*}
 */

export const listContractsupply = (query?: ContractsupplyQuery): AxiosPromise<ContractsupplyVO[]> => {
  return request({
    url: '/customer/contractsupply/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询协议供货详细
 * @param id
 */
export const getContractsupply = (id: string | number): AxiosPromise<ContractsupplyVO> => {
  return request({
    url: '/customer/contractsupply/' + id,
    method: 'get'
  });
};

/**
 * 新增协议供货
 * @param data
 */
export const addContractsupply = (data: ContractsupplyForm) => {
  return request({
    url: '/customer/contractsupply',
    method: 'post',
    data: data
  });
};

/**
 * 修改协议供货
 * @param data
 */
export const updateContractsupply = (data: ContractsupplyForm) => {
  return request({
    url: '/customer/contractsupply',
    method: 'put',
    data: data
  });
};

/**
 * 删除协议供货
 * @param id
 */
export const delContractsupply = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/contractsupply/' + id,
    method: 'delete'
  });
};

/**
 * 审核协议供货
 * @param data
 */
export const auditContractsupply = (data: { id: string | number; status: number }) => {
  return request({
    url: '/customer/contractsupply/edit',
    method: 'put',
    data: data
  });
};
