自动化设置校验
parent
866a91e3cd
commit
bdae6b8390
|
|
@ -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'
|
||||
})
|
||||
}
|
||||
|
|
@ -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'
|
||||
})
|
||||
}
|
||||
|
|
@ -49,12 +49,13 @@
|
|||
:bold="true"
|
||||
@change="switchTab"
|
||||
:height="80"></tn-subsection>
|
||||
<swiper class="swiper" :disable-touch="true" :current="current" :acceleration="true" @change="change" :style="{ height: swiperHeight + 'rpx' }">
|
||||
<swiper-item v-for="item in filmRollerList"
|
||||
:key="item">
|
||||
<swiper class="swiper" :disable-touch="true" :current="current" :acceleration="true"
|
||||
@change="change" :style="{ height: swiperHeight + 'rpx' }">
|
||||
<swiper-item v-for="(roller, key) in filmRollerList"
|
||||
:key="key">
|
||||
<view >
|
||||
<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"/>
|
||||
</view>
|
||||
<!-- <button class="cu-btn line-cyan round shadow" @click="showSelect=true">参考温度:{{ result }}</button>-->
|
||||
|
|
@ -63,8 +64,8 @@
|
|||
<!-- F8F7F8-->
|
||||
<view class="term-content">
|
||||
|
||||
<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 :key="termList[key]['terms'].length">
|
||||
<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">
|
||||
<view class="message">
|
||||
<view class="message__left">
|
||||
|
|
@ -82,16 +83,23 @@
|
|||
</view>
|
||||
<!-- <tn-button backgroundColor="#01BEFF" :plain="true" class="message__right" width="150rpx" height="100rpx"-->
|
||||
<!-- :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__content tn-text-ellipsis">{{ formatValueWithUnit(item.temp, '℃') }}</view>
|
||||
</tn-button>
|
||||
<tn-button :shadow="true" class="message__right" width="150rpx" height="100rpx"
|
||||
:fontSize="40" shape="icon" margin="10rpx 10rpx" @click="openSlider('vent', index)">
|
||||
</view>
|
||||
|
||||
<!-- 替换风口按钮 -->
|
||||
<view
|
||||
class="message__right"
|
||||
@click.stop="openSlider('vent', index)"
|
||||
>
|
||||
<view class="message__name">风口</view>
|
||||
<view class="message__content tn-text-ellipsis">{{ formatValueWithUnit(item.vent, 'cm') }}</view>
|
||||
</tn-button>
|
||||
</view>
|
||||
<!-- <view class="message__tag">阶段{{index+1}}</view>-->
|
||||
</view>
|
||||
</uni-swipe-action-item>
|
||||
|
|
@ -146,6 +154,10 @@
|
|||
<view class="modal-title">{{ `【${selectedText} - ${filmRollerList[current]}】风口校准`}}</view>
|
||||
|
||||
<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-easyinput type="text" placeholderStyle="font-size: 25rpx;" v-model="rollerParam.roller"
|
||||
disabled :inputBorder="false" :clearable="false"/>
|
||||
|
|
@ -226,7 +238,7 @@ import {addRemark, updateRemark} from "../../../api/system/assets/remark";
|
|||
import {generateUniqueId} from "../../../utils/agri";
|
||||
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 { checkTimeConflict } from "@/utils/agri"
|
||||
import { checkTimeConflict } from "../../../utils/agri"
|
||||
|
||||
export default {
|
||||
dicts: ['sys_data_map'],
|
||||
|
|
@ -352,36 +364,41 @@ export default {
|
|||
}
|
||||
],
|
||||
showSelect:false,
|
||||
term:["jm1", "jm2", "jm3"],
|
||||
termList: {
|
||||
"jm1": [],
|
||||
"jm1Param":{
|
||||
termList: [
|
||||
{
|
||||
terms: [],
|
||||
config: {
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
autoTotalLen: null,
|
||||
manualTotalLen: null,
|
||||
reservedLen: null,
|
||||
roller:'jm1'
|
||||
}
|
||||
},
|
||||
"jm2": [],
|
||||
"jm2Param":{
|
||||
{
|
||||
terms: [],
|
||||
config:{
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
autoTotalLen: null,
|
||||
manualTotalLen: null,
|
||||
reservedLen: null,
|
||||
roller:'jm2'
|
||||
}
|
||||
},
|
||||
"jm3": [],
|
||||
"jm3Param":{
|
||||
{
|
||||
terms: [],
|
||||
config:{
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
autoTotalLen: null,
|
||||
manualTotalLen: null,
|
||||
reservedLen: null,
|
||||
roller:'jm3'
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
options: [
|
||||
{
|
||||
text: '删除',
|
||||
|
|
@ -415,6 +432,7 @@ export default {
|
|||
mode: null
|
||||
},
|
||||
rollerParam: {
|
||||
imei: this.value,
|
||||
roller: null,
|
||||
refTemp: '请选择',
|
||||
autoTotalLen: null,
|
||||
|
|
@ -435,28 +453,26 @@ export default {
|
|||
},
|
||||
// 左上角选择时间
|
||||
confirmTemp(event) {
|
||||
this.termList[this.term[this.current] + 'Param'].refTemp = event[0]['label']
|
||||
this.termList[this.term[this.current] + 'Param'].refTempCode = event[0]['value']
|
||||
this.termList[this.current]['config'].refTemp = event[0]['label']
|
||||
this.termList[this.current]['config'].refTempCode = event[0]['value']
|
||||
},
|
||||
// 下拉刷新以及进入组件渲染
|
||||
refresh() {
|
||||
this.termList = {
|
||||
"jm1": [],
|
||||
"jm1Param":{
|
||||
this.termList = [];
|
||||
for (const [index,value] of this.filmRollerList.entries()) {
|
||||
this.termList.push({
|
||||
terms: [],
|
||||
config: {
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
},
|
||||
"jm2": [],
|
||||
"jm2Param":{
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
},
|
||||
"jm3": [],
|
||||
"jm3Param":{
|
||||
refTemp: '请选择',
|
||||
refTempCode: null,
|
||||
},
|
||||
};
|
||||
autoTotalLen: null,
|
||||
manualTotalLen: null,
|
||||
reservedLen: null,
|
||||
roller: `jm${index+1}`,
|
||||
imei: this.value
|
||||
}
|
||||
})
|
||||
}
|
||||
this.showFlag = !((store.getters && store.getters.name !== 'admin') && this.$auth.hasRole("test"))
|
||||
this.$nextTick(() => {
|
||||
this.getSwiperHeight(); // 页面初始化时也计算一次
|
||||
|
|
@ -647,7 +663,7 @@ export default {
|
|||
},
|
||||
// 添加条件更新窗口高度
|
||||
updateSwiperHeight() {
|
||||
if (this.termList[this.term[this.current]].length>4) {
|
||||
if (this.termList[this.current]['terms'].length>3) {
|
||||
// 加上 param-setting 和 add-term 的高度,以及一些间距
|
||||
this.swiperHeight = this.swiperHeight + 160;
|
||||
}
|
||||
|
|
@ -655,25 +671,28 @@ export default {
|
|||
// 获取窗口高度
|
||||
getSwiperHeight() {
|
||||
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) {
|
||||
this.swiperHeight = this.swiperHeight + 160*length ;
|
||||
}
|
||||
},
|
||||
// 添加条件方法
|
||||
addTerm() {
|
||||
var temps = this.termList[this.term[this.current]];
|
||||
var temps = this.termList[this.current]['terms'];
|
||||
if (temps.length >= this.maxTermLength) {
|
||||
this.$modal.alert(`您设置的条件数量已超过上限!上限为${this.maxTermLength}条,请删除后重试!`,
|
||||
"操作提示");
|
||||
return;
|
||||
}
|
||||
this.termList[this.term[this.current]].push({
|
||||
const index = this.current + 1
|
||||
this.termList[this.current]['terms'].push({
|
||||
id: generateUniqueId(),
|
||||
startTime: '请选择时间',
|
||||
endTime: '请选择时间',
|
||||
temp: '选择',
|
||||
vent: '选择'
|
||||
vent: '选择',
|
||||
imei: this.value,
|
||||
roller: `jm${index}`
|
||||
});
|
||||
this.$nextTick(() => {
|
||||
this.updateSwiperHeight(); // 数据更新后,在下一个 tick 更新高度
|
||||
|
|
@ -688,25 +707,19 @@ export default {
|
|||
},
|
||||
// 删除条件
|
||||
onDeleteItem(event, id) {
|
||||
const currentKey = this.term[this.current];
|
||||
const tempList = this.termList[currentKey];
|
||||
const newList = tempList.filter(item => item.id !== id);
|
||||
|
||||
// 1. 先清空当前列表(强制触发组件感知)
|
||||
this.termList[currentKey] = [];
|
||||
// 2. 用$nextTick确保清空后,再赋值新列表
|
||||
this.$nextTick(() => {
|
||||
this.termList = {
|
||||
...this.termList,
|
||||
[currentKey]: newList
|
||||
};
|
||||
// 3. 再次nextTick更新swiper高度
|
||||
// this.rollerIndex = null;
|
||||
const currentKey = this.current;
|
||||
// 1. 先拿到当前页签的 terms 数组
|
||||
const currentTerms = this.termList[currentKey]?.terms || [];
|
||||
// 2. 过滤出要保留的项
|
||||
const newTerms = currentTerms.filter(item => item.id !== id);
|
||||
// 3. 只更新当前页签的 terms,保持 termList 结构不变
|
||||
this.$set(this.termList[currentKey], 'terms', newTerms);
|
||||
// 4. 更新swiper高度(可选)
|
||||
this.$nextTick(() => {
|
||||
this.getSwiperHeight();
|
||||
// 可选:关闭滑动删除的展开状态(避免组件样式异常)
|
||||
uni.$emit('uni-swipe-action-hide');
|
||||
});
|
||||
});
|
||||
},
|
||||
// 选择运行时间
|
||||
changeTime(timeTag, timeIndex) {
|
||||
|
|
@ -715,8 +728,7 @@ export default {
|
|||
this.selectTime = true;
|
||||
},
|
||||
openParamDialog() {
|
||||
this.rollerParam = JSON.parse(JSON.stringify(this.termList[this.term[this.current] + 'Param']));
|
||||
// this.rollerParam.roller = this.term[this.current];
|
||||
this.rollerParam = JSON.parse(JSON.stringify(this.termList[this.current].config));
|
||||
this.$refs.autoParam.open();
|
||||
},
|
||||
// 卷膜参数设置
|
||||
|
|
@ -733,7 +745,7 @@ export default {
|
|||
"操作提示");
|
||||
return;
|
||||
}
|
||||
this.termList[this.term[this.current] + 'Param'] = {...this.rollerParam}
|
||||
this.termList[this.current]['config'] = {...this.rollerParam}
|
||||
this.$refs.autoParam.close();
|
||||
},
|
||||
closeParamDialog() {
|
||||
|
|
@ -741,14 +753,15 @@ export default {
|
|||
},
|
||||
// 选择时间串口点击确定
|
||||
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 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') {
|
||||
this.slider = {
|
||||
title: '适宜温度',
|
||||
|
|
@ -763,7 +776,7 @@ export default {
|
|||
title: '风口大小',
|
||||
min: 0,
|
||||
max: 100,
|
||||
unit: '﹪',
|
||||
unit: 'cm',
|
||||
value: fillerTerm.vent==='选择'?0:fillerTerm.vent,
|
||||
mode: tag
|
||||
}
|
||||
|
|
@ -781,9 +794,9 @@ export default {
|
|||
const slideMode = this.slider.mode;
|
||||
const value = this.slider.value;
|
||||
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') {
|
||||
this.termList[this.term[this.current]][this.rollerIndex].vent = value;
|
||||
this.termList[this.current]['terms'][this.rollerIndex].vent = value;
|
||||
}
|
||||
this.$refs.sliderDialog.close();
|
||||
},
|
||||
|
|
@ -794,6 +807,10 @@ export default {
|
|||
let showTips = null;
|
||||
|
||||
const checkRules = [
|
||||
{
|
||||
tip: '请设置自动化条件后重新保存重试!',
|
||||
validate: (rollerParam, term) => rollerParam.refTemp === '请选择' && !(term && term.length > 0)
|
||||
},
|
||||
{
|
||||
tip: '参考温度未设置,请点击相应页签左上角设置后重试!',
|
||||
validate: (rollerParam, term) => rollerParam.refTemp === '请选择'
|
||||
|
|
@ -822,7 +839,7 @@ export default {
|
|||
},
|
||||
{
|
||||
tip: '温度控制运行时间起不能大于止,请检查填写后重新尝试!',
|
||||
validate: (rollerParam, term) => term.some(item => !(item.startTime > item.endTime))
|
||||
validate: (rollerParam, term) => term.some(item => (item.startTime > item.endTime))
|
||||
},
|
||||
{
|
||||
tip: '温度控制运行时间存在冲突,请检查填写后重新尝试!',
|
||||
|
|
@ -843,9 +860,9 @@ export default {
|
|||
];
|
||||
|
||||
for (const [_, rule] of checkRules.entries()) {
|
||||
for (const [index, item] of this.term.entries()) {
|
||||
const term = termMap[item]; // 温度条件
|
||||
const rollerParam = termMap[item + 'Param']; // 参数设置
|
||||
for (const [index, item] of this.filmRollerList.entries()) {
|
||||
const term = termMap[index]['terms']; // 温度条件
|
||||
const rollerParam = termMap[index]['config']; // 参数设置
|
||||
const filmRoller = this.filmRollerList[index];
|
||||
if (!rollerParam) {
|
||||
this.$tn.message.toast('参数设置失败,请下拉刷新后重试!')
|
||||
|
|
@ -860,8 +877,8 @@ export default {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// todo 校验、后端保存
|
||||
console.info(`要保存的条件:`,termMap)
|
||||
// todo 校验、后端保存 温度设置重复提醒
|
||||
},
|
||||
|
||||
}
|
||||
|
|
@ -1143,6 +1160,14 @@ export default {
|
|||
}
|
||||
.message__middle {
|
||||
flex: 4;
|
||||
.message__name {
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.message__name {
|
||||
font-size: 24rpx;
|
||||
color: #838383;
|
||||
}
|
||||
.message__right {
|
||||
flex: 2;
|
||||
|
|
@ -1150,12 +1175,19 @@ export default {
|
|||
flex-direction: column;
|
||||
align-items: 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;
|
||||
margin-bottom: 8rpx;
|
||||
|
||||
// 点击反馈效果
|
||||
.message__right:active {
|
||||
background-color: #f5f5f5;
|
||||
transform: scale(0.98);
|
||||
}
|
||||
//.message__tag {
|
||||
// font-size: 24rpx;
|
||||
|
|
@ -1176,7 +1208,7 @@ export default {
|
|||
color: #0a0a0a;
|
||||
}
|
||||
}
|
||||
/deep/ .uni-input-input {
|
||||
/deep/.modal-container_ .uni-input-input {
|
||||
text-align: right !important;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,15 +235,20 @@ export function generateUniqueId() {
|
|||
return (timestamp + random).toString(); // 转成字符串,避免数字精度丢失
|
||||
}
|
||||
|
||||
// 极简版:判断时间列表是否存在冲突(支持HH:mm/HH:mm:ss)
|
||||
const checkTimeConflict = list => {
|
||||
// 时间转分钟数的极简写法
|
||||
const toMin = t => {
|
||||
|
||||
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);
|
||||
for (let i = 0; i < valid.length; i++) {
|
||||
const [aS, aE] = [toMin(valid[i].startTime), toMin(valid[i].endTime)];
|
||||
|
|
@ -253,7 +258,7 @@ const checkTimeConflict = list => {
|
|||
}
|
||||
}
|
||||
return { isConflict: false };
|
||||
};
|
||||
}
|
||||
|
||||
// ===================== 测试用例 =====================
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue