|
|
@@ -3,11 +3,12 @@
|
|
|
ref="dialog"
|
|
|
title="配电箱"
|
|
|
size="lg fixed"
|
|
|
- @closed="onClose"
|
|
|
>
|
|
|
<template #default>
|
|
|
<div class="l-flex--row c-sibling-item--v">
|
|
|
- <div class="c-sibling-item u-bold">设备编号</div>
|
|
|
+ <div class="c-sibling-item u-bold">
|
|
|
+ 设备编号
|
|
|
+ </div>
|
|
|
<div class="l-flex--row c-sibling-item far">
|
|
|
<el-input
|
|
|
v-model="identifier"
|
|
|
@@ -24,20 +25,31 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="l-flex--row c-sibling-item--v has-bottom-padding has-bottom-border">
|
|
|
- <div class="c-sibling-item u-bold">当前模式</div>
|
|
|
+ <div class="c-sibling-item u-bold">
|
|
|
+ 当前模式
|
|
|
+ </div>
|
|
|
<el-radio
|
|
|
v-model="mode"
|
|
|
class="c-sibling-item far"
|
|
|
label="manual"
|
|
|
+ :disabled="!connectedDevice"
|
|
|
@change="onModeChange"
|
|
|
- >手动</el-radio>
|
|
|
+ >
|
|
|
+ 手动
|
|
|
+ </el-radio>
|
|
|
<el-radio
|
|
|
v-model="mode"
|
|
|
label="timer"
|
|
|
+ :disabled="!connectedDevice"
|
|
|
@change="onModeChange"
|
|
|
- >定时</el-radio>
|
|
|
+ >
|
|
|
+ 定时
|
|
|
+ </el-radio>
|
|
|
</div>
|
|
|
- <div class="l-flex l-flex__self c-sibling-item--v c-step">
|
|
|
+ <div
|
|
|
+ v-if="connectedDevice"
|
|
|
+ class="l-flex l-flex__self c-sibling-item--v c-step"
|
|
|
+ >
|
|
|
<schema-table
|
|
|
ref="reportTable"
|
|
|
class="l-flex__none c-step__column u-width--lg"
|
|
|
@@ -61,7 +73,7 @@ import {
|
|
|
electricRead,
|
|
|
electricQuery,
|
|
|
electricControl
|
|
|
-} from '../api'
|
|
|
+} from '../api.js'
|
|
|
|
|
|
const ELECTRIC_ID = 1
|
|
|
|
|
|
@@ -72,6 +84,7 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
identifier: '',
|
|
|
+ connectedDevice: '',
|
|
|
mode: '',
|
|
|
reoirtSchema: {
|
|
|
nonPagination: true,
|
|
|
@@ -102,29 +115,27 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- mounted () {
|
|
|
- this.$timer = -1
|
|
|
- },
|
|
|
methods: {
|
|
|
- onClose () {
|
|
|
- clearInterval(this.$timer)
|
|
|
- },
|
|
|
show () {
|
|
|
const loading = this.$showLoading()
|
|
|
// 查询设备编号
|
|
|
getThirdPartyElectricBox(ELECTRIC_ID)
|
|
|
.then(data => {
|
|
|
- this.identifier = data.data.identifier
|
|
|
+ this.identifier = data.data?.identifier || ''
|
|
|
+ this.connectedDevice = this.identifier
|
|
|
})
|
|
|
- .then(this.initPowerBox)
|
|
|
.then(() => {
|
|
|
this.$refs.dialog.show()
|
|
|
})
|
|
|
+ .then(this.initPowerBox)
|
|
|
.finally(() => {
|
|
|
this.$closeLoading(loading)
|
|
|
})
|
|
|
},
|
|
|
initPowerBox () {
|
|
|
+ if (!this.connectedDevice) {
|
|
|
+ return Promise.reject()
|
|
|
+ }
|
|
|
return electricRead({
|
|
|
electricId: ELECTRIC_ID,
|
|
|
commandKey: 6
|
|
|
@@ -211,15 +222,36 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onApply () {
|
|
|
+ if (!this.identifier) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写设备编号'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const pre = this.connectedDevice
|
|
|
+ this.connectedDevice = null
|
|
|
updateThirdPartyElectricBox({
|
|
|
id: ELECTRIC_ID,
|
|
|
identifier: this.identifier
|
|
|
- }).then(this.initPowerBox).then(() => {
|
|
|
- this.$refs.reportTable.pageTo(1)
|
|
|
- this.$refs.table.pageTo(1)
|
|
|
- })
|
|
|
+ }).then(
|
|
|
+ () => {
|
|
|
+ this.connectedDevice = this.identifier
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ this.connectedDevice = pre
|
|
|
+ }
|
|
|
+ ).then(this.initPowerBox)
|
|
|
},
|
|
|
onModeChange (mode) {
|
|
|
+ if (!this.connectedDevice) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请先连接设备'
|
|
|
+ })
|
|
|
+ this.mode = ''
|
|
|
+ return
|
|
|
+ }
|
|
|
electricControl({
|
|
|
electricId: ELECTRIC_ID,
|
|
|
commandKey: 1,
|
|
|
@@ -243,6 +275,13 @@ export default {
|
|
|
this.onSwitch(false)
|
|
|
},
|
|
|
onSwitch (bool) {
|
|
|
+ if (!this.connectedDevice) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请先连接设备'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
electricControl({
|
|
|
commandKey: 2,
|
|
|
electricId: 1,
|