新增大棚重命名,无线不加自动化切换按钮
|
|
@ -41,6 +41,13 @@ export function updateAgri(data) {
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function renameAgriName(data) {
|
||||||
|
return request({
|
||||||
|
url: '/assets/agri/renameAgriName',
|
||||||
|
method: 'put',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 删除大棚管理
|
// 删除大棚管理
|
||||||
export function delAgri(id) {
|
export function delAgri(id) {
|
||||||
|
|
|
||||||
|
|
@ -132,35 +132,9 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
<style scoped >
|
<style scoped >
|
||||||
|
|
||||||
/* 新增:弹窗样式 */
|
|
||||||
.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: 40rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.modal-input-wrap {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
|
||||||
.modal-input-wrap:nth-child(2) {
|
.modal-input-wrap:nth-child(2) {
|
||||||
margin-bottom: 35rpx;
|
margin-bottom: 35rpx;
|
||||||
}
|
}
|
||||||
.modal-label {
|
|
||||||
width: 140rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-btn-wrap {
|
.modal-btn-wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 20rpx;
|
gap: 20rpx;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
import { getHistoryData} from "../../api/system/data";
|
import { getHistoryData} from "../../api/system/data";
|
||||||
import {listAgri} from "../../api/system/assets/agri";
|
import {listAgri} from "../../api/system/assets/agri";
|
||||||
import store from "../../store";
|
import store from "../../store";
|
||||||
import {parseTime,isIntervalMoreThanNDays} from "../../utils/agri";
|
import {parseTime, isIntervalMoreThanNDays, getExactDiffDays} from "../../utils/agri";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
|
|
@ -119,7 +119,6 @@ export default {
|
||||||
startTime: this.dateRange[0],
|
startTime: this.dateRange[0],
|
||||||
endTime: this.dateRange[1]
|
endTime: this.dateRange[1]
|
||||||
}
|
}
|
||||||
console.info("查询参数",param)
|
|
||||||
//模拟从服务器获取数据时的延时
|
//模拟从服务器获取数据时的延时
|
||||||
getHistoryData(param).then(response => {
|
getHistoryData(param).then(response => {
|
||||||
if (response.code === 200 && response.data) {
|
if (response.code === 200 && response.data) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<view class="card shadow shadow-lg bg-white ">
|
<view class="card shadow shadow-lg bg-white ">
|
||||||
<uni-section :title="`当前大棚:【${selectedText}】`" :subTitle="imei" titleFontSize="16px" type="line" >
|
<uni-section :title="`当前大棚:【${selectedText}】`" :subTitle="imei" titleFontSize="16px" type="line" >
|
||||||
<template v-slot:right>
|
<template v-slot:right>
|
||||||
<view class="switch-row">
|
<view class="switch-row" v-if="value!== 1 && !['862538065276939','A','B','C'].includes(value)">
|
||||||
<text class="modal-text">手动</text>
|
<text class="modal-text">手动</text>
|
||||||
<tn-switch
|
<tn-switch
|
||||||
v-model="currentMode"
|
v-model="currentMode"
|
||||||
|
|
|
||||||
|
|
@ -656,76 +656,6 @@ export default {
|
||||||
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: 40rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-input-wrap {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 35rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-label {
|
|
||||||
width: 160rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-current {
|
|
||||||
margin-left: 14rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-input {
|
|
||||||
height: 60rpx;
|
|
||||||
border: 1px solid #eee;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
padding: 0 15rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
width: 80rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
margin-left: 15rpx
|
margin-left: 15rpx
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,33 @@
|
||||||
|
|
||||||
</z-paging>
|
</z-paging>
|
||||||
<add-agri ref="addAgri" @reload="getListData"/>
|
<add-agri ref="addAgri" @reload="getListData"/>
|
||||||
|
|
||||||
|
|
||||||
|
<uni-popup ref="renameAgri" mode="center">
|
||||||
|
<!-- 新增:修改运行时间的弹窗 -->
|
||||||
|
<view class="modal-container">
|
||||||
|
<view class="modal-title">{{ `『 ${agriName} 』重命名设置` }}</view>
|
||||||
|
<view class="modal-input-wrap">
|
||||||
|
<text class="modal-label">旧名称:</text>
|
||||||
|
<text class="modal-label">{{ agriName }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="modal-input-wrap">
|
||||||
|
<text class="modal-label">新名称:</text>
|
||||||
|
<uni-easyinput style="width: 100px" v-model="newAgriName" placeholder="请填写新名称"/>
|
||||||
|
</view>
|
||||||
|
<view class="modal-btn-wrap">
|
||||||
|
<button class="modal-btn cancel" @click="closeWindow">取消</button>
|
||||||
|
<button class="modal-btn confirm" @click="updateAgriName">确定</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ZPaging from "../uni_modules/z-paging/components/z-paging/z-paging.vue";
|
import ZPaging from "../uni_modules/z-paging/components/z-paging/z-paging.vue";
|
||||||
import CustomRefresher from "../components/custom-refresher/custom-refresher.vue";
|
import CustomRefresher from "../components/custom-refresher/custom-refresher.vue";
|
||||||
import { getAgriInfo} from "../api/system/assets/agri";
|
import {getAgriInfo, renameAgriName} from "../api/system/assets/agri";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import TimeUtil from "../utils/TimeUtil";
|
import TimeUtil from "../utils/TimeUtil";
|
||||||
import {getNewSpecialData} from "../api/data/specialData";
|
import {getNewSpecialData} from "../api/data/specialData";
|
||||||
|
|
@ -104,6 +124,7 @@ import AddAgri from "../components/addAgri/addAgri.vue";
|
||||||
import {removeAgri} from "../api/system/assets/userAgri";
|
import {removeAgri} from "../api/system/assets/userAgri";
|
||||||
import * as mqttUtil from "../utils/mqtt";
|
import * as mqttUtil from "../utils/mqtt";
|
||||||
import {getAgriStatus} from "../api/system/mqtt";
|
import {getAgriStatus} from "../api/system/mqtt";
|
||||||
|
import UniPopup from "../uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -111,7 +132,7 @@ export default {
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {AddAgri, CustomRefresher, ZPaging},
|
components: {UniPopup, AddAgri, CustomRefresher, ZPaging},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
listData: [],
|
listData: [],
|
||||||
|
|
@ -122,9 +143,14 @@ export default {
|
||||||
total: 20, // 模拟总条数
|
total: 20, // 模拟总条数
|
||||||
value: 0,
|
value: 0,
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
text: '重命名',
|
||||||
|
style: {
|
||||||
|
backgroundColor: '#2d56d8'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: '删除',
|
text: '删除',
|
||||||
icon: 'delete',
|
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: '#E83A30'
|
backgroundColor: '#E83A30'
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +174,7 @@ export default {
|
||||||
tip: null,
|
tip: null,
|
||||||
online: 0,
|
online: 0,
|
||||||
offline: 0
|
offline: 0
|
||||||
}
|
},
|
||||||
/* pattern: {
|
/* pattern: {
|
||||||
color: '#7A7E83',
|
color: '#7A7E83',
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
|
|
@ -175,6 +201,9 @@ export default {
|
||||||
active: false
|
active: false
|
||||||
}
|
}
|
||||||
]*/
|
]*/
|
||||||
|
agriName:null,
|
||||||
|
imei:null,
|
||||||
|
newAgriName:null
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -309,23 +338,30 @@ export default {
|
||||||
mqttUtil.setOnMessageCallback(this.ackMessage);
|
mqttUtil.setOnMessageCallback(this.ackMessage);
|
||||||
this.getListData();
|
this.getListData();
|
||||||
},
|
},
|
||||||
onDeleteItem(item, agri) {
|
onDeleteItem(e, item) {
|
||||||
if (item.content.text==='删除') {
|
console.log(e, item)// e 是事件对象,item 是列表项数据
|
||||||
|
if (e.content.text === '重命名') { // 通过事件对象的 content.text 判断
|
||||||
|
setTimeout(() => {
|
||||||
|
this.agriName = item.agriName;
|
||||||
|
this.imei = item.imei;
|
||||||
|
this.$refs.renameAgri.open();
|
||||||
|
}, 300)
|
||||||
|
} else if (e.content.text === '删除') { // 删除操作
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '操作提示:',
|
title: '操作提示:',
|
||||||
content: `确定删除大棚【${agri.agriName}】?`,
|
content: `确定删除大棚【${item.agriName}】?`,
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
confirmText: '确定',
|
confirmText: '确定',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
removeAgri(agri).then(response => {
|
removeAgri(item).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$modal.msgSuccess("删除成功!")
|
this.$modal.msgSuccess("删除成功!");
|
||||||
this.getListData();
|
this.getListData();
|
||||||
} else {
|
} else {
|
||||||
this.$modal.msgError("删除失败!")
|
this.$modal.msgError("删除失败!");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -333,7 +369,6 @@ export default {
|
||||||
},
|
},
|
||||||
// 点击列表项
|
// 点击列表项
|
||||||
onItemTap(item) {
|
onItemTap(item) {
|
||||||
|
|
||||||
var agri = JSON.stringify(
|
var agri = JSON.stringify(
|
||||||
{
|
{
|
||||||
imei:item.imei,
|
imei:item.imei,
|
||||||
|
|
@ -467,7 +502,42 @@ export default {
|
||||||
if (!this.listData || this.listData.length === 0) return []; // 空列表处理
|
if (!this.listData || this.listData.length === 0) return []; // 空列表处理
|
||||||
const allImei = this.listData.map(item => item.imei).filter(imei => imei);
|
const allImei = this.listData.map(item => item.imei).filter(imei => imei);
|
||||||
getAgriStatus([...new Set(allImei)])
|
getAgriStatus([...new Set(allImei)])
|
||||||
|
},
|
||||||
|
closeWindow() {
|
||||||
|
this.agriName = null;
|
||||||
|
this.imei = null;
|
||||||
|
this.newAgriName = null;
|
||||||
|
this.$refs.renameAgri.close();
|
||||||
|
},
|
||||||
|
updateAgriName() {
|
||||||
|
if (!this.newAgriName) {
|
||||||
|
this.$modal.msgError("请输入新名称!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uni.showModal({
|
||||||
|
title: '操作提示:',
|
||||||
|
content: `确定将大棚【${this.agriName}】重命名为【${this.newAgriName}】?`,
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确定',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
renameAgriName({
|
||||||
|
imei: this.imei,
|
||||||
|
newAgriName: this.newAgriName
|
||||||
|
}).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.$modal.msgSuccess("大棚重命名成功!");
|
||||||
|
this.getListData(); // 刷新列表
|
||||||
|
this.$refs.renameAgri.close(); // 关闭弹窗
|
||||||
|
} else {
|
||||||
|
this.$modal.msgError("大棚重命名失败!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
BIN
static/agri.png
|
Before Width: | Height: | Size: 1.0 KiB |
BIN
static/alarm.png
|
Before Width: | Height: | Size: 1.5 KiB |
BIN
static/cs.png
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
static/icp.png
|
Before Width: | Height: | Size: 1.1 KiB |
BIN
static/logo.png
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 152 KiB |
BIN
static/news.png
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 97 KiB |
|
|
@ -5,3 +5,76 @@
|
||||||
// iconfont
|
// iconfont
|
||||||
@import "@/static/font/iconfont.css";
|
@import "@/static/font/iconfont.css";
|
||||||
@import "@/static/font_ve87r6kfq3/iconfont.css";
|
@import "@/static/font_ve87r6kfq3/iconfont.css";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 新增:弹窗样式 */
|
||||||
|
.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: 40rpx;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-input-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 35rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-label {
|
||||||
|
width: 160rpx;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-current {
|
||||||
|
margin-left: 14rpx;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-input {
|
||||||
|
height: 60rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
padding: 0 15rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
width: 80rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
@ -295,20 +295,33 @@ export function checkTimeConflict(list) {
|
||||||
* @returns {Boolean} true=间隔大于N天;false=不大于
|
* @returns {Boolean} true=间隔大于N天;false=不大于
|
||||||
*/
|
*/
|
||||||
export function isIntervalMoreThanNDays(time1, time2, days) {
|
export function isIntervalMoreThanNDays(time1, time2, days) {
|
||||||
// 转换并校验时间
|
|
||||||
|
var dayDiff = getExactDiffDays(time1,time2)
|
||||||
|
return dayDiff > days;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算两个时间的相差天数(精确到时分秒,返回小数)
|
||||||
|
* @param {Date|String} time1 第一个时间(可含时分秒)
|
||||||
|
* @param {Date|String} time2 第二个时间(可含时分秒)
|
||||||
|
* @returns {Number} 相差的天数(正数,保留4位小数)
|
||||||
|
*/
|
||||||
|
export function getExactDiffDays(time1, time2) {
|
||||||
|
// 转换为Date对象并校验合法性
|
||||||
const d1 = new Date(time1);
|
const d1 = new Date(time1);
|
||||||
const d2 = new Date(time2);
|
const d2 = new Date(time2);
|
||||||
if (isNaN(d1.getTime()) || isNaN(d2.getTime())) {
|
if (isNaN(d1.getTime()) || isNaN(d2.getTime())) {
|
||||||
throw new Error("时间格式不合法!");
|
throw new Error("时间格式不合法,请检查!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算两个时间的毫秒差(取绝对值,避免顺序问题)
|
// 1. 计算毫秒差(绝对值,避免顺序问题)
|
||||||
const timeDiff = Math.abs(d1.getTime() - d2.getTime());
|
const timeDiffMs = Math.abs(d1.getTime() - d2.getTime());
|
||||||
|
// 2. 转换为天数(1天 = 86400000 毫秒)
|
||||||
const oneDayMs = 24 * 60 * 60 * 1000;
|
const oneDayMs = 24 * 60 * 60 * 1000;
|
||||||
|
const diffDays = timeDiffMs / oneDayMs;
|
||||||
|
|
||||||
// 转换为天数并比较
|
// 保留4位小数,避免精度冗余
|
||||||
const dayDiff = timeDiff / oneDayMs;
|
return Number(diffDays.toFixed(4));
|
||||||
return dayDiff > days;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 测试示例
|
// // 测试示例
|
||||||
|
|
|
||||||