From 351480c2cc022c886429192fc2893e3fc2c9877f Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期四, 07 九月 2023 12:06:25 +0800
Subject: [PATCH] 修改滚动条样式  开始生产增加 loading状态

---
 src/components/AddIssue.vue |  391 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 254 insertions(+), 137 deletions(-)

diff --git a/src/components/AddIssue.vue b/src/components/AddIssue.vue
index d3cb897..fcb6624 100644
--- a/src/components/AddIssue.vue
+++ b/src/components/AddIssue.vue
@@ -28,90 +28,109 @@
               鐢熶骇鏁伴噺锛�<span>{{ taskData.Order.amount || 0 }}</span>
             </div>
           </div>
-          <div class="title-auto-box">
-            <div class="title-box margin_bottom_20">
-              <div class="title-item">
-                璁㈠崟缂栧彿锛歿{ taskData.Order.orderId || "" }}
-              </div>
-              <div class="title-item">
-                宸ュ崟缂栧彿锛歿{ taskData.Order.workOrderId || "" }}
-              </div>
-              <div class="title-item">
-                浜у搧鍚嶇О锛歿{ taskData.Order.productName || "" }}
-              </div>
-              <div class="title-item">
-                鏁伴噺锛歿{ taskData.Order.amount || 0 }}{{ taskData.Order.unit }}
-              </div>
-              <div class="title-item">
-                浜よ揣鏃ユ湡锛歿{ taskData.Order.deliverDate || "" }}
-              </div>
-              <div class="title-item">
-                宸ユ椂锛� {{ taskData.Procedure.procedure.workHours || "" }}
-              </div>
-              <div class="title-item">
-                璧锋鏃堕棿锛� {{ formatDate(taskData.Order.startTime) || "" }}
-                -
-                {{ formatDate(taskData.Order.endTime) }}
-              </div>
-              <div class="title-item">
-                瀹㈡埛鍚嶇О锛歿{ taskData.Order.customer || "" }}
-              </div>
-              <div class="title-item title-item-two">
-                璐х墿鎻忚堪锛� {{ taskData.Order.orderAttr || "" }}
-              </div>
+          <template v-if="messageError">
+            <div class="error-t">
+              <img src="../../public/error.png" />
+            </div>
+            <div class="error-m">
+              {{ messageError }}
+            </div>
+            <div
+              class="font_size_20 color_fff"
+              style="text-align: center; width: 100%; margin: 10px 0"
+            >
+              璇烽噸璇�
+            </div>
+          </template>
+          <template v-else>
+            <div class="title-auto-box">
+              <div class="title-box margin_bottom_20">
+                <div class="title-item">
+                  璁㈠崟缂栧彿锛歿{ taskData.Order.orderId || "" }}
+                </div>
+                <div class="title-item">
+                  宸ュ崟缂栧彿锛歿{ taskData.Order.workOrderId || "" }}
+                </div>
+                <div class="title-item">
+                  浜у搧鍚嶇О锛歿{ taskData.Order.productName || "" }}
+                </div>
+                <div class="title-item">
+                  鏁伴噺锛歿{ taskData.Order.amount || 0
+                  }}{{ taskData.Order.unit }}
+                </div>
+                <div class="title-item">
+                  浜よ揣鏃ユ湡锛歿{ taskData.Order.deliverDate || "" }}
+                </div>
+                <div class="title-item">
+                  宸ユ椂锛� {{ taskData.Procedure.procedure.workHours || "" }}
+                </div>
+                <div class="title-item">
+                  璧锋鏃堕棿锛� {{ formatDate(taskData.Order.startTime) || "" }}
+                  -
+                  {{ formatDate(taskData.Order.endTime) }}
+                </div>
+                <div class="title-item">
+                  瀹㈡埛鍚嶇О锛歿{ taskData.Order.customer || "" }}
+                </div>
+                <div class="title-item title-item-two">
+                  璐х墿鎻忚堪锛� {{ taskData.Order.orderAttr || "" }}
+                </div>
 
