快乐的昕的电脑
2025-10-20 bb06b304a826d5a418d2d50cba47ed376b471625
components/WorkOrder.vue
@@ -1,20 +1,11 @@
<template>
   <view>
      <view class="container" style="display: flex;
               flex-direction: row;
               flex-wrap: nowrap;
               align-content: flex-start;
               justify-content: flex-start;">
      <view class="container" style="display: flex; flex-direction: row; flex-wrap: nowrap; align-content: flex-start; justify-content: flex-start;">
         <!--主界面-->
         <!-- 上部:工单选择和机台信息 -->
         <view class="top-order" style=" display:inline-block;">
         <view class="top-order" style="display:inline-block;">
            <view class="form-row4">
               <view class="form-row" style="display: flex;
                                 flex-direction: column;
                                 flex-wrap: nowrap;
                                 justify-content: flex-start;
                                 align-items: center;">
               <view class="form-row" style="display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: center;">
                  <view class="form-item">
                     <label>工单编号:</label>
                     <input class="inp" type="text" v-model="order.daa001" disabled="true" />
@@ -59,7 +50,7 @@
                  </view>
                  <view class="form-item">
                     <label>产品规格:</label>
                     <input class="inp" type="text" v-model="order.daa004" disabled="true" /><!-- 保留原绑定与注释,未改 -->
                     <input class="inp" type="text" v-model="order.daa004" disabled="true" />
                  </view>
                  <view class="form-item">
                     <label>报工数量:</label>
@@ -69,7 +60,7 @@
            </view>
         </view>
         <view class="form-row1">
            <view class="form-item" style=" display:inline-block;">
            <view class="form-item" style="display:inline-block;">
               <label>工单状态:</label>
               <input class="inp1" type="text" v-model="order.daa018" disabled="true" />
               <!-- 刷新按钮 -->
@@ -87,11 +78,12 @@
         <view class="form-row">
            <view class="form-item">
               <label style="color: red;">日停机次数(时长超5分钟):</label>
               <input class="inp" style="width: 40%;" type="number" v-model="todayFaultNum" disabled="true" />
               <input class="inp" style="width: 40%;" type="number" v-model="todayDowntimeCount" disabled="true" />
            </view>
            <view class="form-item">
               <label>日停机时长(mi):</label>
               <input class="inp" type="text" v-model="todayRunTime" disabled="true" />
               <!-- 这里用计算属性,不能用v-model表达式 -->
               <input class="inp" type="text" :value="downtimeDuration" disabled="true" />
            </view>
            <view class="form-item">
               <label>设备稼动率:</label>
@@ -126,8 +118,12 @@
               <input class="inp" type="text" v-model="initialConclusion" disabled="true" />
            </view>
            <view class="form-item">
               <label>巡检次数:</label><!--首检次数???-->
               <input class="inp" type="number" v-model="patrolCount" disabled="true" />
               <label>首检人员:</label>
               <input class="inp" type="text" v-model="initialInspector" disabled="true" />
            </view>
            <view class="form-item">
               <label>首检次数:</label>
               <input class="inp" type="number" v-model="initialCount" disabled="true" />
            </view>
         </view>
         <view class="form-row">
@@ -138,6 +134,10 @@
            <view class="form-item">
               <label>巡检结论:</label>
               <input class="inp" type="text" v-model="patrolConclusion" disabled="true" />
            </view>
            <view class="form-item">
               <label>巡检人员:</label>
               <input class="inp" type="text" v-model="patrolInspector" disabled="true" />
            </view>
            <view class="form-item">
               <label>巡检次数:</label>
@@ -171,14 +171,26 @@
            productionDuration: '',
            lastInitialCheck: '',
            initialConclusion: '',
            initialInspector: '',
            initialCount: 0,
            lastPatrolCheck: '',
            patrolConclusion: '',
            patrolInspector: '',
            patrolCount: 0,
            timer: null, // Timer reference
            timer: null,
            DAA003List: [],
            lineList: [],
         };
      },
      computed: {
         // 日停机时长 = todayOnlineTime - todayRunTime
         downtimeDuration() {
            // 取order对象中的todayOnlineTime和todayRunTime,都为分钟
            const online = Number(this.order.todayOnlineTime) || 0;
            const run = Number(this.order.todayRunTime) || 0;
            return online - run;
         }
      },
      created() {
         this.fetchData(true);
@@ -186,11 +198,11 @@
         this.init();
      },
      mounted() {
         this.fetchData(false); // Initial fetch
         this.timer = setInterval(this.fetchData, 120000); // Call fetchData every 3 minutes
         this.fetchData(false);
         this.timer = setInterval(this.fetchData, 120000);
      },
      beforeDestroy() {
         clearInterval(this.timer); // Clear the timer on component destruction
         clearInterval(this.timer);
      },
      methods: {
         init() {
@@ -231,7 +243,6 @@
               }
            });
         },
         onDaa003Change(event) {
            let orde = this.lineList[this.DAA003List.indexOf(event)];
            this.orderId = orde.id;
@@ -362,8 +373,9 @@
                     cutterName,  //刀具名称
                     cutterModel, //刀具规格
                     jdl: '',
                     startCjNum: 0, // 新增兜底字段 保留其它注释
                     currentCjNum: 0 // 新增兜底字段
                            startCjNum: 0, // 开工数采
                            currentCjNum: 0, // 当前数采
                            todayDowntimeCount //今日停机次数
                  };
                  return;
               }
