特殊棚添加

master
xce 2026-01-11 22:29:38 +08:00
parent 7f493da241
commit 9eaf3e7e71
1 changed files with 27 additions and 16 deletions

View File

@ -360,26 +360,37 @@ export default {
}, },
makeSpecialData(msgData, tag) { makeSpecialData(msgData, tag) {
const div10 = (v) => (v == null ? null : Math.round((Number(v)/10)*10)/10) const div10 = (v) => (v == null ? null : Math.round((Number(v)/10)*10)/10);
//
const IMEI_SENSOR_MAP = { // 1. B/Ctag
A: SENSOR_MAP, const B_KEYS = {
B: tag?{temp1:'205',humi1:'105',temp2:'206',humi2:'106',temp3:'207',humi3:'107',temp4:'208',humi4:'108'} true: {temp1:'205',humi1:'105',temp2:'206',humi2:'106',temp3:'207',humi3:'107',temp4:'208',humi4:'108'},
:{temp1:'temp5',humi1:'humi5',temp2:'temp6',humi2:'humi6',temp3:'temp7',humi3:'humi7',temp4:'temp8',humi4:'humi8'}, false: {temp1:'temp5',humi1:'humi5',temp2:'temp6',humi2:'humi6',temp3:'temp7',humi3:'humi7',temp4:'temp8',humi4:'humi8'}
C: tag?{temp1:'209',humi1:'109',temp2:'210',humi2:'110',temp3:'211',humi3:'111',temp4:'212',humi4:'112'} };
:{temp1:'temp9',humi1:'humi9',temp2:'temp10',humi2:'humi10',temp3:'temp11',humi3:'humi11',temp4:'temp12',humi4:'humi12'}, const C_KEYS = {
true: {temp1:'209',humi1:'109',temp2:'210',humi2:'110',temp3:'211',humi3:'111',temp4:'212',humi4:'112'},
false: {temp1:'temp9',humi1:'humi9',temp2:'temp10',humi2:'humi10',temp3:'temp11',humi3:'humi11',temp4:'temp12',humi4:'humi12'}
}; };
// // 2.
const IMEI_SENSOR_MAP = {
A: SENSOR_MAP,
B: B_KEYS[tag], // tag
C: C_KEYS[tag]
};
// 3.
const isAdmin = store.getters?.name === 'admin'; const isAdmin = store.getters?.name === 'admin';
const sensorKeys = (isAdmin && ['A','B','C'].includes(this.imei)) const sk = (isAdmin && ['A','B','C'].includes(this.imei)) ? IMEI_SENSOR_MAP[this.imei] : IMEI_SENSOR_MAP.A;
? IMEI_SENSOR_MAP[this.imei]
: IMEI_SENSOR_MAP.A; // 4. liveData
// liveData
this.liveData = Object.fromEntries( this.liveData = Object.fromEntries(
Object.entries(sensorKeys).map(([key, sensorKey]) => [ Object.entries(sk).map(([k, skVal]) => [
key, k,
(tag?div10(msgData[sensorKey]):(this.imei==='A'?msgData[key]: msgData[sensorKey]))|| "已离线..." (tag
? div10(msgData[skVal])
: (this.imei === 'A' ? msgData[k] : msgData[skVal]))
|| "已离线..."
]) ])
); );
}, },