diff --git a/.env.development b/.env.development index ce54d19..6a0e204 100644 --- a/.env.development +++ b/.env.development @@ -3,5 +3,5 @@ VITE_NOW_TYPE = 'dist' VITE_PUSH_URL = 'ws://192.168.1.22:8787' -VITE_BASE_URL = 'http://192.168.1.22:8546' -# VITE_BASE_URL = 'https://erp.lihaink.cn' \ No newline at end of file +# VITE_BASE_URL = 'http://192.168.1.22:8546' +VITE_BASE_URL = 'https://erp.lihaink.cn' \ No newline at end of file diff --git a/index.html b/index.html index 76dd4eb..bfdc1e7 100644 --- a/index.html +++ b/index.html @@ -39,14 +39,14 @@ /* 大屏幕 */ @media screen and (min-width: 993px) and (max-width: 1336px) { html { - font-size: 11px; + font-size: 14px; } } /* 大屏幕 */ @media screen and (min-width: 1336px) and (max-width: 1900px) { html { - font-size: 12px; + font-size: 15px; } } /* 大屏幕 */ diff --git a/src/layout/index.vue b/src/layout/index.vue index cc0af41..cfe940d 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -14,8 +14,8 @@ const connection = new Push({ // 浏览器监听user-1 -const user_channel = connection.subscribe(`user-${userStore.userInfo.id}`); -// const user_channel = connection.subscribe(`user-${1}`); +const user_channel = connection.subscribe(`store_merchant_${userStore.userInfo.merchant.mer_id}`); +// const user_channel = connection.subscribe(`store_merchant_${1}`); // 当user-2频道有message事件的消息时 user_channel.on('message', function (data) { diff --git a/src/layout/myAside.vue b/src/layout/myAside.vue index ce1daa1..bebc25f 100644 --- a/src/layout/myAside.vue +++ b/src/layout/myAside.vue @@ -12,7 +12,7 @@ const navTo = (name) => { const list = ref([ { name: "saleHome", title: "收银", ico: "Sell", count: 0 }, { name: "saleOrder", title: "收银订单", ico: "DataLine", count: 0 }, - { name: "order", title: "待提采购", ico: "DataAnalysis", count: 0 }, + { name: "order", title: "摊贩订单", ico: "DataAnalysis", count: 2 }, { name: "purchaseOrder", title: "采购订单", ico: "Tickets", count: 0 }, // { name: "test", title: "打印", ico: "Tickets", count: 0 }, ]); diff --git a/src/layout/myHeader.vue b/src/layout/myHeader.vue index 060e95f..5f80401 100644 --- a/src/layout/myHeader.vue +++ b/src/layout/myHeader.vue @@ -5,8 +5,11 @@ import { info, logout } from "@/api/user.js"; import { ElMessage } from "element-plus"; import { useRouter } from "vue-router"; import mitt from "@/utils/mitt.js"; +import { usePrintStore } from "@/store/print.js"; +import * as Esc from "@/utils/EscPostUtils.js"; const userStore = useUserStore(); +const printStore = usePrintStore(); const merInfo = ref({}); merInfo.value = userStore.userInfo; @@ -18,24 +21,48 @@ const onLogout = () => { router.push("/login"); }; -const is_connect = ref(false); //是否连接打印机 +const onRefresh = () => { + window.location.reload(); +}; + +const dialogVisible = ref(false); //是否显示重新连接 // 连接打印机 const connect = () => { console.log("连接打印机"); - uni.postMessage({ - data: { - type: "connect", - }, + uni.getEnv((res) => { + if (res.h5) ElMessage.error("请使用APP连接打印机"); + else { + printStore.setConnect(false); + dialogVisible.value = false; + uni.postMessage({ + data: { + type: "connect", + }, + }); + } }); }; +let isPrint = false; //是否正在打印小票 // 预打印 const printReceipt = (content = "") => { console.log("预打印"); + // console.log(Esc.inline3("单价 ", "数量", "小计", " ", 1) + "\n"); + // console.log(Esc.inline3("2.36元 ", "10包", "30.00元", " ", 1) + "\n"); + // return ; + if (isPrint) return; + isPrint = true; uni.getEnv((res) => { - if (res.h5) ElMessage.error("请使用APP打印小票"); - else APPprint(content); + if (res.h5) { + ElMessage.error("请使用APP打印小票"); + isPrint = false; + } else { + APPprint(content); + setTimeout(() => { + isPrint = false; + }, 4000); + } }); }; @@ -43,15 +70,47 @@ const printReceipt = (content = "") => { const APPprint = (content = "") => { let str = ""; if (content === "") { - str += "********************************\n"; - str += "泸优采-小票\n"; - str += "单号: CG171565043141139102\n"; - str += "测试商品1 * 1 \t 1.00元 \n"; - str += "测试商品2 * 1 \t 1.00元 \n"; - str += "测试商品小黄鸭3 * 1 \t 1.00元 \n"; - str += "\n"; - str += "--------------------------------\n"; - str += "\n"; + // str += "********************************\n"; + // str += "莲花农贸市场\n"; + // str += "单号: PF171568087790938356\n"; + // str += "测试商品 0.01元/kg\n"; + // str += "x 3 \t\t 0.10 \n"; + // str += "测试商品白菜 1.33元/kg\n"; + // str += "x 10 \t\t 13.30元\n"; + // str += "测试商品小黄鸭 36.59元/只\n"; + // str += "x 3 \t\t 106.97元\n"; + // str += " \t 合计: ¥235.36\n"; + // str += "\n"; + // str += "--------------------------------\n"; + // str += "\n"; + str += Esc.Size2(0) + Esc.Center() + Esc.boldFontOn() + "莲花农贸市场" + "\n"; + str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n"; + str += Esc.Left() + "单号: PF171568087790938356" + "\n"; + str += Esc.Left() + "下单时间: 2024-5-15 18:00:32" + "\n"; + // 商品信息 + str += Esc.fillLine("=") + "\n"; + str += Esc.inline3("单价 ", "数量", "小计", " ", 1) + "\n"; + str += Esc.Left() + "白菜 大白菜" + "\n"; + str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n"; + str += Esc.Left() + "白菜 大白菜" + "\n"; + str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n"; + str += Esc.Left() + "白菜 大白菜" + "\n"; + str += Esc.inline3("206.36元 ", "10包", "3600.00元", " ", 1) + "\n"; + str += Esc.fillLine("=") + "\n"; + + str += Esc.Left() + "应付款: " + "29.96元" + "\n"; + str += Esc.Left() + "实付款: " + "29.96元" + "\n"; + str += Esc.Left() + "支付方式: " + "微信支付" + "\n"; + str += Esc.Left() + "支付单号: " + "4200002159202405159003084211" + "\n"; + str += Esc.fillLine("=") + "\n"; + + // 票尾 + str += Esc.fillLine(" ") + "\n"; + str += Esc.Center() + "欢迎下次光临!" + "\n"; + str += Esc.feedLines(" ") + "\n"; + // 切纸 + str += Esc.cutPaper(); + console.log(str); } else str = content; uni.postMessage({ data: { @@ -68,8 +127,8 @@ onMounted(() => { "message", function (event) { // alert(JSON.stringify(event.data)); - if(event.data.type === "connect"){ - is_connect.value = true; + if (event.data.type === "connect") { + printStore.setConnect(true); ElMessage.success("已连接打印机T58"); } }, @@ -92,27 +151,49 @@ onUnmounted(() => { >
里海收银系统
+
+ +
- - 打印测试 + + 打印自检
-
- - 点击自动连接打印机 +
+ + 点击自动连接打印机
-
已连接打印机T58
+
+ 已连接打印机T58 +
+ + 打印机已连接,是否重新连接 + +