fix(订单复核): 自动读秤打开弹窗时实时重量未回填称重输入框
- 抽取 tryAutoFillWeighFromScale() 复用自动回填逻辑 - 称重弹窗打开且「已连接+自动读秤」时立即回填当前重量, 修复秤在弹窗打开前已稳定读数时 scaleWeight 不再变化、 watcher 不再触发导致「实时重量有值但输入框未回填」的问题 - 版本号 1.0.125 → 1.0.127
This commit is contained in:
parent
445e4aa209
commit
e21e9d7464
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wms-pda",
|
||||
"version": "1.0.125",
|
||||
"version": "1.0.127",
|
||||
"private": true,
|
||||
"description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)",
|
||||
"scripts": {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "WMS_PDA",
|
||||
"appid" : "__UNI__0B3DAD3",
|
||||
"description" : "多平台快速开发的UI框架",
|
||||
"versionName" : "1.0.125",
|
||||
"versionName" : "1.0.127",
|
||||
"versionCode" : 1000123,
|
||||
"transformPx" : false,
|
||||
"app-plus" : {
|
||||
|
||||
@ -815,6 +815,9 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
|
||||
// 蓝牙秤已连接且开启自动读秤时不聚焦输入框,避免键盘反复弹出闪烁;其余情况保持历史聚焦行为
|
||||
if (this.isScaleConnected && this.autoReadScale) {
|
||||
this.weighInputFocused = false;
|
||||
// 立即用当前已有重量回填:若秤在弹窗打开前已稳定读数,scaleWeight 不再变化,
|
||||
// watcher 不会再次触发,导致「实时重量有值但输入框未回填」
|
||||
this.tryAutoFillWeighFromScale();
|
||||
} else {
|
||||
this._programmaticFocus = true;
|
||||
this.weighInputFocused = false;
|
||||
@ -827,23 +830,8 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
|
||||
}
|
||||
},
|
||||
scaleWeight(val) {
|
||||
if (!this.autoReadScale || !this.showWeighPopup || !this.isScaleConnected || val === null || val === undefined) return;
|
||||
// 用户正在手动编辑时不打断输入
|
||||
if (this.weightEditing) return;
|
||||
const g = this.scaleWeightInGrams();
|
||||
if (g === '') return;
|
||||
const gNum = Math.round(Number(g));
|
||||
if (String(gNum) === String(this.weighWeight)) return;
|
||||
// 阈值保护:重量变化未超过阈值时不回填,避免秤抖动反复覆盖
|
||||
if (this.lastAutoWeight !== '' && !isNaN(gNum) && Math.abs(gNum - Number(this.lastAutoWeight)) < this.autoReadThresholdG) {
|
||||
return;
|
||||
}
|
||||
this.lastAutoWeight = String(g);
|
||||
// App 端聚焦中的原生 input 不响应数据更新,先失焦再回填
|
||||
this.weighInputFocused = false;
|
||||
this.$nextTick(() => {
|
||||
this.weighWeight = gNum;
|
||||
});
|
||||
if (val === null || val === undefined) return;
|
||||
this.tryAutoFillWeighFromScale();
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@ -3340,6 +3328,25 @@ import ReviewDetail from './order-review-comps/ReviewDetail.vue';
|
||||
onWeighInputBlur() {
|
||||
this.weightEditing = false;
|
||||
},
|
||||
tryAutoFillWeighFromScale() {
|
||||
if (!this.autoReadScale || !this.showWeighPopup || !this.isScaleConnected) return;
|
||||
// 用户正在手动编辑时不打断输入
|
||||
if (this.weightEditing) return;
|
||||
const g = this.scaleWeightInGrams();
|
||||
if (g === '') return;
|
||||
const gNum = Math.round(Number(g));
|
||||
if (String(gNum) === String(this.weighWeight)) return;
|
||||
// 阈值保护:重量变化未超过阈值时不回填,避免秤抖动反复覆盖
|
||||
if (this.lastAutoWeight !== '' && !isNaN(gNum) && Math.abs(gNum - Number(this.lastAutoWeight)) < this.autoReadThresholdG) {
|
||||
return;
|
||||
}
|
||||
this.lastAutoWeight = String(g);
|
||||
// App 端聚焦中的原生 input 不响应数据更新,先失焦再回填
|
||||
this.weighInputFocused = false;
|
||||
this.$nextTick(() => {
|
||||
this.weighWeight = gNum;
|
||||
});
|
||||
},
|
||||
scaleWeightInGrams() {
|
||||
const raw = this.scaleWeight;
|
||||
if (raw === null || raw === undefined || raw === '') return '';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user