自动化设置校验

feasure
lld 2026-02-28 23:16:05 +08:00
parent 866a91e3cd
commit bdae6b8390
4 changed files with 236 additions and 111 deletions

44
api/control/autoTerm.js Normal file
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询卷膜运行条件列表
export function listAutoTerm(query) {
return request({
url: '/control/autoTerm/list',
method: 'get',
params: query
})
}
// 查询卷膜运行条件详细
export function getAutoTerm(id) {
return request({
url: '/control/autoTerm/' + id,
method: 'get'
})
}
// 新增卷膜运行条件
export function addAutoTerm(data) {
return request({
url: '/control/autoTerm',
method: 'post',
data: data
})
}
// 修改卷膜运行条件
export function updateAutoTerm(data) {
return request({
url: '/control/autoTerm',
method: 'put',
data: data
})
}
// 删除卷膜运行条件
export function delAutoTerm(id) {
return request({
url: '/control/autoTerm/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询卷膜参数配置列表
export function listRollerParam(query) {
return request({
url: '/control/rollerParam/list',
method: 'get',
params: query
})
}
// 查询卷膜参数配置详细
export function getRollerParam(id) {
return request({
url: '/control/rollerParam/' + id,
method: 'get'
})
}
// 新增卷膜参数配置
export function addRollerParam(data) {
return request({
url: '/control/rollerParam',
method: 'post',
data: data
})
}
// 修改卷膜参数配置
export function updateRollerParam(data) {
return request({
url: '/control/rollerParam',
method: 'put',
data: data
})
}
// 删除卷膜参数配置
export function delRollerParam(id) {
return request({
url: '/control/rollerParam/' + id,
method: 'delete'
})
}

View File

@ -49,12 +49,13 @@
:bold="true" :bold="true"
@change="switchTab" @change="switchTab"
:height="80"></tn-subsection> :height="80"></tn-subsection>
<swiper class="swiper" :disable-touch="true" :current="current" :acceleration="true" @change="change" :style="{ height: swiperHeight + 'rpx' }"> <swiper class="swiper" :disable-touch="true" :current="current" :acceleration="true"
<swiper-item v-for="item in filmRollerList" @change="change" :style="{ height: swiperHeight + 'rpx' }">
:key="item"> <swiper-item v-for="(roller, key) in filmRollerList"
:key="key">
<view > <view >
<view class="param-setting"> <view class="param-setting">
<view class="temp-dialog" @click="showSelect=true">{{ termList[term[current] + 'Param'].refTemp }} <view class="temp-dialog" @click="showSelect=true">{{ termList[current]['config'].refTemp }}
<uni-icons type="down"/> <uni-icons type="down"/>
</view> </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>-->
@ -63,8 +64,8 @@
<!-- F8F7F8--> <!-- F8F7F8-->
<view class="term-content"> <view class="term-content">
<uni-swipe-action :key="termList[term[current]].length"> <uni-swipe-action :key="termList[key]['terms'].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[key].terms"
: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">
@ -82,16 +83,23 @@
</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" <!-- 替换温度按钮 -->
:fontSize="40" shape="icon" margin="10rpx 10rpx" @click="openSlider('temp', index)"> <view
class="message__right"
@click.stop="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> </view>
<tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx"
:fontSize="40" shape="icon" margin="10rpx 10rpx" @click="openSlider('vent', index)"> <!-- 替换风口按钮 -->
<view
class="message__right"
@click.stop="openSlider('vent', index)"
>
<view class="message__name">风口</view> <view class="message__name">风口</view>
<view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.vent, 'cm') }}</view> <view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.vent, 'cm') }}</view>
</tn-button> </view>
<!-- <view class="message__tag">阶段{{index+1}}</view>--> <!-- <view class="message__tag">阶段{{index+1}}</view>-->
</view> </view>
</uni-swipe-action-item> </uni-swipe-action-item>
@ -146,6 +154,10 @@
<view class="modal-title">{{ `${selectedText} - ${filmRollerList[current]}】风口校准`}}</view> <view class="modal-title">{{ `${selectedText} - ${filmRollerList[current]}】风口校准`}}</view>
<uni-forms :model="rollerParam" ref="form" :labelWidth="130" > <uni-forms :model="rollerParam" ref="form" :labelWidth="130" >
<uni-forms-item label="当前卷膜:" prop="refTemp" v-if="false">
<uni-easyinput type="text" placeholderStyle="font-size: 25rpx;" v-model="rollerParam.imei"
disabled :inputBorder="false" :clearable="false"/>
</uni-forms-item>
<uni-forms-item label="当前卷膜:" prop="refTemp" v-if="false"> <uni-forms-item label="当前卷膜:" prop="refTemp" v-if="false">
<uni-easyinput type="text" placeholderStyle="font-size: 25rpx;" v-model="rollerParam.roller" <uni-easyinput type="text" placeholderStyle="font-size: 25rpx;" v-model="rollerParam.roller"
disabled :inputBorder="false" :clearable="false"/> disabled :inputBorder="false" :clearable="false"/>
@ -226,7 +238,7 @@ 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"; import UniSection from "../../../components/uni-section/uni-section.vue";
import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue"; import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
import { checkTimeConflict } from "@/utils/agri" import { checkTimeConflict } from "../../../utils/agri"
export default { export default {
dicts: ['sys_data_map'], dicts: ['sys_data_map'],
@ -352,36 +364,41 @@ export default {
} }
], ],
showSelect:false, showSelect:false,
term:["jm1", "jm2", "jm3"], termList: [
termList: { {
"jm1": [], terms: [],
"jm1Param":{ config: {
refTemp: '请选择', refTemp: '请选择',
refTempCode: null, refTempCode: null,
autoTotalLen: null, autoTotalLen: null,
manualTotalLen: null, manualTotalLen: null,
reservedLen: null, reservedLen: null,
roller:'jm1' roller:'jm1'
}
}, },
"jm2": [], {
"jm2Param":{ terms: [],
refTemp: '请选择', config:{
refTempCode: null, refTemp: '请选择',
autoTotalLen: null, refTempCode: null,
manualTotalLen: null, autoTotalLen: null,
reservedLen: null, manualTotalLen: null,
roller:'jm2' reservedLen: null,
roller:'jm2'
}
}, },
"jm3": [], {
"jm3Param":{ terms: [],
refTemp: '请选择', config:{
refTempCode: null, refTemp: '请选择',
autoTotalLen: null, refTempCode: null,
manualTotalLen: null, autoTotalLen: null,
reservedLen: null, manualTotalLen: null,
roller:'jm3' reservedLen: null,
}, roller:'jm3'
}, }
}
],
options: [ options: [
{ {
text: '删除', text: '删除',
@ -415,6 +432,7 @@ export default {
mode: null mode: null
}, },
rollerParam: { rollerParam: {
imei: this.value,
roller: null, roller: null,
refTemp: '请选择', refTemp: '请选择',
autoTotalLen: null, autoTotalLen: null,
@ -435,28 +453,26 @@ export default {
}, },
// //
confirmTemp(event) { confirmTemp(event) {
this.termList[this.term[this.current] + 'Param'].refTemp = event[0]['label'] this.termList[this.current]['config'].refTemp = event[0]['label']
this.termList[this.term[this.current] + 'Param'].refTempCode = event[0]['value'] this.termList[this.current]['config'].refTempCode = event[0]['value']
}, },
// //
refresh() { refresh() {
this.termList = { this.termList = [];
"jm1": [], for (const [index,value] of this.filmRollerList.entries()) {
"jm1Param":{ this.termList.push({
refTemp: '请选择', terms: [],
refTempCode: null, config: {
}, refTemp: '请选择',
"jm2": [], refTempCode: null,
"jm2Param":{ autoTotalLen: null,
refTemp: '请选择', manualTotalLen: null,
refTempCode: null, reservedLen: null,
}, roller: `jm${index+1}`,
"jm3": [], imei: this.value
"jm3Param":{ }
refTemp: '请选择', })
refTempCode: null, }
},
};
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(() => {
this.getSwiperHeight(); // this.getSwiperHeight(); //
@ -647,7 +663,7 @@ export default {
}, },
// //
updateSwiperHeight() { updateSwiperHeight() {
if (this.termList[this.term[this.current]].length>4) { if (this.termList[this.current]['terms'].length>3) {
// param-setting add-term // param-setting add-term
this.swiperHeight = this.swiperHeight + 160; this.swiperHeight = this.swiperHeight + 160;
} }
@ -655,25 +671,28 @@ export default {
// //
getSwiperHeight() { getSwiperHeight() {
this.swiperHeight = 720; this.swiperHeight = 720;
var length = this.termList[this.term[this.current]].length-4; var length = this.termList[this.current]['terms'].length-4;
if (length>0) { if (length>0) {
this.swiperHeight = this.swiperHeight + 160*length ; this.swiperHeight = this.swiperHeight + 160*length ;
} }
}, },
// //
addTerm() { addTerm() {
var temps = this.termList[this.term[this.current]]; var temps = this.termList[this.current]['terms'];
if (temps.length >= this.maxTermLength) { if (temps.length >= this.maxTermLength) {
this.$modal.alert(`您设置的条件数量已超过上限!上限为${this.maxTermLength}条,请删除后重试!`, this.$modal.alert(`您设置的条件数量已超过上限!上限为${this.maxTermLength}条,请删除后重试!`,
"操作提示"); "操作提示");
return; return;
} }
this.termList[this.term[this.current]].push({ const index = this.current + 1
this.termList[this.current]['terms'].push({
id: generateUniqueId(), id: generateUniqueId(),
startTime: '请选择时间', startTime: '请选择时间',
endTime: '请选择时间', endTime: '请选择时间',
temp: '选择', temp: '选择',
vent: '选择' vent: '选择',
imei: this.value,
roller: `jm${index}`
}); });
this.$nextTick(() => { this.$nextTick(() => {
this.updateSwiperHeight(); // tick this.updateSwiperHeight(); // tick
@ -688,24 +707,18 @@ export default {
}, },
// //
onDeleteItem(event, id) { onDeleteItem(event, id) {
const currentKey = this.term[this.current]; // this.rollerIndex = null;
const tempList = this.termList[currentKey]; const currentKey = this.current;
const newList = tempList.filter(item => item.id !== id); // 1. terms
const currentTerms = this.termList[currentKey]?.terms || [];
// 1. // 2.
this.termList[currentKey] = []; const newTerms = currentTerms.filter(item => item.id !== id);
// 2. $nextTick // 3. terms termList
this.$set(this.termList[currentKey], 'terms', newTerms);
// 4. swiper
this.$nextTick(() => { this.$nextTick(() => {
this.termList = { this.getSwiperHeight();
...this.termList, uni.$emit('uni-swipe-action-hide');
[currentKey]: newList
};
// 3. nextTickswiper
this.$nextTick(() => {
this.getSwiperHeight();
//
uni.$emit('uni-swipe-action-hide');
});
}); });
}, },
// //
@ -715,8 +728,7 @@ export default {
this.selectTime = true; this.selectTime = true;
}, },
openParamDialog() { openParamDialog() {
this.rollerParam = JSON.parse(JSON.stringify(this.termList[this.term[this.current] + 'Param'])); this.rollerParam = JSON.parse(JSON.stringify(this.termList[this.current].config));
// this.rollerParam.roller = this.term[this.current];
this.$refs.autoParam.open(); this.$refs.autoParam.open();
}, },
// //
@ -733,7 +745,7 @@ export default {
"操作提示"); "操作提示");
return; return;
} }
this.termList[this.term[this.current] + 'Param'] = {...this.rollerParam} this.termList[this.current]['config'] = {...this.rollerParam}
this.$refs.autoParam.close(); this.$refs.autoParam.close();
}, },
closeParamDialog() { closeParamDialog() {
@ -741,14 +753,15 @@ export default {
}, },
// //
confirmTime(time) { confirmTime(time) {
this.termList[this.term[this.current]][this.rollerIndex][this.timeTag] = `${time.hour}:${time.minute}` this.termList[this.current]['terms'][this.rollerIndex][this.timeTag] = `${time.hour}:${time.minute}`
}, },
/** /**
* @param tag 参数 * @param tag 参数
* @param index 条件 * @param index 条件
*/ */
openSlider(tag, index) { openSlider(tag, index) {
var fillerTerm = this.termList[this.term[this.current]][index]; console.info(tag,index)
var fillerTerm = this.termList[this.current]['terms'][index];
if (tag === 'temp') { if (tag === 'temp') {
this.slider = { this.slider = {
title: '适宜温度', title: '适宜温度',
@ -763,7 +776,7 @@ export default {
title: '风口大小', title: '风口大小',
min: 0, min: 0,
max: 100, max: 100,
unit: '', unit: 'cm',
value: fillerTerm.vent==='选择'?0:fillerTerm.vent, value: fillerTerm.vent==='选择'?0:fillerTerm.vent,
mode: tag mode: tag
} }
@ -781,9 +794,9 @@ export default {
const slideMode = this.slider.mode; const slideMode = this.slider.mode;
const value = this.slider.value; const value = this.slider.value;
if (slideMode === 'temp') { if (slideMode === 'temp') {
this.termList[this.term[this.current]][this.rollerIndex].temp = value; this.termList[this.current]['terms'][this.rollerIndex].temp = value;
} else if (slideMode === 'vent') { } else if (slideMode === 'vent') {
this.termList[this.term[this.current]][this.rollerIndex].vent = value; this.termList[this.current]['terms'][this.rollerIndex].vent = value;
} }
this.$refs.sliderDialog.close(); this.$refs.sliderDialog.close();
}, },
@ -794,6 +807,10 @@ export default {
let showTips = null; let showTips = null;
const checkRules = [ const checkRules = [
{
tip: '请设置自动化条件后重新保存重试!',
validate: (rollerParam, term) => rollerParam.refTemp === '请选择' && !(term && term.length > 0)
},
{ {
tip: '参考温度未设置,请点击相应页签左上角设置后重试!', tip: '参考温度未设置,请点击相应页签左上角设置后重试!',
validate: (rollerParam, term) => rollerParam.refTemp === '请选择' validate: (rollerParam, term) => rollerParam.refTemp === '请选择'
@ -822,7 +839,7 @@ export default {
}, },
{ {
tip: '温度控制运行时间起不能大于止,请检查填写后重新尝试!', tip: '温度控制运行时间起不能大于止,请检查填写后重新尝试!',
validate: (rollerParam, term) => term.some(item => !(item.startTime > item.endTime)) validate: (rollerParam, term) => term.some(item => (item.startTime > item.endTime))
}, },
{ {
tip: '温度控制运行时间存在冲突,请检查填写后重新尝试!', tip: '温度控制运行时间存在冲突,请检查填写后重新尝试!',
@ -843,9 +860,9 @@ export default {
]; ];
for (const [_, rule] of checkRules.entries()) { for (const [_, rule] of checkRules.entries()) {
for (const [index, item] of this.term.entries()) { for (const [index, item] of this.filmRollerList.entries()) {
const term = termMap[item]; // const term = termMap[index]['terms']; //
const rollerParam = termMap[item + 'Param']; // const rollerParam = termMap[index]['config']; //
const filmRoller = this.filmRollerList[index]; const filmRoller = this.filmRollerList[index];
if (!rollerParam) { if (!rollerParam) {
this.$tn.message.toast('参数设置失败,请下拉刷新后重试!') this.$tn.message.toast('参数设置失败,请下拉刷新后重试!')
@ -860,8 +877,8 @@ export default {
return; return;
} }
} }
console.info(`要保存的条件:`,termMap)
// todo // todo
}, },
} }
@ -1143,6 +1160,14 @@ export default {
} }
.message__middle { .message__middle {
flex: 4; flex: 4;
.message__name {
margin-bottom: 8rpx;
}
}
.message__name {
font-size: 24rpx;
color: #838383;
} }
.message__right { .message__right {
flex: 2; flex: 2;
@ -1150,12 +1175,19 @@ export default {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border: 1px solid #D9D9D9; width: 150rpx;
height: 100rpx;
margin: 10rpx;
border-radius: 50rpx;
background-color: #fff;
box-shadow: 0 2rpx 4rpx #D9D9D9;
transition: all 0.2s ease;
} }
.message__name {
font-size: 24rpx; //
color: #838383; .message__right:active {
margin-bottom: 8rpx; background-color: #f5f5f5;
transform: scale(0.98);
} }
//.message__tag { //.message__tag {
// font-size: 24rpx; // font-size: 24rpx;
@ -1176,7 +1208,7 @@ export default {
color: #0a0a0a; color: #0a0a0a;
} }
} }
/deep/ .uni-input-input { /deep/.modal-container_ .uni-input-input {
text-align: right !important; text-align: right !important;
font-size: 28rpx; font-size: 28rpx;
} }

View File

@ -235,15 +235,20 @@ export function generateUniqueId() {
return (timestamp + random).toString(); // 转成字符串,避免数字精度丢失 return (timestamp + random).toString(); // 转成字符串,避免数字精度丢失
} }
// 极简版判断时间列表是否存在冲突支持HH:mm/HH:mm:ss
const checkTimeConflict = list => {
// 时间转分钟数的极简写法
const toMin = t => {
const [h, m] = t.split(':').map(Number);
return h * 60 + (m || 0);
};
// 过滤有效数据 + 双层循环判断冲突 const toMin = (t) => {
const [h, m] = t.split(':').map(Number);
return h * 60 + (m || 0);
};
// ===================== 对外导出的函数(按需导出) =====================
/**
* 函数1判断时间列表是否冲突
* @param {Array} list - 包含startTime/endTime的时间配置列表
* @returns {Object} 冲突检测结果
*/
export function checkTimeConflict(list) {
if (!Array.isArray(list)) return { isConflict: false };
const valid = list.filter(i => i.startTime && i.endTime); const valid = list.filter(i => i.startTime && i.endTime);
for (let i = 0; i < valid.length; i++) { for (let i = 0; i < valid.length; i++) {
const [aS, aE] = [toMin(valid[i].startTime), toMin(valid[i].endTime)]; const [aS, aE] = [toMin(valid[i].startTime), toMin(valid[i].endTime)];
@ -253,7 +258,7 @@ const checkTimeConflict = list => {
} }
} }
return { isConflict: false }; return { isConflict: false };
}; }
// ===================== 测试用例 ===================== // ===================== 测试用例 =====================
/* /*