From f6739d7542be48f7f8139c3d5fc7b2326e5cfc8d Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期三, 22 十一月 2023 11:06:35 +0800 Subject: [PATCH] feat: 轮询plc时间调整; 接口报错时也轮询plc --- src/components/TaskControlModal.vue | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 101 insertions(+), 18 deletions(-) diff --git a/src/components/TaskControlModal.vue b/src/components/TaskControlModal.vue index 65e2c38..e9c7302 100644 --- a/src/components/TaskControlModal.vue +++ b/src/components/TaskControlModal.vue @@ -65,9 +65,9 @@ 宸ユ椂锛� {{ currentTaskData.Procedure.procedure.workHours || "" }} </div> <div class="title-item"> - 璁″垝鏃堕棿锛� {{ formatDate(currentTaskData.Order.startTime) || "" }} + 璁″垝鏃堕棿锛� {{ formatDate(currentTaskData.Procedure.startTime) || "" }} - - {{ formatDate(currentTaskData.Order.endTime) }} + {{ formatDate(currentTaskData.Procedure.endTime) }} </div> <div class="title-item"> @@ -93,6 +93,10 @@ > 宸ヨ壓鍙傛暟 </div> + <!-- 鏈幏鍙栧埌宸ヨ壓鍙傛暟, 涓斿綋鍓嶈澶囧厑璁稿湪娌℃湁宸ヨ壓鍙傛暟鐨勬儏鍐典笅鐢熶骇, 鍒欐彁绀�--> + <div v-if="processParamsLoaded && !currentProcessParams?.length && currentDeviceAllowNoParams" class="title-item title-item-two"> + 鏈幏鍙栧埌宸ヨ壓鍙傛暟, 璇锋墜鍔ㄨ缃垨鍦ㄤ簯绔伐鑹烘ā鍨嬩腑涓婁紶 + </div> <div class="title-item title-item-two" v-for="(item, index) in currentProcessParams" @@ -101,6 +105,14 @@ {{ item.Key }}锛歿{ item.Value || "" }} </div> + </div> + </div> + <div class="process-err-tip" v-if="getProcessParamsErrMsg && !currentDeviceAllowNoParams"> + <div class="tip-icon"> + <span class="el-icon-error color_error"></span> + </div> + <div class="tip-content"> + 鎻愮ず: {{getProcessParamsErrMsg}} </div> </div> <div class="process-box" v-if="showBtn === 2 || showBtn === 3"> @@ -128,8 +140,12 @@ </div> </template> <div class="gif-right"> - ----- 鍓╀綑鏃堕棿 ----- - <span>00:00:{{ 30 - Number(num) < 10 ? 0 : '' }}{{ 30 - Number(num) }}</span> + <div> + ----- 鍓╀綑鏃堕棿 ----- + </div> + <div> + <span>00:00:{{ 30 - Number(num) < 10 ? 0 : '' }}{{ 30 - Number(num) }}</span> + </div> </div> </div> {{ message }} @@ -152,13 +168,13 @@ </template> </div> <!--宸︾炕椤垫寜閽�--> - <div v-show="showPreviousTaskBtn" class="paginator-btn previous" @click="previousTask"><</div> + <div v-show="showPreviousTaskBtn" class="paginator-btn previous" :class="{disabled:showBtn ===2 ||messageError}" @click="previousTask"><</div> <!--鍙崇炕椤垫寜閽�--> - <div v-show="showNextTaskBtn" class="paginator-btn next" @click="nextTask">></div> + <div v-show="showNextTaskBtn" class="paginator-btn next" :class="{disabled:showBtn ===2 ||messageError}" @click="nextTask">></div> </div> <div slot="footer" :class="messageError?'dialog-footer tac btn-error':'dialog-footer tac'" style="overflow: hidden"> - <template v-if="messageError"> + <template v-if="(messageError || getProcessParamsErrMsg) && !currentDeviceAllowNoParams"> <div class="btn" v-if="messageError ==='涓嬪彂鎴愬姛锛�'||getProcessParamsErrMsg" @click="closeClick"> <img src="../../public/close-btn.png"/> </div> @@ -203,7 +219,8 @@ </template> <script> -import {getTaskInfo, sendProcessParams, startTask,} from "@/api/home"; // 浜х嚎 +import {getDeviceList, getTaskInfo, sendProcessParams, startTask,} from "@/api/home"; // 浜х嚎 +import {channelNameConfig} from "@/common/constants"; export default { name: 'TaskControlModal', components: {}, @@ -222,6 +239,7 @@ currentTaskIndex: 0, // 褰撳墠灞曠ず鐨勪换鍔″搴旂殑宸ヨ壓鍙傛暟 currentProcessParams: [], + processParamsLoaded:false, getProcessParamsErrMsg: '', // 浠诲姟鍒楄〃 taskList: [], @@ -235,17 +253,17 @@ isLoading: false, second: 0, secondTimer: null, - // 閫氶亾鍚嶇О閰嶇疆 Channel 0 瀵瑰簲灞曠ず 0, Channel 1 瀵瑰簲灞曠ず A,鏆傛椂蹇界暐鍏朵綑鎯呭喌 - channelNameConfig: { - 0: '0', - 1: 'A' - } + channelNameConfig: channelNameConfig, + currentDeviceAllowNoParams:false, + deviceInfo:null }; }, mounted() { this.getTaskList().then(() => { const firstData = this.taskList[0] const id = firstData?.Procedure?.ID + console.log(this.taskList) + this.getDeviceInfo() if (id) { this.currentTaskIndex = this.taskList.findIndex(ele => ele.Procedure.ID === id) this.getCurrentTaskProduceParams(id) @@ -295,6 +313,7 @@ if (this.secondTimer) { clearInterval(this.secondTimer) } + this.processParamsLoaded=false this.num = 0; this.showBtn = 1; this.isLoading = false @@ -303,6 +322,7 @@ this.messageError = '' this.resParams = {}; if (newVal) { + this.getDeviceInfo() this.getTaskList().then(() => { const firstData = this.taskList[0] const id = firstData?.Procedure?.ID @@ -352,25 +372,56 @@ console.error(err) },) }, + getDeviceInfo(){ + getDeviceList().then(res=>{ + this.deviceInfo = res.data + this.currentDeviceAllowNoParams=this.getConfig(this.deviceInfo) + }).catch(err=>{ + console.error(err) + }) + }, + getConfig(deviceInfo){ + const currentDeviceInfo = deviceInfo.deviceList?.find((ele) => { + return ele.deviceID === deviceInfo.currentDeviceID + }) + return !currentDeviceInfo?.needSetProcessParams + }, /** * 鑾峰彇褰撳墠灞曠ず鐨勪换鍔$殑宸ヨ壓鍙傛暟 */ getCurrentTaskProduceParams(id) { // const id = this.currentTaskData?.Procedure?.ID if (id) { + this.currentProcessParams = [] + this.getProcessParamsErrMsg = "" + this.processParamsLoaded =false startTask({id}).then((res) => { if (res.code === 200) { this.currentProcessParams = res.data.Params ?? [] + this.getProcessParamsErrMsg ='' } else { + this.currentProcessParams = [] this.getProcessParamsErrMsg = res.msg ?? '鑾峰彇宸ヨ壓鍙傛暟澶辫触锛�'; } + this.getInfo() + },err=>{ + console.error(err) + this.currentProcessParams = [] + this.getProcessParamsErrMsg = '鑾峰彇宸ヨ壓鍙傛暟澶辫触锛�' + }).finally(()=>{ + this.processParamsLoaded =true }); } }, + /** * 鍓嶇炕椤� */ previousTask() { + // 鐢熶骇鍑嗗鍊掕鏃朵腑鍜屼笅鍙戝け璐ョ姝㈢炕椤� + if (this.showBtn === 2 || this.messageError){ + return + } if (this.currentTaskIndex - 1 >= 0) { this.currentTaskIndex -= 1 this.$nextTick(() => { @@ -385,6 +436,10 @@ * 鍚庣炕椤� */ nextTask() { + // 鐢熶骇鍑嗗鍊掕鏃朵腑鍜屼笅鍙戝け璐ョ姝㈢炕椤� + if (this.showBtn === 2 || this.messageError){ + return + } if (this.currentTaskIndex + 1 <= this.taskList.length - 1) { this.currentTaskIndex += 1 this.$nextTick(() => { @@ -400,12 +455,9 @@ if (this.currentTaskData?.Procedure?.ID && this.currentTaskData?.Procedure?.Status === 1) { this.num = 0; this.showBtn = 1; - this.show = true; + // this.show = true; } else { - this.show = false; - } - if (this.getProcessParamsErrMsg) { - this.messageError = this.getProcessParamsErrMsg; + // this.show = false; } }, getDateObj(date, fmt) { @@ -904,6 +956,12 @@ &.next { right: -60px; padding-left: 4px; + + } + &.disabled{ + background-color: #cccccc; + opacity: 0.8; + cursor: not-allowed; } } @@ -924,5 +982,30 @@ color: #ffffffaa; font-size: 16px; } + +} +.process-err-tip{ + box-sizing: border-box; + padding-top: 10px; + height: 160px; + width: 100%; + .tip-icon{ + display: flex; + align-items: center; + justify-content: center; + height: 70px; + .el-icon-error{ + font-size: 70px; + } + } + .tip-content{ + height: 70px; + display: flex; + align-items: center; + justify-content: center; + color: #fff; + font-size: 17px; + font-weight: 500; + } } </style> -- Gitblit v1.8.0