smart-power-ui/src/views/iot/device/profile/details.vue

1043 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="iot-project-details-warp">
<div class="iot-project-details-warp-info main-device-select-card">
<div class="device-info-left">
<span>设备名称{{infoData.deviceName}}</span>
<span>设备key{{infoData.deviceKey}}</span>
<span>所属型号{{infoData.modelName}}</span>
<div
:class="
infoData['deviceState'] == 'ONLINE'
? 'dev-info-state'
: 'dev-info-state off-line'
"
>在线状态
<i
v-if="infoData['deviceState'] == 'ONLINE'"
class="iconfont iconSYS_STA_1"
/>
<i v-else class="iconfont iconlixian" />
<span style="margin-left: 1px" class="dev-info-state-txt">{{
infoData["deviceState"] == "ONLINE" ? "在线" : "离线"
}}</span>
</div>
</div>
<div class="link-to-list">
<el-button icon="el-icon-d-arrow-left" size="small" style="margin-left: 10px;" title="返回列表" type="primary" @click="toTableClick"
>返回列表</el-button
>
</div>
</div>
<div class="info-tabs main-device-card">
<div v-show="breadcrumbList.length > 1" class="breadcrumb-wrap">
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="index">
<span :class="item.deviceId === deviceId ? 'breadcrumb-span show-wrap' : 'breadcrumb-span'" @click="deviceClick(item, index)">{{item.deviceName}}</span>
</el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-tabs
v-model="activeName"
:class="breadcrumbList.length > 1 ? 'children-wrap' : ''"
class="device-detail-tabs"
>
<el-tab-pane label="运行状态" name="runingState">
<div class="tabs-body protocol-wrap">
<device-run-starts-wrap
v-if="devudeRunState"
:deviceInfo="infoData"
:prodId="infoData.prodKey"
:sourceId="deviceId"
:wsUrl="iotWebSocketBaseUrl"
@updateDeviceState="changeDeviceState"
></device-run-starts-wrap>
</div>
</el-tab-pane>
<el-tab-pane label="事件" name="eventLog">
<div class="tabs-body">
<event-log
v-if="activeName === 'eventLog'"
:pDevcieInfo="infoData"
:sourceId="infoData.deviceId"
></event-log>
</div>
</el-tab-pane>
<el-tab-pane label="设备信息" name="info">
<div class="tabs-body">
<info-wrap :infoData="infoData" @updateInfo="updateInfo($event)" />
</div>
</el-tab-pane>
<el-tab-pane v-if="infoData.deviceType === '10001'" label="子设备" name="child">
<div class="tabs-body">
<child-device
v-if="activeName === 'child'"
:pDevcieInfo="infoData"
:sourceId="infoData.deviceId"
@toChildEvent="toNewDevice"
></child-device>
</div>
</el-tab-pane>
<el-tab-pane label="触发器" name="trigger">
<div class="tabs-body protocol-wrap">
<trigger-wrap :deviceInfo="infoData" :sourceId="infoData.deviceId"></trigger-wrap>
</div>
</el-tab-pane>
<el-tab-pane label="日志" name="devLog">
<div class="tabs-body">
<device-log
v-if="activeName === 'devLog'"
:pDevcieInfo="infoData"
:sourceId="infoData.deviceId"
></device-log>
</div>
</el-tab-pane>
<el-tab-pane label="场景" name="scene">
<div class="tabs-body">
<e-device-scene
v-if="activeName === 'scene'"
:sourceId="infoData.deviceId"
/>
</div>
</el-tab-pane>
<el-tab-pane label="功能" name="function">
<div class="tabs-body">
<function-wrap v-if="activeName === 'function'" :deviceInfo="infoData" :sourceId="deviceId"></function-wrap>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import { getDevice } from "@/api/iot/device";
import InfoWrap from "./info";
import ChildDevice from "./childDevice";
import DeviceLog from "@/views/profile/DeviceDetailsView/deviceLog";
import EventLog from "@/views/profile/DeviceDetailsView/eventLog";
import DeviceRunStartsWrap from "@/views/profile/DeviceRunStarts/index";
import { iotWebSocketBaseUrl } from "@/config/env";
import TriggerWrap from "@/views/profile/DeviceTrigger/index";
import EDeviceScene from '@/views/profile/EDeviceScene/indexView'
import functionWrap from "@/views/iot/device/profile/functionWrap"
import { setFunctionControl } from '../../../../api/iot/device'
export default {
name: "DetailsWrap",
props: ["sourceId"],
components: {
InfoWrap,
ChildDevice,
DeviceLog,
DeviceRunStartsWrap,
TriggerWrap,
EDeviceScene,
functionWrap,
EventLog
},
data() {
return {
infoData: {},
iotWebSocketBaseUrl,
activeName: "runingState",
breadcrumbList: [],
tempType: "bs",
deviceId: "",
devudeRunState: false,
timingPingWs_flag: null,
};
},
created() {
this.deviceId = this.sourceId;
this.deviceInfo();
},
methods: {
// 跳转详情页
toTableClick() {
this.$emit('toTableClick')
},
// 点击查看设备详情
deviceClick(row, index) {
if (row.deviceId === this.deviceId) {
return;
}
const leng = this.breadcrumbList.length - 1;
this.breadcrumbList.splice(index + 1, leng);
this.activeName = "runingState";
this.deviceId = row.deviceId;
this.devudeRunState = false;
this.deviceInfo();
},
changeDeviceState(e){
console.log("更新设备状态",e)
this.infoData.deviceState = e.state;
},
// 设备详情
deviceInfo() {
getDevice(this.deviceId).then(response => {
// if(response.data.deviceLabel && response.data.deviceLabel[0] == '空间'){
// response.data.deviceLabel.shift();
// }
this.infoData = response.data;
if(response.data && response.data.deviceKey && (response.data.deviceType === '10001' || response.data.deviceType === '10002' || response.data.deviceType === '10013')){
this.timingPingWs(response.data)
}
if (this.breadcrumbList.length <= 0) {
this.breadcrumbList.push(this.infoData);
}
for (var i = 0; i < this.breadcrumbList.length; i++) {
if (
this.breadcrumbList[i]["deviceId"] === this.infoData["deviceId"]
) {
this.breadcrumbList[i] = this.infoData;
} else if (i === this.breadcrumbList.length - 1) {
this.breadcrumbList.push(this.infoData);
}
}
this.devudeRunState = true;
});
},
// 定时 ping ws
timingPingWs(row) {
this.extenSubmit(row);
clearInterval(this.timingPingWs_flag);
const _this = this;
this.timingPingWs_flag = setInterval(function() {
_this.extenSubmit(row);
}, 110000);
},
//开启
extenSubmit(row) {
let params = {
input: {
ltime: 15, // 上报间隔(0.1秒)
dtime: 1200 //上报时长(0.1秒)
},
deviceKey: row.deviceKey,
funcId: "set_live_time"
};
//使用新版功能
setFunctionControl(params).then(res => {
console.log(res);
});
},
toNewDevice(data) {
this.tempType = "children";
this.deviceId = data.deviceId;
this.devudeRunState = false;
this.deviceInfo();
this.activeName = "runingState";
},
updateInfo(...data) {
this.deviceInfo();
}
}
};
</script>
<style lang="scss">
.iot-project-details-warp {
.breadcrumb-wrap {
position: absolute;
top: 15px;
z-index: 10;
left: 20px;
width: 90%;
overflow: hidden;
.breadcrumb-span:hover {
color: #1890ff;
cursor: default;
}
.show-wrap {
color: #1890ff;
}
}
.iot-project-details-warp-info{
display: flex;
justify-content: space-between;
align-items: center;
.device-info-left{
display: flex;
align-items: center;
font-size: 14px;
span{
margin-right: 20px;
}
.dev-info-state {
display: flex;
align-items: center;
justify-content: flex-start;
.iconfont{
color: #00c805;
margin-right: 2px;
}
.dev-info-state-txt{
color: #00c805;
}
&.off-line {
.iconfont{
color: #da2710;
}
.dev-info-state-txt{
color: #da2710;
}
}
}
}
}
.product-release-dialog {
.title-i {
font-size: 20px;
color: #9c9a9a;
line-height: 18px;
}
.i-color {
color: rgb(0, 193, 222);
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.top-tigs {
background: #fbfbfc;
border: 1px solid #ecedee;
padding: 20px;
margin-bottom: 25px;
color: #999;
}
.form-bottom-prod-details {
margin-top: 40px;
height: 10px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.bottom-div {
height: 70px;
font-size: 12px;
border: 1px solid #ecedee;
margin: -1px;
}
.one-div {
width: 15%;
float: left;
border-right: 1px solid #ecedee;
height: 30px;
line-height: 30px;
/* padding-left: 10px; */
text-align: center;
font-size: 18px;
height: 70px;
line-height: 76px;
text-align: center;
font-size: 18px;
}
.two-div {
width: calc(100% - 36%);
float: left;
padding: 22px 10px 10px 10px;
font-size: 12px;
}
.there-div {
width: 10%;
float: left;
padding-top: 28px;
}
.four-div {
width: 5%;
float: left;
padding-top: 28px;
}
}
.heard {
padding: 20px 40px 0;
background-color: #fff;
height: 112px;
padding: 0px;
}
.info-title {
margin-top: 0px;
margin-bottom: 16px;
line-height: 29px;
overflow: hidden;
height: 30px;
.title {
float: left;
font-size: 20px;
margin: 0 8px 0 0;
line-height: 28px;
}
.el-button--small,
.el-button--small.is-round {
padding: 8px 15px;
float: right;
}
}
.info-icon {
margin-top: -70px;
float: left;
width: 101px;
border: 1px dotted rgb(205, 203, 203);
height: 101px;
.image {
width: 100px;
height: 100px;
}
}
.info-des {
font-size: 14px;
width: 100%;
float: left;
.info-row {
overflow: hidden;
display: block;
text-overflow: ellipsis;
line-height: 20px;
white-space: nowrap;
.label {
color: #aaa;
}
.centent {
color: #999;
margin-right: 8px;
}
}
}
.info-tabs {
position: relative;
box-sizing: border-box;
.el-tabs__content {
//height: calc(100vh - 191px);
//overflow: auto;
}
.el-tabs__header {
background-color: #fff;
position: relative;
// top: -10px;
.el-tabs__nav-wrap {
margin-left: 0px;
.el-tabs__item {
font-size: 16px;
}
}
}
.el-tabs__nav-scroll {
}
.el-tabs--border-card > .el-tabs__header .el-tabs__item.is-active {
background: #fff;
color: #333;
border: 0;
}
.el-tabs--border-card > .el-tabs__header .el-tabs__item {
// border-color: red;
color: #909399;
background: #d3deec;
border-radius: 8px 8px 0 0;
border-bottom: 0;
margin-left: 15px;
}
.tabs-body {
margin-left: 0px;
margin-right: 0px;
padding: 0px;
overflow: hidden;
background-color: #fff;
margin-bottom: 0px;
}
.protocol-wrap {
.el-tabs__nav-scroll {
height: auto;
padding-top: 0;
padding-left: 0;
background: #fff;
}
}
}
.children-wrap {
.el-tabs__header {
.el-tabs__nav-scroll {
height: 85px;
.el-tabs__nav {
margin-top: 20px;
}
}
}
}
.child-table {
margin-top: 25px;
// margin-left: 20px;
margin-right: 0px;
padding: 0px;
overflow: hidden;
background-color: #fff;
}
}
.product-release-dialog {
.title-i {
font-size: 20px;
color: #9c9a9a;
line-height: 18px;
}
.i-color {
color: rgb(0, 193, 222);
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.top-tigs {
background: #fbfbfc;
border: 1px solid #ecedee;
padding: 20px;
margin-bottom: 25px;
color: #999;
}
.form-bottom-prod-details {
margin-top: 15px;
height: 30px;
border-top: 1px solid #747373;
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.bottom-div {
height: 70px;
font-size: 12px;
border: 1px solid #ecedee;
margin: 0px;
}
.one-div {
width: 15%;
float: left;
border-right: 1px solid #ecedee;
height: 30px;
line-height: 30px;
/* padding-left: 10px; */
text-align: center;
font-size: 18px;
height: 70px;
line-height: 76px;
text-align: center;
font-size: 18px;
}
.two-div {
width: calc(100% - 36%);
float: left;
padding: 22px 10px 10px 10px;
font-size: 12px;
}
.there-div {
width: 10%;
float: left;
padding-top: 28px;
}
.four-div {
width: 5%;
float: left;
padding-top: 28px;
}
}
.product-detail-info {
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.form-buttons-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.el-form-item--mini.el-form-item,
.el-form-item--small.el-form-item {
margin-bottom: 10px;
margin-left: 60px;
}
.el-form--label-top .el-form-item__label {
padding: 0 0 9px;
margin-top: 10px;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
line-height: 17px;
}
.avue-input-number,
.el-cascader,
.el-date-editor.el-input,
.el-date-editor.el-input__inner,
.el-select {
width: 100%;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.form-buttons-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
}
}
.product-topic-dialog {
.top-tips {
height: 150px;
margin: 20px;
margin-top: 30px;
margin-right: 0px;
border: 1px solid #00c1df;
padding: 10px 10px 0;
background: #e6f9fc;
display: flex;
border-radius: 3px;
padding-left: 20px;
padding-top: 20px;
margin-bottom: 0px;
}
.el-form-item__error {
left: 80px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 90%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.el-select {
width: 100%;
}
.form-buttonx-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.product-fun-dialog {
.insert-div {
width: 100%;
margin-bottom: 10px;
padding-top: 10px;
padding-left: 30px;
}
.el-transfer-panel {
// margin-left: 10px;
width: 225px;
}
.el-transfer__buttons {
padding: 0px 10px;
}
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.fw {
.el-input--mini {
width: 155px;
}
}
.el-form-item__error {
left: 120px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 92%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.form-buttonb-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.product-custom-fun {
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.fw {
.el-input--mini {
width: 155px;
}
}
.el-form-item__error {
left: 120px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 92%;
}
.el-select {
width: 100%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.form-buttona-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.product-prop-standard-dialog {
.insert-div {
width: 100%;
margin-bottom: 10px;
padding-top: 10px;
padding-left: 30px;
}
.el-transfer-panel {
// margin-left: 10px;
width: 225px;
}
.el-transfer__buttons {
padding: 0px 10px;
}
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.fw {
.el-input--mini {
width: 155px;
}
}
.el-form-item__error {
left: 120px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 92%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.form-buttonb-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.product-prop-custom-dialog {
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.fw {
.el-input--mini {
width: 155px;
}
}
.el-form-item__error {
left: 120px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 92%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.form-buttona-div {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
width: 100%;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.model-function-dialog {
.el-textarea {
width: 92%;
}
.el-input {
width: 92%;
}
.question-button.el-button--text {
padding-bottom: 0px;
color: rgb(204, 204, 204);
background: 0 0;
padding-left: 0;
padding-right: 0;
font-size: 18px;
padding-top: 0px;
margin-top: 0px;
}
.fw {
.el-input--mini {
width: 155px;
}
}
.el-form-item__error {
left: 120px;
}
.el-dialog__body {
padding: 0px;
padding-right: 20px;
}
.el-dialog__header {
border-bottom: 1px solid rgb(116, 115, 115);
}
.el-form--label-top .el-form-item__label {
padding-top: 23px;
padding-bottom: 0px;
}
.el-form-item {
margin-bottom: -17px;
width: 92%;
}
.el-form-item--mini .el-form-item__content,
.el-form-item--mini .el-form-item__label {
padding-left: 40px;
}
.el-select {
width: 100%;
}
.form-bottom-prod-details {
margin-top: 30px;
height: 50px;
border-top: 1px solid rgb(116, 115, 115);
text-align: right;
padding-top: 15px;
width: calc(100% + 20px);
.el-button {
margin-right: 10px;
margin-left: 0px;
}
}
.funType-div {
// margin-left: 40px;
}
}
.sr {
.el-form-item {
margin-bottom: -17px;
width: 100%;
}
}
.iot-project-details-warp .info-tabs .el-tabs__content::-webkit-scrollbar {
/*滚动条整体样式*/
width: 8px; /*高宽分别对应横竖滚动条的尺寸*/
height: 3px;
}
.iot-project-details-warp
.info-tabs
.el-tabs__content::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
box-shadow: inset 0 0 5px #9e9d9d;
background: #ffffff;
}
.iot-project-details-warp
.info-tabs
.el-tabs__content::-webkit-scrollbar-track {
/*滚动条里面轨道*/
box-shadow: inset 0 0 5px #f6f6f6;
border-radius: 10px;
background: #ffffff;
}
</style>