diff --git a/package.json b/package.json
index 2c1fb99..ac0fd3b 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "vite-electron",
"private": true,
- "version": "1.4.11",
+ "version": "1.4.12",
"main": "dist-electron/main.js",
"scripts": {
"dev": "chcp 65001 && vite",
diff --git a/src/components/lodop/refundPrint.js b/src/components/lodop/refundPrint.js
new file mode 100644
index 0000000..5e0ddb6
--- /dev/null
+++ b/src/components/lodop/refundPrint.js
@@ -0,0 +1,96 @@
+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 t1 = 40;
+ let t2 = (100 - t1) / 3;
+ let html = `
+
+ ${data.shop_name}
+
+
+ 退款单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】
+
+
+ 订单号:${data.orderInfo && data.orderInfo.orderNo}
+
+
+ 交易时间:${data.createdAt}
+
+
+ 收银员:${data.loginAccount}
+
+
+
+
+
+
+ | 品名 |
+ 单价 |
+ 数量 |
+ 小计 |
+
+ `;
+
+ let table = "";
+ for (let item of data.carts) {
+ table += `
+
+ |
+ ${item.name}
+ ${
+ item.skuName
+ ? `规格:${item.skuName} `
+ : ""
+ }
+ |
+ ${item.salePrice} |
+ ${item.number} |
+
+ ${item.totalAmount}
+ |
+
+ `;
+ }
+
+ let str = `
+
+
+
+
+
+ 应退
+ ¥${data.amount}
+
+
+ 余额:
+ 0.00
+
+
+
+
+
+ 打印时间:${data.printTime}
+
+ .
+ .
+ .
+ .
+ `;
+
+ let lastHtml = `${html}${table}${str}`;
+
+ setTimeout(() => {
+ LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, lastHtml);
+ LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", "");
+ LODOP.PRINT();
+ }, 800);
+};
diff --git a/src/store/print.js b/src/store/print.js
index 89a851e..4581d36 100644
--- a/src/store/print.js
+++ b/src/store/print.js
@@ -6,6 +6,7 @@ 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";
export const usePrint = defineStore({
id: "print",
@@ -203,5 +204,17 @@ export const usePrint = defineStore({
console.log("订单发票:没有小票打印机");
}
},
+ // 打印退单小票
+ printRefund(data) {
+ if (
+ this.deviceNoteList.length &&
+ this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
+ ) {
+ data.deviceName = this.deviceNoteList[0].config.deviceName;
+ refundPrint(data);
+ } else {
+ console.log("退单小票:没有小票打印机");
+ }
+ },
},
});
diff --git a/src/views/home/components/settleAccount.vue b/src/views/home/components/settleAccount.vue
index 52c580e..ff02f0e 100644
--- a/src/views/home/components/settleAccount.vue
+++ b/src/views/home/components/settleAccount.vue
@@ -122,6 +122,7 @@ const isPrint = ref(true);
const printHandle = _.throttle(async function () {
try {
if (!isPrint.value) return;
+ printLoading.value = true;
const data = {
shop_name: store.userInfo.shopName,
loginAccount: store.userInfo.loginAccount,
@@ -134,20 +135,20 @@ const printHandle = _.throttle(async function () {
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
};
printStore.labelPrint(data)
- printStore.pushReceiptData(data)
- // try {
- // printLoading.value = true;
- // await print({
- // type: "normal",
- // ispre: true,
- // orderId: props.orderInfo.id,
- // });
- // printLoading.value = false;
- // // ElMessage.success("打印成功");
- // } catch (error) {
- // printLoading.value = false;
- // console.log(error);
- // }
+ setTimeout(() => {
+ printLoading.value = false;
+ }, 1500)
+ if (printStore.deviceNoteList.length) {
+ printStore.pushReceiptData(data)
+ } else {
+ await print({
+ type: "normal",
+ ispre: true,
+ orderId: props.orderInfo.id,
+ });
+ printLoading.value = false;
+ ElMessage.success("打印成功");
+ }
} catch (error) {
console.log(error);
}
@@ -194,8 +195,19 @@ async function printOrderLable() {
})
// 打印标签
printStore.labelPrint(data)
- // 打印小票
- printStore.pushReceiptData(data)
+
+ if (printStore.deviceNoteList.length) {
+ // 打印小票
+ printStore.pushReceiptData(data)
+ } else {
+ await print({
+ type: "normal",
+ ispre: true,
+ orderId: props.orderInfo.id,
+ });
+ printLoading.value = false;
+ ElMessage.success("打印成功");
+ }
} catch (error) {
console.log(error);
}
diff --git a/src/views/order/components/invoice.vue b/src/views/order/components/invoice.vue
index ae418a4..048e408 100644
--- a/src/views/order/components/invoice.vue
+++ b/src/views/order/components/invoice.vue
@@ -46,17 +46,25 @@ const orderInfo = ref({})
async function printEwmHandle() {
try {
printEwmLoading.value = true
- printStore.printInvoice({
- url: ewmInfo.value.wechat_url
- })
- // const res = await syjprintqrcode({
- // id: ewmInfo.value.id
- // })
- ElMessage.success('打印成功')
- showEwmDialog.value = false
- setTimeout(() => {
- printEwmLoading.value = false
- }, 1000)
+ if (printStore.deviceNoteList.length) {
+ printStore.printInvoice({
+ url: ewmInfo.value.wechat_url
+ })
+ ElMessage.success('打印成功')
+ showEwmDialog.value = false
+ setTimeout(() => {
+ printEwmLoading.value = false
+ }, 1000)
+ } else {
+ const res = await syjprintqrcode({
+ id: ewmInfo.value.id
+ })
+ ElMessage.success('打印成功')
+ showEwmDialog.value = false
+ setTimeout(() => {
+ printEwmLoading.value = false
+ }, 1000)
+ }
} catch (error) {
console.log(error);
printEwmLoading.value = false
diff --git a/src/views/order/index.vue b/src/views/order/index.vue
index fe047d0..0ac60b9 100644
--- a/src/views/order/index.vue
+++ b/src/views/order/index.vue
@@ -142,8 +142,19 @@
(orderDetaildata.status == 'refund' ||
orderDetaildata.status == 'closed')
">开发票
- 重打小票
- 重打标签
+ 重打小票
+ 重打标签
+
+ 重打小票
+
@@ -445,47 +456,94 @@ const print = lodash.throttle(
setTimeout(() => {
labelPrintLoading.value = false
}, 1000)
- } else {
- normalPrintLoading.value = true
- const data = {
- shop_name: store.userInfo.shopName,
- loginAccount: store.userInfo.loginAccount,
- carts: [],
- amount: printLabelOrder.value.orderAmount,
- remark: printLabelOrder.value.remark,
- orderInfo: printLabelOrder.value,
- outNumber: printLabelOrder.value.outNumber,
- createdAt: dayjs(printLabelOrder.value.createdAt).format(
- "YYYY-MM-DD HH:mm:ss"
- ),
- printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ } else if (e == 'normal') {
+ if (printStore.deviceNoteList.length) {
+ normalPrintLoading.value = true
+ const data = {
+ shop_name: store.userInfo.shopName,
+ loginAccount: store.userInfo.loginAccount,
+ carts: [],
+ amount: printLabelOrder.value.orderAmount,
+ remark: printLabelOrder.value.remark,
+ orderInfo: printLabelOrder.value,
+ outNumber: printLabelOrder.value.outNumber,
+ createdAt: dayjs(printLabelOrder.value.createdAt).format(
+ "YYYY-MM-DD HH:mm:ss"
+ ),
+ printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ }
+ printLabelOrder.value.skuInfos.map(item => {
+ data.carts.push(
+ {
+ categoryId: item.categoryId,
+ name: item.productName,
+ number: item.num,
+ skuName: item.productSkuName,
+ salePrice: formatDecimal(item.priceAmount / item.num),
+ totalAmount: formatDecimal(item.priceAmount)
+ }
+ )
+ })
+ printStore.pushReceiptData(data);
+ setTimeout(() => {
+ normalPrintLoading.value = false
+ }, 1000)
+ } else {
+ // 云打票
+ await cloudPrinterprint({
+ type: e,
+ orderId: orderDetaildata.value.id,
+ ispre: false,
+ });
+ ElMessage({
+ message: "成功打票",
+ type: "success",
+ });
+ }
+ } else if (e == 'refund') {
+ if (printStore.deviceNoteList.length) {
+ normalPrintLoading.value = true
+ const data = {
+ shop_name: store.userInfo.shopName,
+ loginAccount: store.userInfo.loginAccount,
+ carts: [],
+ amount: printLabelOrder.value.orderAmount,
+ remark: printLabelOrder.value.remark,
+ orderInfo: printLabelOrder.value,
+ outNumber: printLabelOrder.value.outNumber,
+ createdAt: dayjs(printLabelOrder.value.createdAt).format(
+ "YYYY-MM-DD HH:mm:ss"
+ ),
+ printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ }
+ printLabelOrder.value.skuInfos.map(item => {
+ data.carts.push(
+ {
+ categoryId: item.categoryId,
+ name: item.productName,
+ number: item.num,
+ skuName: item.productSkuName,
+ salePrice: formatDecimal(item.priceAmount / item.num),
+ totalAmount: formatDecimal(item.priceAmount)
+ }
+ )
+ })
+ printStore.printRefund(data);
+ setTimeout(() => {
+ normalPrintLoading.value = false
+ }, 1000)
+ } else {
+ // 云打票
+ await cloudPrinterprint({
+ type: 'normal',
+ orderId: orderDetaildata.value.id,
+ ispre: false,
+ });
+ ElMessage({
+ message: "成功打票",
+ type: "success",
+ });
}
- printLabelOrder.value.skuInfos.map(item => {
- data.carts.push(
- {
- categoryId: item.categoryId,
- name: item.productName,
- number: item.num,
- skuName: item.productSkuName,
- salePrice: formatDecimal(item.priceAmount / item.num),
- totalAmount: formatDecimal(item.priceAmount)
- }
- )
- })
- printStore.pushReceiptData(data);
- setTimeout(() => {
- normalPrintLoading.value = false
- }, 1000)
- // // 云打票
- // await cloudPrinterprint({
- // type: e,
- // orderId: orderDetaildata.value.id,
- // ispre: false,
- // });
- // ElMessage({
- // message: "成功打票",
- // type: "success",
- // });
}
} catch (error) {
console.log(error);
diff --git a/src/views/work/index.vue b/src/views/work/index.vue
index c97391f..da86f9b 100644
--- a/src/views/work/index.vue
+++ b/src/views/work/index.vue
@@ -159,125 +159,83 @@ const dialogVisible = ref(false) //交班
const infoData = ref({})
const loading = ref(false);
-const printList = ref([]);
-const localPrintList = ref([])
-
const isPrint = ref(true)
-// 获取打印机状态
-async function bySubTypeAjax() {
- try {
- const res = await bySubType({
- shopId: store.userInfo.shopId,
- contentType: "local",
- subType: "cash",
- });
- printList.value = res;
- } catch (error) {
- console.log(error);
- }
-}
-
-// 获取本地打印机列表
-function getPrintList() {
- ipcRenderer.send("getPrintList");
- ipcRenderer.on("printList", (event, arg) => {
- localPrintList.value = arg;
- // console.log(localPrintList.value);
- });
-}
-
-// 检查本地打印机是否能正常使用
-function checkLocalPrint(deviceName) {
- let print = ''
- for (let item of localPrintList.value) {
- if (item.name == deviceName) {
- print = item
- }
- }
-
- if (!print.name) {
- return false
- } else {
- return true
- }
-}
// 开始交班
const exit = async () => {
try {
- loading.value = true;
- let data = {}
- // 获取交班打印小票数据
- data = await handoverData({
- id: infoData.value.id
- })
+ if (printStore.deviceNoteList.length) {
+ loading.value = true;
+ let data = {}
+ // 获取交班打印小票数据
+ data = await handoverData({
+ id: infoData.value.id
+ })
- data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
- data.printShop = isPrint.value
- printStore.printWork(data)
+ data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
+ data.printShop = isPrint.value
+ printStore.printWork(data)
- // return
- await loginlogout({
- status: 1
- })
+ // return
+ await loginlogout({
+ status: 1
+ })
- useStorage.del('userInfo')
- useStorage.del('token')
- useStorage.del('douyin')
- useStorage.del('categorysActive')
+ useStorage.del('userInfo')
+ useStorage.del('token')
+ useStorage.del('douyin')
+ useStorage.del('categorysActive')
- ElMessage.success("交班成功");
- setTimeout(() => {
- router.replace({
- name: "login",
- });
- }, 1000);
- loading.value = false;
- return
- if (printList.value.length) {
- console.log('本地打印');
- if (!checkLocalPrint(printList.value[0].config.deviceName)) {
- loading.value = true;
- let res = await loginlogout({
- status: 1
- })
- // useStorage.clear()
- useStorage.del('userInfo')
- useStorage.del('token')
- useStorage.del('douyin')
- useStorage.del('categorysActive')
- ElMessage.success("交班成功");
- setTimeout(() => {
- router.replace({
- name: "login",
- });
- }, 1000);
- loading.value = false;
- } else {
- // 获取交班打印小票数据
- const data = await handoverData({
- id: infoData.value.id
- })
- data.deviceName = printList.value[0].config.deviceName
- data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
- ipcRenderer.send("printerWorkSync", JSON.stringify(data));
- // return
- // useStorage.clear()
- useStorage.del('userInfo')
- useStorage.del('token')
- useStorage.del('douyin')
- useStorage.del('categorysActive')
- ElMessage.success("交班成功");
- setTimeout(() => {
- router.replace({
- name: "login",
- });
- }, 1000);
- loading.value = false;
- }
+ ElMessage.success("交班成功");
+ setTimeout(() => {
+ router.replace({
+ name: "login",
+ });
+ }, 1000);
+ loading.value = false;
+ // console.log('本地打印');
+ // if (!checkLocalPrint(printList.value[0].config.deviceName)) {
+ // loading.value = true;
+ // let res = await loginlogout({
+ // status: 1
+ // })
+ // // useStorage.clear()
+ // useStorage.del('userInfo')
+ // useStorage.del('token')
+ // useStorage.del('douyin')
+ // useStorage.del('categorysActive')
+ // ElMessage.success("交班成功");
+ // setTimeout(() => {
+ // router.replace({
+ // name: "login",
+ // });
+ // }, 1000);
+ // loading.value = false;
+ // } else {
+ // // 获取交班打印小票数据
+ // const data = await handoverData({
+ // id: infoData.value.id
+ // })
+ // data.deviceName = printList.value[0].config.deviceName
+ // data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
+ // ipcRenderer.send("printerWorkSync", JSON.stringify(data));
+ // // return
+ // // useStorage.clear()
+ // useStorage.del('userInfo')
+ // useStorage.del('token')
+ // useStorage.del('douyin')
+ // useStorage.del('categorysActive')
+ // ElMessage.success("交班成功");
+ // setTimeout(() => {
+ // router.replace({
+ // name: "login",
+ // });
+ // }, 1000);
+ // loading.value = false;
+ // }
} else {
- console.log('云打印');
+ console.log('云打印交班数据');
loading.value = true;
await tglogout()