This commit is contained in:
Iruka 2025-02-18 15:41:31 +08:00
parent 2d3d90ea16
commit 5b78381ef0
6 changed files with 334 additions and 23 deletions

View File

@ -315,6 +315,12 @@
"navigationBarTitleText": "阀门",
"navigationStyle": "custom"
}
}, {
"path": "pages/dev-ops/editMp",
"style": {
"navigationBarTitleText": "修改墒情",
"navigationStyle": "custom"
}
},
/******************************* ******************************/
{

View File

@ -4,7 +4,7 @@
<template #top>
<custom-nav-bar :left="true" title="设备运维"></custom-nav-bar>
<view class="search">
<uni-forms ref="form" :model="queryParams" labelWidth="0px">
<uni-forms ref="form" labelWidth="0px">
<uni-forms-item label="" name="">
<custom-land-tree :defaultLand="land" @change="handleTreeChange"
style="width: 100%;float: left;margin-right: 2px;"></custom-land-tree>
@ -153,6 +153,48 @@
</view>
</view>
</uni-collapse-item>
<uni-collapse-item title-border="none" :border="false" v-if="dataList[3]">
<template v-slot:title>
<view class="cards-title">
<view>
<view class="text">墒情</view>
</view>
</view>
</template>
<view class="content">
<view class="cards-content" v-for="item in dataList[3]">
<view class="card card-grey">
<view class="cards-title">
<view>
<view>{{ item.name }}</view>
</view>
<view class="right">
<u-button type="success" size="mini" text="刷新"
:loading="dc.dataObj[item.deviceCode]?.refresh"
@click="dc.refreshDeviceItem(item.deviceCode, item)" />
</view>
</view>
<view class="cards-content">
<view class="txt-list">
<view class="list2">
<view style="width: 100px;">
<text>层数</text>{{ item.floors }}
</view>
<view style="width: calc(100% - 100px);">
<text>深度</text>{{ item.depth }}
</view>
</view>
</view>
<view class="btn-grid">
<u-button type="primary" size="normal" text="修改配置"
v-hasPermi="['iot:deviceMp:add','iot:deviceMp:remove']"
@click="editMp(item)" />
</view>
</view>
</view>
</view>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
</z-paging>
@ -173,6 +215,7 @@
</custom-popup>
</template>
<script>
import plugins from "../../plugins";
import * as DevOpsApi from "@/api/dev-ops/index.js"
export default {
@ -203,7 +246,7 @@
list.push(lfObj);
}
this.rolaFrequency.range = list;
this.setQueryParams(getApp().ijs.land);
this.setQueryParams(getApp().ijs.getLandData);
const that = this;
getApp().on("mqtt", "mqtt_devOps_station", function(e) {
if (e.type == "state") {
@ -229,8 +272,21 @@
}
}
});
//
uni.$off("reload-type");
uni.$on("reload-type", (e) => {
plugins.modal.loading()
DevOpsApi.getList(that.landId).then(res => {
plugins.modal.closeLoading()
console.error("res:", res);
if (e == "mp") {
that.dataList[3] = res.data[e];
}
});
});
},
onShow() {},
mounted() {},
onUnload() {
getApp().mqttUnsubscribes(this.topics);
@ -254,43 +310,47 @@
},
queryList(pageNo, pageSize) {
DevOpsApi.getList(this.landId).then(res => {
// console.error("res:", res);
let station = [],
console.error("res:", res);
let topicRow = [],
station = [],
butterflyValve = [],
valve = [];
valve = [],
mp = [];
if (res.data.station) {
station = res.data.station;
topicRow = topicRow.concat(station);
}
if (res.data.butterflyValve) {
butterflyValve = res.data.butterflyValve;
topicRow = topicRow.concat(butterflyValve);
}
if (res.data.valve) {
valve = res.data.valve;
topicRow = topicRow.concat(valve);
}
if (res.data.mp) {
mp = res.data.mp;
}
let data = [];
if (station.length == 0 && butterflyValve.length == 0 && valve.length == 0) {
if (!station.length && !butterflyValve.length && !valve.length && !mp.length) {
data = [];
} else {
data = [station, butterflyValve, valve];
data = [station, butterflyValve, valve, mp];
}
this.$refs.paging.completeByTotal(data);
this.mqttSubscribes(data);
this.mqttSubscribes(topicRow);
});
},
mqttSubscribes(rows) {
console.error("rows:", rows);
if (rows && rows.length) {
let topics = [];
let topic = "jsy/iot/deviceConfig";
rows.forEach((x, index) => {
let topic = "jsy/iot/deviceConfig";
x.forEach(item => {
if (index == 0) {
topics.push(`${topic}/${item.deviceTypeId}/${item.deviceCode}`);
} else {
topics.push(
`${topic}/${item.device.deviceTypeId}/${item.device.deviceCode}`);
}
});
let item = x?.device || x;
topics.push(`${topic}/${item.deviceTypeId}/${item.deviceCode}`);
});
console.error("topics:", topics);
this.topics = topics;
getApp().mqttSubscribes(this.topics);
}
@ -400,6 +460,12 @@
console.error("压力查询:", item);
},
/************************************************** 墒情 **************************************************/
editMp(item) {
uni.navigateTo({
url: '/pages/dev-ops/editMp?id=' + item.id
});
},
/************************************************** 公共 **************************************************/

215
pages/dev-ops/editMp.vue Normal file
View File

@ -0,0 +1,215 @@
<template>
<!-- 顶部导航栏 -->
<custom-nav-bar :left="true" leftText="" @leftClick="" title="配置墒情"></custom-nav-bar>
<view class="create-container">
<u-form ref="formRef" :model="formData" :rules="rules">
<u-form-item label="方案名称" prop="name" required>
<!-- <u-input border="none" v-model="formData.name" :placeholder="rules.name[0].message" :disabled="true" /> -->
{{ formData.name }}
</u-form-item>
<u-line color="#D2D2D2"></u-line>
<u-form-item label="层数" prop="floors" required>
<u-input border="none" v-model="formData.floors" :placeholder="rules.floors[0].message" />
</u-form-item>
<u-line color="#D2D2D2"></u-line>
<u-form-item label="第一层深度" prop="firstDepth" required>
<u-input border="none" v-model="formData.firstDepth" @blur="inputChange($event,'firstDepth')"
:placeholder="rules.firstDepth[0].message" />
</u-form-item>
<u-line color="#D2D2D2"></u-line>
<u-form-item label="间隔" prop="interval" required>
<u-input border="none" v-model="formData.interval" @blur="inputChange($event,'interval')"
:placeholder="rules.interval[0].message" />
</u-form-item>
<u-line color="#D2D2D2"></u-line>
<u-form-item label="深度" prop="depth" required>
<!-- <u-input border="none" v-model="formData.depth" @blur="inputChange($event,'depth')"
:placeholder="rules.depth[0].message" /> -->
{{ formData.depth }}
</u-form-item>
<u-line color="#D2D2D2"></u-line>
<view class="form-btn">
<u-button type="success" size="large" text="确定" @click="confirm" />
<u-button size="large" text="取消" @click="close" />
</view>
</u-form>
</view>
</template>
<script>
import plugins from '../../plugins';
import * as mpApi from '@/api/iot/deviceMp.js'
export default {
data() {
return {
id: null,
formData: {
landId: undefined, // id
deviceId: undefined, // id
name: undefined, //
floors: undefined, //
firstDepth: undefined, //
interval: undefined, //
depth: undefined, //
},
rules: {
name: [{
required: true,
message: '请输入墒情名称',
// trigger: ['change', 'blur']
}],
floors: [{
required: true,
message: '请输入层数',
}, //
{
pattern: /^[0-9]*$/g,
//
transform(value) {
return String(value);
},
message: '只能包含数字'
}
],
firstDepth: [{
required: true,
message: '请输入第一层深度',
}, //
{
pattern: /^\d+(\.\d{1,2})?$/,
//
transform(value) {
return String(value);
},
message: '只能包含数字或2位内的小数'
}
],
interval: [{
required: true,
message: '请输入间隔',
}, //
{
pattern: /^\d+(\.\d{1,2})?$/,
//
transform(value) {
return String(value);
},
message: '只能包含数字或2位内的小数'
}
],
}
};
},
watch: {
"formData.floors": function(newV, oldV) {
this.calcDepth()
},
"formData.firstDepth": function(newV, oldV) {
this.calcDepth()
},
"formData.interval": function(newV, oldV) {
this.calcDepth()
},
},
onLoad(par) {
this.id = par.id || -1;
this.initData();
},
onShow() {},
methods: {
async initData() {
uni.showLoading()
mpApi.getDeviceMp(this.id).then(res => {
uni.hideLoading()
if (res.data) {
res.data.firstDepth = res.data.depth.split(",")[0];
res.data.interval = res.data.depth.split(",")[1] - res.data.depth.split(",")[0];
this.formData = res.data;
} else {
plugins.modal.alert("数据异常", () => {
this.close();
})
}
}).catch(error => {
uni.hideLoading()
})
},
inputChange(e, filed) {
//
let cleaned = e.replace(/[^0-9.]/g, '');
//
const [integerPart, decimalPart = ""] = cleaned.split('.').slice(0, 2);
const formattedDecimal = decimalPart ? `${integerPart}.${decimalPart.slice(0, 2)}` : integerPart;
this.formData[filed] = formattedDecimal;
},
//
calcDepth() {
if (this.formData.floors && this.formData.firstDepth && this.formData.interval) {
let firstDepth = Number(this.formData.firstDepth);
let interval = Number(this.formData.interval);
let depth = "";
for (var i = 0; i < this.formData.floors; i++) {
if (i == 0) {
depth = firstDepth;
} else {
depth = depth + "," + (firstDepth + (i * interval));
}
}
this.formData.depth = depth;
} else {
this.formData.depth = "";
}
},
confirm() {
this.$refs.formRef.validate().then(valid => {
if (valid) {
mpApi.updateDeviceMp(this.formData).then(response => {
plugins.modal.alert("修改配置成功", () => {
uni.$emit("reload-type", "mp")
this.close();
})
});
}
}).catch(() => {});
},
close() {
uni.navigateBack();
},
}
}
</script>
<style lang="scss" scoped>
body {
background-color: #fff;
}
//
.create-container {
padding: 0 20px;
background-color: #FFF;
// .custom-input {
// width: 280px;
// }
// .form-item {
// margin-left: 20px;
// display: flex;
// align-items: flex-start;
// width: 100%;
// }
::v-deep .u-form-item__body__left {
width: 100px !important;
}
}
//
.popup-content {
padding: 20px;
background-color: #fff;
text-align: center;
}
</style>

View File

@ -207,8 +207,11 @@
});
break;
case "DevOps": //
// uni.navigateTo({
// url: '/pages/dev-ops/index'
// });
uni.navigateTo({
url: '/pages/dev-ops/index'
url: '/pages/dev-ops/device'
});
break;
case "retrace": //

