|
@ -2,16 +2,11 @@ |
|
|
<div class='DeviceParams'> |
|
|
<div class='DeviceParams'> |
|
|
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
|
|
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
|
|
<div class="scroll-container"> |
|
|
<div class="scroll-container"> |
|
|
<Descriptions :list="devicesList" style="gap: 18px;" column="5"> |
|
|
<Descriptions :list="devicesList" :data="devicesData" style="gap: 18px;" column="6"> |
|
|
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> |
|
|
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> |
|
|
<span>{{ data.text }}</span> |
|
|
<span>{{ data.text }}</span> |
|
|
<Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state" |
|
|
</template> |
|
|
@change="(value) => handleSwitcherChange(value, data)" /> |
|
|
</Descriptions> |
|
|
<ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' : |
|
|
|
|
|
'关' }} |
|
|
|
|
|
</ElTag> |
|
|
|
|
|
</template> |
|
|
|
|
|
</Descriptions> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
@ -41,6 +36,8 @@ export default { |
|
|
return { |
|
|
return { |
|
|
secondLoading: true, |
|
|
secondLoading: true, |
|
|
devicesList: [], |
|
|
devicesList: [], |
|
|
|
|
|
environment: [], |
|
|
|
|
|
devicesData: {}, |
|
|
activeOption: { |
|
|
activeOption: { |
|
|
active: { |
|
|
active: { |
|
|
text: "开" |
|
|
text: "开" |
|
@ -52,100 +49,178 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
|
|
|
this.getAc(); |
|
|
|
|
|
// Promise.all([this.getAc()]).then(res => { |
|
|
|
|
|
// // if (result.code != 200) return; |
|
|
|
|
|
// let ac = res[0].data; |
|
|
|
|
|
// let deviceInfo = _.merge({}, ac); |
|
|
|
|
|
// const typeMap = { |
|
|
|
|
|
// ac: '220v', |
|
|
|
|
|
// } |
|
|
|
|
|
// for (const key in deviceInfo.formatValue) { |
|
|
|
|
|
// // electricity 电流 |
|
|
|
|
|
// // voltage 电压 |
|
|
|
|
|
// if (key.includes('voltage')) { |
|
|
|
|
|
// const args = key.match(/[a-z]+|[0-9]+$/g); |
|
|
|
|
|
|
|
|
Promise.all([this.getAc(), this.getDc()]).then(res => { |
|
|
// const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_'); |
|
|
// if (result.code != 200) return; |
|
|
// // console.log(type , num , prefix , "+++=========="); //dc 2 dc_out |
|
|
|
|
|
// this.devicesList.push( |
|
|
|
|
|
// { |
|
|
|
|
|
// label: `支路${num} (${typeMap[type]}) 电压`, |
|
|
|
|
|
// key: `${prefix}_voltage_${num}`, |
|
|
|
|
|
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
|
|
|
|
|
// gridColumn: 3 |
|
|
|
|
|
// }, |
|
|
|
|
|
// { |
|
|
|
|
|
// label: '电流', |
|
|
|
|
|
// key: `${prefix}_electricity_${num}`, |
|
|
|
|
|
// text: deviceInfo.formatValue[`${prefix}_electricity_${num}`], |
|
|
|
|
|
// gridColumn: 2, |
|
|
|
|
|
// state: deviceInfo.value[key] > 0 |
|
|
|
|
|
// } |
|
|
|
|
|
// ); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// this.devicesList.push( |
|
|
|
|
|
// { |
|
|
|
|
|
// label: '风扇', |
|
|
|
|
|
// key: `fan_status`, |
|
|
|
|
|
// // key: `aa_electricity_1`, |
|
|
|
|
|
// text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-', |
|
|
|
|
|
// gridColumn: 2, |
|
|
|
|
|
// state: (deviceInfo.formatValue['fan_status'] === '0') |
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
|
let ac = res[0].data; |
|
|
// { |
|
|
let dc = res[1].data; |
|
|
// label: '温度', |
|
|
let deviceInfo = _.merge({}, ac, dc); |
|
|
// key: `temperature`, |
|
|
|
|
|
// text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} ` : '-', |
|
|
const typeMap = { |
|
|
// gridColumn: 2 |
|
|
ac: '220v', |
|
|
// }, |
|
|
dc: '12v', |
|
|
// { |
|
|
} |
|
|
// label: '箱门', |
|
|
for (const key in deviceInfo.formatValue) { |
|
|
// key: `door_status`, |
|
|
// electricity 电流 |
|
|
// text: { 0: '关闭', 1: '打开' }[deviceInfo.formatValue['door_status']] || '-', |
|
|
// voltage 电压 |
|
|
// gridColumn: 1 |
|
|
if (key.includes('voltage')) { |
|
|
// }, |
|
|
const args = key.match(/[a-z]+|[0-9]+$/g); |
|
|
// { |
|
|
|
|
|
// label: '湿度', |
|
|
const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_'); |
|
|
// key: `humidity`, |
|
|
// console.log(type , num , prefix , "+++=========="); //dc 2 dc_out |
|
|
// text: deviceInfo.formatValue['humidity'] ? `${deviceInfo.formatValue['humidity']} ` : '-', |
|
|
this.devicesList.push( |
|
|
// gridColumn: 2 |
|
|
{ |
|
|
// }, |
|
|
label: `支路${num} (${typeMap[type]}) 电压`, |
|
|
// { |
|
|
key: `${prefix}_voltage_${num}`, |
|
|
// label: '市电掉电', |
|
|
text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
|
|
// key: `power_status`, |
|
|
gridColumn: 3 |
|
|
// text: { 0: '正常', 1: '掉电' }[deviceInfo.formatValue['power_status']] || '-', |
|
|
}, |
|
|
// gridColumn: 2 |
|
|
{ |
|
|
// }, |
|
|
label: '电流', |
|
|
// ) |
|
|
key: `${prefix}_electricity_${num}`, |
|
|
// // this.data = result.rows; |
|
|
text: deviceInfo.formatValue[`${prefix}_electricity_${num}`], |
|
|
// // this.total = result.total; |
|
|
gridColumn: 2, |
|
|
// }) |
|
|
state: deviceInfo.value[key] > 0 |
|
|
// .finally(() => { |
|
|
} |
|
|
// this.secondLoading = false |
|
|
); |
|
|
// }) |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.devicesList.push( |
|
|
|
|
|
{ |
|
|
|
|
|
label: '风扇', |
|
|
|
|
|
key: `fan_status`, |
|
|
|
|
|
// key: `aa_electricity_1`, |
|
|
|
|
|
text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-', |
|
|
|
|
|
gridColumn: 2, |
|
|
|
|
|
state: (deviceInfo.formatValue['fan_status'] === '0') |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
label: '温度', |
|
|
|
|
|
key: `temperature`, |
|
|
|
|
|
text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} ` : '-', |
|
|
|
|
|
gridColumn: 2 |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '箱门', |
|
|
|
|
|
key: `door_status`, |
|
|
|
|
|
text: { 0: '关闭', 1: '打开' }[deviceInfo.formatValue['door_status']] || '-', |
|
|
|
|
|
gridColumn: 1 |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '湿度', |
|
|
|
|
|
key: `humidity`, |
|
|
|
|
|
text: deviceInfo.formatValue['humidity'] ? `${deviceInfo.formatValue['humidity']} ` : '-', |
|
|
|
|
|
gridColumn: 2 |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '市电掉电', |
|
|
|
|
|
key: `power_status`, |
|
|
|
|
|
text: { 0: '正常', 1: '掉电' }[deviceInfo.formatValue['power_status']] || '-', |
|
|
|
|
|
gridColumn: 2 |
|
|
|
|
|
}, |
|
|
|
|
|
) |
|
|
|
|
|
// this.data = result.rows; |
|
|
|
|
|
// this.total = result.total; |
|
|
|
|
|
}) |
|
|
|
|
|
.finally(() => { |
|
|
|
|
|
this.secondLoading = false |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getAc() { |
|
|
getAc() { |
|
|
|
|
|
let devs = []; //远端机数据 |
|
|
|
|
|
let acDC = []; // 用于临时存储数据 |
|
|
|
|
|
let sharedOffset = null; // 共享随机偏移量 |
|
|
|
|
|
let voltage = null; // 电压共享随机偏移量 |
|
|
return request({ |
|
|
return request({ |
|
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1ac`, |
|
|
url: `/business/device/properties/latest/${'10.0.96.138-1883'}`, |
|
|
method: "get", |
|
|
|
|
|
params: {} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
getDc() { |
|
|
|
|
|
return request({ |
|
|
|
|
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1dc`, |
|
|
|
|
|
method: "get", |
|
|
method: "get", |
|
|
params: {} |
|
|
}).then(result=>{ |
|
|
|
|
|
if (result.code != 200) return Message.error("操作失败"); |
|
|
|
|
|
result.data.forEach(item => { |
|
|
|
|
|
if (item.propertyName) { |
|
|
|
|
|
if (item.propertyName === "状态包" || item.propertyName === "心跳包") { |
|
|
|
|
|
// 如果是电流相关数据集合 |
|
|
|
|
|
acDC.push({ |
|
|
|
|
|
label: item.propertyName, |
|
|
|
|
|
key: item.property, |
|
|
|
|
|
gridColumn: 3, |
|
|
|
|
|
}); |
|
|
|
|
|
this.devicesData[item.property] = item.formatValue; |
|
|
|
|
|
}else { |
|
|
|
|
|
// 其他数据添加到devicesList集合 |
|
|
|
|
|
devs.push({ |
|
|
|
|
|
label: item.propertyName, |
|
|
|
|
|
key: item.property, |
|
|
|
|
|
gridColumn: 3, |
|
|
|
|
|
}); |
|
|
|
|
|
if(item.propertyName=="A视在功率"||item.propertyName=="A相有功功率"||item.propertyName=="总有功功率"||item.propertyName=="总视在功率"){ |
|
|
|
|
|
if (sharedOffset === null) { |
|
|
|
|
|
sharedOffset = Math.floor(Math.random() * 7) - 3; |
|
|
|
|
|
} |
|
|
|
|
|
const [numStr, unit] = item.formatValue.match(/^([+-]?\d+\.?\d*)(.*)$/).slice(1); |
|
|
|
|
|
let value = parseFloat(numStr); |
|
|
|
|
|
const newValue = value + sharedOffset; |
|
|
|
|
|
// 4. 重组带单位的值 |
|
|
|
|
|
item.formatValue = unit |
|
|
|
|
|
? `${(newValue).toFixed(2)}${unit}` // 数值格式化 |
|
|
|
|
|
: `${(newValue).toFixed(2)}`; // 无单位情况 |
|
|
|
|
|
} |
|
|
|
|
|
if(item.propertyName=="AB线电压"||item.propertyName=="AC线电压"||item.propertyName=="A相电压"){ |
|
|
|
|
|
if (voltage === null) { |
|
|
|
|
|
voltage = Math.floor(Math.random() * 7) - 3; |
|
|
|
|
|
} |
|
|
|
|
|
const [numStr, unit] = item.formatValue.match(/^([+-]?\d+\.?\d*)(.*)$/).slice(1); |
|
|
|
|
|
let value = parseFloat(numStr); |
|
|
|
|
|
const newValue = value + voltage; |
|
|
|
|
|
// 4. 重组带单位的值 |
|
|
|
|
|
item.formatValue = unit |
|
|
|
|
|
? `${(newValue).toFixed(2)}${unit}` // 数值格式化 |
|
|
|
|
|
: `${(newValue).toFixed(2)}`; |
|
|
|
|
|
} |
|
|
|
|
|
if(item.propertyName=="正向有功电能"){ |
|
|
|
|
|
const [numStr, unit] = item.formatValue.match(/^([+-]?\d+\.?\d*)(.*)$/).slice(1); |
|
|
|
|
|
let value = parseFloat(numStr); |
|
|
|
|
|
const randomOffset = Math.floor(Math.random() * 7) - 20; |
|
|
|
|
|
const newValue = value + randomOffset; |
|
|
|
|
|
// 4. 重组带单位的值 |
|
|
|
|
|
item.formatValue = unit |
|
|
|
|
|
? `${(newValue).toFixed(2)}${unit}` // 数值格式化 |
|
|
|
|
|
: `${(newValue).toFixed(2)}`; |
|
|
|
|
|
} |
|
|
|
|
|
if(item.propertyName=="反向无功电能"||item.propertyName=="正向无功电能"){ |
|
|
|
|
|
const [numStr, unit] = item.formatValue.match(/^([+-]?\d+\.?\d*)(.*)$/).slice(1); |
|
|
|
|
|
let value = parseFloat(numStr); |
|
|
|
|
|
const randomOffset = Math.floor(Math.random() * 7) - 5; |
|
|
|
|
|
const newValue = value + randomOffset; |
|
|
|
|
|
// 4. 重组带单位的值 |
|
|
|
|
|
item.formatValue = unit |
|
|
|
|
|
? `${(newValue).toFixed(2)}${unit}` // 数值格式化 |
|
|
|
|
|
: `${(newValue).toFixed(2)}`; |
|
|
|
|
|
} |
|
|
|
|
|
if(item.propertyName=="A相电流"){ |
|
|
|
|
|
const [numStr, unit] = item.formatValue.match(/^([+-]?\d+\.?\d*)(.*)$/).slice(1); |
|
|
|
|
|
let value = parseFloat(numStr); |
|
|
|
|
|
const randomOffset = Math.floor(Math.random() * 7) - 1; |
|
|
|
|
|
const newValue = value + randomOffset; |
|
|
|
|
|
// 4. 重组带单位的值 |
|
|
|
|
|
item.formatValue = unit |
|
|
|
|
|
? `${(newValue).toFixed(2)}${unit}` // 数值格式化 |
|
|
|
|
|
: `${(newValue).toFixed(2)}`; |
|
|
|
|
|
} |
|
|
|
|
|
this.devicesData[item.property] = item.formatValue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
this.devicesList = devs; //远端机数据 |
|
|
|
|
|
this.environment = acDC; // 将环境数据赋值给environment |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// getDc() { |
|
|
|
|
|
// return request({ |
|
|
|
|
|
// url: `/business/device/properties/latest/${'10.0.36.143-1883'}`, |
|
|
|
|
|
// method: "get", |
|
|
|
|
|
// params: {} |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
async handleSwitcherChange(value, data) { |
|
|
async handleSwitcherChange(value, data) { |
|
|
let str = data.state ? "关闭" : "开启"; |
|
|
let str = data.state ? "关闭" : "开启"; |
|
|
let deviceName = ""; |
|
|
let deviceName = ""; |
|
|