jsk 小票打印机提交

This commit is contained in:
jiask 2025-11-21 10:41:40 +08:00
parent 73308c98ee
commit b2fcf4ae4f
1 changed files with 51 additions and 48 deletions

View File

@ -223,11 +223,7 @@
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" width="80"/> <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" width="80"/>
<el-table-column label="用户编号" align="center" prop="userId" :show-overflow-tooltip="true" width="120"/> <el-table-column label="用户编号" align="center" prop="userId" :show-overflow-tooltip="true" width="120"/>
<el-table-column label="用户姓名" align="center" prop="nickName" :show-overflow-tooltip="true" width="100"/> <el-table-column label="用户姓名" align="center" prop="nickName" :show-overflow-tooltip="true" width="100"/>
<el-table-column label="用户手机号" align="center" prop="phoneNumber" :show-overflow-tooltip="true" width="120"> <el-table-column label="用户手机号" align="center" prop="phoneNumber" :show-overflow-tooltip="true" width="120"/>
<template scope="scope">
<span>{{ hidePhone(scope.row.phoneNumber) }}</span>
</template>
</el-table-column>
<el-table-column label="所属组织" align="center" prop="deptFullName" :show-overflow-tooltip="true" width="120"/> <el-table-column label="所属组织" align="center" prop="deptFullName" :show-overflow-tooltip="true" width="120"/>
<el-table-column label="所属区域" align="center" prop="areaName" :show-overflow-tooltip="true" width="120"/> <el-table-column label="所属区域" align="center" prop="areaName" :show-overflow-tooltip="true" width="120"/>
<el-table-column label="所属食堂" align="center" prop="canteenName" :show-overflow-tooltip="true" width="120"/> <el-table-column label="所属食堂" align="center" prop="canteenName" :show-overflow-tooltip="true" width="120"/>
@ -551,16 +547,16 @@
<!-- 提醒对话框 --> <!-- 提醒对话框 -->
<el-dialog :title="handleType+'提醒'" :visible.sync="openRemind" width="40%" append-to-body> <el-dialog :title="handleType+'提醒'" :visible.sync="openRemind" width="40%" append-to-body>
<!-- <div>--> <div>
<!-- <el-select v-model="printerName" clearable collapse-tags style="width: 220px">--> <el-select v-model="printerName" clearable collapse-tags style="width: 220px">
<!-- <el-option--> <el-option
<!-- v-for="item in printList"--> v-for="item in printList"
<!-- :key="item.value"--> :key="item.value"
<!-- :label="item.name"--> :label="item.name"
<!-- :value="item.value"--> :value="item.value"
<!-- />--> />
<!-- </el-select>--> </el-select>
<!-- </div>--> </div>
<div class="remind-question">请问是否对以下可{{ handleType }}订单进行{{ handleType }}操作</div> <div class="remind-question">请问是否对以下可{{ handleType }}订单进行{{ handleType }}操作</div>
<div class="remind-title">{{ handleType }}订单 {{ ableList.length }} </div> <div class="remind-title">{{ handleType }}订单 {{ ableList.length }} </div>
<div v-for="(item,index) in ableList" :key="item.orderId">{{ (index + 1) }}. <div v-for="(item,index) in ableList" :key="item.orderId">{{ (index + 1) }}.
@ -708,7 +704,6 @@ export default {
created() { created() {
// this.printerName = '' // this.printerName = ''
// this.printList = [] // this.printList = []
this.getAreaTreeData() this.getAreaTreeData()
this.getDeptTree() this.getDeptTree()
this.getList() this.getList()
@ -725,29 +720,37 @@ export default {
}) })
}, },
updatePrinterList(printers) { updatePrinterList(printers) {
console.log("Printers from getPrinterList:", printers) this.printList = printers.map(item => ({
if (!Array.isArray(printers)) { name: item.logicalName,
console.error('Expected an array of printers, but got:', typeof printers) value: item.logicalName
return }))
}
this.printList = Array.isArray(printers)
? printers.map((item, index) => ({
name: item.logicalName,
value: index,
}))
: []
console.log('Available printers:', this.printList) console.log('Available printers:', this.printList)
console.log('Available printers size:', this.printList.length)
if (this.printList.length > 0) { if (this.printList.length > 0) {
console.log('Setting default printer to:', this.printList[0].value) this.printerName = this.printList[0].name
this.printerName = this.printList[0].value
} }
console.log('this.printerName:', this.printerName) // console.log("Printers from getPrinterList:", printers)
console.log('this.printList:', this.printList) // if (!Array.isArray(printers)) {
this.$nextTick(() => { // console.error('Expected an array of printers, but got:', typeof printers)
// // return
this.$forceUpdate() // }
}) // this.printList = Array.isArray(printers)
// ? printers.map((item, index) => ({
// name: item.logicalName,
// value: index,
// }))
// : []
// console.log('Available printers:', this.printList)
// console.log('Available printers size:', this.printList.length)
// if (this.printList.length > 0) {
// console.log('Setting default printer to:', this.printList[0].value)
// this.printerName = this.printList[0].value
// }
// console.log('this.printerName:', this.printerName)
// console.log('this.printList:', this.printList)
// this.$nextTick(() => {
// //
// this.$forceUpdate()
// })
}, },
// //
getAreaTreeData() { getAreaTreeData() {
@ -1068,15 +1071,15 @@ export default {
this.$modal.msgSuccess('批量核销完成') this.$modal.msgSuccess('批量核销完成')
} }
if (this.handleType == '打印小票') { if (this.handleType == '打印小票') {
// if (this.printList.length === 0) { if (this.printList.length === 0) {
// this.$modal.msgWarning(',,') this.$modal.msgWarning('请先开启小票打印机服务,获取打印机列表,可尝试强制刷新浏览器!')
// return return
// } }
// if (this.printerName === '') { if (this.printerName === '') {
// this.$modal.msgWarning('') this.$modal.msgWarning('请先选择小票打印机!')
// return return
// } }
const _titles = ['菜品名称', '数量', '单价', '总价'] const _titles = ['菜品名称', '数量', '订单', '金额']
const _columnWidths = [20, 10, 10, 8] const _columnWidths = [20, 10, 10, 8]
console.log(this.ableList) console.log(this.ableList)
this.ableList.forEach(item => { this.ableList.forEach(item => {
@ -1085,8 +1088,8 @@ export default {
let row = [] let row = []
row.push(it.goodsName) row.push(it.goodsName)
row.push(it.quantity) row.push(it.quantity)
row.push((it.salePrice / 100).toFixed(2)) row.push((it.payableAmount / 100).toFixed(2))
row.push((it.totalAmount / 100).toFixed(2)) row.push((it.payableAmount / 100).toFixed(2))
_rows.push(row) _rows.push(row)
}) })
this.PosPrinter.cleanBuffer() this.PosPrinter.cleanBuffer()
@ -1105,7 +1108,7 @@ export default {
.printAndFeed(2) .printAndFeed(2)
.feedAndCut(50) .feedAndCut(50)
//TODO //TODO
this.prepareAndPrint('Printer1') this.prepareAndPrint(this.printerName);
}) })
this.$modal.msgSuccess('打印小票完成') this.$modal.msgSuccess('打印小票完成')