暂时提交

master
lld 2026-01-21 23:59:45 +08:00
parent 7350b39f15
commit 696bcbd4e5
4 changed files with 139 additions and 24 deletions

View File

@ -16,6 +16,15 @@ export default {
} }
}, },
onLaunch: function() { onLaunch: function() {
//
if (process.env.NODE_ENV === 'development') {
// HBuilderX
document.addEventListener('uni-app:reload', () => {
console.log('开发环境代码热更新') ;
mqttUtil.disconnectMqtt(); // MQTT
});
}
// #ifdef H5 // #ifdef H5
// H5/ // H5/
window.addEventListener('beforeunload', () => { window.addEventListener('beforeunload', () => {

View File

@ -0,0 +1,52 @@
import request from '@/utils/request'
// 查询dtu设备备注列表
export function listRemark(query) {
return request({
url: '/assets/remark/list',
method: 'get',
params: query
})
}
// 查询dtu设备备注详细
export function getRemark(id) {
return request({
url: '/assets/remark/' + id,
method: 'get'
})
}
// 查询dtu设备备注详细
export function getRemarkByImei(imei) {
return request({
url: '/assets/remark/getDtuByImei',
method: 'get',
params: imei
})
}
// 新增dtu设备备注
export function addRemark(data) {
return request({
url: '/assets/remark',
method: 'post',
data: data
})
}
// 修改dtu设备备注
export function updateRemark(data) {
return request({
url: '/assets/remark',
method: 'put',
data: data
})
}
// 删除dtu设备备注
export function delRemark(id) {
return request({
url: '/assets/remark/' + id,
method: 'delete'
})
}

View File

@ -25,7 +25,8 @@
{{ liveData[item.key] }} {{ liveData[item.key] }}
<text v-if="isEffectiveValue(liveData[item.key])" class="tempStyle"></text> <text v-if="isEffectiveValue(liveData[item.key])" class="tempStyle"></text>
</text> </text>
<text class="data">{{ item.label }}</text> <text class="data" v-if="dtu_remark[item.key]">{{ dtu_remark[item.key] }}</text>
<text class="data" v-else>{{ item.label }}</text>
</view> </view>
</view> </view>
@ -40,7 +41,8 @@
{{ liveData[item.key] }} {{ liveData[item.key] }}
<text v-if="isEffectiveValue(liveData[item.key])" class="humiStyle"> %RH</text> <text v-if="isEffectiveValue(liveData[item.key])" class="humiStyle"> %RH</text>
</text> </text>
<text class="data">{{ item.label }}</text> <text class="data" v-if="dtu_remark[item.key]">{{ dtu_remark[item.key] }}</text>
<text class="data" v-else>{{ item.label }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -85,10 +87,10 @@
<uni-popup ref="inputDialog" mode="center" > <uni-popup ref="inputDialog" mode="center" >
<!-- 新增修改运行时间的弹窗 --> <!-- 新增修改运行时间的弹窗 -->
<view class="modal-container"> <view class="modal-container">
<view class="modal-title">{{ `${selectedText} - ${currentCard.name}运行时间` }}</view> <view class="modal-title">{{ `${selectedText} - ${currentCard.name}设置` }}</view>
<view class="modal-input-wrap"> <view class="modal-input-wrap">
<text class="modal-label">当前时间</text> <text class="modal-label">当前时间</text>
<text class="modal-current">{{ currentCardTime ? `${currentCardTime}` : '未设置' }}</text> <text class="modal-current">{{ currentCardTime>0 ? `${currentCardTime}` : '未设置' }}</text>
</view> </view>
<view class="modal-input-wrap" > <view class="modal-input-wrap" >
<text class="modal-label">修改后时间</text> <text class="modal-label">修改后时间</text>
@ -100,6 +102,11 @@
<!-- <uni-number-box v-model="newLimitTime" />--> <!-- <uni-number-box v-model="newLimitTime" />-->
<text class="modal-unit"></text> <text class="modal-unit"></text>
</view> </view>
<view class="modal-input-wrap" >
<text class="modal-label">别名设置</text>
<uni-easyinput style="width: 100px" v-model="remark" placeholder="不填展示默认备注" />
</view>
<view class="modal-btn-wrap"> <view class="modal-btn-wrap">
<button class="modal-btn cancel" @click="close"></button> <button class="modal-btn cancel" @click="close"></button>
<button class="modal-btn confirm" @click="confirmModifyTime"></button> <button class="modal-btn confirm" @click="confirmModifyTime"></button>
@ -128,6 +135,7 @@ import {addLimit, getAgriByImei, updateLimit} from "../../api/system/assets/limi
import {listAgri} from "../../api/system/assets/agri"; import {listAgri} from "../../api/system/assets/agri";
import {getNewSpecialData} from "../../api/data/specialData"; import {getNewSpecialData} from "../../api/data/specialData";
import store from "../../store"; import store from "../../store";
import {getRemarkByImei, updateRemark} from "../../api/system/assets/remark";
export default { export default {
dicts: ['sys_data_map'], dicts: ['sys_data_map'],
@ -156,6 +164,8 @@ export default {
message: {}, message: {},
// connected // connected
connected: false, connected: false,
remark:'',
dtu_remark:{},
liveData: { liveData: {
temp1: '数据加载中...', temp1: '数据加载中...',
temp2: '数据加载中...', temp2: '数据加载中...',
@ -228,7 +238,7 @@ export default {
fontStyle: '', fontStyle: '',
// //
currentCard: {}, // currentCard: {}, //
currentCardTime: 0, // currentCardTime: '', //
newLimitTime: 0, // newLimitTime: 0, //
}; };
}, },
@ -298,6 +308,7 @@ export default {
this.fontStyle = 'font-size:16px;' this.fontStyle = 'font-size:16px;'
}) })
this.getAgriByImei(); this.getAgriByImei();
this.getRemarkByImei();
} }
} else { } else {
this.selectedText = ''; // this.selectedText = ''; //
@ -308,6 +319,13 @@ export default {
this.reset(); this.reset();
this.style=""; this.style="";
}, },
getRemarkByImei() {
getRemarkByImei({imei:this.imei}).then(response => {
if (response.code===200 && (response.data)) {
this.dtu_remark={...response.data}
}
});
},
getAgriByImei() { getAgriByImei() {
getAgriByImei(this.imei).then(response => { getAgriByImei(this.imei).then(response => {
if (response.code === 200) { if (response.code === 200) {
@ -593,6 +611,7 @@ export default {
this.currentCard = card; // this.currentCard = card; //
this.currentCardTime = this.limitTimes[`${card.type}Limit`]; // this.currentCardTime = this.limitTimes[`${card.type}Limit`]; //
this.newLimitTime = this.currentCardTime; // this.newLimitTime = this.currentCardTime; //
this.remark = this.remark[card.type] || card.name;
this.$refs.inputDialog.open() this.$refs.inputDialog.open()
}, },
close() { close() {
@ -608,31 +627,62 @@ export default {
}); });
return; return;
}*/ }*/
var showText = `确定修改${this.selectedText}-${this.currentCard.name}\n1. `;
// limitTimes$set // limitTimes$set
if (this.newLimitTime !== this.currentCardTime) { var limitTimeUpdate = this.newLimitTime !== this.currentCardTime;
if (limitTimeUpdate) {
showText += `运行时间为:${this.newLimitTime} 秒?`
}
var remarkName = this.remark !== (this.remark[this.currentCard.type] || this.currentCard.name);
if (limitTimeUpdate && remarkName) {
showText += `\n2. `
}
if (remarkName) {
showText += `别名设置为:${this.remark}`
}
if (limitTimeUpdate || remarkName) {
//
// //
uni.showModal({ uni.showModal({
title: '温馨提示:', title: '温馨提示:',
content: `确定修改${this.selectedText}-${this.currentCard.name}运行时间为:${this.newLimitTime} 秒?`, content: `${showText}`,
cancelText: '取消', cancelText: '取消',
confirmText: '确定', confirmText: '确定',
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
var updateFlag = true;
if (limitTimeUpdate) {
this.$set(this.limitTimes, `${this.currentCard.type}Limit`, this.newLimitTime); this.$set(this.limitTimes, `${this.currentCard.type}Limit`, this.newLimitTime);
if (this.limitTimes.imei) { if (this.limitTimes.imei) {
updateLimit(this.limitTimes).then(response => { updateLimit(this.limitTimes).then(response => {
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败") if (response.code!==200) updateFlag=false;
}) })
return; } else {
}
this.$set(this.limitTimes, 'imei', this.imei); this.$set(this.limitTimes, 'imei', this.imei);
this.$set(this.limitTimes, 'agriName', this.selectedText); this.$set(this.limitTimes, 'agriName', this.selectedText);
this.$set(this.limitTimes, 'agriId', this.agriId); this.$set(this.limitTimes, 'agriId', this.agriId);
addLimit(this.limitTimes).then(response => { addLimit(this.limitTimes).then(response => {
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败") if (response.code!==200) updateFlag=false;
this.getAgriByImei(); this.getAgriByImei();
}) })
}
}
if (remarkName) {
this.$set(this.dtu_remark, `${this.currentCard.type}`, this.remark);
if (this.dtu_remark.imei) {
updateRemark(this.dtu_remark).then(response => {
if (response.code!==200) updateFlag=false;
})
} else {
this.$set(this.dtu_remark, 'imei', this.imei);
updateRemark(this.dtu_remark).then(response => {
if (response.code!==200) updateFlag=false;
this.getRemarkByImei();
})
}
}
updateFlag?this.$modal.msgError("修改成功"):this.$modal.msgSuccess("修改失败")
} }
} }
}) })
@ -801,14 +851,15 @@ export default {
font-size: 30rpx; font-size: 30rpx;
font-weight: 500; font-weight: 500;
text-align: center; text-align: center;
margin-bottom: 30rpx; margin-bottom: 40rpx;
color: #333; color: #333;
} }
.modal-input-wrap { .modal-input-wrap {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 25rpx; margin-bottom: 35rpx;
font-size: 26rpx; font-size: 26rpx;
margin-left: 20rpx;
} }
.modal-label { .modal-label {
width: 160rpx; width: 160rpx;
@ -855,4 +906,7 @@ export default {
.uni-stat-tooltip { .uni-stat-tooltip {
width: 300rpx; width: 300rpx;
} }
/deep/ .is-input-border {
width: 340rpx;
}
</style> </style>

View File

@ -302,7 +302,7 @@ export function startMqttOnlinePing(intervalMs = 20000) {
const payload = JSON.stringify({ ts: Date.now() }); const payload = JSON.stringify({ ts: Date.now() });
// qos=0 足够retain 不要 // qos=0 足够retain 不要
mqttState.client.publish(topic, payload, { qos: 0, retain: false }); mqttState.client.publish(topic, payload, { qos: 0, retain: false });
console.info(`主题:${topic}${payload}`) // console.info(`主题:${topic}${payload}`)
} catch (e) {} } catch (e) {}
}; };