From c3d26d0fe57fd0a46ecb1c2763e1cc66994c6185 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期一, 21 八月 2023 16:07:40 +0800
Subject: [PATCH] 增加判断

---
 src/views/visualization.vue |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/src/views/visualization.vue b/src/views/visualization.vue
index 6322a9b..2a269d9 100644
--- a/src/views/visualization.vue
+++ b/src/views/visualization.vue
@@ -13,8 +13,10 @@
         </p>
         <div class="statelist">
           <span class="title-item"
-            >璁㈠崟缂栧彿:
-            <span class="color_4efefa">{{ taskData.Order.orderId || "" }}</span>
+            >宸ュ崟缂栧彿:
+            <span class="color_4efefa">{{
+              taskData.Order.workOrderId || ""
+            }}</span>
           </span>
           <span class="title-item"
             >褰撳墠宸ュ簭:
@@ -76,9 +78,7 @@
                 {{ taskData.Procedure.procedure.workHours || "" }}
               </el-descriptions-item>
               <el-descriptions-item label="璧锋鏃堕棿"
-                >{{
-                  formatDate(taskData.Procedure.procedure.startTime) || ""
-                }}
+                >{{ formatDate(taskData.Procedure.procedure.startTime) || "" }}
                 -
                 {{
                   formatDate(taskData.Procedure.procedure.endTime)
@@ -199,14 +199,13 @@
                         }}</span
                       >
                       <span class="card-top-r-b">
-                       
                         <el-progress
                           define-back-color="#133EAF"
                           color="#09E5ED"
                           :text-inside="true"
                           :stroke-width="10"
                           :percentage="
-                           parseInt(finishNumber / taskData.Order.amount)
+                            parseInt(finishNumber / taskData.Order.amount)
                           "
                           :show-text="false"
                         ></el-progress>
@@ -224,8 +223,18 @@
                     <!-- <div class="card_content">
                       
                     </div> -->
-                    <div class="card_top-4"><div>宸ヨ壓缂栧彿锛歿{ list.number }}</div>
-                      <div style="font-size:14px;color:#cfcfcf;line-height:20px">宸ヨ壓鐨勫叿浣撲俊鎭鐐瑰嚮鎺у埗鏌ョ湅锛�</div></div>
+                    <div class="card_top-4">
+                      <div>宸ヨ壓缂栧彿锛歿{ list.number }}</div>
+                      <div
+                        style="
+                          font-size: 14px;
+                          color: #cfcfcf;
+                          line-height: 20px;
+                        "
+                      >
+                        宸ヨ壓鐨勫叿浣撲俊鎭鐐瑰嚮鎺у埗鏌ョ湅锛�
+                      </div>
+                    </div>
                   </template>
                 </div>
               </el-carousel-item>
@@ -395,7 +404,7 @@
           </div> -->
         </div>
         <div class="right_base">
-          <div class="right-small-title" style="line-height:40px;">鐭ヨ瘑搴�</div>
+          <div class="right-small-title" style="line-height: 40px">鐭ヨ瘑搴�</div>
           <Knowledge />
           <div class="right-base-btn call">
             <el-button type="primary"
@@ -469,15 +478,14 @@
       outputMaterials: [],
       procedureList: [
         [
-        {
-            number:10,
-            name:'宸ュ簭'
+          {
+            number: 10,
+            name: "宸ュ簭",
           },
           {
-            number:10,
+            number: 10,
           },
-          
-        ]
+        ],
       ],
       taskData: {
         Order: {
@@ -593,9 +601,20 @@
     },
 
     getTaskInfo() {
+      this.taskData = {
+        Order: {},
+        Procedure: { procedure: { inputMaterials: [], outputMaterials: [] } },
+      };
       getTaskInfo().then((res) => {
         if (res.code == 200) {
-          this.taskData = res.data;
+          this.taskData = res.data
+            ? res.data
+            : {
+                Order: {},
+                Procedure: {
+                  procedure: { inputMaterials: [], outputMaterials: [] },
+                },
+              };
           this.procedureList.push([
             {
               name: "宸ュ簭",
@@ -631,17 +650,25 @@
     },
     // 鍙充晶鎺у埗
     controlClick() {
-      this.$refs.control.islook = true;
+      if (Object.keys(this.taskData).length > 0 && this.taskData.Procedure.ID) {
+        this.$refs.control.islook = true;
+      } else {
+        this.$message.error("褰撳墠璁惧娌℃湁宸ュ簭锛�");
+      }
     },
     // 鍙充晶瀹屾垚
     finishClick() {
-      finishTask({ id: this.taskData.Procedure.ID }).then((res) => {
-        if (res.code == 200) {
-          this.finishShow = false;
-          this.getTaskInfo();
-          this.$message.success("鎿嶄綔鎴愬姛锛�");
-        }
-      });
+      if (Object.keys(this.taskData).length > 0 && this.taskData.Procedure.ID) {
+        finishTask({ id: this.taskData.Procedure.ID }).then((res) => {
+          if (res.code == 200) {
+            this.finishShow = false;
+            this.getTaskInfo();
+            this.$message.success("鎿嶄綔鎴愬姛锛�");
+          }
+        });
+      } else {
+        this.$message.error("褰撳墠璁惧娌℃湁宸ュ簭锛�");
+      }
     },
     getRandomNumber(min, max) {
       return Math.floor(Math.random() * (max - min + 1) + min);
@@ -750,7 +777,7 @@
 .right-small-btn {
   margin-top: 10px;
   width: calc(100% - 20px);
-  margin:0 auto;
+  margin: 0 auto;
   position: absolute;
   bottom: 10px;
   left: 10px;
@@ -977,7 +1004,7 @@
           line-height: 40px;
           color: #fff;
           background: rgb(19, 35, 90);
-          font-size:20px;
+          font-size: 20px;
         }
         .card-info-box {
           position: absolute;

--
Gitblit v1.8.0