自动化ui

feasure
lld 2026-02-25 23:23:40 +08:00
parent 0ecae4ec9e
commit 100e916332
1 changed files with 185 additions and 37 deletions

View File

@ -36,7 +36,13 @@
</view> </view>
</view> </view>
</view> </view>
<!----> </uni-section>
<uni-section title="自动化参数配置" titleFontSize="16px" type="line"
v-if="value!== 1 && !['862538065276939','A','B','C'].includes(value)">
<template v-slot:right>
<button @click="saveAutoTerm" style="margin-right: 10rpx" class="cu-btn bg-cyan shadow">保存</button>
</template>
<!--自动化设置-->
<view class="film-roller"> <view class="film-roller">
<tn-subsection :list="filmRollerList" <tn-subsection :list="filmRollerList"
:current="current" :current="current"
@ -48,23 +54,23 @@
:key="item"> :key="item">
<view > <view >
<view class="param-setting"> <view class="param-setting">
<tn-button @click="showSelect=true">{{ result }} <view class="temp-dialog" @click="showSelect=true">{{ termList[term[current] + 'Param'].refTemp }}
<uni-icons type="down"/> <uni-icons type="down"/>
</tn-button> </view>
<!-- <button class="cu-btn line-cyan round shadow" @click="showSelect=true">{{ result }}</button>--> <!-- <button class="cu-btn line-cyan round shadow" @click="showSelect=true">{{ result }}</button>-->
<tn-button class="param-dialog">参数设置弹窗</tn-button> <text @click="openParamDialog" class="param-dialog">参数设置弹窗</text>
</view> </view>
<!-- F8F7F8--> <!-- F8F7F8-->
<view class="term-content"> <view class="term-content">
<uni-swipe-action :key="termList[term[current]].length"> <uni-swipe-action :key="termList[term[current]].length">
<uni-swipe-action-item class="swiper-custom" v-for="(item, index) in termList[term[current]]" <uni-swipe-action-item class="swiper-custom" v-for="(item, index) in termList[term[current]]"
:key="item.id" :index="index" @click="onDeleteItem($event, item.id)" :right-options="options"> :key="item.id" :index="index" @click="onDeleteItem($event, item.id)" :right-options="options">
<view class="message"> <view class="message">
<view class="message__left"> <view class="message__left">
<view class="message__tag">温度控制</view> <view class="message__tag">温度控制</view>
<view class="message__content tn-text-ellipsis">{{ index+1 }}</view> <view class="message__content tn-text-ellipsis">{{ index+1 }}</view>
<!-- <tn-avatar shape="square" size="lg" src="https://resource.tuniaokj.com/images/avatar/xiaomai1.jpg"></tn-avatar>--> <!-- <tn-avatar shape="square" size="lg" src="https://resource.tuniaokj.com/images/avatar/xiaomai1.jpg"></tn-avatar>-->
</view> </view>
<view class="message__middle" @click="changeTime('startTime',index)"> <view class="message__middle" @click="changeTime('startTime',index)">
<view class="message__name">运行时间开始</view> <view class="message__name">运行时间开始</view>
@ -74,36 +80,34 @@
<view class="message__name">运行时间终止</view> <view class="message__name">运行时间终止</view>
<view class="message__content tn-text-ellipsis">{{ item.endTime }}</view> <view class="message__content tn-text-ellipsis">{{ item.endTime }}</view>
</view> </view>
<!-- <tn-button backgroundColor="#01BEFF" :plain="true" class="message__right" width="150rpx" height="100rpx"--> <!-- <tn-button backgroundColor="#01BEFF" :plain="true" class="message__right" width="150rpx" height="100rpx"-->
<!-- :fontSize="40" shape="icon" margin="10rpx 10rpx">--> <!-- :fontSize="40" shape="icon" margin="10rpx 10rpx">-->
<tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx" <tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx"
:fontSize="40" shape="icon" margin="10rpx 10rpx"> :fontSize="40" shape="icon" margin="10rpx 10rpx" @click="openSlider('temp', index)">
<view class="message__name">温度</view> <view class="message__name">温度</view>
<view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.temp, '℃') }}</view> <view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.temp, '℃') }}</view>
</tn-button> </tn-button>
<tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx" <tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx"
:fontSize="40" shape="icon" margin="10rpx 10rpx"> :fontSize="40" shape="icon" margin="10rpx 10rpx" @click="openSlider('vent', index)">
<view class="message__name">风口</view> <view class="message__name">风口</view>
<view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.vent, '%') }}</view> <view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.vent, '%') }}</view>
</tn-button> </tn-button>
<!-- <view class="message__tag">阶段{{index+1}}</view>--> <!-- <view class="message__tag">阶段{{index+1}}</view>-->
</view> </view>
</uni-swipe-action-item> </uni-swipe-action-item>
</uni-swipe-action> </uni-swipe-action>
</view> </view>
<view class="add-term" @click="addTerm"> <view class="add-term" >
<uni-icons color="var(--cyan)" type="plus" size="40"/> <uni-icons color="var(--cyan)" type="plus" size="40" @click="addTerm"/>
<text>添加条</text> <text @click="addTerm"></text>
</view> </view>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
</uni-section> </uni-section>
<tn-picker mode="time" v-model="selectTime" :params="timeParams" @confirm="confirmTime"></tn-picker> <tn-picker mode="time" v-model="selectTime" :params="timeParams" @confirm="confirmTime"></tn-picker>
<tn-select title="请选择数据" :safeAreaInsetBottom="true" :searchShow="false" v-model="showSelect" mode="single" :list="tempList" @confirm="confirmTemp"></tn-select> <tn-select title="请选择数据" :safeAreaInsetBottom="true" :searchShow="false" v-model="showSelect" mode="single" :list="tempList" @confirm="confirmTemp"></tn-select>
<uni-popup ref="inputDialog" mode="center"> <uni-popup ref="inputDialog" mode="center">
@ -136,10 +140,10 @@
</view> </view>
</uni-popup> </uni-popup>
<uni-popup ref="inputDialog" mode="center"> <uni-popup ref="autoParam" mode="center">
<!-- 新增修改运行时间的弹窗 --> <!-- 新增修改运行时间的弹窗 -->
<view class="modal-container"> <view class="modal-container">
<view class="modal-title">{{ `${selectedText} - ${currentCard.name}设置` }}</view> <view class="modal-title">{{ `${selectedText} - 自动化】参数设置` }}</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 > 0 ? `${currentCardTime}` : '未设置' }}</text> <text class="modal-current">{{ currentCardTime > 0 ? `${currentCardTime}` : '未设置' }}</text>
@ -160,8 +164,33 @@
<uni-easyinput style="width: 100px" v-model="remark" placeholder="不填展示默认备注"/> <uni-easyinput style="width: 100px" v-model="remark" placeholder="不填展示默认备注"/>
</view> </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="closeParamDialog"></button>
<button class="modal-btn confirm" @click="confirmModifyTime"></button> <button class="modal-btn confirm" @click="setAutoParam"></button>
</view>
</view>
</uni-popup>
<uni-popup ref="sliderDialog" mode="center">
<view class="modal-container">
<view class="modal-title">{{ `${selectedText} - 自动化】参数设置` }}</view>
<!-- 核心修改给容器加 flex 布局样式 -->
<view class="modal-slider">
<text class="slider-label">{{ slider.title }}</text>
<slider
:value="slider.value"
:min="slider.min"
:max="slider.max"
show-value
class="slider-component"
@change="changeSlider"
/>
<text class="slider-unit">{{ slider.unit }}</text>
</view>
<view class="modal-btn-wrap">
<button class="modal-btn cancel" @click="closeSlider"></button>
<button class="modal-btn confirm" @click="confirmSlider"></button>
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
@ -176,6 +205,7 @@ import {addLimit, getAgriByImei, updateLimit} from "../../../api/system/assets/l
import store from "../../../store"; import store from "../../../store";
import {addRemark, updateRemark} from "../../../api/system/assets/remark"; import {addRemark, updateRemark} from "../../../api/system/assets/remark";
import {generateUniqueId} from "../../../utils/agri"; import {generateUniqueId} from "../../../utils/agri";
import UniSection from "../../../components/uni-section/uni-section.vue";
export default { export default {
dicts: ['sys_data_map'], dicts: ['sys_data_map'],
@ -252,6 +282,7 @@ export default {
} }
}, },
components: { components: {
UniSection,
UniPopup // UniPopup //
}, },
mounted() { mounted() {
@ -299,12 +330,20 @@ export default {
} }
], ],
showSelect:false, showSelect:false,
result: "请选择",
term:["jm1", "jm2", "jm3"], term:["jm1", "jm2", "jm3"],
termList: { termList: {
"jm1": [], "jm1": [],
"jm2": [], "jm1Param":{
"jm3": [], refTemp: '请选择',
},
"jm2": [],
"jm2Param":{
refTemp: '请选择',
},
"jm3": [],
"jm3Param":{
refTemp: '请选择'
},
}, },
options: [ options: [
{ {
@ -326,9 +365,18 @@ export default {
}, },
selectTime: false, selectTime: false,
timeTag: null, timeTag: null,
timeIndex: null, follerIndex: null,
defaultTime: null, defaultTime: null,
maxTermLength: 5, maxTermLength: 5,
autoParam:false,
slider: {
title: '请选择',
min:0,
max:100,
value:0,
unit:'',
mode: null
},
}; };
}, },
@ -343,15 +391,24 @@ export default {
}, },
// //
confirmTemp(event) { confirmTemp(event) {
this.result = event[0]['label'] this.termList[this.term[this.current] + 'Param'].refTemp = event[0]['label']
console.info(`选择温度:${event[0]['label']}`) console.info(`选择温度:${event[0]['label']}`)
}, },
// //
refresh() { refresh() {
this.termList = { this.termList = {
"jm1": [], "jm1": [],
"jm1Param":{
refTemp: '请选择',
},
"jm2": [], "jm2": [],
"jm2Param":{
refTemp: '请选择',
},
"jm3": [], "jm3": [],
"jm3Param":{
refTemp: '请选择'
},
}; };
this.showFlag = !((store.getters && store.getters.name !== 'admin') && this.$auth.hasRole("test")) this.showFlag = !((store.getters && store.getters.name !== 'admin') && this.$auth.hasRole("test"))
this.$nextTick(() => { this.$nextTick(() => {
@ -607,14 +664,76 @@ export default {
// //
changeTime(timeTag, timeIndex) { changeTime(timeTag, timeIndex) {
this.timeTag = timeTag; this.timeTag = timeTag;
this.timeIndex = timeIndex; this.follerIndex = timeIndex;
this.selectTime = true; this.selectTime = true;
}, },
openParamDialog() {
this.$refs.autoParam.open();
},
//
setAutoParam() {
var jmTerm = this.term[this.current];
// todo
this.$refs.autoParam.close();
},
closeParamDialog() {
this.$refs.autoParam.close();
},
// //
confirmTime(time) { confirmTime(time) {
this.termList[this.term[this.current]][this.timeIndex][this.timeTag] = `${time.hour}:${time.minute}` this.termList[this.term[this.current]][this.follerIndex][this.timeTag] = `${time.hour}:${time.minute}`
}, },
} /**
* @param tag 参数
* @param index 条件
*/
openSlider(tag, index) {
var fillerTerm = this.termList[this.term[this.current]][index];
if (tag === 'temp') {
this.slider = {
title: '适宜温度',
min: 0,
max: 40,
unit: '℃',
value: fillerTerm.temp==='选择'?0:fillerTerm.temp,
mode: tag
}
} else if (tag === 'vent') {
this.slider = {
title: '风口大小',
min: 0,
max: 100,
unit: '﹪',
value: fillerTerm.vent==='选择'?0:fillerTerm.vent,
mode: tag
}
}
this.follerIndex = index;
this.$refs.sliderDialog.open();
},
changeSlider(e) {
this.slider.value = e.detail.value
},
closeSlider() {
this.$refs.sliderDialog.close();
},
confirmSlider() {
const slideMode = this.slider.mode;
const value = this.slider.value;
if (slideMode === 'temp') {
this.termList[this.term[this.current]][this.follerIndex].temp = value;
} else if (slideMode === 'vent') {
this.termList[this.term[this.current]][this.follerIndex].vent = value;
}
this.$refs.sliderDialog.close();
},
//
saveAutoTerm() {
var termMap = this.termList;
// todo
}
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -759,10 +878,31 @@ export default {
font-size: 26rpx; font-size: 26rpx;
width: 80rpx; width: 80rpx;
} }
/* 核心样式:让子元素水平排列 */
.modal-slider {
display: flex;
align-items: center; /* 垂直居中对齐 */
padding: 10rpx 20rpx; /* 增加内边距,避免拥挤 */
gap: 10rpx; /* 元素之间的间距 */
}
.modal-unit { /* 标题样式:固定宽度,避免挤压滑块 */
margin-left: 10rpx; .slider-label {
color: #666; flex: 0 0 auto; /* 不拉伸、不收缩 */
font-size: 28rpx;
white-space: nowrap; /* 防止标题换行 */
}
/* 滑块样式:占满剩余空间 */
.slider-component {
flex: 1; /* 自动填充剩余宽度 */
}
/* 单位样式:固定宽度 */
.slider-unit {
flex: 0 0 auto;
font-size: 28rpx;
margin-left: 5rpx;
} }
.modal-btn-wrap { .modal-btn-wrap {
@ -801,7 +941,7 @@ export default {
overflow: hidden; overflow: hidden;
} }
.film-roller { .film-roller {
padding: 20rpx; padding: 10rpx 20rpx 20rpx 20rpx;
} }
.swiper { .swiper {
box-sizing: border-box; box-sizing: border-box;
@ -821,7 +961,7 @@ export default {
//padding: 10px 20px; //padding: 10px 20px;
font-size: 40rpx; font-size: 40rpx;
color: #42b3ff; color: #42b3ff;
margin-top: 30rpx; margin-top: 50rpx;
//border: 1px solid var(--cyan); //border: 1px solid var(--cyan);
//border-radius: 8px; //border-radius: 8px;
//background-color: #fff; //background-color: #fff;
@ -829,8 +969,15 @@ export default {
.param-setting { .param-setting {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 28rpx;
color: #0a0a0a;
margin-top: 15rpx;
.temp-dialog {
margin-left: 20rpx;
}
.param-dialog { .param-dialog {
margin-left: auto; /* 自动填充左侧空间,将按钮推到最右侧 */ margin-left: auto; /* 自动填充左侧空间,将按钮推到最右侧 */
margin-right: 20rpx;
} }
} }
.term-content { .term-content {
@ -882,6 +1029,7 @@ export default {
// text-align: center; // text-align: center;
//} //}
.message__content { .message__content {
font-size: 26rpx; font-size: 27rpx;
color: #020e15;
} }
</style> </style>