暂时提交
parent
7350b39f15
commit
696bcbd4e5
9
App.vue
9
App.vue
|
|
@ -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', () => {
|
||||||
|
|
|
||||||
|
|
@ -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'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -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) {
|
||||||
this.$set(this.limitTimes, `${this.currentCard.type}Limit`, this.newLimitTime);
|
var updateFlag = true;
|
||||||
if (this.limitTimes.imei) {
|
if (limitTimeUpdate) {
|
||||||
updateLimit(this.limitTimes).then(response => {
|
this.$set(this.limitTimes, `${this.currentCard.type}Limit`, this.newLimitTime);
|
||||||
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败")
|
if (this.limitTimes.imei) {
|
||||||
})
|
updateLimit(this.limitTimes).then(response => {
|
||||||
return;
|
if (response.code!==200) updateFlag=false;
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$set(this.limitTimes, 'imei', this.imei);
|
||||||
|
this.$set(this.limitTimes, 'agriName', this.selectedText);
|
||||||
|
this.$set(this.limitTimes, 'agriId', this.agriId);
|
||||||
|
addLimit(this.limitTimes).then(response => {
|
||||||
|
if (response.code!==200) updateFlag=false;
|
||||||
|
this.getAgriByImei();
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.$set(this.limitTimes, 'imei', this.imei);
|
if (remarkName) {
|
||||||
this.$set(this.limitTimes, 'agriName', this.selectedText);
|
this.$set(this.dtu_remark, `${this.currentCard.type}`, this.remark);
|
||||||
this.$set(this.limitTimes, 'agriId', this.agriId);
|
if (this.dtu_remark.imei) {
|
||||||
addLimit(this.limitTimes).then(response => {
|
updateRemark(this.dtu_remark).then(response => {
|
||||||
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败")
|
if (response.code!==200) updateFlag=false;
|
||||||
this.getAgriByImei();
|
})
|
||||||
})
|
} 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>
|
||||||
|
|
@ -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) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue