|
@@ -53,6 +53,7 @@
|
|
|
<el-button type="success" :disabled="!selectedDevices.length" @click="batchDeviceSwitch(1)">开</el-button>
|
|
|
<el-button type="danger" :disabled="!selectedDevices.length" @click="batchDeviceSwitch(0)">关</el-button>
|
|
|
</el-header>
|
|
|
+ <el-alert title="批量对设备进行开关操作时,离线设备不会有反应" type="warning" />
|
|
|
<el-main>
|
|
|
<el-table :data="filterTableData" @selection-change="handleSelectionChange">
|
|
|
<el-table-column type="selection" width="55" />
|
|
@@ -66,7 +67,7 @@
|
|
|
<el-tooltip
|
|
|
class="item"
|
|
|
effect="dark"
|
|
|
- :content="`时控1:${item2.timeCondition1OnTime}-${item2.timeCondition1OffTime},时控2:${item2.timeCondition2OnTime}-${item2.timeCondition2OffTime}`"
|
|
|
+ :content="`${item2.name} 时控1:${item2.timeCondition1OnTime}-${item2.timeCondition1OffTime},时控2:${item2.timeCondition2OnTime}-${item2.timeCondition2OffTime}`"
|
|
|
placement="top-start"
|
|
|
>
|
|
|
<!-- ${item2}-${scope.row.relayTimeStr[index]}-->
|
|
@@ -107,7 +108,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" prop="action" width="400" align="center">
|
|
|
<template #header>
|
|
|
- <el-input v-model="search" size="small" placeholder="搜索" />
|
|
|
+ <el-input v-model="search" placeholder="搜索" style="width: 200px;"/>
|
|
|
</template>
|
|
|
<template #default="scope">
|
|
|
<el-button type="success" @click="switchDevice(scope.row,1)">开</el-button>
|
|
@@ -334,6 +335,7 @@ const addDevice = () => {
|
|
|
|
|
|
// sn不能重复
|
|
|
const isRepeatSn = (sn) => {
|
|
|
+ console.log(sn)
|
|
|
for (let i = 0; i < regionData.value.length; i++) {
|
|
|
for (let j = 0; j < regionData.value[i].devices.length; j++) {
|
|
|
if (regionData.value[i].devices[j].sn === sn) {
|
|
@@ -347,19 +349,23 @@ const isRepeatSn = (sn) => {
|
|
|
//编辑
|
|
|
const isUpdateDevice = ref(false)
|
|
|
const updateDeviceData = ref()
|
|
|
+const oldUpdateDeviceData = ref()
|
|
|
const openUpdateDevice = (val) => {
|
|
|
updateDeviceData.value = val
|
|
|
+ oldUpdateDeviceData.value = JSON.parse(JSON.stringify(val))
|
|
|
isUpdateDevice.value = true
|
|
|
}
|
|
|
|
|
|
const updateDevice = () => {
|
|
|
if (updateDeviceData.value.id === null || updateDeviceData.value.sn === null) {
|
|
|
ElMessage.error("数据不能为空")
|
|
|
+ updateDeviceData.value.sn = oldUpdateDeviceData.value.sn
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (isRepeatSn(addDeviceData.value.sn)) {
|
|
|
+ if (isRepeatSn(updateDeviceData.value.sn)) {
|
|
|
ElMessage.error("sn已被使用")
|
|
|
+ updateDeviceData.value.sn = oldUpdateDeviceData.value.sn
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -386,6 +392,7 @@ const deleteDevice = (index) => {
|
|
|
message: '删除成功',
|
|
|
})
|
|
|
save()
|
|
|
+ getData()
|
|
|
})
|
|
|
.catch(() => {
|
|
|
ElMessage({
|
|
@@ -398,10 +405,14 @@ const deleteDevice = (index) => {
|
|
|
// 开关回路
|
|
|
const switchLoop = async(val) => {
|
|
|
val.state = val.state === 1 ? 0 : 1
|
|
|
- console.log(val)
|
|
|
+
|
|
|
await deviceLoopSwitch(val).then(res => {
|
|
|
console.log(res)
|
|
|
// 开关回路
|
|
|
+ if (res.msg === "设备连接丢失") {
|
|
|
+ ElMessage.error("设备离线")
|
|
|
+ val.state = val.state === 1 ? 0 : 1
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
// 开关设备
|
|
@@ -436,6 +447,10 @@ const batchDeviceSwitch = async (state) => {
|
|
|
for (let i = 0; i < deviceData.value.length; i++) {
|
|
|
for (let j = 0; j < selectedDevices.value.length; j++) {
|
|
|
if (deviceData.value[i].sn === selectedDevices.value[j].sn) {
|
|
|
+ if (selectedDevices.value[j].state === 0){
|
|
|
+ //离线跳过
|
|
|
+ continue
|
|
|
+ }
|
|
|
for (let k = 0; k < deviceData.value[i].deviceLoops.length; k++) {
|
|
|
if (deviceData.value[i].deviceLoops[k].deviceId === selectedDevices.value[j].sn) {
|
|
|
deviceData.value[i].deviceLoops[k].state = state
|