fix: 数据补报解析
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 24s
All checks were successful
iot-test-platform CI/CD / build-and-deploy (push) Successful in 24s
This commit is contained in:
@@ -149,6 +149,23 @@
|
||||
</ul>
|
||||
|
||||
<div v-if="mode === 'badge'">
|
||||
<div v-if="mode === 'command'">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">接口类型</label>
|
||||
<select v-model="commandForm.apiType" class="form-select form-select-sm" @change="updateJsonTemplate">
|
||||
<option value="location">位置查询 (8201)</option>
|
||||
<option value="text">文本下发 (8300)</option>
|
||||
<option value="general">通用指令 (API)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">请求参数 (JSON)</label>
|
||||
<textarea v-model="commandForm.jsonBody" class="form-control font-monospace form-control-sm" rows="8"></textarea>
|
||||
</div>
|
||||
<button @click="sendCommand" class="btn btn-primary btn-sm w-100">
|
||||
<i class="fas fa-terminal me-2"></i>发送指令
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">工牌 ID</label>
|
||||
<input v-model="badgeForm.id" class="form-control form-control-sm" placeholder="BADGE-001">
|
||||
@@ -199,23 +216,6 @@
|
||||
<button @click="sendCustomJson" class="btn btn-secondary btn-sm w-100">发送自定义数据</button>
|
||||
</div>
|
||||
|
||||
<div v-if="mode === 'command'">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">接口类型</label>
|
||||
<select v-model="commandForm.apiType" class="form-select form-select-sm" @change="updateJsonTemplate">
|
||||
<option value="location">位置查询 (8201)</option>
|
||||
<option value="text">文本下发 (8300)</option>
|
||||
<option value="general">通用指令 (API)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small text-muted">请求参数 (JSON)</label>
|
||||
<textarea v-model="commandForm.jsonBody" class="form-control font-monospace form-control-sm" rows="8"></textarea>
|
||||
</div>
|
||||
<button @click="sendCommand" class="btn btn-primary btn-sm w-100">
|
||||
<i class="fas fa-terminal me-2"></i>发送指令
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -278,7 +278,7 @@
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div v-if="badge.location" class="text-dark fw-bold mb-1" title="点击查看详情">
|
||||
{{ badge.location.lat.toFixed(4) }}, {{ badge.location.lon.toFixed(4) }}
|
||||
{{ badge.location.lat.toFixed(6) }}, {{ badge.location.lon.toFixed(6) }}
|
||||
</div>
|
||||
<div v-else class="text-muted mb-1">-</div>
|
||||
<div class="text-muted" style="font-size: 0.7rem;">GPS坐标</div>
|
||||
@@ -288,14 +288,21 @@
|
||||
|
||||
<!-- 详细蓝牙列表 (折叠展示) -->
|
||||
<div v-if="badge.bluetooth && badge.bluetooth.length > 0" class="mt-2 bg-light rounded p-2" style="font-size: 0.75rem;">
|
||||
<div v-for="(ble, idx) in badge.bluetooth.slice(0, 2)" :key="idx" class="d-flex justify-content-between text-muted">
|
||||
<div v-for="(ble, idx) in badge.bluetooth.slice(0, 4)" :key="idx" class="d-flex justify-content-between text-muted">
|
||||
<span>MAC: {{ ble.mac }}</span>
|
||||
<span>RSSI: {{ ble.rssi }}</span>
|
||||
<span>RSSI: {{ ble.rssi }} dBm</span>
|
||||
</div>
|
||||
<div v-if="badge.bluetooth.length > 2" class="text-center text-primary" style="font-size: 0.7rem;">
|
||||
+{{ badge.bluetooth.length - 2 }} 更多...
|
||||
<div v-if="badge.bluetooth.length > 4" class="text-center text-primary" style="font-size: 0.7rem;">
|
||||
+{{ badge.bluetooth.length - 4 }} 更多...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 按键事件提示 -->
|
||||
<div v-if="badge.lastButtonEvent" class="mt-2 alert alert-warning p-1 mb-0 text-center" style="font-size: 0.75rem;">
|
||||
<i class="fas fa-hand-pointer me-1"></i>
|
||||
{{ formatButtonEvent(badge.lastButtonEvent) }}
|
||||
<span class="text-muted ms-1">({{ formatTime(badge.lastButtonEvent.timestamp) }})</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -444,10 +451,26 @@
|
||||
|
||||
// 1. 处理工牌数据 (识别 type=badge)
|
||||
if (data.type === 'badge' && data.id) {
|
||||
// 合并旧数据,保留 lastButtonEvent 如果新数据没有覆盖它
|
||||
const oldData = this.badges[data.id] || {};
|
||||
const newButtonEvent = data.buttonEvent;
|
||||
|
||||
this.badges[data.id] = {
|
||||
...oldData,
|
||||
...data,
|
||||
lastUpdate: now
|
||||
lastUpdate: now,
|
||||
// 如果这次是按键事件,更新 lastButtonEvent;否则保留旧的(可以加个超时自动清除逻辑)
|
||||
lastButtonEvent: newButtonEvent || oldData.lastButtonEvent
|
||||
};
|
||||
|
||||
// 简单的超时清除按键提示 (5秒后消失)
|
||||
if (newButtonEvent) {
|
||||
setTimeout(() => {
|
||||
if (this.badges[data.id] && this.badges[data.id].lastButtonEvent === newButtonEvent) {
|
||||
this.badges[data.id].lastButtonEvent = null;
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 处理计数器数据 (识别 type=counter)
|
||||
@@ -603,6 +626,20 @@
|
||||
if (source === 'SYSTEM') return 'bg-info text-dark';
|
||||
if (source === 'TCP') return 'bg-warning text-dark';
|
||||
return 'bg-success';
|
||||
},
|
||||
formatButtonEvent(evt) {
|
||||
if (!evt) return '';
|
||||
let action = '按键';
|
||||
// 0x01-0x0A: 短按
|
||||
if (evt.keyId >= 0x01 && evt.keyId <= 0x0A) {
|
||||
action = `短按 ${evt.keyId}号键`;
|
||||
}
|
||||
// 0x0B-0x14: 长按
|
||||
else if (evt.keyId >= 0x0B && evt.keyId <= 0x14) {
|
||||
const keyNum = evt.keyId - 0x0A;
|
||||
action = `长按 ${keyNum}号键`;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
|
||||
Reference in New Issue
Block a user