diff --git a/api/control/autoTerm.js b/api/control/autoTerm.js index 857abdf..078c1be 100644 --- a/api/control/autoTerm.js +++ b/api/control/autoTerm.js @@ -42,3 +42,18 @@ export function delAutoTerm(id) { method: 'delete' }) } + +export function getAgriTerm(imei) { + return request({ + url: '/control/autoTerm/getAgriTerm/' + imei, + method: 'get' + }) +} + +export function saveAgriTerm(data) { + return request({ + url: '/control/autoTerm/saveAgriTerm', + method: 'put', + data: data + }) +} \ No newline at end of file diff --git a/pages/home/control/automatic.vue b/pages/home/control/automatic.vue index 06a3ad4..c7ce711 100644 --- a/pages/home/control/automatic.vue +++ b/pages/home/control/automatic.vue @@ -225,6 +225,28 @@ + + + @@ -239,6 +261,7 @@ 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 {getAgriTerm, saveAgriTerm} from "../../../api/control/autoTerm"; export default { dicts: ['sys_data_map'], @@ -364,6 +387,39 @@ export default { } ], showSelect:false, + demo: { + config: [ + { + refTemp: '请选择', + refTempCode: null, + autoTotalLen: null, + manualTotalLen: null, + reservedLen: null, + roller:'jm1' + }, + { + refTemp: '请选择', + refTempCode: null, + autoTotalLen: null, + manualTotalLen: null, + reservedLen: null, + roller:'jm2' + }, + { + refTemp: '请选择', + refTempCode: null, + autoTotalLen: null, + manualTotalLen: null, + reservedLen: null, + roller:'jm3' + } + ], + terms: [ + [/* 卷膜1的条件列表 */], + [/* 卷膜2的条件列表 */], + [/* 卷膜3的条件列表 */] + ] + }, termList: [ { terms: [], @@ -439,6 +495,7 @@ export default { manualTotalLen: null, reservedLen: null }, + showTip:false }; }, @@ -458,26 +515,23 @@ export default { }, // 下拉刷新以及进入组件渲染 refresh() { - 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.getAgriTerm(); this.showFlag = !((store.getters && store.getters.name !== 'admin') && this.$auth.hasRole("test")) this.$nextTick(() => { this.getSwiperHeight(); // 页面初始化时也计算一次 }); }, + getAgriTerm() { + getAgriTerm(this.imei).then(response => { + if (response.code === 200) { + + this.termList = response.data; + } + }).catch(err => { + }).finally(() => { + + }); + }, // 修改运行时间以及设备备注弹窗 openTimeModal(card) { if ((store.getters && store.getters.name !== 'admin') @@ -878,9 +932,46 @@ export default { } } console.info(`要保存的条件:`,termMap) - // todo 校验、后端保存 温度设置重复提醒 + const hasDuplicate = this.termList + .filter(item => item.config.refTempCode) // 过滤空值 + .reduce(({ map, isDup }, item) => { + const code = item.config.refTempCode; + if (map.has(code)) isDup = true; // 已有该key,标记为重复 + else map.set(code, true); // 无则存入map + return { map, isDup }; + }, { map: new Map(), isDup: false }) + .isDup; + if (hasDuplicate) { + this.showTip = true; + } else { + uni.showModal({ + title: '操作提示:', + content: '', + cancelText: '取消', + confirmText: '确定', + success: (res) => { + if (res.confirm) { + this.saveAgriTerm(); + } + } + }) + } }, - + saveAgriTerm() { + saveAgriTerm(this.termList).then(response => { + if (response.code===200) { + this.$modal.msgSuccess("自动化条件保存成功!") + } else { + this.$modal.msgError("自动化条件保存失败!请重试或联系客服!") + } + }) + }, + showTips(event) { + this.showTip = false; + if (event.index===1) { + this.saveAgriTerm(); + } + } } };