View File

@ -28,11 +28,16 @@ export default {
uni.hideToast()
},
// 弹出提示
alert(text) {
alert(text, callback = null) {
uni.showModal({
title: '提示',
content: text,
showCancel: false
showCancel: false,
success: function(res) {
if (typeof callback === 'function') {
callback();
}
}
})
},
// 确认窗体

View File

@ -1,4 +1,6 @@
import store from "@/store"
const user = store.state.user.user;
import plugin from "@/plugins"
import constant from "@/utils/constant.js"
import * as commonUtils from "@/utils/common.js"
import {
@ -45,6 +47,20 @@ class indexUtil {
}
}
get getLandData() {
console.error("land");
if (!user?.userId) {
plugin.modal.msg("请重新登录")
return null;
}
if (!this.land) {
this.initData(user.userId, function(_land, _wo) {});
}
return this.land;
}
/**
* 获取数据的规则
* 如果是第一次打开则先获取缓存如果有缓存则先使用缓存然后异步更新数据如果没有缓存则只能查询数据
@ -195,7 +211,7 @@ class indexUtil {
}
})
}
// 刷新控制中阀门
refreshControlling() {
const landId = this.land?.id;
@ -211,7 +227,7 @@ class indexUtil {
}
})
}
// 缓存数据
setStorage(type, data) {
switch (type) {