1.1.1
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">说明</text>
|
||||
<text class="value value-desc">{{ scanMode === 'uniapp' ? '使用默认摄像头扫码' : scanMode === 'idata' ? '仅支持 iData 设备内置扫码' : '通用 Android PDA 设备' }}
|
||||
<text class="value value-desc">{{ scanModeDesc }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -130,10 +130,22 @@ export default {
|
||||
scanModeText() {
|
||||
const map = {
|
||||
uniapp: '安卓设备',
|
||||
idata: 'IDATA PDA设备',
|
||||
android: '带扫码PDA设备'
|
||||
idata: 'IDATA设备',
|
||||
android: '通用扫码设备',
|
||||
pda: 'PDA设备'
|
||||
}
|
||||
return map[this.scanMode] || '安卓设备'
|
||||
},
|
||||
|
||||
// 扫码模式说明
|
||||
scanModeDesc() {
|
||||
const map = {
|
||||
uniapp: '使用默认摄像头扫码',
|
||||
idata: '仅支持 iData 设备内置扫码',
|
||||
android: '通用 Android PDA 设备',
|
||||
pda: '带物理扫码键 PDA 设备(hbyapi 广播协议)'
|
||||
}
|
||||
return map[this.scanMode] || '使用默认摄像头扫码'
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -174,8 +186,9 @@ export default {
|
||||
// 使用对象数组,key:value 形式定义选项
|
||||
const modeOptions = [
|
||||
{ key: 'uniapp', label: '安卓设备' },
|
||||
{ key: 'idata', label: 'IDATA PDA设备' },
|
||||
{ key: 'android', label: '带扫码PDA设备' }
|
||||
{ key: 'idata', label: 'IDATA设备' },
|
||||
{ key: 'android', label: '通用扫码设备' },
|
||||
{ key: 'pda', label: 'PDA设备' }
|
||||
]
|
||||
|
||||
const res = await uni.showActionSheet({
|
||||
|
||||
@@ -294,9 +294,10 @@ export default {
|
||||
*/
|
||||
selectCommandType(type) {
|
||||
this.commandType = type
|
||||
printerService.setCommandType(type)
|
||||
// 切换指令类型时同步更新纸张尺寸
|
||||
printerService.setPaperSize(this.paperWidth, this.paperHeight)
|
||||
// 测试页临时切换指令类型,不覆盖正式配置
|
||||
printerService.setCommandTypeTemporary(type)
|
||||
// 切换指令类型时同步更新纸张尺寸(临时生效)
|
||||
printerService.setPaperSizeTemporary(this.paperWidth, this.paperHeight)
|
||||
},
|
||||
/**
|
||||
* 选择打印纸尺寸
|
||||
@@ -304,7 +305,8 @@ export default {
|
||||
selectPaperSize(width, height) {
|
||||
this.paperWidth = width
|
||||
this.paperHeight = height
|
||||
printerService.setPaperSize(width, height)
|
||||
// 测试页临时切换纸张尺寸,不覆盖正式配置
|
||||
printerService.setPaperSizeTemporary(width, height)
|
||||
},
|
||||
/**
|
||||
* 快捷模板
|
||||
@@ -325,29 +327,29 @@ export default {
|
||||
riqi: new Date().toISOString().split('T')[0],
|
||||
zhongliang: '10kg',
|
||||
beizhu: '测试备注',
|
||||
biaoshi: '',
|
||||
biaoshi: [1, 2, 3, 4],
|
||||
qrcode: 'https://www.cswm.org.cn/qr/?code=7G6MOYELnFHZfF1Y0F8e6gjxR2K2pALNJJNhJSuOg17LV6IZfuDWUnF2qC3Rsdejs&type=WFBQ'
|
||||
}
|
||||
// 确保 service 使用当前的 commandType 和 paperSize
|
||||
printerService.setCommandType(this.commandType)
|
||||
printerService.setPaperSize(this.paperWidth, this.paperHeight)
|
||||
// 确保 service 使用当前的 commandType 和 paperSize(临时生效,不覆盖配置)
|
||||
printerService.setCommandTypeTemporary(this.commandType)
|
||||
printerService.setPaperSizeTemporary(this.paperWidth, this.paperHeight)
|
||||
this.printContent = printerService.generateWasteLabel(testData)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'qrcode') {
|
||||
printerService.setCommandType(this.commandType)
|
||||
printerService.setPaperSize(this.paperWidth, this.paperHeight)
|
||||
if (type === 'qrcode') {
|
||||
printerService.setCommandTypeTemporary(this.commandType)
|
||||
printerService.setPaperSizeTemporary(this.paperWidth, this.paperHeight)
|
||||
this.printContent = printerService.generateQRCodeTemplate('https://www.example.com')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'barcode') {
|
||||
printerService.setCommandType(this.commandType)
|
||||
printerService.setPaperSize(this.paperWidth, this.paperHeight)
|
||||
if (type === 'barcode') {
|
||||
printerService.setCommandTypeTemporary(this.commandType)
|
||||
printerService.setPaperSizeTemporary(this.paperWidth, this.paperHeight)
|
||||
this.printContent = printerService.generateBarcodeTemplate('1234567890')
|
||||
return
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 清空打印内容
|
||||
@@ -367,9 +369,9 @@ export default {
|
||||
|
||||
this.isPrinting = true
|
||||
try {
|
||||
// 确保打印前同步配置
|
||||
printerService.setCommandType(this.commandType)
|
||||
printerService.setPaperSize(this.paperWidth, this.paperHeight)
|
||||
// 确保打印前同步配置(测试页临时生效,不覆盖正式配置)
|
||||
printerService.setCommandTypeTemporary(this.commandType)
|
||||
printerService.setPaperSizeTemporary(this.paperWidth, this.paperHeight)
|
||||
await printerService.printText(this.printContent)
|
||||
uni.showToast({ title: '打印成功', icon: 'success' })
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user