import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CrmQuoteMaterialVO, CrmQuoteMaterialForm, CrmQuoteMaterialQuery } from '@/api/oa/crm/crmQuoteMaterial/types';

/**
 * 查询报价单物料明细列表
 * @param query
 * @returns {*}
 */

export const listCrmQuoteMaterial = (query?: CrmQuoteMaterialQuery): AxiosPromise<CrmQuoteMaterialVO[]> => {
  return request({
    url: '/oa/crm/crmQuoteMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询报价单物料明细详细
 * @param quoteMaterialId
 */
export const getCrmQuoteMaterial = (quoteMaterialId: string | number): AxiosPromise<CrmQuoteMaterialVO> => {
  return request({
    url: '/oa/crm/crmQuoteMaterial/' + quoteMaterialId,
    method: 'get'
  });
};

/**
 * 新增报价单物料明细
 * @param data
 */
export const addCrmQuoteMaterial = (data: CrmQuoteMaterialForm) => {
  return request({
    url: '/oa/crm/crmQuoteMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改报价单物料明细
 * @param data
 */
export const updateCrmQuoteMaterial = (data: CrmQuoteMaterialForm) => {
  return request({
    url: '/oa/crm/crmQuoteMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除报价单物料明细
 * @param quoteMaterialId
 */
export const delCrmQuoteMaterial = (quoteMaterialId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/crmQuoteMaterial/' + quoteMaterialId,
    method: 'delete'
  });
};

/**
 * 下拉框查询报价单物料明细列表
 * @param query
 * @returns {*}
 */
export function getCrmQuoteMaterialList (query) {
    return request({
        url: '/oa/crm/crmQuoteMaterial/getCrmQuoteMaterialList',
        method: 'get',
        params: query
    });
};