@@ -385,8 +397,6 @@
               //this.productionDuration = (this.order.todayOnlineTime / 3600).toFixed(2) + "h";
               this.todayFaultNum = this.order.todayFaultNum;
               this.utilizationRate = this.order.jdl + '%';
               // this.startTime = this.order.workStartDate;
               // this.endTime = this.order.workEndDate;
               let title = this.machineNo + '号机台 工单号' + this.order.daa001 + ',当前数采' + this.order.currentCjNum; // 标题中使用 currentCjNum
               this.setTitle(title);
            })
@@ -404,9 +414,24 @@
                  orderNo: this.orderNo
               }
            }).then(res => {
               //this.order = res.data.tbBillList;
               this.lastInitialCheck = res.data.tbBillList.fcheckDate;
               this.initialConclusion = res.data.tbBillList.fcheckResu;
               let sjList = res.data.tbBillList;
               if (Array.isArray(sjList) && sjList.length > 0) {
                  let latest = sjList[0];
                  this.lastInitialCheck = latest.fcheckDate;
                  this.initialConclusion = latest.fcheckResu;
                  this.initialInspector = latest.fcheckBy; // 首检人员(工号-姓名)
                  this.initialCount = latest.xjCount ?? sjList.length; // 优先用xjCount字段
               } else if (sjList) {
                  this.lastInitialCheck = sjList.fcheckDate;
                  this.initialConclusion = sjList.fcheckResu;
                  this.initialInspector = sjList.fcheckBy; // 首检人员(工号-姓名)
                  this.initialCount = sjList.xjCount ?? 1;
               } else {
                  this.lastInitialCheck = '';
                  this.initialConclusion = '';
                  this.initialInspector = '';
                  this.initialCount = 0;
               }
            })
         },
         getXJByOrder() {
@@ -416,10 +441,24 @@
                  orderNo: this.orderNo
               }
            }).then(res => {
               //this.order = res.data.tbBillList;
               this.lastPatrolCheck = res.data.tbBillList.fcheckDate;
               this.patrolConclusion = res.data.tbBillList.fcheckResu;
               this.patrolCount = res.data.tbBillList.xjCount;
               let xjList = res.data.tbBillList;
               if (Array.isArray(xjList) && xjList.length > 0) {
                  let latest = xjList[0];
                  this.lastPatrolCheck = latest.fcheckDate;
                  this.patrolConclusion = latest.fcheckResu;
                  this.patrolInspector = latest.fcheckBy; // 巡检人员(工号-姓名)
                  this.patrolCount = latest.xjCount ?? xjList.length;
               } else if (xjList) {
                  this.lastPatrolCheck = xjList.fcheckDate;
                  this.patrolConclusion = xjList.fcheckResu;
                  this.patrolInspector = xjList.fcheckBy; // 巡检人员(工号-姓名)
                  this.patrolCount = xjList.xjCount ?? 1;
               } else {
                  this.lastPatrolCheck = '';
                  this.patrolConclusion = '';
                  this.patrolInspector = '';
                  this.patrolCount = 0;
               }
            })
         }
      }
@@ -435,7 +474,6 @@
      position: absolute;
      top: -11px;
      right: 21px;
      /* padding: 10px 20px; */
      cursor: pointer;
      float: right;
      background-color: #00A2E9;
@@ -443,11 +481,10 @@
      border: none;
      font-size: 29px;
      border-radius: 15px;
      margin-top: -23px;
      padding-left: 25px;
      padding-right: 25px;
      margin-top: 9px;
      margin-bottom: 20px;
      padding-left: 25px;
      padding-right: 25px;
   }
      .refresh-btn:hover {
@@ -474,9 +511,7 @@
      border-radius: 0.5vw;
      margin-top: 0.3vh;
      font-size: 1.3vw;
      /* Larger font for inputs */
   }
   .status-block p {
      margin: 1vh 0;
@@ -484,7 +519,6 @@
      font-weight: bold;
   }
   /* 卡片样式 */
   .card {
      background-color: #fff;
      border-radius: 0.8vw;
@@ -494,10 +528,8 @@
      margin-top: -1vh;
      margin-bottom: 2vh;
      font-size: 1.5vw;
      /* Base font size for card content */
   }
   /* 卡片标题在左上角 */
   .card-header {
      position: absolute;
      top: -1vh;
@@ -507,19 +539,16 @@
      border-radius: 0.5vw;
      font-weight: bold;
      font-size: 1.8vw;
      /* Larger font for headers */
   }
   .form-item label {
      float: left;
      margin-top: 8px;
      font-size: 1.5vw;
      /* Larger font for labels */
      display: inline-block;
      margin-bottom: 0.5vh;
      color: #333;
   }
   .status-row label,
   .check-row label {
@@ -527,7 +556,6 @@
      padding-right: 1vw;
      text-align: right;
      font-size: 1.5vw;
      /* Increased font for labels in status sections */
   }
   .status-row input,
@@ -579,7 +607,6 @@
      border-radius: 100%;
      text-align: center;
      margin-top: -42px;
      /*    margin-left: 37px; */
      font-size: 96px;
      background-color: #476ee1fc;
      color: #ffffff;