jsy-app/pages/dev-ops/valve.vue

293 lines
8.2 KiB
Vue
Raw Normal View History

2024-12-28 21:29:59 +08:00
<template>
2024-12-31 19:42:29 +08:00
<z-paging ref="paging" @query="queryList" v-model="dataList" :auto-show-system-loading="true"
empty-view-text="抱歉,暂时还没有相关数据!">
<template #top>
<custom-nav-bar :left="true" title="阀门"></custom-nav-bar>
</template>
<view class="index-container">
<view class="item-container" v-for="item in dataList">
<view style="display: flex; align-items: center; justify-content: space-between;">
<view class="flex-text" style="margin: 15px;">
<view class="flex-text-one" style="color: black;">{{ item.wo.showName }}</view>
<view>{{ item.device.deviceCode }}</view>
<view style="margin-left: 10px;">
<u-tag text="在线" type="success" plain v-if="dc.dataObj[item.device.deviceCode]?.online" />
<u-tag text="离线" type="error" plain v-else />
</view>
</view>
<view style="margin-right: 5px;">
<u-button type="success" text="刷新" icon="reload"
:loading="dc.dataObj[item.device.deviceCode]?.refresh"
@click="dc.refreshDeviceItem(item.device.deviceCode, item.device)" />
</view>
</view>
<u-gap height="1" bgColor="#D2D2D2"></u-gap>
<view style="display: flex;justify-content: space-between;align-items: center;">
<uni-row class="data">
<uni-col :span="12">
<view class="flex-text global-font-size-1">
<view class="flex-text-one">电量</view>
<view>{{ dc.dataObj[item.device.deviceCode]?.adc.b || '-' }}%</view>
</view>
</uni-col>
<uni-col :span="12">
<view class="flex-text global-font-size-1">
<view class="flex-text-one">频段</view>
2025-01-02 20:28:11 +08:00
<view>
{{ dataObj[item.device.deviceCode]?.lf || item.device.deviceExtendValve.rolaFrequency}}
</view>
2024-12-31 19:42:29 +08:00
</view>
</uni-col>
<uni-col :span="12">
<view class="flex-text global-font-size-1">
<view class="flex-text-one">/硬件版本</view>
2025-01-02 20:28:11 +08:00
<view>{{ dataObj[item.device.deviceCode]?.sv || item.device.softVer}} /
{{ dataObj[item.device.deviceCode]?.dv || item.device.deviceVersion }}
</view>
2024-12-31 19:42:29 +08:00
</view>
</uni-col>
<uni-col :span="12">
<view class="flex-text global-font-size-1">
<view class="flex-text-one">压力</view>
<view>{{ dc.dataObj[item.device.deviceCode]?.adc.p || '-' }}</view>
</view>
</uni-col>
<uni-col :span="8">
<u-button type="success" @click="restart(item)" disabled>重启</u-button>
</uni-col>
2025-01-02 17:54:53 +08:00
<uni-col :span="8" v-hasPermi="['iot:dev-ops:vlf']">
2024-12-31 19:42:29 +08:00
<u-button type="success" @click="editRolaFrequency(item)">修改频段</u-button>
</uni-col>
2025-01-02 17:54:53 +08:00
<uni-col :span="8" v-hasPermi="['iot:dev-ops:gvc']">
<u-button type="success" @click="getConfig(item)">获取配置</u-button>
2024-12-31 19:42:29 +08:00
</uni-col>
<uni-col :span="8">
<u-button type="success" @click="" disabled>压力校准</u-button>
</uni-col>
<uni-col :span="8">
<u-button type="success" @click="" disabled>桥接</u-button>
</uni-col>
<uni-col :span="8">
<u-button type="success" @click="" disabled>删除桥接</u-button>
</uni-col>
</uni-row>
</view>
</view>
</view>
</z-paging>
2024-12-28 21:29:59 +08:00
2025-01-02 16:29:11 +08:00
<!-- 修改频段 -->
<custom-popup ref="refFrequency" :title="rolaFrequency.item?.deviceCode" :footer="true"
@confirm="editRolaFrequencyHandler">
<view class="jz-info" style="width: 80vw;height:150px;padding: 10px;">
2025-01-02 13:16:03 +08:00
<uni-forms ref="baseForm" style="padding-top: 10px;">
2025-01-02 16:29:11 +08:00
<uni-forms-item label="原频段" required>
2025-01-02 13:16:03 +08:00
<uni-data-select v-model="rolaFrequency.old" :localdata="rolaFrequency.range" :clear="false" />
2024-12-31 19:42:29 +08:00
</uni-forms-item>
<uni-forms-item label="新频段" required>
2025-01-02 13:16:03 +08:00
<uni-data-select v-model="rolaFrequency.new" :localdata="rolaFrequency.range" :clear="false" />
2024-12-31 19:42:29 +08:00
</uni-forms-item>
</uni-forms>
</view>
2025-01-02 16:29:11 +08:00
</custom-popup>
2024-12-31 19:42:29 +08:00
</template>
2024-12-28 21:29:59 +08:00
<script>
2024-12-31 19:42:29 +08:00
import * as DevOpsApi from "@/api/dev-ops/index.js"
export default {
data() {
return {
station: null,
queryParams: {
landId: null, //地块id
stationId: null, //基站id
},
dataList: [],
dc: getApp().dc, // 设备控制公共代码
2025-01-02 20:28:11 +08:00
dataObj: {},
topics: [],
2024-12-31 19:42:29 +08:00
rolaFrequency: {
item: null,
2025-01-02 13:16:03 +08:00
old: null,
new: null,
2024-12-31 19:42:29 +08:00
range: [],
},
}
},
onLoad(par) {
if (par.station) {
this.station = JSON.parse(par.station)
this.queryParams = {
landId: this.station.landId,
stationId: this.station.id,
}
} else {
this.queryParams = {
landId: -1,
stationId: -1,
}
}
// 频段
let list = [];
for (let i = 410; i < 491; i++) {
let lfObj = {
value: i,
text: i.toString()
}
list.push(lfObj);
}
this.rolaFrequency.range = list;
2025-01-02 20:28:11 +08:00
const that = this;
2025-01-07 10:02:41 +08:00
getApp().on("mqtt", "mqtt_devOps_valve", function(e) {
2025-01-02 20:28:11 +08:00
if (e.type == "state") {
// that.mqttConnected = e.connected;
} else if (e.type == "msg") {
if (e.topic.includes("jsy/iot/deviceConfig/2/") || e.topic.includes(
"jsy/iot/deviceConfig/13/")) {
const arr = e.topic.split("/");
const deviceCode = arr[4];
let obj = that.dataObj[deviceCode] || {};
if (e.data.type == "gvc") {
obj = Object.assign(obj, {
dv: e.data.data.dv,
sv: e.data.data.sv,
lf: e.data.data.lf,
})
}
if (e.data.type == "vlf" && e.data.res == 1) {
obj = Object.assign(obj, {
lf: e.data.data,
})
}
2025-01-07 10:02:41 +08:00
2025-01-02 20:28:11 +08:00
that.dataObj[deviceCode] = obj;
}
}
});
2024-12-31 19:42:29 +08:00
},
onShow() {},
mounted() {},
2025-01-02 20:28:11 +08:00
onUnload() {
getApp().mqttUnsubscribes(this.topics);
2025-01-07 10:02:41 +08:00
getApp().off("mqtt", "mqtt_devOps_valve")
2025-01-02 20:28:11 +08:00
},
2024-12-31 19:42:29 +08:00
methods: {
queryList(pageNo, pageSize) {
DevOpsApi.getStationValvelist(this.queryParams.landId, this.queryParams.stationId).then(res => {
this.$refs.paging.completeByTotal(res.rows);
2025-01-02 20:28:11 +08:00
this.mqttSubscribes(res.rows);
2024-12-31 19:42:29 +08:00
});
},
2025-01-02 20:28:11 +08:00
mqttSubscribes(rows) {
if (rows && rows.length) {
let topic = [];
rows.forEach(item => {
topic.push(`jsy/iot/deviceConfig/${item.device.deviceTypeId}/${item.device.deviceCode}`);//获取配置
});
this.topics = topic;
getApp().mqttSubscribes(this.topics);
}
},
2024-12-31 19:42:29 +08:00
// 重启
restart(item) {
console.error("重启:", item);
},
// 修改频段
editRolaFrequency(item) {
2025-01-02 16:29:11 +08:00
this.$refs.refFrequency.show();
2024-12-31 19:42:29 +08:00
this.rolaFrequency.item = item.device;
2025-01-02 13:16:03 +08:00
this.rolaFrequency.old = item.device.deviceExtendValve.rolaFrequency;
this.rolaFrequency.new = item.device.deviceExtendValve.rolaFrequency;
2024-12-31 19:42:29 +08:00
},
// 获取配置
getConfig(item) {
2025-01-02 17:54:53 +08:00
this.$showConfirm("获取配置").then(res => {
if (res.confirm) {
DevOpsApi.gvc(item.device.deviceCode).then(res => {
this.$toast(res.msg)
})
}
})
2024-12-31 19:42:29 +08:00
},
// 关闭弹出层
close() {
for (var key in this.pop) {
this.pop[key] = false;
}
},
2025-01-02 16:29:11 +08:00
editRolaFrequencyHandler(e) {
if (!e) {
return;
}
2024-12-31 19:42:29 +08:00
// if (this.rolaFrequency.item.rolaFrequency == this.rolaFrequency.rolaFrequency) {
// this.$toast("新旧频段不能相同!")
// return;
// }
2025-01-02 13:16:03 +08:00
let msg = `您确定要修改【${this.rolaFrequency.item.deviceCode}】的频段为【${this.rolaFrequency.new}】?`;
2024-12-31 19:42:29 +08:00
this.$showConfirm(msg).then(res => {
if (res.confirm) {
2025-01-02 17:54:53 +08:00
DevOpsApi.vlf({
2024-12-31 19:42:29 +08:00
stationCode: this.station.deviceCode,
deviceCode: this.rolaFrequency.item.deviceCode,
2025-01-02 13:16:03 +08:00
oldFrequency: this.rolaFrequency.old,
newFrequency: this.rolaFrequency.new
2024-12-31 19:42:29 +08:00
}).then(res => {
this.$toast(res.msg)
})
} else {
this.pop.rolaFrequency = true;
}
})
},
}
}
2024-12-28 21:29:59 +08:00
</script>
2024-12-31 19:42:29 +08:00
<style lang="scss">
.index-container {
.list {
margin: 0px 10px;
}
.list-size {
display: flex;
padding: 5px 5px;
background: white;
justify-content: center;
}
.search {
background-color: white;
padding: 10px;
}
.item-container {
margin: 10px 10px;
background-color: white;
padding-bottom: 10px;
border-radius: 10px;
box-shadow: 1px 1px 2px 2px rgba(0, 0, 0, 0.05);
}
.flex-text {
display: flex;
align-items: center;
.flex-text-one {
color: #939393;
font-weight: bold;
}
}
.data {
margin: 10px 20px !important;
width: 100%;
.uni-col {
margin-bottom: 5px;
}
}
}
2024-12-28 21:29:59 +08:00
</style>