From 482efd9ee971fe7d799a015dc288340c85b8805c Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 29 九月 2022 11:24:17 +0800
Subject: [PATCH] 1.新增  提交类按钮只能提交一次的控制2.关联类的按钮  接口返回成功后显示对话框

---
 src/views/zzmx/chda.vue |  110 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 72 insertions(+), 38 deletions(-)

diff --git a/src/views/zzmx/chda.vue b/src/views/zzmx/chda.vue
index 19a17ce..a77a8cd 100644
--- a/src/views/zzmx/chda.vue
+++ b/src/views/zzmx/chda.vue
@@ -161,6 +161,7 @@
             prop="partspec"
             label="鐗╂枡瑙勬牸"
             width="110"
+            show-tooltip-when-overflow
             sortable="custom"
           >
             <template slot-scope="{row}">
@@ -372,7 +373,12 @@
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button @click="dialogVisibleCancel">鍙� 娑�</el-button>
-          <el-button type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+          <el-button
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="dialogVisibleConfirm"
+          >纭� 瀹�</el-button>
         </div>
       </span>
     </el-dialog>
@@ -606,7 +612,12 @@
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button @click="routeDialogVisibleCancel">鍙� 娑�</el-button>
-          <el-button type="primary" @click="routeDialogVisibleConfirm">纭� 瀹�</el-button>
+          <el-button
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="routeDialogVisibleConfirm"
+          >纭� 瀹�</el-button>
         </div>
       </span>
     </el-dialog>
@@ -953,6 +964,7 @@
 
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
+          this.$store.state.app.buttonIsDisabled = true
           const data = {
             id: this.dialogForm.id,
             materialcode: this.dialogForm.materialcode,
@@ -968,9 +980,10 @@
           }
           AddUpdateInventoryFile(data).then(res => {
             if (res.code === '200') {
-              this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.dialogVisible = false
+              this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.getInventoryFileSelect()
+              this.$store.state.app.buttonIsDisabled = false
             } else {
               this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
             }
@@ -992,46 +1005,60 @@
     },
     /* 鐐瑰嚮鍏宠仈宸ヨ壓璺嚎妯″潡*/
     // 宸ヨ壓璺嚎鐐瑰嚮
-    async routeClick(row) {
-      console.log(row)
+    routeClick(row) {
+      const loading = this.$loading({
+        lock: true,
+        text: '姝e湪鍔犺浇鏁版嵁锛岃绋嶇瓑...',
+        spinner: 'el-icon-loading',
+        customClass: 'osloading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+
       this.defaultroute_code = row.default_route
       this.dialogFormRoute.projectCode = row.partcode
       this.dialogFormRoute.projectName = row.partname
-      this.dialogVisibleRoute = true
-      const { data: res } = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
-      this.dialogFormRoute.routeOperationArr = res
-      // let waitFlag = false// 鍥炴樉绛夊緟鏄惁鏀捐
 
-      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
-        item.isSelected1 = false
-        item.isSelected2 = false
-        if (index === 0) {
-          item.isSelected1 = true
-          this.projectTableData = item.Data
-        }
-        if (item.flag === 'Y') {
-          item.isSelected2 = true
-          this.$nextTick(() => {
-            $('input:checkbox').eq(index).prop('checked', true)
-          })
+      InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode }).then(res => {
+        if (res.code === '200') {
+          setTimeout(() => {
+            loading.close()
+            this.dialogVisibleRoute = true
+            this.dialogFormRoute.routeOperationArr = res.data
+            // let waitFlag = false// 鍥炴樉绛夊緟鏄惁鏀捐
 
-          // const interval = setInterval(() => {
-          //   if ($('input:checkbox').length > 0) {
-          //     waitFlag = true
-          //   }
-          //   if (waitFlag) {
-          //     clearInterval(interval)
-          //     this.$nextTick(() => {
-          //       $('input:checkbox').eq(index).prop('checked', true)
-          //     })
-          //   }
-          // }, 100)
+            this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
+              item.isSelected1 = false
+              item.isSelected2 = false
+              if (index === 0) {
+                item.isSelected1 = true
+                this.projectTableData = item.Data
+              }
+              if (item.flag === 'Y') {
+                item.isSelected2 = true
+                this.$nextTick(() => {
+                  $('input:checkbox').eq(index).prop('checked', true)
+                })
+
+                // const interval = setInterval(() => {
+                //   if ($('input:checkbox').length > 0) {
+                //     waitFlag = true
+                //   }
+                //   if (waitFlag) {
+                //     clearInterval(interval)
+                //     this.$nextTick(() => {
+                //       $('input:checkbox').eq(index).prop('checked', true)
+                //     })
+                //   }
+                // }, 100)
+              }
+            })
+
+            this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
+          }, 1000)
+        } else {
+          loading.close()
         }
       })
-
-      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
-
-      console.log(this.defaultroute_codeArr, 123)
     },
     // 瀵硅瘽妗嗗叧闂�
     handleCloseRoute() {
@@ -1056,12 +1083,13 @@
           data.push({ code: item.code, name: item.name })
         }
       })
-
+      this.$store.state.app.buttonIsDisabled = true
       const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
       if (res.code === '200') {
+        this.dialogVisibleRoute = false
         this.$message.success('淇濆瓨鎴愬姛锛�')
         await this.getInventoryFileSelect()
-        this.dialogVisibleRoute = false
+        this.$store.state.app.buttonIsDisabled = false
       }
     },
     // 澶х洅瀛愮偣鍑讳簨浠�
@@ -1374,7 +1402,13 @@
 }
 </style>
 <style>
+.osloading{
+  font-size: 26px !important;
+}
 
+.el-loading-text{
+  font-size: 26px !important;
+}
 .el-table .custom-row {
   background: #f8f8fa;
 }

--
Gitblit v1.9.3