zhoule
7 months ago
10 changed files with 642 additions and 20 deletions
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,55 @@ |
|||||
|
<template> |
||||
|
<Dialog v-model="modelVisible" title="设备操作" width="600px"> |
||||
|
<div class="DeviceControlDialog"> |
||||
|
<DeviceParams :dialogData="dialogData" /> |
||||
|
</div> |
||||
|
</Dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import Dialog from "@screen/components/Dialog/index.vue"; |
||||
|
import DeviceParams from "./DeviceParams.vue"; |
||||
|
|
||||
|
export default { |
||||
|
name: "DeviceControlDialog", |
||||
|
components: { |
||||
|
Dialog, |
||||
|
DeviceParams, |
||||
|
}, |
||||
|
model: { |
||||
|
prop: "visible", |
||||
|
event: "update:value", |
||||
|
}, |
||||
|
props: { |
||||
|
visible: Boolean, |
||||
|
dialogData: { |
||||
|
type: Object, |
||||
|
default: () => ({}), |
||||
|
}, |
||||
|
}, |
||||
|
computed: { |
||||
|
modelVisible: { |
||||
|
get() { |
||||
|
return this.visible; |
||||
|
}, |
||||
|
set(val) { |
||||
|
this.$emit("update:value", val); |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.DeviceControlDialog { |
||||
|
width: 510px; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
gap: 15px; |
||||
|
min-height: 360px; |
||||
|
|
||||
|
.tips { |
||||
|
font-size: 12px; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,199 @@ |
|||||
|
<template> |
||||
|
<div class='DeviceParams'> |
||||
|
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
||||
|
<Descriptions :list="devicesList" style="gap: 18px;" column="5"> |
||||
|
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> |
||||
|
<span>{{ data.text }}</span> |
||||
|
<Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state" |
||||
|
@change="(value) => handleSwitcherChange(value, data)" /> |
||||
|
<ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' : |
||||
|
'关' }} |
||||
|
</ElTag> |
||||
|
</template> |
||||
|
</Descriptions> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import Descriptions from '@screen/components/Descriptions.vue'; |
||||
|
import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue'; |
||||
|
|
||||
|
import request from "@/utils/request"; |
||||
|
import { Message } from 'element-ui'; |
||||
|
import { confirm } from "@screen/utils/common"; |
||||
|
|
||||
|
export default { |
||||
|
name: 'DeviceParams', |
||||
|
components: { |
||||
|
Descriptions, |
||||
|
Switcher |
||||
|
}, |
||||
|
props: { |
||||
|
dialogData: { |
||||
|
type: Object, |
||||
|
default: () => ({}) |
||||
|
}, |
||||
|
disabled: Boolean |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
secondLoading: true, |
||||
|
devicesList: [], |
||||
|
activeOption: { |
||||
|
active: { |
||||
|
text: "开" |
||||
|
}, |
||||
|
unActive: { |
||||
|
text: "关" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
|
||||
|
Promise.all([this.getAc(), this.getDc()]).then(res => { |
||||
|
// if (result.code != 200) return; |
||||
|
|
||||
|
let ac = res[0].data; |
||||
|
let dc = res[1].data; |
||||
|
let deviceInfo = _.merge({}, ac, dc); |
||||
|
|
||||
|
const typeMap = { |
||||
|
ac: '220v', |
||||
|
dc: '12v', |
||||
|
} |
||||
|
for (const key in deviceInfo.formatValue) { |
||||
|
// electricity 电流 |
||||
|
// voltage 电压 |
||||
|
if (key.includes('electricity')) { |
||||
|
const args = key.match(/[a-z]+|[0-9]+$/g); |
||||
|
|
||||
|
const type = args[0], num = args.slice(-1)[0], prefix = args.slice(0, 2).join('_'); |
||||
|
// 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[key], |
||||
|
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') |
||||
|
}, |
||||
|
|
||||
|
{ |
||||
|
label: '温度', |
||||
|
key: `temperature`, |
||||
|
text: deviceInfo.formatValue['temperature'] ? `${deviceInfo.formatValue['temperature']} °C` : '-', |
||||
|
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: { |
||||
|
getAc() { |
||||
|
return request({ |
||||
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1ac`, |
||||
|
method: "get", |
||||
|
params: {} |
||||
|
}) |
||||
|
}, |
||||
|
getDc() { |
||||
|
return request({ |
||||
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || '10.0.36.143-1883'}/1dc`, |
||||
|
method: "get", |
||||
|
params: {} |
||||
|
}) |
||||
|
}, |
||||
|
async handleSwitcherChange(value, data) { |
||||
|
let str = data.state ? "关闭" : "开启"; |
||||
|
let deviceName = ""; |
||||
|
if (data.key.includes("fan")) { |
||||
|
str += "风扇?"; |
||||
|
deviceName = "fan_out_en"; |
||||
|
} else { |
||||
|
str += "该支路?" |
||||
|
deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en; |
||||
|
} |
||||
|
data.state = value; |
||||
|
const isContinue = await confirm({ message: `${str}` }) |
||||
|
.catch(() => { |
||||
|
data.state = !value; |
||||
|
}); |
||||
|
|
||||
|
if (!isContinue) return; |
||||
|
|
||||
|
// https://www.yuque.com/dayuanzhong-ovjwn/gkht0m/ww776d5kzs72ilzh?singleDoc= |
||||
|
request({ |
||||
|
url: `/business/device/functions/${this.dialogData.iotDeviceId}/${102}`, |
||||
|
method: "POST", |
||||
|
data: { |
||||
|
deviceName, |
||||
|
// 开关:1=打开,0=关闭 |
||||
|
value: value ? 1 : 0 |
||||
|
} |
||||
|
}) |
||||
|
.then(result => { |
||||
|
if (result.code != 200) { |
||||
|
Message.error("操作失败"); |
||||
|
data.state = !value; |
||||
|
return; |
||||
|
}; |
||||
|
Message.success("操作成功"); |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
data.state = !value; |
||||
|
Message.error("操作失败"); |
||||
|
}) |
||||
|
}, |
||||
|
getSlotKey(key) { |
||||
|
return key.includes('electricity') || key.includes('fan') ? key : '' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang='scss' scoped> |
||||
|
.DeviceParams { |
||||
|
height: 100%; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,166 @@ |
|||||
|
<template> |
||||
|
<div class='DeviceParams'> |
||||
|
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
||||
|
<Descriptions :list="devicesList" style="gap: 18px;" column="5"> |
||||
|
<template v-for="item in devicesList" #[`content-${item.key}`]="{ data }"> |
||||
|
<span style="font-size: 15px;font-weight: 400;color: #3de8ff;">{{ data.text }}</span> |
||||
|
<Switcher v-if="!disabled" class="switcher" :activeOption="activeOption" :value="data.state" |
||||
|
@change="(value) => handleSwitcherChange(value, data)" /> |
||||
|
<ElTag style="margin-left: 20px;" v-else effect="dark" :type="data.state ? '' : 'info'">{{ data.state ? '开' : |
||||
|
'关' }} |
||||
|
</ElTag> |
||||
|
</template> |
||||
|
</Descriptions> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import Descriptions from '@screen/components/Descriptions.vue'; |
||||
|
import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue'; |
||||
|
import { cloneDeep } from 'lodash'; |
||||
|
import request from "@/utils/request"; |
||||
|
import { Message } from 'element-ui'; |
||||
|
import { confirm } from "@screen/utils/common"; |
||||
|
import { batchFunctions } from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js"; |
||||
|
import { multiResultShow } from "@screen/utils/common"; |
||||
|
|
||||
|
export default { |
||||
|
name: 'DeviceParams', |
||||
|
components: { |
||||
|
Descriptions, |
||||
|
Switcher |
||||
|
}, |
||||
|
props: { |
||||
|
dialogData: { |
||||
|
type: Object, |
||||
|
default: () => ({}) |
||||
|
}, |
||||
|
disabled: Boolean, |
||||
|
isMultiControl: Boolean, |
||||
|
selectItems: { |
||||
|
type: Array, |
||||
|
default: () => [] |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
secondLoading: true, |
||||
|
devicesList: [ |
||||
|
{ |
||||
|
labelHidden: true, |
||||
|
text: `支路1 (220v): `, |
||||
|
key: `ac_out_1_en`, |
||||
|
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
||||
|
gridColumn: 1, |
||||
|
state: 0 |
||||
|
}, |
||||
|
{ |
||||
|
labelHidden: true, |
||||
|
text: `支路2 (220v): `, |
||||
|
key: `ac_out_2_en`, |
||||
|
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
||||
|
gridColumn: 1, |
||||
|
state: 0 |
||||
|
}, |
||||
|
{ |
||||
|
labelHidden: true, |
||||
|
text: `支路1 (12v): `, |
||||
|
key: `dc_out_1_en`, |
||||
|
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
||||
|
gridColumn: 1, |
||||
|
state: 0 |
||||
|
}, |
||||
|
{ |
||||
|
labelHidden: true, |
||||
|
text: `支路2 (12v): `, |
||||
|
key: `dc_out_2_en`, |
||||
|
// text: deviceInfo.formatValue[`${prefix}_voltage_${num}`], |
||||
|
gridColumn: 1, |
||||
|
state: 0 |
||||
|
}, |
||||
|
{ |
||||
|
labelHidden: true, |
||||
|
text: '风扇:', |
||||
|
key: `fan_out_en`, |
||||
|
// text: { 0: '正常', 1: '开' }[deviceInfo.formatValue['fan_status']] || '-', |
||||
|
gridColumn: 1, |
||||
|
state: 0 |
||||
|
}, |
||||
|
], |
||||
|
activeOption: { |
||||
|
active: { |
||||
|
text: "开" |
||||
|
}, |
||||
|
unActive: { |
||||
|
text: "关" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
|
||||
|
}, |
||||
|
methods: { |
||||
|
async handleSwitcherChange(value, data) { |
||||
|
let str = data.state ? "关闭" : "开启"; |
||||
|
let deviceName = data.key; |
||||
|
str += `${data.text.replace(":", "")}?`; |
||||
|
// if (data.key.includes("fan")) { |
||||
|
// str += "风扇?"; |
||||
|
// deviceName = "fan_out_en"; |
||||
|
// } else { |
||||
|
// str += "该支路?" |
||||
|
// deviceName = data.key.match(/^[a-z]+_out|[0-9]+/g).join("_") + "_en"; //dc_out_2_en ac_out_2_en; |
||||
|
// } |
||||
|
data.state = value; |
||||
|
|
||||
|
if (!this.selectItems.length) { |
||||
|
setTimeout(() => { data.state = !value; }, 10); |
||||
|
return Message.error("请至少选择一个设备!"); |
||||
|
} |
||||
|
const selectItems = this.selectItems.map(item => JSON.parse(item)); |
||||
|
|
||||
|
const isContinue = await confirm({ message: `${str}` }) |
||||
|
.catch(() => { |
||||
|
data.state = !value; |
||||
|
}); |
||||
|
|
||||
|
if (!isContinue) return; |
||||
|
|
||||
|
batchFunctions( |
||||
|
{ |
||||
|
"devices": selectItems, |
||||
|
"functions": [ |
||||
|
{ |
||||
|
"functionId": "102", |
||||
|
"params": { |
||||
|
deviceName, |
||||
|
// 开关:1=打开,0=关闭 |
||||
|
value: value ? 1 : 0 |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
}) |
||||
|
.then(result => { |
||||
|
multiResultShow(result.data, item => item.result.code == 200, "操作"); |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
data.state = !value; |
||||
|
Message.error("操作失败"); |
||||
|
}) |
||||
|
}, |
||||
|
getSlotKey(key) { |
||||
|
return key.includes('electricity') || key.includes('fan') ? key : '' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang='scss' scoped> |
||||
|
.DeviceParams { |
||||
|
height: 100%; |
||||
|
padding-right: 9px; |
||||
|
padding-left: 14px; |
||||
|
margin-top: 15px; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,195 @@ |
|||||
|
<template> |
||||
|
<Dialog v-model="obverseVisible" title="远端机" width="600px"> |
||||
|
<Video class="video-stream" :pileNum="dialogData.stakeMark" /> |
||||
|
|
||||
|
<div class="RemoteMachine"> |
||||
|
<ElTabs v-model="activeName" class="tabs"> |
||||
|
<ElTabPane label="基本信息" name="first"> |
||||
|
<!-- {{ dialogData }} --> |
||||
|
<Descriptions :list="list" :data="data" style="gap: 18px" /> |
||||
|
</ElTabPane> |
||||
|
<ElTabPane label="设备参数" name="second"> |
||||
|
<DeviceParams disabled :dialogData="dialogData" /> |
||||
|
</ElTabPane> |
||||
|
<ElTabPane label="在线率统计" name="third"> |
||||
|
<LineChart v-if="activeName === 'third'" :productId="dialogData.id" style="height: 180px" /> |
||||
|
</ElTabPane> |
||||
|
</ElTabs> |
||||
|
</div> |
||||
|
<template #footer> |
||||
|
<Button v-if="activeName != 'first' && data.deviceState == '1'" @click.native="deviceControlVisible = true"> |
||||
|
设备操作 |
||||
|
</Button> |
||||
|
<Button v-else-if="activeName != 'first'" style="background-color: #bbb"> |
||||
|
设备离线 |
||||
|
</Button> |
||||
|
</template> |
||||
|
|
||||
|
<DeviceControlDialog v-model="deviceControlVisible" :dialogData="dialogData" /> |
||||
|
</Dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import Dialog from "@screen/components/Dialog/index.vue"; |
||||
|
import Button from "@screen/components/Buttons/Button.vue"; |
||||
|
import Descriptions from "@screen/components/Descriptions.vue"; |
||||
|
import Video from "@screen/components/Video"; |
||||
|
import LineChart from "../../LineChart/index.vue"; |
||||
|
import DeviceParams from "./components/DeviceParams.vue"; |
||||
|
import DeviceControlDialog from "./components/DeviceControlDialog.vue"; |
||||
|
|
||||
|
import request from "@/utils/request"; |
||||
|
|
||||
|
import { |
||||
|
getRoadInfoByStakeMark, |
||||
|
getProduct, |
||||
|
} from "@screen/pages/Home/components/RoadAndEvents/utils/httpList.js"; |
||||
|
import { dialogDelayVisible } from "./../mixin"; |
||||
|
|
||||
|
// 广播发布 |
||||
|
export default { |
||||
|
name: "RemoteMachine", |
||||
|
mixins: [dialogDelayVisible], |
||||
|
components: { |
||||
|
Dialog, |
||||
|
Descriptions, |
||||
|
LineChart, |
||||
|
Video, |
||||
|
Button, |
||||
|
DeviceParams, |
||||
|
DeviceControlDialog, |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
activeName: "first", |
||||
|
releaseVisible: false, |
||||
|
deviceControlVisible: false, |
||||
|
data: { |
||||
|
deviceName: "LH24", |
||||
|
roadName: "G35济泽高速", |
||||
|
stakeMark: "k094+079", |
||||
|
direction: "1", |
||||
|
organizationName: "山东高速济南发展公司", |
||||
|
brand: "XXX厂家", |
||||
|
deviceState: "0", |
||||
|
}, |
||||
|
list: [ |
||||
|
{ |
||||
|
label: "设备名称", |
||||
|
key: "deviceName", |
||||
|
}, |
||||
|
{ |
||||
|
label: "设备桩号", |
||||
|
key: "stakeMark", |
||||
|
}, |
||||
|
{ |
||||
|
label: "道路名称", |
||||
|
key: "roadName", |
||||
|
}, |
||||
|
{ |
||||
|
label: "设备方向", |
||||
|
key: "direction", |
||||
|
enum: "CameraDirectionEnum", |
||||
|
}, |
||||
|
{ |
||||
|
label: "设备状态", |
||||
|
key: "deviceState", |
||||
|
// enum: "DeviceTypeEnum", |
||||
|
visible: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: "设备状态", |
||||
|
key: "deviceStateLiteral", |
||||
|
// enum: "DeviceTypeEnum", |
||||
|
}, |
||||
|
{ |
||||
|
label: "设备厂商", |
||||
|
key: "manufacturer", |
||||
|
}, |
||||
|
], |
||||
|
}; |
||||
|
}, |
||||
|
async created() { |
||||
|
if (this.dialogData) { |
||||
|
this.data = { |
||||
|
...this.dialogData, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
let deviceInfo = await this.getDeviceInfo(); |
||||
|
this.data = { |
||||
|
roadName: null, |
||||
|
deviceStateLiteral: deviceInfo?.data.formatValue.deviceState, |
||||
|
...this.data |
||||
|
}; |
||||
|
|
||||
|
getProduct(this.dialogData.productId).then((data) => { |
||||
|
this.dialogData.brand = data.brand; |
||||
|
}); |
||||
|
|
||||
|
const roadInfo = await getRoadInfoByStakeMark(this.dialogData.stakeMark); |
||||
|
|
||||
|
if (roadInfo) this.data.roadName = roadInfo.roadName; |
||||
|
console.log('this.data', this.data) |
||||
|
}, |
||||
|
methods: { |
||||
|
async getDeviceInfo() { |
||||
|
return request({ |
||||
|
url: `/business/device/properties/latest/${this.dialogData.iotDeviceId || "10.0.36.143-1883" |
||||
|
}/3`, |
||||
|
method: "get", |
||||
|
params: {}, |
||||
|
}); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
div.switcher { |
||||
|
font-size: 12px; |
||||
|
padding: 2px; |
||||
|
} |
||||
|
</style> |
||||
|
<style lang="scss" scoped> |
||||
|
.RemoteMachine { |
||||
|
width: 510px; |
||||
|
// height: 240px; |
||||
|
color: #fff; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
|
||||
|
.camera-video { |
||||
|
flex: 1.5; |
||||
|
} |
||||
|
|
||||
|
.tabs { |
||||
|
flex: 1; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
|
||||
|
::v-deep { |
||||
|
.el-tabs__content { |
||||
|
flex: 1; |
||||
|
|
||||
|
.el-tab-pane { |
||||
|
height: 100%; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.bottom { |
||||
|
margin-top: 12px; |
||||
|
display: flex; |
||||
|
gap: 9px; |
||||
|
align-items: center; |
||||
|
justify-content: end; |
||||
|
|
||||
|
>div { |
||||
|
font-size: 16px; |
||||
|
padding: 6px 12px; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue