对接支付优惠
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { bySubType } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useShop } from "@/store/shop.js";
|
||||
import dayjs from "dayjs";
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
||||
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||
import refundPrint from "@/components/lodop/refundPrint.js";
|
||||
import { printerList } from "@/api/account.js";
|
||||
|
||||
export const usePrint = defineStore("print", {
|
||||
state: () => ({
|
||||
@@ -22,8 +21,6 @@ export const usePrint = defineStore("print", {
|
||||
actions: {
|
||||
// 获取本地打印机和已添加的可以用打印机列表
|
||||
async init() {
|
||||
const store = useUser();
|
||||
|
||||
// 获取本地打印机
|
||||
ipcRenderer.send("getPrintList");
|
||||
ipcRenderer.on("printList", (event, arg) => {
|
||||
@@ -32,26 +29,24 @@ export const usePrint = defineStore("print", {
|
||||
this.localDevices = arg;
|
||||
});
|
||||
|
||||
// // 获取已添加的小票打印机
|
||||
// this.deviceNoteList = await bySubType({
|
||||
// shopId: store.userInfo.shopId,
|
||||
// contentType: "local",
|
||||
// subType: "cash",
|
||||
// });
|
||||
|
||||
// // 获取已添加的标签打印机
|
||||
// this.deviceLableList = await bySubType({
|
||||
// shopId: store.userInfo.shopId,
|
||||
// contentType: "local",
|
||||
// subType: "label",
|
||||
// });
|
||||
console.log("打印队列初始化成功");
|
||||
// 获取已添加的打印机
|
||||
const res = await printerList();
|
||||
this.deviceNoteList = res.records.filter(
|
||||
(item) => item.status && item.subType == "cash"
|
||||
);
|
||||
this.deviceLableList = res.records.filter(
|
||||
(item) => item.status && item.subType == "label"
|
||||
);
|
||||
console.log("打印队列初始化成功", {
|
||||
deviceNoteList: this.deviceNoteList,
|
||||
deviceLableList: this.deviceLableList,
|
||||
});
|
||||
},
|
||||
// 检查本地打印机是否能正常使用
|
||||
checkLocalPrint(deviceName) {
|
||||
checkLocalPrint(address) {
|
||||
let print = "";
|
||||
for (let item of this.localDevices) {
|
||||
if (item.name == deviceName) {
|
||||
if (item.name == address) {
|
||||
print = item;
|
||||
}
|
||||
}
|
||||
@@ -64,16 +59,13 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
// 打印标签小票
|
||||
labelPrint(props) {
|
||||
const shopInfo = useShop();
|
||||
const store = useUser();
|
||||
|
||||
if (
|
||||
this.deviceLableList.length &&
|
||||
this.checkLocalPrint(this.deviceLableList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceLableList[0].address)
|
||||
) {
|
||||
let pids = this.deviceLableList[0].config.categoryList.map(
|
||||
(item) => item.id
|
||||
);
|
||||
|
||||
let pids = this.deviceLableList[0].categoryList;
|
||||
let count = 0;
|
||||
let sum = 0;
|
||||
|
||||
@@ -94,16 +86,19 @@ export const usePrint = defineStore("print", {
|
||||
name: item.name,
|
||||
skuName: item.skuName,
|
||||
masterId: props.orderInfo.tableName,
|
||||
deviceName: this.deviceLableList[0].config.deviceName,
|
||||
// deviceName: "Xprinter XP-T202UA",
|
||||
deviceName: this.deviceLableList[0].address,
|
||||
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
isPrint: false,
|
||||
count: `${count}/${sum}`,
|
||||
ticketLogo: shopInfo.info.ticketLogo,
|
||||
ticketLogo: store.shopInfo.ticketLogo,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log("this.labelList===", this.labelList);
|
||||
// return;
|
||||
|
||||
// 执行打印操作
|
||||
this.startLabelPrint();
|
||||
} else {
|
||||
@@ -133,38 +128,17 @@ export const usePrint = defineStore("print", {
|
||||
// console.log("pushReceiptData===", props);
|
||||
if (!isDevice) {
|
||||
// 测试打印,无需校验本地打印机
|
||||
const store = useUser();
|
||||
props.shop_name = store.userInfo.shopName;
|
||||
props.loginAccount = store.userInfo.loginAccount;
|
||||
props.createdAt = dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss");
|
||||
props.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
if (!props.orderInfo.masterId) {
|
||||
props.orderInfo.masterId = props.orderInfo.tableName;
|
||||
}
|
||||
props.orderInfo.outNumber = props.outNumber;
|
||||
|
||||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
} else {
|
||||
props.deviceName = "MHT-POS58 2";
|
||||
if (!props.orderInfo.masterId) {
|
||||
props.orderInfo.masterId = props.orderInfo.tableName;
|
||||
}
|
||||
props.orderInfo.outNumber = props.outNumber;
|
||||
if (!props.discountAmount) {
|
||||
props.discountAmount = props.amount;
|
||||
}
|
||||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
return;
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
const store = useUser();
|
||||
props.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
props.shop_name = store.userInfo.shopName;
|
||||
props.loginAccount = store.userInfo.loginAccount;
|
||||
props.deviceName = this.deviceNoteList[0].address;
|
||||
props.shop_name = store.shopInfo.shopName;
|
||||
props.loginAccount = store.userInfo.name;
|
||||
props.createdAt = dayjs(props.createdAt).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
);
|
||||
@@ -201,9 +175,9 @@ export const usePrint = defineStore("print", {
|
||||
printWork(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
lodopPrintWork(data);
|
||||
} else {
|
||||
console.log("交班小票:没有小票打印机");
|
||||
@@ -213,9 +187,9 @@ export const usePrint = defineStore("print", {
|
||||
printInvoice(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
invoicePrint(data);
|
||||
} else {
|
||||
console.log("订单发票:没有小票打印机");
|
||||
@@ -225,9 +199,9 @@ export const usePrint = defineStore("print", {
|
||||
printRefund(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
refundPrint(data);
|
||||
} else {
|
||||
console.log("退单小票:没有小票打印机");
|
||||
|
||||
Reference in New Issue
Block a user