1.1.1
This commit is contained in:
+40
-3
@@ -82,6 +82,13 @@ export default {
|
||||
expanded: false
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 从台账详情跳转:携带数字识别码,自动查询
|
||||
if (options && options.code) {
|
||||
this.form.code = decodeURIComponent(options.code)
|
||||
this.handleQuery()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 扫码结果回调:填充数字识别码 -> 自动查询 */
|
||||
onBarcodeScanned(barcode) {
|
||||
@@ -119,13 +126,17 @@ export default {
|
||||
uni.showToast({ title: '打印中...', icon: 'none' })
|
||||
try {
|
||||
await printerService.init()
|
||||
await printerService.autoConnect()
|
||||
const connected = await printerService.autoConnect()
|
||||
if (!connected) {
|
||||
// 真实失败原因已在 printerService 内 console.error 输出
|
||||
throw new Error('打印机连接失败,请检查设备蓝牙是否开启或已配对')
|
||||
}
|
||||
await printerService.printWasteLabel(printData)
|
||||
await this.handleDisconnect()
|
||||
uni.showToast({ title: '打印成功', icon: 'success' })
|
||||
} catch (error) {
|
||||
console.error('[补打] 打印失败:', error)
|
||||
uni.showToast({ title: '打印失败: ' + error, icon: 'none' })
|
||||
uni.showToast({ title: '打印失败: ' + error.message, icon: 'none' })
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
@@ -142,6 +153,32 @@ export default {
|
||||
}
|
||||
},
|
||||
// #endif
|
||||
/**
|
||||
* 解析危废危险特性,返回标识点位置编号数组
|
||||
* 固定映射:1=腐蚀性(左上)、2=毒性(右上)、3=易燃性(左下)、4=反应性(右下)
|
||||
* 感染性不占位
|
||||
* @param {Object} data 危废信息对象(危险特性字段 hazardous_properties 或 wxtx,逗号分隔)
|
||||
* @returns {number[]} 位置编号数组,如 [1,2,3,4]
|
||||
*/
|
||||
processBiaoshi(data) {
|
||||
const raw = (data && (data.hazardous_properties || data.wxtx)) || '';
|
||||
if (!raw) return [];
|
||||
const properties = raw.split(',').map(s => s.trim()).filter(Boolean);
|
||||
const PROPERTY_TO_POSITION = {
|
||||
'腐蚀性': 1,
|
||||
'毒性': 2,
|
||||
'易燃性': 3,
|
||||
'反应性': 4
|
||||
};
|
||||
const positions = [];
|
||||
properties.forEach(prop => {
|
||||
const pos = PROPERTY_TO_POSITION[prop];
|
||||
if (pos !== undefined && !positions.includes(pos)) {
|
||||
positions.push(pos);
|
||||
}
|
||||
});
|
||||
return positions;
|
||||
},
|
||||
printData() {
|
||||
const printData = {
|
||||
'mingcheng': this.previewData.fwmc || '', // 危废名称
|
||||
@@ -157,7 +194,7 @@ export default {
|
||||
'riqi': (this.previewData.cssj || '').split(' ')[0], // 产生时间(仅日期)
|
||||
'zhongliang': (this.previewData.csl || '') + ' ' + (this.previewData.jldw || ''), // 重量
|
||||
'beizhu': this.previewData.wxtx || '-', // 备注 危险特征
|
||||
'biaoshi': '', // 标识
|
||||
'biaoshi': this.processBiaoshi(this.previewData), // 标识(危险特性点位)
|
||||
'qrcode': this.previewData.wxfwbqewm || '', // 二维码
|
||||
'lianxidianhua': this.previewData.lxrsj || '', // 联系电话
|
||||
'rongqileixing': this.previewData.rqlx || '', // 容器类型
|
||||
|
||||
Reference in New Issue
Block a user