import request from '@/utils/request';
import {download} from '@/utils/request';
import {AxiosPromise, AxiosResponse} from 'axios';
import {
    ProductTypeVo,
    ProductTypeQuery,
    SkuQueryVo, SkuVo, MakeOrderSkuDetailVO,  SsdSkuDetailVOList
} from '@/api/product/types';
import {AllBusinessVO} from "@/api/business/allBusiness/types";

/**
 * 查询产品类别列表
 * @param query
 * @returns {*}
 */

export const listProductType = (query?: ProductTypeQuery & PageQuery): AxiosPromise<{ records: ProductTypeVo[] }> => {
    return request({
        url: '/sku/get_product_type_list',
        method: 'post',
        data: query
    });
};

/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const querySkuVoList = (query?: SkuQueryVo & PageQuery): AxiosPromise< { records: SkuVo[], total: number } > => {
    return request({
        url: '/sku/list',
        method: 'post',
        data: query
    });
};


/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const getSkuConfig = (): AxiosPromise<{ data:any }> => {
    return request({
        url: '/sku/ssd_config',
        method: 'get',
    });
};


/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const ssdStep1GetSku = (data: MakeOrderSkuDetailVO) => {
    return request({
        url: '/sku/ssd_step_1_get_sku',
        method: 'POST',
        data: data
    });
};
/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const getPriceCNY = (data: MakeOrderSkuDetailVO) => {
    return request({
        url: '/quotation/getPriceCNY',
        method: 'POST',
        data: data
    });
};
/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const getPriceUSD = (data: MakeOrderSkuDetailVO) => {
    return request({
        url: '/quotation//getPriceUSD',
        method: 'POST',
        data: data
    });
};

/**
 * 查询sku列表
 * @param query
 * @returns {*}
 */

export const ssdStep1GetSkuList = (data: SsdSkuDetailVOList) => {
    return request({
        url: '/sku/ssd_step_1_get_sku_list',
        method: 'POST',
        data: data
    });
};
/**
 * 查询汇率
 * @param query
 * @returns {*}
 */

export const getUSDtoCnyRate = () => {
    return request({
        url: '/sku/get-rate',
        method: 'get',
    });
};


export const quotationAdd = (data: SsdSkuDetailVOList) => {
    return request({
        url: '/quotation/add',
        method: 'POST',
        data: data
    });
};

export const quotationEdite = (data: SsdSkuDetailVOList) => {
    return request({
        url: '/quotation/edit',
        method: 'POST',
        data: data
    });
};

export const getDetail = (params) => {
    return request({
        url: '/quotation/get-detail',
        method: 'get',
        params
    });
};


export const downLodaQuotation = (ssdSkuDetailVOList: SsdSkuDetailVOList, fileName) => {
    return download('/sku/dow-quotation-file',ssdSkuDetailVOList,fileName );
};


export const downLodaQuotationById = (params: any, fileName) => {
    return download('/quotation/dow-quotation-file', params,fileName );
};
// export const downLodaQuotationById = (businessId: string|number) => {
//     return request({
//         url: '/sku/dow-quotation-file',
//         method: 'post',
//         data:{businessId: businessId}
//     });
// };
//
