From bdae6b839094926c3e79c4f526bb68be72e90630 Mon Sep 17 00:00:00 2001 From: lld <15027638633@163.com> Date: Sat, 28 Feb 2026 23:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/control/autoTerm.js | 44 ++++++ api/control/rollerParam.js | 44 ++++++ pages/home/control/automatic.vue | 236 ++++++++++++++++++------------- utils/agri.js | 23 +-- 4 files changed, 236 insertions(+), 111 deletions(-) create mode 100644 api/control/autoTerm.js create mode 100644 api/control/rollerParam.js diff --git a/api/control/autoTerm.js b/api/control/autoTerm.js new file mode 100644 index 0000000..857abdf --- /dev/null +++ b/api/control/autoTerm.js @@ -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' + }) +} diff --git a/api/control/rollerParam.js b/api/control/rollerParam.js new file mode 100644 index 0000000..cf89115 --- /dev/null +++ b/api/control/rollerParam.js @@ -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' + }) +} diff --git a/pages/home/control/automatic.vue b/pages/home/control/automatic.vue index 2e1f999..06a3ad4 100644 --- a/pages/home/control/automatic.vue +++ b/pages/home/control/automatic.vue @@ -49,12 +49,13 @@ :bold="true" @change="switchTab" :height="80"> - - + + - 参考温度:{{ termList[term[current] + 'Param'].refTemp }} + 参考温度:{{ termList[current]['config'].refTemp }} @@ -63,8 +64,8 @@ - - + @@ -82,16 +83,23 @@ - + + 温度 {{ formatValueWithUnit(item.temp, '℃') }} - - + + + + 风口 {{ formatValueWithUnit(item.vent, 'cm') }} - + @@ -146,6 +154,10 @@ {{ `【${selectedText} - ${filmRollerList[current]}】风口校准`}} + + + @@ -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":{ - refTemp: '请选择', - refTempCode: null, - autoTotalLen: null, - manualTotalLen: null, - reservedLen: null, - roller:'jm1' + termList: [ + { + terms: [], + config: { + refTemp: '请选择', + refTempCode: null, + autoTotalLen: null, + manualTotalLen: null, + reservedLen: null, + roller:'jm1' + } }, - "jm2": [], - "jm2Param":{ - refTemp: '请选择', - refTempCode: null, - autoTotalLen: null, - manualTotalLen: null, - reservedLen: null, - roller:'jm2' + { + terms: [], + config:{ + refTemp: '请选择', + refTempCode: null, + autoTotalLen: null, + manualTotalLen: null, + reservedLen: null, + roller:'jm2' + } }, - "jm3": [], - "jm3Param":{ - refTemp: '请选择', - refTempCode: null, - autoTotalLen: null, - manualTotalLen: null, - reservedLen: null, - roller:'jm3' - }, - }, + { + 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":{ - refTemp: '请选择', - refTempCode: null, - }, - "jm2": [], - "jm2Param":{ - refTemp: '请选择', - refTempCode: null, - }, - "jm3": [], - "jm3Param":{ - refTemp: '请选择', - refTempCode: null, - }, - }; + this.termList = []; + for (const [index,value] of this.filmRollerList.entries()) { + this.termList.push({ + terms: [], + config: { + 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,24 +707,18 @@ 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.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.termList = { - ...this.termList, - [currentKey]: newList - }; - // 3. 再次nextTick更新swiper高度 - this.$nextTick(() => { - this.getSwiperHeight(); - // 可选:关闭滑动删除的展开状态(避免组件样式异常) - uni.$emit('uni-swipe-action-hide'); - }); + this.getSwiperHeight(); + uni.$emit('uni-swipe-action-hide'); }); }, // 选择运行时间 @@ -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; } diff --git a/utils/agri.js b/utils/agri.js index faf088b..cd182a0 100644 --- a/utils/agri.js +++ b/utils/agri.js @@ -235,15 +235,20 @@ export function generateUniqueId() { 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); 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 }; -}; +} // ===================== 测试用例 ===================== /*