小票全部采用本地usb打印
This commit is contained in:
@@ -61,11 +61,11 @@
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<div class="print_view">
|
||||
<div class="title t1">溜溜</div>
|
||||
<div class="title t2">结算单【#002】</div>
|
||||
<div class="row">订单号:202404021023542223445</div>
|
||||
<div class="row">交易时间:2024-04-02 10:15</div>
|
||||
<div class="row">收银员:【POS-1】1</div>
|
||||
<div class="title t1">{{ printData.shop_name }}</div>
|
||||
<div class="title t2">预结算单【{{ printData.orderInfo.masterId }}】</div>
|
||||
<div class="row">订单号:{{ printData.orderInfo.orderNo }}</div>
|
||||
<div class="row">交易时间:{{ printData.createdAt }}</div>
|
||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||
<div class="line"></div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
@@ -74,51 +74,31 @@
|
||||
<td>数量</td>
|
||||
<td>小计</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||
<td>
|
||||
<div>娃哈哈矿泉水</div>
|
||||
<div class="sku">500ml</div>
|
||||
<div>{{ item.name }}</div>
|
||||
<div class="sku">{{ item.skuName }}</div>
|
||||
</td>
|
||||
<td>1.0</td>
|
||||
<td>10</td>
|
||||
<td>10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div>柠檬奶茶</div>
|
||||
<div class="sku">加冰、加珍珠</div>
|
||||
</td>
|
||||
<td>10.0</td>
|
||||
<td>2</td>
|
||||
<td>20</td>
|
||||
<td>{{ item.salePrice }}</td>
|
||||
<td>{{ item.number }}</td>
|
||||
<td>{{ item.totalAmount }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="line"></div>
|
||||
<div class="row between">
|
||||
<span>合计:</span>
|
||||
<span>30.00</span>
|
||||
<span>合计:</span>
|
||||
<span>{{ printData.amount }}</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>合计:</span>
|
||||
<span>30.00</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>原价:20.00,节省了0</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>积分:</span>
|
||||
<span>0</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>余额:</span>
|
||||
<span>余额:</span>
|
||||
<span>0.00</span>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
<div class="row">备注:</div>
|
||||
<div class="row">打印时间:2024-04-02 10:15</div>
|
||||
<div class="row">备注:{{ printData.remark }}</div>
|
||||
<div class="row">打印时间:{{ printData.printTime }}</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button plain style="width: 100%" @click="printHandle">
|
||||
<el-button plain style="width: 100%" :loading="printDataLoading" @click="printHandle">
|
||||
打印测试小票
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -137,7 +117,7 @@
|
||||
<script setup>
|
||||
import dayjs from 'dayjs'
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { tbPrintMachinePost, tbPrintMachineDetail } from "@/api/device";
|
||||
@@ -175,6 +155,39 @@ const form = ref({
|
||||
shopId: store.userInfo.shopId,
|
||||
});
|
||||
|
||||
const printDataLoading = ref(false)
|
||||
const printData = reactive({
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: '【测试】娃哈哈矿泉水',
|
||||
skuName: '500ml',
|
||||
salePrice: '1.0',
|
||||
number: '10',
|
||||
totalAmount: '10'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '【测试】柠檬奶茶',
|
||||
skuName: '加冰、加珍珠',
|
||||
salePrice: '10',
|
||||
number: '2',
|
||||
totalAmount: '20'
|
||||
}
|
||||
],
|
||||
amount: '30.00',
|
||||
remark: '',
|
||||
orderInfo: {
|
||||
masterId: '#002',
|
||||
orderNo: '202404021023542223445'
|
||||
},
|
||||
deviceName: form.value.config.deviceName,
|
||||
createdAt: '2024-04-02 10:15',
|
||||
printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
});
|
||||
|
||||
// 获取打印机列表
|
||||
function getPrintList() {
|
||||
ipcRenderer.send("getPrintList");
|
||||
@@ -189,43 +202,12 @@ function printHandle() {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
|
||||
// ipcRenderer.send(
|
||||
// "printStart",
|
||||
// JSON.stringify({ deviceName: form.value.config.deviceName })
|
||||
// );
|
||||
|
||||
const data = {
|
||||
shop_name: '溜溜',
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: '娃哈哈矿泉水',
|
||||
skuName: '500ml',
|
||||
salePrice: '1.0',
|
||||
number: '10',
|
||||
totalAmount: '10'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '柠檬奶茶',
|
||||
skuName: '加冰、加珍珠',
|
||||
salePrice: '10',
|
||||
number: '2',
|
||||
totalAmount: '20'
|
||||
}
|
||||
],
|
||||
amount: '30.00',
|
||||
remark: '',
|
||||
orderInfo: {
|
||||
masterId: '#002',
|
||||
orderNo: '202404021023542223445'
|
||||
},
|
||||
deviceName: form.value.config.deviceName,
|
||||
createdAt: '2024-04-02 10:15',
|
||||
printTime: '2024-04-02 10:15',
|
||||
};
|
||||
ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
printDataLoading.value = true
|
||||
printData.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
printStore.pushReceiptData(printData)
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<div class="intro">用来打印商品标签的打印机。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="icon" style="background-color: #8fc783">
|
||||
<el-image :src="icons.kitchen" style="width: 44px; height: 44px"></el-image>
|
||||
</div>
|
||||
@@ -96,7 +96,7 @@
|
||||
<div class="name">添加出品打印机</div>
|
||||
<div class="intro">用来打印商品至厨房或出品台的打印机。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<span class="member_info" v-if="memberInfo.telephone">会员:{{ memberInfo.telephone }}</span>
|
||||
</div>
|
||||
<div class="btm">
|
||||
<span class="p">服务员:{{ store.userInfo.shopName || "暂无" }}</span>
|
||||
<span class="p">服务员:{{ store.userInfo.loginAccount || "暂无" }}</span>
|
||||
<span class="t">{{
|
||||
props.orderInfo.createdAt &&
|
||||
dayjs(props.orderInfo.createdAt).format("MM-DD HH:mm")
|
||||
@@ -155,6 +155,7 @@ const printHandle = _.throttle(async function () {
|
||||
// 打印订单标签
|
||||
async function printOrderLable() {
|
||||
try {
|
||||
if (!isPrint.value) return
|
||||
const res = await orderfindOrder({
|
||||
shopId: store.userInfo.shopId,
|
||||
status: '',
|
||||
@@ -298,6 +299,10 @@ onMounted(() => {
|
||||
|
||||
.p {
|
||||
color: #999;
|
||||
width: 160px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import { ElMessage } from 'element-plus'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { issuedby, carsubinvoicing, syjprintqrcode } from '@/api/invoice.js'
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
|
||||
const emits = defineEmits(['loadComplete', 'success'])
|
||||
@@ -44,12 +46,17 @@ const orderInfo = ref({})
|
||||
async function printEwmHandle() {
|
||||
try {
|
||||
printEwmLoading.value = true
|
||||
const res = await syjprintqrcode({
|
||||
id: ewmInfo.value.id
|
||||
printStore.printInvoice({
|
||||
url: ewmInfo.value.wechat_url
|
||||
})
|
||||
// const res = await syjprintqrcode({
|
||||
// id: ewmInfo.value.id
|
||||
// })
|
||||
ElMessage.success('打印成功')
|
||||
showEwmDialog.value = false
|
||||
printEwmLoading.value = false
|
||||
setTimeout(() => {
|
||||
printEwmLoading.value = false
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
printEwmLoading.value = false
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div style="margin-left: 10px;">返回</div>
|
||||
<div style="margin-left: 4px;">返回</div>
|
||||
</div>
|
||||
<router-link to='/workrecord' class="box_top_right">
|
||||
交班记录
|
||||
@@ -145,6 +145,9 @@ import { bySubType } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import { formatDecimal } from '@/utils/index.js'
|
||||
import { usePrint } from "@/store/print.js";
|
||||
const printStore = usePrint();
|
||||
|
||||
const socket = useSocket();
|
||||
|
||||
const store = useUser();
|
||||
@@ -200,8 +203,36 @@ function checkLocalPrint(deviceName) {
|
||||
}
|
||||
}
|
||||
|
||||
// 开始交班
|
||||
const exit = async () => {
|
||||
try {
|
||||
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)
|
||||
|
||||
await loginlogout({
|
||||
status: 1
|
||||
})
|
||||
|
||||
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)) {
|
||||
@@ -213,6 +244,7 @@ const exit = async () => {
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
@@ -233,6 +265,7 @@ const exit = async () => {
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
@@ -262,6 +295,7 @@ const exit = async () => {
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
@@ -272,6 +306,7 @@ const exit = async () => {
|
||||
}
|
||||
socket.close()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user