|
@@ -2,31 +2,31 @@
|
|
|
<div class="print">
|
|
|
<!-- <div @click="pringPdf">打印测试</div> -->
|
|
|
<div id="form1">
|
|
|
- <div style="font-size: 24px;font-weight: bold;text-align: center;">#{{printData.daySeq}}{{printData.orderSource}}</div>
|
|
|
- <!-- <div style="font-size: 18px;text-align: center;margin:10px 0;">{{printData.shopName}}</div>
|
|
|
- <div style="font-size: 18px;font-weight: bold;">期望09月15日 18:45送达</div>
|
|
|
+ <div style="font-size: 22px;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 style="font-size: 13px;margin-bottom:5px;">下单时间:{{printData.createTime}}</div>
|
|
|
- <div style="font-size: 13px;">订单编号:{{printData.outOrderId}}</div>
|
|
|
+ <div style="font-size: 13px;margin-bottom:5px;">下单时间:{{printInfo.createTime}}</div>
|
|
|
+ <div style="font-size: 13px;">订单编号:{{printInfo.outOrderId}}</div>
|
|
|
<div>----------------商品--------------</div>
|
|
|
- <div style="font-size: 20px; display: flex;flex-wrap:wrap;justify-content:space-between;" v-for="(v,i) in printData.orderGoodsDtoList" :key="i">
|
|
|
+ <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="printData.taxpayerId || printData.invoiceTitle" style="margin-top: 5px;">----------------发票--------------</div>
|
|
|
- <div v-if="printData.invoiceTitle" style="font-size: 13px;">抬头: {{printData.invoiceTitle}}</div>
|
|
|
- <div v-if="printData.taxpayerId" style="font-size: 13px;">税号: {{printData.taxpayerId}}</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(printData.deliverFee)}}元</span></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>{{printData.originalPrice}}元</span></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: 18px;font-weight:bold;display:flex;justify-content: space-between;"><span>实付:</span><span>{{printData.totalPrice}}元</span></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 style="font-size: 18px;font-weight: bold;">地址: {{printData.recipientAddress}}</div>
|
|
|
- <div style="font-size: 13px;">{{printData.recipientName}}</div>
|
|
|
- <div style="font-size: 14px;">{{printData.recipientPhone}}</div> -->
|
|
|
- <div>----------------#{{printData.daySeq}}完--------------</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>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -37,29 +37,52 @@ export default {
|
|
|
name: "UsbAutoPrint",
|
|
|
props: { printNum: Number, printData: Object },
|
|
|
data() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ printInfo: {},
|
|
|
+ orderType: 1, // 1是新订单2是取消单
|
|
|
+ num: 1,
|
|
|
+ };
|
|
|
},
|
|
|
// 监听属性 类似于data概念
|
|
|
computed: {},
|
|
|
// 监控data中的数据变化
|
|
|
- watch: {},
|
|
|
+ watch: {
|
|
|
+ printNum: {
|
|
|
+ handler(newVal, oldVal) {
|
|
|
+ console.log(newVal, this.printData);
|
|
|
+ if (JSON.stringify(this.printData) !== "{}") {
|
|
|
+ this.printInfo = this.printData;
|
|
|
+ this.pringPdf();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created() {
|
|
|
- console.log("需要打印的内容:", this.content);
|
|
|
- },
|
|
|
+ created() {},
|
|
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
- mounted() {
|
|
|
- if (JSON.stringify(this.printData) !== "{}") {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.pringPdf();
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
pringPdf() {
|
|
|
- this.CreateOneFormPage();
|
|
|
+ let len = this.printInfo.orderSource.length;
|
|
|
+ if (this.num === 1) {
|
|
|
+ this.printInfo.orderSource = this.printInfo.orderSource + "(顾客联)";
|
|
|
+ }
|
|
|
+ if (this.num === 2) {
|
|
|
+ this.printInfo.orderSource =
|
|
|
+ this.printInfo.orderSource.slice(0, len - 5) + "(商家联)";
|
|
|
+ }
|
|
|
+ if (this.num === 3) {
|
|
|
+ this.printInfo.orderSource =
|
|
|
+ this.printInfo.orderSource.slice(0, len - 5) + "(厨房联)";
|
|
|
+ }
|
|
|
+ console.log("打印:", this.num, this.printInfo.orderSource);
|
|
|
+ this.$nextTick(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.CreateOneFormPage();
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
},
|
|
|
CreateOneFormPage() {
|
|
|
LODOP = getLodop();
|
|
@@ -79,7 +102,22 @@ export default {
|
|
|
);
|
|
|
LODOP.SET_PRINT_STYLEA(0, "Horient", 2);
|
|
|
LODOP.PRINT();
|
|
|
- this.$emit("printOver", this.printNum);
|
|
|
+ // 新订单未打印完三联,继续打印
|
|
|
+ if (this.orderType === 1 && this.num < 3) {
|
|
|
+ console.log("num", this.num);
|
|
|
+ this.num += 1;
|
|
|
+ this.pringPdf();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 新订单第三联打完,出去打印下一单
|
|
|
+ if (this.orderType === 1 && this.num === 3) {
|
|
|
+ this.num = 1;
|
|
|
+ this.$emit("printOver", true);
|
|
|
+ }
|
|
|
+ // 取消单打印
|
|
|
+ if (this.orderType === 2) {
|
|
|
+ this.$emit("printOver", true);
|
|
|
+ }
|
|
|
// LODOP.PRINT_DESIGN();
|
|
|
// LODOP.PREVIEW();
|
|
|
},
|