|
@@ -1,32 +1,47 @@
|
|
|
<template>
|
|
|
<div class="print">
|
|
|
- <!-- <div @click="pringPdf">打印测试</div> -->
|
|
|
<div id="form1">
|
|
|
<div style="font-size: 20px;font-weight: bold;text-align: center;">#{{printInfo.daySeq}}{{printInfo.orderSource}}</div>
|
|
|
- <div style="font-size: 18px;text-align: center;margin:10px 0;">{{printInfo.shopName}}</div>
|
|
|
- <div style="font-size: 18px;font-weight: bold;text-align: center;">{{printInfo.deliveryTime}}</div>
|
|
|
- <div>------------------------------------</div>
|
|
|
+ <div v-if="orderType === 2" style="font-size: 20px;font-weight: bold;text-align: center;">取消单</div>
|
|
|
+ <div style="font-size: 12px;text-align: center;margin:5px 0;">{{printInfo.shopName}}</div>
|
|
|
+ <div style="font-size: 16px;font-weight: bold;text-align: center;">{{printInfo.deliveryTime === '0' ? '立即送达' : '期望' + printInfo.deliveryTime}}</div>
|
|
|
+ <div v-if="pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
<div style="font-size: 13px;margin-bottom:5px;">下单时间:{{printInfo.createTime}}</div>
|
|
|
<div style="font-size: 13px;">订单编号:{{printInfo.outOrderId}}</div>
|
|
|
- <div>----------------商品--------------</div>
|
|
|
+ <div v-if="pageWidth === 1" style="text-align: center;">---------------商品-------------</div>
|
|
|
+ <div v-if="pageWidth === 2" style="text-align: center;">------------------商品----------------</div>
|
|
|
<div style="font-size: 18px; display: flex;flex-wrap:wrap;justify-content:space-between;" v-for="(v,i) in printInfo.orderGoodsDtoList" :key="i">
|
|
|
<div>{{v.foodName}}</div>
|
|
|
<div style="width:100%;text-align:right"><span style="margin-right:20px;">x{{v.quantity}}</span><span>{{v.price}}</span></div>
|
|
|
</div>
|
|
|
- <div v-if="printInfo.taxpayerId || printInfo.invoiceTitle" style="margin-top: 5px;">----------------发票--------------</div>
|
|
|
- <div v-if="printInfo.invoiceTitle" style="font-size: 13px;">抬头: {{printInfo.invoiceTitle}}</div>
|
|
|
- <div v-if="printInfo.taxpayerId" style="font-size: 13px;">税号: {{printInfo.taxpayerId}}</div>
|
|
|
- <div>------------------------------------</div>
|
|
|
- <div style="font-size: 13px;display:flex;justify-content: space-between;"><span>配送费:</span><span>{{Number(printInfo.deliverFee)}}元</span></div>
|
|
|
- <div>------------------------------------</div>
|
|
|
- <div style="font-size: 13px;display:flex;justify-content: space-between;"><span>原价:</span><span>{{printInfo.originalPrice}}元</span></div>
|
|
|
- <div>------------------------------------</div>
|
|
|
- <div style="font-size: 20px;font-weight:bold;display:flex;justify-content: space-between;"><span>实付:</span><span>{{printInfo.totalPrice}}元</span></div>
|
|
|
- <div>------------------------------------</div>
|
|
|
+ <div v-if="(printInfo.taxpayerId || printInfo.invoiceTitle) && num !== 3 && pageWidth === 1" style="margin-top: 5px; text-align: center;">---------------发票-------------</div>
|
|
|
+ <div v-if="(printInfo.taxpayerId || printInfo.invoiceTitle) && num !== 3 && pageWidth === 2" style="margin-top: 5px; text-align: center;">------------------发票----------------</div>
|
|
|
+ <div v-if="printInfo.invoiceTitle && num !== 3" style="font-size: 13px;">抬头: {{printInfo.invoiceTitle}}</div>
|
|
|
+ <div v-if="printInfo.taxpayerId && num !== 3" style="font-size: 13px;">税号: {{printInfo.taxpayerId}}</div>
|
|
|
+ <div v-if="printInfo.caution && num !== 3 && pageWidth === 1" style="margin-top: 5px;text-align: center;">---------------备注-------------</div>
|
|
|
+ <div v-if="printInfo.caution && num !== 3 && pageWidth === 2" style="margin-top: 5px;text-align: center;">------------------备注----------------</div>
|
|
|
+ <div v-if="printInfo.caution && num !== 3" style="font-size: 20px;font-weight: bold;">{{printInfo.caution}}</div>
|
|
|
+ <div v-if="printInfo.caution && num === 3 && pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="printInfo.caution && num === 3 && pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
+ <div v-if="printInfo.caution && num === 3" style="font-size: 20px;font-weight: bold;">备注: {{printInfo.caution}}</div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 12px;display:flex;justify-content: space-between;"><span>配送费:</span><span>{{Number(printInfo.deliverFee)}}元</span></div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 12px;display:flex;justify-content: space-between;"><span>餐盒费:</span><span>{{Number(printInfo.boxFee)}}元</span></div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 12px;display:flex;justify-content: space-between;"><span>原价:</span><span>{{printInfo.originalPrice}}元</span></div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="num !== 3 && pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 20px;font-weight:bold;display:flex;justify-content: space-between;"><span>实付:</span><span>{{printInfo.totalPrice}}元</span></div>
|
|
|
+ <div v-if="pageWidth === 1" style="text-align: center;">------------------------------------</div>
|
|
|
+ <div v-if="pageWidth === 2" style="text-align: center;">----------------------------------------</div>
|
|
|
<div style="font-size: 20px;font-weight: bold;">地址: {{printInfo.recipientAddress}}</div>
|
|
|
- <div style="font-size: 13px;">{{printInfo.recipientName}}</div>
|
|
|
- <div style="font-size: 14px;">{{printInfo.recipientPhone}}</div>
|
|
|
- <div>----------------#{{printInfo.daySeq}}完--------------</div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 13px;">{{printInfo.recipientName}}</div>
|
|
|
+ <div v-if="num !== 3" style="font-size: 14px;">{{printInfo.recipientPhone}}</div>
|
|
|
+ <div v-if="pageWidth === 1" style="text-align: center;">---------------#{{printInfo.daySeq}}完-------------</div>
|
|
|
+ <div v-if="pageWidth === 2" style="text-align: center;">------------------#{{printInfo.daySeq}}完----------------</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -35,12 +50,13 @@
|
|
|
import { getLodop } from "./LodopFuncs.js";
|
|
|
export default {
|
|
|
name: "UsbAutoPrint",
|
|
|
- props: { printNum: Number, printData: Object },
|
|
|
+ // orderType: 1, // 1是新订单2是取消单
|
|
|
+ props: { printNum: Number, printData: Object, orderType: Number },
|
|
|
data() {
|
|
|
return {
|
|
|
printInfo: {},
|
|
|
- orderType: 1, // 1是新订单2是取消单
|
|
|
num: 1,
|
|
|
+ pageWidth: 1, //1是57mm、2是80mm
|
|
|
};
|
|
|
},
|
|
|
// 监听属性 类似于data概念
|
|
@@ -66,14 +82,14 @@ export default {
|
|
|
methods: {
|
|
|
pringPdf() {
|
|
|
let len = this.printInfo.orderSource.length;
|
|
|
- if (this.num === 1) {
|
|
|
+ if (this.num === 1 && this.orderType === 1) {
|
|
|
this.printInfo.orderSource = this.printInfo.orderSource + "(顾客联)";
|
|
|
}
|
|
|
- if (this.num === 2) {
|
|
|
+ if (this.num === 2 && this.orderType === 1) {
|
|
|
this.printInfo.orderSource =
|
|
|
this.printInfo.orderSource.slice(0, len - 5) + "(商家联)";
|
|
|
}
|
|
|
- if (this.num === 3) {
|
|
|
+ if (this.num === 3 && this.orderType === 1) {
|
|
|
this.printInfo.orderSource =
|
|
|
this.printInfo.orderSource.slice(0, len - 5) + "(厨房联)";
|
|
|
}
|
|
@@ -92,14 +108,26 @@ export default {
|
|
|
//设置打印份数是1份
|
|
|
LODOP.SET_PRINT_COPIES(1);
|
|
|
// 参数含义 http://www.c-lodop.com/demolist/PrintSample5.html
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3, 570, 100, "");
|
|
|
- LODOP.ADD_PRINT_HTM(
|
|
|
- 40,
|
|
|
- 0,
|
|
|
- "53mm",
|
|
|
- "100%",
|
|
|
- document.getElementById("form1").innerHTML
|
|
|
- );
|
|
|
+ if (this.pageWidth === 1) {
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, 570, 100, "");
|
|
|
+ LODOP.ADD_PRINT_HTM(
|
|
|
+ 40,
|
|
|
+ 10,
|
|
|
+ "51mm",
|
|
|
+ "100%",
|
|
|
+ document.getElementById(`form1`).innerHTML
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (this.pageWidth === 2) {
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3, 800, 100, "");
|
|
|
+ LODOP.ADD_PRINT_HTM(
|
|
|
+ 40,
|
|
|
+ 80,
|
|
|
+ "60mm",
|
|
|
+ "100%",
|
|
|
+ document.getElementById(`form1`).innerHTML
|
|
|
+ );
|
|
|
+ }
|
|
|
LODOP.SET_PRINT_STYLEA(0, "Horient", 2);
|
|
|
LODOP.PRINT();
|
|
|
// 新订单未打印完三联,继续打印
|