-              <div class="title-item title-item-two">
-                鍙傛暟瑕佹眰锛歿{ taskData.Order.parameter || "" }}
+                <div class="title-item title-item-two">
+                  鍙傛暟瑕佹眰锛歿{ taskData.Order.parameter || "" }}
+                </div>
+              </div>
+              <div class="title-box margin_bottom_20">
+                <div
+                  style="
+                    color: #fff;
+                    font-size: 18px;
+                    font-weight: 700;
+                    margin-bottom: 10px;
+                    margin-top: 20px;
+                  "
+                >
+                  宸ヨ壓鍙傛暟
+                </div>
+                <div
+                  class="title-item title-item-two"
+                  v-for="(item, index) in Arr"
+                  :key="index"
+                >
+                  {{ item.Key }}锛歿{ item.Value || "" }} 
+                  
+                </div>
               </div>
             </div>
-            <div class="title-box margin_bottom_20">
+            <div class="process-box" v-if="showBtn == 2 || showBtn == 3">
               <div
                 style="
-                  color: #fff;
-                  font-size: 18px;
+                  color: red;
+                  font-size: 16px;
+                  width: 100%;
+                  text-align: center;
                   font-weight: 700;
-                  margin-bottom: 10px;
-                  margin-top: 20px;
+                  margin-bottom: 20px;
+                  margin-top: 10px;
                 "
               >
-                宸ヨ壓鍙傛暟
+                {{ message }}
               </div>
-              <div
-                class="title-item title-item-two"
-                v-for="(item, index) in Arr"
-                :key="index"
-              >
-                {{ item.Key }}锛歿{ item.Value || "" }}
-              </div>
-            </div>
-          </div>
-          <div class="process-box"  v-if="showBtn==2||showBtn==3">
-            <div
-              style="
-                color: red;
-                font-size: 16px;
-                width: 100%;
-                text-align: center;
-                font-weight: 700;
-                margin-bottom: 20px;
-                margin-top: 10px;
-              "
-            >
-              璇风‘璁ょ敓浜у畨鍏紒
-            </div>
-            <div class="progress-item">
-              <span>{{ parseInt(num/60*100) }}%</span>
-            <el-progress
-             style="width:calc(100% - 50px);float:right"
+              <div class="progress-item">
+                <span>{{ parseInt((num / 60) * 100) }}%</span>
+                <el-progress
+                  style="width: calc(100% - 50px); float: right"
                   define-back-color="#CDC6C6"
                   color="#00cc66"
                   text-color="#fff"
                   :text-inside="true"
                   :stroke-width="20"
-                  :percentage="parseInt(num/60*100)"
+                  :percentage="parseInt((num / 60) * 100)"
                 ></el-progress>
-                </div>
-          </div>
+              </div>
+            </div>
+          </template>
+
           <!-- <div class="circel-text">
          <div class="circel-text-b">
           鐢熶骇鏁伴噺锛�<span>{{ Order.amount||0 }}</span>{{ Order.unit||'' }}
@@ -120,25 +139,45 @@
         </div>
       </div>
       <div slot="footer" class="dialog-footer tac" style="overflow: hidden">
-        <div class="btn" @click="closeClick">
-          <img src="../../public/btn1.png" />
-        </div>
-        <div class="btn" v-if="showBtn==1" @click="confirmClick1">
-          <img src="../../public/confirm3.png" />
-        </div>
-        <div class="btn" v-if="showBtn==2">
-          <img src="../../public/confirm2.png" />
-        </div>
-        <div class="btn" v-if="showBtn==3" @click="onSubmit()">
-          <img src="../../public/confirm1.png" />
-        </div>
+        <template v-if="messageError">
+          <div class="btn" style="margin-left: 220px" @click="confirmClick2">
+            <img src="../../public/confirm3.png" />
+          </div>
+        </template>
+        <template v-else>
+          <div class="btn" @click="closeClick">
+            <img src="../../public/btn1.png" />
+          </div>
+          <div class="btn" v-if="showBtn == 1" @click="confirmClick1">
+            <img src="../../public/confirm3.png" />
+          </div>
+          <div class="btn" v-if="showBtn == 2">
+            <img src="../../public/confirm2.png" />
+          </div>
+          <div
+            class="btn"
+            v-if="showBtn == 3"
+            v-prevent-re-click="3000"
+            @click="onSubmit()"
+          >
+            <i class="el-icon-loading icon-loading" v-if="isLoading"/>
+            <img src="../../public/confirm1.png" />
+          </div>
+         
+        </template>
       </div>
