暂提-----运行时间

master
xce 2026-01-09 14:34:29 +08:00
parent 07ab68aba5
commit 3105c590bb
1 changed files with 143 additions and 7 deletions

View File

@ -56,7 +56,7 @@
class="control-card" class="control-card"
v-for="card in deviceCards" v-for="card in deviceCards"
:key="card.type" :key="card.type"
@click="handleCardClick(1 - status[card.type], card.type)" @click="openTimeModal(card)"
> >
<view class="card-text"> <view class="card-text">
<text class="card-main">{{ card.name }}</text> <text class="card-main">{{ card.name }}</text>
@ -65,7 +65,8 @@
<text class="limit-time">运行时间{{ limitTimes[card.type] || 0 }} s</text> <text class="limit-time">运行时间{{ limitTimes[card.type] || 0 }} s</text>
</view> </view>
</view> </view>
<view class="card-icon" :class="{ active: status[card.type] === 1 }"> <view class="card-icon" :class="{ active: status[card.type] === 1 }" @click.stop="handleCardClick(1 - status[card.type], card.type)">
<!-- @click.stop防止冒泡触发卡片点击的弹窗事件 -->
<uni-icons <uni-icons
:type="status[card.type] === 1 ? 'circle' : 'circle-filled'" :type="status[card.type] === 1 ? 'circle' : 'circle-filled'"
size="24" size="24"
@ -75,6 +76,42 @@
</view> </view>
</view> </view>
</uni-section> </uni-section>
<!-- 输入框示例 -->
<!-- <uni-popup ref="inputDialog" type="dialog">-->
<!-- <uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!"-->
<!-- placeholder="请输入内容" @confirm="confirmModifyTime"></uni-popup-dialog>-->
<!-- </uni-popup>-->
<uni-popup v-model="timeModalVisible" ref="inputDialog" mode="center" :z-index="99999">
<!-- 新增修改运行时间的弹窗 -->
<!-- <uni-popup v-model="timeModalVisible" mode="center">-->
<view class="modal-container">
<view class="modal-title">修改{{ currentCard.name }}运行时间</view>
<view class="modal-input-wrap">
<text class="modal-label">当前时间</text>
<text class="modal-current">{{ currentCardTime }} s</text>
</view>
<view class="modal-input-wrap">
<text class="modal-label">新时间</text>
<input
class="modal-input"
type="number"
v-model.number="newTime"
placeholder="请输入1-60的数字"
min="1"
max="60"
/>
<text class="modal-unit">s</text>
</view>
<view class="modal-btn-wrap">
<button class="modal-btn cancel" @click="">取消</button>
<button class="modal-btn confirm" @click="confirmModifyTime"></button>
</view>
</view>
</uni-popup>
</view> </view>
</template> </template>
@ -87,13 +124,15 @@ const SENSOR_MAP = {
const MQTT_TOPIC_SUFFIX = { UP: "/up", DOWN: "/down" }; const MQTT_TOPIC_SUFFIX = { UP: "/up", DOWN: "/down" };
import UniDatetimePicker from "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue"; import UniDatetimePicker from "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
import UniPopup from "../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; //
import { findDtuDataByInfo } from "@/api/system/data"; import { findDtuDataByInfo } from "@/api/system/data";
import mqttUtil from '@/utils/mqtt'; import mqttUtil from '@/utils/mqtt';
export default { export default {
dicts: ['sys_data_map'], dicts: ['sys_data_map'],
components: { components: {
UniDatetimePicker UniDatetimePicker,
UniPopup //
}, },
data() { data() {
return { return {
@ -190,7 +229,12 @@ export default {
jm3k: 0, jm3k: 0,
jm3g: 0 jm3g: 0
}, },
fontStyle: '' fontStyle: '',
//
timeModalVisible: false, //
currentCard: {}, //
currentCardTime: 0, //
newTime: 0 //
}; };
}, },
onLoad() { onLoad() {
@ -309,13 +353,13 @@ export default {
// //
this.message = JSON.stringify({[type]: status}) this.message = JSON.stringify({[type]: status})
// //
this.publishMessage(); // this.publishMessage();
// //
this.deviceType = type; this.deviceType = type;
//todo //todo
// this.status[type] = this.status[type] === 0 ? 1 : 0; this.$set(this.status, type, this.status[type] === 0 ? 1 : 0);
// this.show[type] = this.status[type] === 0 ? "" : ""; this.$set(this.show, type, this.status[type] === 0 ? "暂停" : "运行");
} }
} }
@ -446,6 +490,39 @@ export default {
// 湿 // 湿
isEffectiveValue(value) { isEffectiveValue(value) {
return this.testNumber(value); return this.testNumber(value);
},
//
openTimeModal(card) {
this.currentCard = card; //
this.currentCardTime = this.limitTimes[card.type]; //
this.newTime = this.currentCardTime; //
this.timeModalVisible = true; //
console.info(`this.timeModalVisible:${this.timeModalVisible}`);
this.$refs.inputDialog.open()
},
//
confirmModifyTime() {
// 1-60
if (!this.newTime || this.newTime < 1 || this.newTime > 60) {
uni.showToast({
title: '请输入1-60的有效数字',
icon: 'none'
});
return;
}
// limitTimes$set
this.$set(this.limitTimes, this.currentCard.type, this.newTime);
//
uni.showToast({
title: '运行时间修改成功',
icon: 'success'
});
//
this.$refs.inputDialog.close()
//
// this.saveLimitTimeToServer(this.currentCard.type, this.newTime);
} }
}, },
onHide() { onHide() {
@ -594,4 +671,63 @@ export default {
/deep/ .uni-section-header__slot-right { /deep/ .uni-section-header__slot-right {
color: green; color: green;
} }
/* 新增:弹窗样式 */
.modal-container {
width: 600rpx;
background: #fff;
border-radius: 16rpx;
padding: 30rpx 20rpx;
}
.modal-title {
font-size: 30rpx;
font-weight: 500;
text-align: center;
margin-bottom: 30rpx;
color: #333;
}
.modal-input-wrap {
display: flex;
align-items: center;
margin-bottom: 25rpx;
font-size: 26rpx;
}
.modal-label {
width: 120rpx;
color: #666;
}
.modal-current {
color: #333;
}
.modal-input {
flex: 1;
height: 60rpx;
border: 1px solid #eee;
border-radius: 8rpx;
padding: 0 15rpx;
font-size: 26rpx;
}
.modal-unit {
margin-left: 10rpx;
color: #666;
}
.modal-btn-wrap {
display: flex;
gap: 20rpx;
margin-top: 40rpx;
}
.modal-btn {
flex: 1;
height: 70rpx;
border-radius: 8rpx;
font-size: 26rpx;
}
.modal-btn.cancel {
background: #f5f5f5;
color: #666;
}
.modal-btn.confirm {
background: #007aff;
color: #fff;
}
</style> </style>