import { config, networkUtils } from '../../utils';

const { request } = networkUtils;
const { api } = config;
const { rfq } = api;
const { inquiry } = rfq;

export async function query(params: object) {
  return request({
    url: inquiry,
    method: 'get',
    data: params,
  });
}

export async function getSingle(id: number) {
  return request({
    url: `${inquiry}/${id}`,
    method: 'get',
  });
}

export async function copy(id: number) {
  return request({
    url: `${inquiry}/copy/${id}`,
    method: 'get',
  });
}

export async function create(params: object) {
  return request({
    url: `${inquiry}/saveOrUpdate`,
    method: 'post',
    data: params,
  });
}

export async function remove(ids: number[]) {
  return request({
    url: `${inquiry}/del`,
    method: 'post',
    data: ids,
  });
}

export async function queryMaterial(params: object) {
  return request({
    url: `${inquiry}/item`,
    method: 'post',
    data: params,
  });
}
export async function querySupp(id: number) {
  return request({
    url: `${inquiry}/supp/${id}`,
    method: 'get',
  });
}
export async function queryOu(id: number) {
  return request({
    url: `${inquiry}/ou/${id}`,
    method: 'get',
  });
}


export async function querySuppItem(params: object) {
  return request({
    url: `${inquiry}/suppItem`,
    method: 'get',
    data: params,
  });
}

export async function update(params: object) {
  return request({
    url: `${inquiry}/approveStatus`,
    method: 'post',
    data: params,
  });
}

export async function queryPqItem(peId: number) {
  return request({
    url: `${inquiry}/${peId}/pqds`,
    method: 'get',
  });
}

export async function yjconfirm(peId: number) {
  return request({
    url: `${inquiry}/yjconfirm/${peId}`,
    method: 'post',
  });
}

export async function switchBargain(params: object) {
  return request({
    url: `${inquiry}/switchBargain`,
    method: 'post',
    data: params,
  });
}

export async function suppTaxRates(suppId: number) {
  return request({
    url: `${inquiry}/suppTaxRates/${suppId}`,
    method: 'get',
  });
}
