新增本地USB打印
This commit is contained in:
@@ -82,7 +82,7 @@ function checkOrTryHttp() {
|
||||
try {
|
||||
var WSK1 = new WebSocket(URL_WS1);
|
||||
WSK1.onopen = function (e) {
|
||||
setTimeout("checkOrTryHttp()", 200);
|
||||
setTimeout(checkOrTryHttp(), 200);
|
||||
}
|
||||
WSK1.onmessage = function (e) {
|
||||
if (!window.getCLodop) eval(e.data);
|
||||
@@ -90,7 +90,7 @@ function checkOrTryHttp() {
|
||||
WSK1.onerror = function (e) {
|
||||
var WSK2 = new WebSocket(URL_WS2);
|
||||
WSK2.onopen = function (e) {
|
||||
setTimeout("checkOrTryHttp()", 200);
|
||||
setTimeout(checkOrTryHttp(), 200);
|
||||
}
|
||||
WSK2.onmessage = function (e) {
|
||||
if (!window.getCLodop) eval(e.data);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dayjs } from 'element-plus'
|
||||
import { ref, defineProps, defineExpose, defineEmits } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import _lodash from 'lodash'
|
||||
import getLodop from './LodopFuncs'
|
||||
const props = defineProps({
|
||||
@@ -59,7 +59,11 @@ const Printing = () => {
|
||||
<div style="width: 100%;font-size: 12px; margin-top:6px;">发票类型:${props.form.type}</div>
|
||||
<div style="width: 100%;font-size: 12px; margin-top:6px;">生成时间:${dayjs().format('YYYY-MM-DD HH:mm:ss')}</div>
|
||||
<div style="width: 100%;font-size: 12px; margin-top:6px;">*二维码有效期30天,超过自动失效!</div>
|
||||
<div style="width: 100%;font-size: 14px; margin-top: 15px;">您可以使用微信,扫码开票</div>`
|
||||
<div style="width: 100%;font-size: 14px; margin-top: 15px;">您可以使用微信,扫码开票</div>`,
|
||||
'150px',
|
||||
'5px',
|
||||
'100%',
|
||||
'100%',
|
||||
)
|
||||
LODOP.SET_LICENSES('', 'DCFF409304DFCEB3E2C644BF96CD0720', '', '')
|
||||
LODOP.PRINT()
|
||||
|
||||
83
src/components/lodop/receiptPrint.js
Normal file
83
src/components/lodop/receiptPrint.js
Normal file
@@ -0,0 +1,83 @@
|
||||
import getLodop from "./LodopFuncs.js";
|
||||
|
||||
export default (data) => {
|
||||
let LODOP = getLodop();
|
||||
LODOP.PRINT_INIT("打印小票");
|
||||
// 设置打印纸大小D
|
||||
LODOP.SET_PRINT_PAGESIZE(3, "58mm", 20, "");
|
||||
//设置默认打印机(这里用的是打印机名称)
|
||||
LODOP.SET_PRINTER_INDEX(data.deviceName);
|
||||
// 文字内容
|
||||
let html = `
|
||||
<div style="font-size: 30px;display:flex;justify-content:center;">
|
||||
${data.shop_name}
|
||||
</div>
|
||||
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
|
||||
预结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】
|
||||
</div>
|
||||
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
|
||||
${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""}
|
||||
</div>
|
||||
<div style="margin-top: 30px;font-size: 12px;">
|
||||
订单号:${data.orderInfo && data.orderInfo.orderNo}
|
||||
</div>
|
||||
<div style="margin-top: 4px;font-size: 12px;">
|
||||
交易时间:${data.createdAt}
|
||||
</div>
|
||||
<div style="margin-top: 4px;font-size: 12px;">
|
||||
收银员:${data.loginAccount}
|
||||
</div>
|
||||
<div style="margin-top: 6px;margin-bottom: 6px;border-bottom:1px dashed #000;"></div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:50%;">品名</td>
|
||||
<td style="font-size: 12px;width:16.66%;">单价</td>
|
||||
<td style="font-size: 12px;width:16.66%;">数量</td>
|
||||
<td style="font-size: 12px;width:16.66%;">小计</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
let table = "";
|
||||
for (let item of data.carts) {
|
||||
table += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:50%;">
|
||||
<div>${item.name}</div>
|
||||
<div class="sku">规格:${item.skuName || ""}</div>
|
||||
</td>
|
||||
<td style="font-size: 12px;width:16.66%;">${item.salePrice}</td>
|
||||
<td style="font-size: 12px;width:16.66%;">${item.number}</td>
|
||||
<td style="font-size: 12px;width:16.66%;">
|
||||
${item.totalAmount}
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
|
||||
let str = `
|
||||
</table>
|
||||
<div style="margin-top: 6px; border-bottom:1px dashed #000;"></div>
|
||||
<div style="margin-top: 6px; font-size: 22px;display:flex;justify-content: space-between;">
|
||||
<span>应收</span>
|
||||
<span>¥${data.amount}</span>
|
||||
</div>
|
||||
<div style="margin-top: 4px; font-size: 12px;">
|
||||
<span>余额:</span>
|
||||
<span>0.00</span>
|
||||
</div>
|
||||
<div style="margin-top: 6px; border-bottom:1px dashed #000;"></div>
|
||||
<div style="margin-top: 4px; font-size: 12px;">备注:${data.remark}</div>
|
||||
<div style="margin-top: 4px; padding-bottom: 50px;font-size: 12px;">
|
||||
打印时间:${data.printTime}
|
||||
</div>
|
||||
<div style="height: 50px;"></div>
|
||||
`;
|
||||
|
||||
let lastHtml = `${html}${table}${str}`;
|
||||
|
||||
setTimeout(() => {
|
||||
LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, lastHtml);
|
||||
LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", "");
|
||||
LODOP.PRINT();
|
||||
}, 800);
|
||||
};
|
||||
Reference in New Issue
Block a user