import cache from "@/utils/cache";

/**
 * 打印发票
 * @param {JSON} invoiceReqFlowNo 发票打印信息
 * @param {Number} invoiceType 发票类型
 */
function printInvoice(invoiceReqFlowNo, invoiceType) {
    let token = cache.getToken();
    return new Promise(function (resolve, reject) {
        if (invoiceReqFlowNo) {
            window.location.href = `PrintAssist://{"Type":"PrintInvoice","reqFlowNo":"${invoiceReqFlowNo}","InvoiceType":"${invoiceType}","Token":"${token}"}`
            resolve();
        } else {
            reject('发票打印信息无效！');
        }
    })
}

/**
 * 打印机页边距设置
 */
function printMargins() {
    window.location.href = `PrintAssist://{"Type":"set"}`;
}

export {
    printInvoice,
    printMargins,
}