小票全部采用本地usb打印

This commit is contained in:
gyq
2024-07-30 18:04:53 +08:00
parent b2e450fd52
commit 49cabfed21
13 changed files with 459 additions and 291 deletions

View File

@@ -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-11</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)
}
// 提交打印机

View File

@@ -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>