This commit is contained in:
gyq 2024-06-11 18:26:06 +08:00
parent 0b42be9964
commit 883eb268f3
9 changed files with 349 additions and 12 deletions

View File

@ -2,7 +2,7 @@
ENV = development
# 测试
# VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
# 阿伟
# VITE_API_URL = 'http://192.168.2.96:10587/cashier-client'
@ -11,4 +11,4 @@ ENV = development
# VITE_API_URL = 'http://192.168.2.41:10587/cashier-client'
# 正式
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'

View File

@ -2,7 +2,7 @@
ENV = production
# 线上环境接口地址
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/'
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/'
# 测试
# VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'

View File

@ -98,6 +98,60 @@ app.whenReady().then(() => {
},
});
});
// 交班小票的窗口
// const workPrintWin = new BrowserWindow({
// show: true,
// width: 464,
// height: 1726,
// webPreferences: {
// nodeIntegration: true,
// contextIsolation: false,
// },
// });
// if (process.env.VITE_DEV_SERVER_URL) {
// // 加载打印的html文件
// workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
// } else {
// workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html")); // 打包后使用文件路径访问应用
// }
// // 接收渲染进程发送的数据
// ipcMain.on("printerWorkSync", (event, arg) => {
// workPrintWin.webContents.send("getParams", arg);
// });
// // 执行交班小票的打印操作
// ipcMain.on("printWorkStart", (event, arg) => {
// console.log(arg);
// const _parmas = JSON.parse(arg);
// // console.log(_parmas)
// let name = _parmas.deviceName;
// printWin.webContents.print({
// silent: true,
// deviceName: name,
// pageSize: {
// width: 58000,
// height: 216000,
// },
// scaleFactor: 80,
// landscape: false,
// margins: {
// marginType: "none",
// top: 0,
// bottom: 0,
// left: 0,
// right: 0,
// },
// dpi: {
// horizontal: 203,
// vertical: 203,
// },
// });
// });
});
app.on("window-all-closed", () => {

View File

@ -1,7 +1,7 @@
{
"name": "vite-electron",
"private": true,
"version": "1.2.14",
"version": "1.2.15",
"main": "dist-electron/main.js",
"scripts": {
"dev": "chcp 65001 && vite",

79
public/work_print.css Normal file
View File

@ -0,0 +1,79 @@
* {
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding: 0 8mm;
}
.print_view {
padding: 20px 0;
}
.print_view .title {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
margin-bottom: 4px;
}
.print_view .title.t1 {
font-size: 24px;
}
.print_view .title.t2 {
margin-bottom: 15px;
}
.print_view .row {
margin-top: 2px;
font-size: 12px;
}
.print_view .row.between {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.print_view .line {
margin: 10px 0;
border-bottom: 1px solid #000;
}
.print_view .table {
width: 100%;
}
.print_view .table tr {
width: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.print_view .table tr:not(:last-child) {
margin-bottom: 10px;
}
.print_view .table tr td {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
font-size: 12px;
}
.print_view .table tr td:nth-child(1) {
-webkit-box-flex: 2;
-ms-flex: 2;
flex: 2;
}
.print_view .table tr td:not(:first-child) {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
}
.print_view .table tr td .sku {
font-size: 10px;
}

97
public/work_print.html Normal file
View File

@ -0,0 +1,97 @@
<!--
~ Copyright (c) 2023. Author Hubert Formin <2399270194@qq.com>
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Print preview</title>
<link rel="stylesheet" href="./work_print.css" />
</head>
<body>
<div id="app">
<div class="print_view">
<div class="title t1">{{data.shop_name}}</div>
<div class="title t2">
交班小票
</div>
<div class="row">
交班时间:{{data.orderInfo && data.orderInfo.orderNo}}
</div>
<div class="row">收银员:【POS-1】1</div>
<table class="table">
<tr>
<td>品名</td>
<td>单价</td>
<td>数量</td>
<td>小计</td>
</tr>
<tr v-for="item in data.carts" :key="item.id">
<td>
<div>{{item.name}}</div>
<div class="sku">{{item.skuName}}</div>
</td>
<td>{{item.salePrice}}</td>
<td>{{item.number}}</td>
<td>{{item.totalAmount}}</td>
</tr>
</table>
<div class="row between">
<span>合计:</span>
<span>{{data.amount}}</span>
</div>
<!-- <div class="row between">
<span>合计:</span>
<span>30.00</span>
</div> -->
<div class="row between">
<span>原价:{{data.amount}}节省了0</span>
</div>
<div class="row between">
<span>积分:</span>
<span>0</span>
</div>
<div class="row between">
<span>余额:</span>
<span>0.00</span>
</div>
<div class="row">备注:</div>
<div class="row">打印时间:{{data.printTime}}</div>
</div>
</div>
<script type="module">
const { ipcRenderer } = require("electron");
import {
createApp,
ref,
onMounted,
} from "../node_modules/vue/dist/vue.esm-browser.js";
createApp({
setup() {
const data = ref({});
onMounted(() => {
ipcRenderer.on("getParams", (event, arg) => {
data.value = JSON.parse(arg);
console.log(data.value);
setTimeout(() => {
ipcRenderer.send(
"printStart",
JSON.stringify({ deviceName: data.value.deviceName })
);
}, 500);
});
});
return {
data,
};
},
}).mount("#app");
</script>
</body>
</html>

71
public/work_print.scss Normal file
View File

@ -0,0 +1,71 @@
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
padding: 0 8mm;
}
.print_view {
padding: 20px 0;
.title {
display: flex;
justify-content: center;
margin-bottom: 4px;
&.t1 {
font-size: 24px;
}
&.t2 {
margin-bottom: 15px;
}
}
.row {
margin-top: 2px;
font-size: 12px;
&.between {
display: flex;
justify-content: space-between;
}
}
.line {
margin: 10px 0;
border-bottom: 1px solid #000;
}
.table {
width: 100%;
tr {
width: 100%;
display: flex;
&:not(:last-child) {
margin-bottom: 10px;
}
td {
flex: 1;
font-size: 12px;
&:nth-child(1) {
flex: 2;
}
&:not(:first-child) {
display: flex;
justify-content: flex-end;
}
.sku {
font-size: 10px;
}
}
}
}
}

View File

@ -62,3 +62,16 @@ export function queryQuickPay(params) {
params,
});
}
/**
* 叫号
* @param {*} params
* @returns
*/
export function sendMessage(params) {
return request({
method: "get",
url: "/order/sendMessage",
params,
});
}

View File

@ -98,13 +98,19 @@
</div>
</div>
<div class="orderbox_right_button">
<el-button style="width: 100%;"
v-if="orderDetaildata.orderType != 'return' && (orderDetaildata.status == 'refund' || orderDetaildata.status == 'closed')"
type="primary" @click="recharge = true">退单</el-button>
<div class="orderbox_right_buttonbutton">
<!-- // -->
<el-button @click="print('normal')" style="width: 45%;" type="">重打收银打票</el-button>
<el-button @click="print('label')" style="width: 45%;" type="">重打标签小票</el-button>
<el-button style="width: 100%;" type="warning" :loading="callLoading" @click="callNumberHandle">
叫号
</el-button>
</div>
<div class="orderbox_right_buttonbutton">
<el-button style="width: 100%;"
v-if="orderDetaildata.orderType != 'return' && (orderDetaildata.status == 'refund' || orderDetaildata.status == 'closed')"
type="primary" @click="recharge = true">退单</el-button>
</div>
<div class="orderbox_right_buttonbutton">
<el-button @click="print('normal')" style="flex: 1;">重打收银打票</el-button>
<el-button @click="print('label')" style="flex: 1;">重打标签小票</el-button>
</div>
</div>
</div>
@ -234,7 +240,7 @@ import { ref, onMounted, reactive } from 'vue'
import { ElMessage, dayjs } from 'element-plus'
import { useUser } from "@/store/user.js"
import lodash from 'lodash'
import { orderfindOrder, orderorderDetail, payreturnOrder, cloudPrinterprint } from '@/api/order/index.js'
import { orderfindOrder, orderorderDetail, payreturnOrder, cloudPrinterprint, sendMessage } from '@/api/order/index.js'
import add from '@/views/order/components/add.vue'
import cashTable from '@/views/order/components/cashTable.vue'
import { clearNoNum } from '@/utils'
@ -427,6 +433,23 @@ const handleCurrentChange = (val) => { //页码
const inputChange = lodash.debounce(function () { //
asyncorderfindOrder()
}, 500)
//
const callLoading = ref(false)
const callNumberHandle = async () => {
try {
callLoading.value = true
const res = await sendMessage({
orderId: orderDetaildata.value.id
})
callLoading.value = false
ElMessage.success('叫号成功')
} catch (error) {
callLoading.value = false
console.log(error);
}
}
onMounted(() => {
// resetMembrform.value = { ...membrform.value }
asyncorderfindOrder()