From 1bc3f32b126277b5349564485665b462bb760354 Mon Sep 17 00:00:00 2001
From: zhangchunxu <1842059105@qq.com>
Date: 星期五, 04 八月 2023 13:21:26 +0800
Subject: [PATCH] 修改 招标项目 失单

---
 force-app/main/default/lwc/lexUploadToRecognitionModel/lexUploadToRecognitionModel.js |   95 +++++++++++++++++++++++++++++++----------------
 1 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/force-app/main/default/lwc/lexUploadToRecognitionModel/lexUploadToRecognitionModel.js b/force-app/main/default/lwc/lexUploadToRecognitionModel/lexUploadToRecognitionModel.js
index 987e871..9025162 100644
--- a/force-app/main/default/lwc/lexUploadToRecognitionModel/lexUploadToRecognitionModel.js
+++ b/force-app/main/default/lwc/lexUploadToRecognitionModel/lexUploadToRecognitionModel.js
@@ -12,7 +12,10 @@
 import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
 import updateColunm from '@salesforce/apex/MaintenanceContractSetColunmWebService.updateColunm';
 import up2sap from '@salesforce/apex/MaintenanceContractWebService.up2sap';
-import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import {
+    ShowToastEvent
+} from 'lightning/platformShowToastEvent';
+import LightningConfirm from 'lightning/confirm';
 
 export default class LexUploadToRecognitionModel extends LightningElement {
     @api recordId;
@@ -54,54 +57,68 @@
                 this.PaymentPlanSumFirstC = result.PaymentPlanSumFirstC;
 
                 this.uploadToRecognitionModel();
-                this.dispatchEvent(new CloseActionScreenEvent());
             }
         }).catch(error => {
             console.log(error);
-        }).finally(() => {
-
-        });
+        })
     }
 
     // 涓婁紶璁ゆ鍚堝悓
     uploadToRecognitionModel() {
         if (this.ContractQuotationOrNotC == '杩樻病鍋氭姤浠�') {
-            this.ShowToastEvent("鎮ㄨ繕娌℃湁鍋氬悎鍚屾姤浠凤紝涓嶈兘涓婁紶璁ゆ鍚堝悓銆�", "error") 
+            this.ShowToastEvent("鎮ㄨ繕娌℃湁鍋氬悎鍚屾姤浠凤紝涓嶈兘涓婁紶璁ゆ鍚堝悓銆�", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
         } else if (this.MaintenanceContractNoC == undefined) {
-            this.ShowToastEvent('鍚堝悓鍙风爜涓虹┖锛屼笉鑳戒笂浼犺娆惧悎鍚屻��', "error") 
+            this.ShowToastEvent('鍚堝悓鍙风爜涓虹┖锛屼笉鑳戒笂浼犺娆惧悎鍚屻��', "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
         } else if (this.uploadToSapTimeC != undefined) {
-            this.ShowToastEvent('宸茬粡涓婁紶SAP锛屼笉鑳藉啀娆′笂浼犺娆惧悎鍚屻��', "error") 
+            this.ShowToastEvent('宸茬粡涓婁紶SAP锛屼笉鑳藉啀娆′笂浼犺娆惧悎鍚屻��', "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
         } else if (this.uploadToRMTimeC != undefined) {
-            this.ShowToastEvent('宸茬粡涓婁紶璁ゆ鍚堝悓锛屼笉鑳藉啀娆′笂浼犺娆惧悎鍚屻��', "error") 
+            this.ShowToastEvent('宸茬粡涓婁紶璁ゆ鍚堝悓锛屼笉鑳藉啀娆′笂浼犺娆惧悎鍚屻��', "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
         } else {
             if (!this.oldIsRecognitionModelC) {
-                this.ShowToastEvent('缁忛攢鍟嗕负绌烘垨缁忛攢鍟嗕笉鏄厛娆惧璞★紝涓嶉渶瑕佷笂浼犺娆惧悎鍚屻��', "error") 
+                this.ShowToastEvent('缁忛攢鍟嗕负绌烘垨缁忛攢鍟嗕笉鏄厛娆惧璞★紝涓嶉渶瑕佷笂浼犺娆惧悎鍚屻��', "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
             } else if (this.PaymentPlanSumFirstC == undefined) {
-                this.ShowToastEvent('绗竴娆¤鍒掍粯娆鹃噾棰濅笉鑳戒负绌恒��', "error") 
+                this.ShowToastEvent('绗竴娆¤鍒掍粯娆鹃噾棰濅笉鑳戒负绌恒��', "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
             } else {
-                if (!confirm('璇风‘璁ゆ槸鍚﹁涓婁紶璁ゆ鍚堝悓銆�')) {
-                    return;
-                }
-                updateColunm({
-                    mcid: this.Id
-                }).then(result => {
-                    if (result != '1') {
-                        alert('涓婁紶璁ゆ鍚堝悓澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触') 
-                        location.href = "/" + this.Id;
-                    }
-                })
-                up2sap({
-                    mcid: this.Id
-                }).then(rtn => {
-                    if (rtn == '1') {
-                        alert("涓婁紶璁ゆ鍚堝悓鎴愬姛") 
-                        location.href = "/" + this.Id;
-                    } else {
-                        alert(rtn) 
-                    }
-                })
+                this.handleConfirmClick('璇风‘璁ゆ槸鍚﹁涓婁紶璁ゆ鍚堝悓銆�');
             }
         }
+    }
+
+    ll() {
+        updateColunm({
+            mcid: this.Id
+        }).then(result => {
+            if (result != '1') {
+                this.ShowToastEvent('涓婁紶璁ゆ鍚堝悓澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触', "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                window.reload();
+            }
+        })
+        up2sap({
+            mcid: this.Id
+        }).then(rtn => {
+            if (rtn == '1') {
+                this.ShowToastEvent("涓婁紶璁ゆ鍚堝悓鎴愬姛", "success");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                window.reload();
+            } else {
+                this.ShowToastEvent(rtn, "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
+            }
+        })
     }
 
     // 寮圭獥
@@ -113,4 +130,18 @@
         });
         this.dispatchEvent(event);
     }
+
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value'
+        });
+
+        if (result) {
+            this.ll();
+        } else {
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1