From f9625961d0678f81b9ce8e1d4a933c73b7fd4209 Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期四, 19 十月 2023 17:43:35 +0800 Subject: [PATCH] feat: 生产目标数首次是来源于下发的任务,然后需要显示从PLC获取的目标数 --- src/views/visualization.vue | 154 ++++++++++++++++++++++++++++++++++----------------- 1 files changed, 103 insertions(+), 51 deletions(-) diff --git a/src/views/visualization.vue b/src/views/visualization.vue index 94cf74b..2523cc2 100644 --- a/src/views/visualization.vue +++ b/src/views/visualization.vue @@ -31,7 +31,7 @@ </span> </span> </template> - 鐢熶骇绠$悊鐪嬫澘 + 鏅鸿兘宸ヤ綔鍙� <span class="font el-icon-setting set-title" style="float: right" @@ -104,7 +104,7 @@ style="font-size: 35px; font-weight: 600" class="color_green" > - {{ taskData.finishNumber || 0 }}{{ taskData.Order.unit }} + {{ processingStatistics(taskData).finishNumber }}{{ taskData.Order.unit }} </dd> </dl> </div> @@ -117,7 +117,7 @@ style="font-size: 35px; font-weight: 600" class="color_green" > - {{ taskData.Order.amount || 0 }}{{ taskData.Order.unit }} + {{ processingStatistics(taskData).totalNumber }}{{ taskData.Order.unit }} </dd> </dl> </div> @@ -166,16 +166,7 @@ text-color="#fff" :text-inside="true" :stroke-width="30" - :percentage=" - (taskData.Order && taskData.finishNumber != 0 && taskData.Order.amount) - ? parseInt( - (taskData.finishNumber / taskData.Order.amount) * - 100 - )>100?100:parseInt( - (taskData.finishNumber / taskData.Order.amount) * - 100 - ): 0 - " + :percentage="calculateProgress(processingStatistics(taskData))" ></el-progress> </el-descriptions-item> <!-- <el-descriptions-item label="鍚堟牸鐜�" style="width: 100%"> @@ -297,15 +288,7 @@ </div> <div class="card_top-3"> <span class="card-top-r-t" - >瀹屾垚杩涘害锛歿{ - (taskData.Order && taskData.finishNumber != 0 && taskData.Order.amount) - ? parseInt( - (taskData.finishNumber / - taskData.Order.amount) * - 100 - ) - : 0 - }}</span + >瀹屾垚杩涘害锛歿{calculateProgress(processingStatistics(taskData))}}</span > <span class="card-top-r-b"> <el-progress @@ -314,19 +297,7 @@ text-color="#fff" :text-inside="true" :stroke-width="10" - :percentage=" - (taskData.Order && taskData.finishNumber != 0) - ? parseInt( - (taskData.finishNumber / - taskData.Order.amount) * - 100 - )>100?100:parseInt( - (taskData.finishNumber / - taskData.Order.amount) * - 100 - ) - : 0 - " + :percentage="calculateProgress(processingStatistics(taskData))" :show-text="false" ></el-progress> </span> @@ -343,11 +314,11 @@ <div class="process-params-title"> <el-popover width="200" - :content="taskData.number" + :content="list.number" placement="top-start" trigger="click" > - <span slot="reference">宸ヨ壓缂栧彿锛歿{ taskData.number }}</span> + <span slot="reference">宸ヨ壓缂栧彿锛歿{ list.number }}</span> </el-popover> </div> @@ -524,7 +495,7 @@ <div class="right-person-box" v-if="workers && workers.length > 0"> <dl class="right-small-person" - v-for="(item, index) in workers" + v-for="(item, index) in deduplicateWorkers(displayWorkers())" :key="index" > <dt> @@ -605,8 +576,6 @@ </template> --> <!-- 鎺у埗鐨勫脊妗� --> - <AddControl ref="control" :Arr="Arr" /> - <!-- 鎺у埗鐨勫脊妗� --> <TaskControlModal ref="control" :activeName="activeName" @@ -641,6 +610,7 @@ import ProcessModel from "../components/ProcessModel.vue"; import TaskControlModal from "@/components/TaskControlModal.vue"; import {channelNameConfig} from "@/common/constants"; +import _ from 'lodash' export default { components: { TaskControlModal, @@ -662,6 +632,8 @@ // 鍙充晶瀹屾垚 finishShow:{}, workers:[], + // 淇濆瓨褰撳墠涓嶅悓閫氶亾鐨勫�肩彮浜� + channelWorkersMap:{0:[],1:[]}, TasksCopy:[], Tasks: [ { @@ -810,13 +782,62 @@ // } }, methods: { + processingStatistics(taskData){ + const status = taskData?.Procedure?.Status; + // 濡傛灉status = 2 鍔犲伐涓�, 鍒欏姞宸ユ暟鍜岀洰鏍囨暟搴斿彇杞鎺ュ彛涓殑 finishNumber 鍜� totalNumber + // 濡傛灉status = 1 鏈紑濮�, 鐩爣鏁� 鍙� taskData.Order.amount 鍔犲伐鏁板彇 0 + // 濡傛灉status = 3 宸插畬鎴�, 鐩爣鏁板拰鍔犲伐鏁伴兘鍙� amount + let finishNumber = 0; + let totalNumber = 0; + if (status === 1){ + totalNumber = taskData?.Order?.amount ?? 0 + finishNumber = 0 + }else if (status === 2){ + totalNumber = taskData?.totalNumber ?? 0 + finishNumber = taskData?.finishNumber ?? 0 + }else if (status === 3){ + totalNumber = taskData?.Order?.amount ?? 0 + finishNumber = taskData?.Order?.amount ?? 0 + } + + console.log({ + /** 鐩爣鏁� */ + totalNumber: +totalNumber, + /** 鍔犲伐鏁� */ + finishNumber: +finishNumber, + }) + + return { + /** 鐩爣鏁� */ + totalNumber: +totalNumber, + /** 鍔犲伐鏁� */ + finishNumber: +finishNumber, + } + }, + /** + * 璁$畻鐢熶骇杩涘害 + * @param statistics + * @return {number} 杩涘害,0~100 + */ + calculateProgress(statistics){ + if (statistics.finishNumber === statistics.totalNumber){ + return 100 + } + + const result = Math.floor(statistics.finishNumber / statistics.totalNumber * 100) + return result > 100 ? 100 : result + }, + deduplicateWorkers(workers){ + return _.uniqBy(workers,ele=>ele.workerName) + }, updateGet(number,val){ + if(val){ + this.getTaskInfo(this.activeName,'new') + return true; + } this.listData.number=number if(this.index){ this.TasksCopy[this.index].number=number - } - if(val){ - this.getTaskInfo(this.activeName,'new') } }, getModelList(){ @@ -1074,6 +1095,25 @@ }); }, + /** + * 鏍规嵁褰撳墠灞曠ず鐨勬槸0閫氶亾杩樻槸1閫氶亾杩樻槸涓や釜閫氶亾灞曠ず瀵瑰簲鐨勫�肩彮浜� + * @return {*[]} + */ + displayWorkers(){ + let showWorkers = [] + if (this.activeName===1){ + showWorkers =[...this.channelWorkersMap[0]] + }else if (this.activeName===2){ + showWorkers =[...this.channelWorkersMap[0],...this.channelWorkersMap[1]] + }else if (this.activeName===3){ + showWorkers =[...this.channelWorkersMap[1]] + }else { + return [] + } + + return showWorkers + }, + getTaskInfo(val,info) { this.Tasks = []; this.TasksCopy=[] @@ -1103,11 +1143,22 @@ } } this.workers=res.data.workers?res.data.workers:[] + + // 灏嗗�肩彮浜烘牴鎹�氶亾鍙峰垎缁� + const groupByChannel= _.groupBy(res.data.Tasks,ele=>ele.Channel) + const taskList0= _.first(groupByChannel[0]) + const taskList1= _.first(groupByChannel[1]) + const worker0List = taskList0?.Procedure?.procedure?.workers ?? [] + const worker1List = taskList1?.Procedure?.procedure?.workers ?? [] + this.channelWorkersMap['0'] =worker0List + this.channelWorkersMap['1'] =worker1List + for (let i in this.TasksCopy) { this.TasksCopy[i].procedureList = []; this.TasksCopy[i].inputMaterials = []; this.TasksCopy[i].outputMaterials = []; this.TasksCopy[i].finishNumber = 0; + this.TasksCopy[i].totalNumber = 0; this.TasksCopy[i].number=0; this.TasksCopy[i].isUpdateIcon=false; this.finishShow['finishShow&'+i]=false @@ -1133,6 +1184,7 @@ }); this.TasksCopy[i].Arr=res.data.Params ? res.data.Params : [] // this.isFinsh=Number(i)+1 + this.$forceUpdate() } }); } @@ -1140,11 +1192,12 @@ this.setInterCard("outputMaterials", "cardBox3&" + i, i); } this.getProcessModelList(); + this.getStartArr() this.cutClick(val?val:1) - if(info){ + if(info=='new'){ return true; } - this.getStartArr() + this.getProgressInfo(); if (!this.procInfoTimer&&!this.resprocInfoTimer) { this.procInfoTimer = setInterval(() => { @@ -1161,7 +1214,7 @@ // }, 60000); // } // } - + }); // this.TasksCopy.push(this.object) // this.TasksCopy.push(this.object) @@ -1220,10 +1273,9 @@ procedureId: this.TasksCopy[i].Procedure.ID, }).then((res) => { if (res.code == 200) { - this.TasksCopy[i].finishNumber = res.data.finishNumber - ? res.data.finishNumber - : 0; - this.plcStatus=res.data.plcStatus?res.data.plcStatus:0 + this.TasksCopy[i].finishNumber = res.data?.finishNumber ?? 0; + this.TasksCopy[i].totalNumber = res.data?.totalNumber ?? 0; + this.plcStatus = res.data?.plcStatus ?? 0 } this.resprocInfoTimer=res; }); @@ -1750,7 +1802,7 @@ width: 100%; height: 30px; // text-align: left; - font-size: 24px; + font-size: 28px!important; margin: 0; text-align: center; line-height: 36px; -- Gitblit v1.8.0