+      <!-- <ErrorIssue ref="error" :messageError="messageError" @shutdown="shutdown"/> -->
     </div>
   </el-dialog>
 </template>
 
 <script>
-import { startTask, setProductNumber,sendProcessParams } from "@/api/home/index"; // 浜х嚎
+import {
+  startTask,
+  setProductNumber,
+  sendProcessParams,
+} from "@/api/home/index"; // 浜х嚎
+// import ErrorIssue from "@/components/ErrorIssue";
 export default {
   components: {},
   props: {
@@ -163,10 +202,14 @@
   },
   data() {
     return {
-      islook: true,
-      showBtn:1,
-      num:0,
-      timer:null,
+      islook: false,
+      showBtn: 1,
+      num: 0,
+      timer: null,
+      message: "璇风‘璁ょ敓浜у畨鍏紒",
+      messageError: "",
+      resParams: {},
+      isLoading:false,
     };
   },
   mounted() {
@@ -176,35 +219,44 @@
     taskData(val) {
       this.getInfo();
     },
-    num(){
-      if(this.num==60){
-        clearInterval(this.timer)
-        this.showBtn=3;
+    num() {
+      if (this.num == 60) {
+        clearInterval(this.timer);
+        this.showBtn = 3;
       }
-    }
+    },
   },
   methods: {
-    confirmClick1(){
-      this.num=0;
-      this.showBtn=2;
-      this.timer=setInterval(()=>{
-       this.num=this.num+1;
-      },1000)
-      
+    confirmClick2() {
+      this.messageError = "";
     },
-    closeClick(){
-      if(this.timer){
-        clearInterval(this.timer)
+    confirmClick1() {
+      this.num = 0;
+      this.showBtn = 2;
+      (this.message = "璇风‘璁ょ敓浜у畨鍏紒"),
+        (this.timer = setInterval(() => {
+          this.num = this.num + 1;
+        }, 1000));
+    },
+    closeClick() {
+      if (this.timer) {
+        clearInterval(this.timer);
       }
-      this.num=0;
+      this.num = 0;
       this.shutdown();
     },
     getInfo() {
-      // if (Object.keys(this.taskData).length > 0 && this.taskData.Procedure.ID) {
-      //   this.islook=true
-      // }else{
-      //   this.islook=false;
-      // }
+      if (
+        Object.keys(this.taskData).length > 0 &&
+        this.taskData.Procedure.ID &&
+        this.taskData.Procedure.Status == 1
+      ) {
+        this.num = 0;
+        this.showBtn = 1;
+        this.islook = true;
+      } else {
+        this.islook = false;
+      }
     },
     getDateObj(date, fmt) {
       if (/(y+)/.test(fmt)) {
@@ -244,23 +296,61 @@
         return "";
       }
     },
+
     onSubmit() {
-      if(this.taskData.Procedure.ID){
-        sendProcessParams({id:this.taskData.Procedure.ID}).then(res=>{
-          if(res.code==200){
-            setProductNumber().then((res) => {
-              if (res.code == 200) {
-                this.$message.success("涓嬪彂鎴愬姛锛�");
-                // this.$message.success("涓嬪彂鐢熶骇鏁伴噺鎴愬姛锛�");
-                this.$emit("getSetProductNumber");
-                this.shutdown();
-              }
-            });
-          }
-        })
-     
-      }
       
+      if (this.taskData.Procedure.ID) {
+        (this.message = "鍙傛暟涓嬪彂涓�..."), (this.num = 0);
+        this.timer = setInterval(() => {
+          this.num = this.num + 1;
+          if (this.num == 60 || this.resParams) {
+            this.num = 60;
+            this.getCode(this.resParams);
+          }
+        }, 1000);
+        if(this.isLoading){
+          return true;
+        }
+        this.isLoading=true;
+          sendProcessParams({ id: this.taskData.Procedure.ID }).then((res) => {
+            console.log(res,'====res')
+            if (res.code == 200) {
+              setProductNumber().then((res) => {
+                this.resParams = res;
+                this.isLoading=false;
+              });
+            } else {
+              this.isLoading=false;
+              this.resParams = res;
+            }
+          });
+          setTimeout(()=>{
+            this.isLoading=false;
+          },30000)
+      }
+    },
+    getCode(res) {
+      if (res.code == 200) {
+        if (this.num == 60) {
+          this.messageError = "涓嬪彂鎴愬姛锛�";
+          clearInterval(this.timer);
+          // this.num = 60;
+          // this.showBtn = 2;
+          this.message = "璇风‘璁ょ敓浜у畨鍏紒";
+
+          this.num = 0;
+          this.showBtn= 1
+          this.shutdown();
+          this.$emit('getSetProductNumber')
+          // this.$message.success("涓嬪彂鐢熶骇鏁伴噺鎴愬姛锛�");
+        }
+      } else {
+        this.messageError = res.msg ? res.msg : "鎶辨瓑锛屽伐搴忎笅鍙戝け璐ワ紒";
+        clearInterval(this.timer);
+        this.num = 60;
+        this.showBtn = 2;
+        this.message = "璇风‘璁ょ敓浜у畨鍏紒";
+      }
     },
     shutdown() {
       this.islook = false;
@@ -284,6 +374,9 @@
 .color_4efefa {
   color: #4efefa !important;
 }
+.color_fff {
+  color: #fff;
+}
 .font_size_20 {
   font-size: 20px !important;
 }
@@ -305,6 +398,7 @@
       width: 55%;
     }
   }
+
   .title-bng {
     height: 42px;
     line-height: 42px;
@@ -320,6 +414,21 @@
     width: 100% !important;
   }
 }
+.error-t {
+  width: 120px;
+  margin: 50px auto 40px;
+  img {
+    width: 100%;
+    display: inline-block;
+  }
+}
+.error-m {
+  line-height: 35px;
+  font-size: 26px;
+  color: #fff;
+  margin-bottom: 20px;
+  text-align: center;
+}
 ::v-deep .el-dialog {
   background: transparent;
 }
@@ -334,8 +443,16 @@
   height: auto;
   float: left;
   display: inline-block;
+  position:relative;
   img {
     width: 100%;
+  }
+  .icon-loading{
+    font-size:19px;
+    color:#4efefa;
+    position:absolute;
+    line-height:2.7;
+    left:18%;
   }
   &:nth-of-type(1) {
     margin-right: 30px;
@@ -418,29 +535,29 @@
 }
 .dialog-content-box {
   height: calc(100% - 200px);
-  overflow: hidden;
+  // overflow: hidden;
   padding: 50px 20px 20px;
   .el-form {
     overflow: hidden;
   }
   .title-auto-box {
-    height: calc(100% - 130px);
+    height: calc(100% - 150px);
     overflow: auto;
   }
-  .progress-item{
-    width:55%;
-    padding:2px 8px;
-    height:20px;
-    background:#fff;
-    border-radius:30px;
-    margin:0 auto;
-    border:2px solid rgba(255,255,255,0.5);
-    box-shadow: 1px 5px 5px rgba(255,255,255,0.5);
-    span{
-      float:left;
+  .progress-item {
+    width: 55%;
+    padding: 2px 8px;
+    height: 20px;
+    background: #fff;
+    border-radius: 30px;
+    margin: 0 auto;
+    border: 2px solid rgba(255, 255, 255, 0.5);
+    box-shadow: 1px 5px 5px rgba(255, 255, 255, 0.5);
+    span {
+      float: left;
       font-weight: 700;
-      color:#333;
-      font-size:15px;
+      color: #333;
+      font-size: 15px;
     }
   }
 }

--
Gitblit v1.8.0