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 | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/components/TaskControlModal.vue b/src/components/TaskControlModal.vue index 2134a65..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" @@ -103,7 +107,7 @@ </div> </div> </div> - <div class="process-err-tip" v-if="getProcessParamsErrMsg"> + <div class="process-err-tip" v-if="getProcessParamsErrMsg && !currentDeviceAllowNoParams"> <div class="tip-icon"> <span class="el-icon-error color_error"></span> </div> @@ -136,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 }} @@ -166,7 +174,7 @@ </div> <div slot="footer" :class="messageError?'dialog-footer tac btn-error':'dialog-footer tac'" style="overflow: hidden"> - <template v-if="messageError || getProcessParamsErrMsg"> + <template v-if="(messageError || getProcessParamsErrMsg) && !currentDeviceAllowNoParams"> <div class="btn" v-if="messageError ==='涓嬪彂鎴愬姛锛�'||getProcessParamsErrMsg" @click="closeClick"> <img src="../../public/close-btn.png"/> </div> @@ -211,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: {}, @@ -230,6 +239,7 @@ currentTaskIndex: 0, // 褰撳墠灞曠ず鐨勪换鍔″搴旂殑宸ヨ壓鍙傛暟 currentProcessParams: [], + processParamsLoaded:false, getProcessParamsErrMsg: '', // 浠诲姟鍒楄〃 taskList: [], @@ -243,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) @@ -303,6 +313,7 @@ if (this.secondTimer) { clearInterval(this.secondTimer) } + this.processParamsLoaded=false this.num = 0; this.showBtn = 1; this.isLoading = false @@ -311,6 +322,7 @@ this.messageError = '' this.resParams = {}; if (newVal) { + this.getDeviceInfo() this.getTaskList().then(() => { const firstData = this.taskList[0] const id = firstData?.Procedure?.ID @@ -360,12 +372,29 @@ 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 ?? [] @@ -379,6 +408,8 @@ console.error(err) this.currentProcessParams = [] this.getProcessParamsErrMsg = '鑾峰彇宸ヨ壓鍙傛暟澶辫触锛�' + }).finally(()=>{ + this.processParamsLoaded =true }); } }, @@ -424,9 +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; + // this.show = false; } }, getDateObj(date, fmt) { -- Gitblit v1.8.0