增加限位时间+ 大棚相关api接入+登录密码展示
parent
e720c37b68
commit
610814d178
|
|
@ -0,0 +1,44 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询大棚管理列表
|
||||
export function listAgri(query) {
|
||||
return request({
|
||||
url: '/assets/agri/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询大棚管理详细
|
||||
export function getAgri(id) {
|
||||
return request({
|
||||
url: '/assets/agri/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增大棚管理
|
||||
export function addAgri(data) {
|
||||
return request({
|
||||
url: '/assets/agri',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改大棚管理
|
||||
export function updateAgri(data) {
|
||||
return request({
|
||||
url: '/assets/agri',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除大棚管理
|
||||
export function delAgri(id) {
|
||||
return request({
|
||||
url: '/assets/agri/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询告警方式设置列表
|
||||
export function listAlarm(query) {
|
||||
return request({
|
||||
url: '/assets/alarm/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询告警方式设置详细
|
||||
export function getAlarm(id) {
|
||||
return request({
|
||||
url: '/assets/alarm/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增告警方式设置
|
||||
export function addAlarm(data) {
|
||||
return request({
|
||||
url: '/assets/alarm',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改告警方式设置
|
||||
export function updateAlarm(data) {
|
||||
return request({
|
||||
url: '/assets/alarm',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除告警方式设置
|
||||
export function delAlarm(id) {
|
||||
return request({
|
||||
url: '/assets/alarm/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询执行时间限位管理列表
|
||||
export function listLimit(query) {
|
||||
return request({
|
||||
url: '/assets/limit/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询执行时间限位管理详细
|
||||
export function getLimit(id) {
|
||||
return request({
|
||||
url: '/assets/limit/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增执行时间限位管理
|
||||
export function addLimit(data) {
|
||||
return request({
|
||||
url: '/assets/limit',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改执行时间限位管理
|
||||
export function updateLimit(data) {
|
||||
return request({
|
||||
url: '/assets/limit',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除执行时间限位管理
|
||||
export function delLimit(id) {
|
||||
return request({
|
||||
url: '/assets/limit/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 大棚运行时间限位查询
|
||||
export function getAgriByImei(id) {
|
||||
return request({
|
||||
url: '/assets/limit/getAgriByImei/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
2
main.js
2
main.js
|
|
@ -13,7 +13,7 @@ Vue.use(plugins)
|
|||
Vue.config.productionTip = false
|
||||
Vue.prototype.$store = store
|
||||
Vue.prototype.getDicts = getDicts
|
||||
|
||||
window.wx={}
|
||||
App.mpType = 'app'
|
||||
|
||||
const app = new Vue({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<view class="container">
|
||||
<!-- 控制设置标题 -->
|
||||
<view class="control-title">控制设置</view>
|
||||
<uni-section title="请选择大棚:" titleFontSize="18px" type="line">
|
||||
<uni-section title="请选择大棚:" :subTitle="imei" titleFontSize="18px" type="line">
|
||||
<view class="uni-px-5 uni-pb-5">
|
||||
<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
|
||||
</view>
|
||||
|
|
@ -62,7 +62,9 @@
|
|||
<text class="card-main">{{ card.name }}</text>
|
||||
<view class="card-sub-wrapper">
|
||||
<text class="card-sub" v-if="showStatusText">{{ show[card.type] || '未知' }}</text>
|
||||
<text class="limit-time">运行时间:{{ limitTimes[card.type] || 0 }} s</text>
|
||||
<text class="limit-time">
|
||||
运行时间:{{ limitTimes[`${card.type}Limit`] && limitTimes[`${card.type}Limit`]!=='0' ? `${limitTimes[`${card.type}Limit`]} s` : '- -' }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card-icon" :class="{ active: status[card.type] === 1 }" @click.stop="handleCardClick(1 - status[card.type], card.type)">
|
||||
|
|
@ -79,35 +81,22 @@
|
|||
|
||||
|
||||
|
||||
<!-- 输入框示例 -->
|
||||
<!-- <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 ref="inputDialog" mode="center" >
|
||||
<!-- 新增:修改运行时间的弹窗 -->
|
||||
<!-- <uni-popup v-model="timeModalVisible" mode="center">-->
|
||||
<view class="modal-container">
|
||||
<view class="modal-title">修改{{ currentCard.name }}运行时间</view>
|
||||
<view class="modal-title">{{ `【${selectedText} - ${currentCard.name}】运行时间` }}</view>
|
||||
<view class="modal-input-wrap">
|
||||
<text class="modal-label">当前时间:</text>
|
||||
<text class="modal-current">{{ currentCardTime }} s</text>
|
||||
<text class="modal-current">{{ currentCardTime ? `${currentCardTime} 秒` : '未设置' }}</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 class="modal-input-wrap" >
|
||||
<text class="modal-label">修改后时间:</text>
|
||||
<uni-number-box v-model="newLimitTime" />
|
||||
<text class="modal-unit">秒</text>
|
||||
</view>
|
||||
<view class="modal-btn-wrap">
|
||||
<button class="modal-btn cancel" @click="">取消</button>
|
||||
<button class="modal-btn cancel" @click="close">取消</button>
|
||||
<button class="modal-btn confirm" @click="confirmModifyTime">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -117,6 +106,8 @@
|
|||
|
||||
<script>
|
||||
// 优化:抽离魔法值常量
|
||||
import UniPopupDialog from "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue";
|
||||
|
||||
const SENSOR_MAP = {
|
||||
temp1: "201", temp2: "202", temp3: "203", temp4: "204",
|
||||
humi1: "101", humi2: "102", humi3: "103", humi4: "104"
|
||||
|
|
@ -127,10 +118,15 @@ import UniDatetimePicker from "../../uni_modules/uni-datetime-picker/components/
|
|||
import UniPopup from "../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; // 引入弹窗组件
|
||||
import { findDtuDataByInfo } from "@/api/system/data";
|
||||
import mqttUtil from '@/utils/mqtt';
|
||||
import UniNumberBox from "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue";
|
||||
import {addLimit, getAgriByImei, updateLimit} from "../../api/system/assets/limit";
|
||||
import {listAgri} from "../../api/system/assets/agri";
|
||||
|
||||
export default {
|
||||
dicts: ['sys_data_map'],
|
||||
components: {
|
||||
UniNumberBox,
|
||||
UniPopupDialog,
|
||||
UniDatetimePicker,
|
||||
UniPopup // 注册弹窗组件
|
||||
},
|
||||
|
|
@ -141,22 +137,12 @@ export default {
|
|||
subscribeTopic:'/up',
|
||||
},
|
||||
value: 1,
|
||||
selectedText: '',
|
||||
// 优化:语义化变量名(替换原 hide: false)
|
||||
showStatusText: false,
|
||||
control: '正在加载中...',
|
||||
range: [{
|
||||
"value": '864865085016294',
|
||||
"text": "十方北棚"
|
||||
}, {
|
||||
"value": '864536071808560',
|
||||
"text": "七方北棚",
|
||||
}, {
|
||||
"value": '862538065276939',
|
||||
"text": "七方南棚",
|
||||
},{
|
||||
"value": '864865085008135',
|
||||
"text": "八方北棚"
|
||||
}],
|
||||
range: [],
|
||||
agriId:'',
|
||||
imei:'',
|
||||
publishTopic: '/down',
|
||||
title:'',
|
||||
|
|
@ -212,14 +198,14 @@ export default {
|
|||
},
|
||||
// 新增:限位时间配置
|
||||
limitTimes: {
|
||||
jbk: 30,
|
||||
jbg: 25,
|
||||
jm1k: 30,
|
||||
jm1g: 28,
|
||||
jm2k: 30,
|
||||
jm2g: 26,
|
||||
jm3k: 30,
|
||||
jm3g: 29
|
||||
jbkLimit: 0,
|
||||
jbgLimit: 0,
|
||||
jm1kLimit: 0,
|
||||
jm1gLimit: 0,
|
||||
jm2kLimit: 0,
|
||||
jm2gLimit: 0,
|
||||
jm3kLimit: 0,
|
||||
jm3gLimit: 0
|
||||
},
|
||||
deviceType: '',
|
||||
status: {
|
||||
|
|
@ -234,10 +220,9 @@ export default {
|
|||
},
|
||||
fontStyle: '',
|
||||
// 新增:弹窗相关变量
|
||||
timeModalVisible: false, // 弹窗显示状态
|
||||
currentCard: {}, // 当前点击的卡片信息
|
||||
currentCardTime: 0, // 当前卡片的运行时间
|
||||
newTime: 0 // 新的运行时间
|
||||
newLimitTime: 0 // 新的运行时间
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
|
|
@ -257,6 +242,7 @@ export default {
|
|||
});
|
||||
},
|
||||
onShow() {
|
||||
this.getAgriList();
|
||||
// 注册MQTT消息回调(接收设备消息)
|
||||
mqttUtil.setOnMessageCallback(this.ackMessage);
|
||||
// 更新连接状态
|
||||
|
|
@ -275,6 +261,7 @@ export default {
|
|||
const selectedItem = this.range.find(item => item.value === e);
|
||||
if (selectedItem) {
|
||||
this.selectedText = selectedItem.text; // 获取展示文本
|
||||
this.agriId = selectedItem.agriId;
|
||||
this.title= this.selectedText;
|
||||
var queryParams = {
|
||||
imei: this.imei
|
||||
|
|
@ -286,15 +273,38 @@ export default {
|
|||
this.temp = "最后更新时间:"+response.data.time;
|
||||
this.fontStyle = 'font-size:16px;'
|
||||
})
|
||||
this.getAgriByImei();
|
||||
} else {
|
||||
this.selectedText = ''; // 无匹配项时清空
|
||||
this.title='';
|
||||
this.value=1;
|
||||
this.agriId = '';
|
||||
}
|
||||
this.reset();
|
||||
this.style="";
|
||||
},
|
||||
|
||||
getAgriByImei() {
|
||||
getAgriByImei(this.imei).then(response => {
|
||||
if (response.code === 200) {
|
||||
if (!response.data) {
|
||||
return;
|
||||
}
|
||||
this.limitTimes = response.data;
|
||||
}
|
||||
})
|
||||
},
|
||||
getAgriList() {
|
||||
listAgri().then(response => {
|
||||
if (response.code === 200) {
|
||||
this.range = response.rows.map(item => ({
|
||||
agriId: item.id,
|
||||
text: item.agriName,
|
||||
value: item.imei // 提取并改名
|
||||
}));
|
||||
console.info(this.range);
|
||||
}
|
||||
})
|
||||
},
|
||||
reset() {
|
||||
Object.keys(this.show).forEach(key => {
|
||||
this.show[key] = "暂停";
|
||||
|
|
@ -305,6 +315,16 @@ export default {
|
|||
Object.keys(this.liveData).forEach(key => {
|
||||
this.liveData[key] = '数据加载中...';
|
||||
});
|
||||
this.limitTimes= {
|
||||
jbkLimit: 0,
|
||||
jbgLimit: 0,
|
||||
jm1kLimit: 0,
|
||||
jm1gLimit: 0,
|
||||
jm2kLimit: 0,
|
||||
jm2gLimit: 0,
|
||||
jm3kLimit: 0,
|
||||
jm3gLimit: 0
|
||||
};
|
||||
this.deviceType = '';
|
||||
this.control = '正在加载中...';
|
||||
this.message = {};
|
||||
|
|
@ -498,34 +518,56 @@ export default {
|
|||
// 新增:打开修改运行时间的弹窗
|
||||
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.currentCardTime = this.limitTimes[`${card.type}Limit`]; // 记录当前时间
|
||||
this.newLimitTime = this.currentCardTime; // 默认填充当前时间
|
||||
this.$refs.inputDialog.open()
|
||||
},
|
||||
|
||||
close() {
|
||||
this.$refs.inputDialog.close()
|
||||
},
|
||||
// 新增:确认修改运行时间
|
||||
confirmModifyTime() {
|
||||
// 校验输入:必须是1-60的数字
|
||||
if (!this.newTime || this.newTime < 1 || this.newTime > 60) {
|
||||
/*if (!this.newLimitTime || this.newLimitTime < 1 || this.newLimitTime > 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'
|
||||
});
|
||||
if (this.newLimitTime !== this.currentCardTime) {
|
||||
// 提示修改成功
|
||||
uni.showModal({
|
||||
title: '温馨提示:',
|
||||
content: `确定修改${this.selectedText}-${this.currentCard.name}运行时间为:${this.newLimitTime} 秒?`,
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.$set(this.limitTimes, `${this.currentCard.type}Limit`, this.newLimitTime);
|
||||
if (this.limitTimes.imei) {
|
||||
updateLimit(this.limitTimes).then(response => {
|
||||
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败")
|
||||
})
|
||||
return;
|
||||
}
|
||||
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 => {
|
||||
response.code === 200 ? this.$modal.msgSuccess("修改成功"):this.$modal.msgSuccess("修改失败")
|
||||
this.getAgriByImei();
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// 关闭弹窗
|
||||
this.$refs.inputDialog.close()
|
||||
// (可选)这里可以加接口请求,把新时间同步到后端
|
||||
// this.saveLimitTimeToServer(this.currentCard.type, this.newTime);
|
||||
// this.saveLimitTimeToServer(this.currentCard.type, this.newLimitTime);
|
||||
}
|
||||
},
|
||||
onHide() {
|
||||
|
|
@ -627,7 +669,7 @@ export default {
|
|||
}
|
||||
|
||||
.uni-pb-5 {
|
||||
padding-bottom: 40rpx;
|
||||
padding-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
|
|
@ -696,7 +738,7 @@ export default {
|
|||
font-size: 26rpx;
|
||||
}
|
||||
.modal-label {
|
||||
width: 120rpx;
|
||||
width: 160rpx;
|
||||
color: #666;
|
||||
}
|
||||
.modal-current {
|
||||
|
|
@ -733,4 +775,11 @@ export default {
|
|||
background: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
.icon {
|
||||
margin-left: 15rpx
|
||||
}
|
||||
.uni-stat-tooltip {
|
||||
width: 300rpx;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
@ -10,9 +10,17 @@
|
|||
<view class="iconfont icon-user icon"></view>
|
||||
<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
|
||||
</view>
|
||||
<view class="input-item flex align-center">
|
||||
<view class="input-item flex align-center" style="position: relative;">
|
||||
<view class="iconfont icon-password icon"></view>
|
||||
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
|
||||
<input v-model="loginForm.password" :type="isShowPwd?'text':'password'" class="input" placeholder="请输入密码" maxlength="20" />
|
||||
<!-- 替换为 uni-icons 密码图标 -->
|
||||
<uni-icons
|
||||
class="pwd-icon"
|
||||
:type="isShowPwd ? 'eye-filled' : 'eye'"
|
||||
size="18"
|
||||
color="#666"
|
||||
@click="isShowPwd = !isShowPwd"
|
||||
></uni-icons>
|
||||
</view>
|
||||
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
|
||||
<view class="iconfont icon-code icon"></view>
|
||||
|
|
@ -41,10 +49,13 @@
|
|||
<script>
|
||||
import { getCodeImg } from '@/api/login'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import UniIcons from "../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
|
||||
|
||||
export default {
|
||||
components: {UniIcons},
|
||||
data() {
|
||||
return {
|
||||
isShowPwd: false,
|
||||
codeUrl: "",
|
||||
captchaEnabled: true,
|
||||
// 用户注册开关
|
||||
|
|
@ -147,7 +158,13 @@
|
|||
page {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.pwd-icon {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
.normal-login-container {
|
||||
width: 100%;
|
||||
|
||||
|
|
@ -184,14 +201,19 @@
|
|||
color: #999;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 100%;
|
||||
.input,
|
||||
.input:focus,
|
||||
.input:active,
|
||||
.input:hover {
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
background-color: #f5f6f7; /* 输入框背景色(和页面背景区分) */
|
||||
text-align: left;
|
||||
padding-left: 15px;
|
||||
border: none;
|
||||
outline: none !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
|
|
|
|||
Loading…
Reference in New Issue