From f1bb6af7ec8ea81ba1b40eef0dabeeef3eee4bbb Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 12 四月 2024 11:48:56 +0800
Subject: [PATCH] 123

---
 force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js |   88 +++++++++++++++++++-------------------------
 1 files changed, 38 insertions(+), 50 deletions(-)

diff --git a/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js b/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js
index 82f0cd4..5bd9188 100644
--- a/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js
+++ b/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js
@@ -14,6 +14,10 @@
 import updateFirstContract from '@salesforce/apex/updateFirstServiceContractWebService.updateFirstContract';
 import Check_plan from '@salesforce/apex/MaintenanceContractWebService.Check_plan';
 import up2sap from '@salesforce/apex/MaintenanceContractWebService.up2sap';
+import {
+    ShowToastEvent
+} from 'lightning/platformShowToastEvent';
+
 export default class LexUploadToSap extends LightningElement {
     @api recordId;
     str;
@@ -67,101 +71,85 @@
         });
     }
 
+    // 涓婁紶SAP
     uploadToSap() {
         if (this.MCApprovalStatusC != 'Pass') {
-            alert("鍚堝悓澶嶆牳鎵瑰噯鍚庢墠鍙互涓婁紶SAP銆�");
+            this.ShowToastEvent("鍚堝悓澶嶆牳鎵瑰噯鍚庢墠鍙互涓婁紶SAP銆�", "error")
+            // alert("鍚堝悓澶嶆牳鎵瑰噯鍚庢墠鍙互涓婁紶SAP銆�");
         } else if (this.MaintenanceContractNoC == undefined) {
-            alert('缁翠慨鍚堝悓绠$悊缂栫爜涓虹┖锛屼笉鑳戒笂浼燬AP銆�');
+            this.ShowToastEvent('缁翠慨鍚堝悓绠$悊缂栫爜涓虹┖锛屼笉鑳戒笂浼燬AP銆�', "error")
+            // alert('缁翠慨鍚堝悓绠$悊缂栫爜涓虹┖锛屼笉鑳戒笂浼燬AP銆�');
         } else if (this.uploadToSapTimeC != undefined) {
-            alert('宸茬粡涓婁紶SAP锛屼笉鑳介噸澶嶄笂浼犮��');
+            this.ShowToastEvent('宸茬粡涓婁紶SAP锛屼笉鑳介噸澶嶄笂浼犮��', "error")
+            // alert('宸茬粡涓婁紶SAP锛屼笉鑳介噸澶嶄笂浼犮��');
         } else {
-            //update wangweipeng 2021/11/20 start
-            //鍒ゆ柇鏄惁闇�瑕佸厛涓婁紶璁ゆ鍚堝悓鍚楋紝濡傛灉闇�瑕侀偅涔堝垽鏂粬鏄惁宸茬粡涓婁紶锛屽鏋滀笂浼狅紝閭d箞鍒ゆ柇浠栨槸鍚﹀畬鎴愯娆撅紝濡傛灉閮芥弧瓒筹紝閭d箞鎵嶈兘姝e父璧版帴鍙d笂浼燬AP
-            //鍒ゆ柇鏄娆惧悎鍚屽悧
             if (this.oldIsRecognitionModelC) {
-                //鍒ゆ柇鏄惁宸茬粡涓婁紶璁ゆ鍚堝悓
                 if (this.uploadToRMTimeC == undefined) {
-                    console.log("a");
-                    alert('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘涓婁紶SAP銆�');
+                    this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘涓婁紶SAP銆�', "error")
+                    // alert('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘涓婁紶SAP銆�');
                     return;
                 } else {
-                    //鍒ゆ柇鏄惁瀹屾垚璁ゆ
                     if (!this.IsRecognitionModelTrueC) {
-                        console.log("b");
-                        alert('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳戒笂浼燬AP銆�');
+                        this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳戒笂浼燬AP銆�', "error")
+                        // alert('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳戒笂浼燬AP銆�');
                         return;
                     }
                 }
             }
-            //update wangweipeng 2021/11/20 end
-            // sforce.connection.sessionId = this.api.sessionId;
-            // var mcid = this.Id;
-            // var result = sforce.apex.execute("MaintenanceContractSetColunmWebService", "updateColunm", {
-            //     mcid: mcid
-            // });
             updateColunm({
                 mcid: this.Id
-            }).then(result=>{
-                console.log("updateColunm" + result);
+            }).then(result => {
                 if (result != '1') {
-                    console.log("c");
-                    alert('涓婁紶SAP澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触');
-                    //location.href = "/" + this.Id;
+                    this.ShowToastEvent('涓婁紶SAP澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触', "error")
+                    // alert('涓婁紶SAP澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触');
                 }
             });
-            
-            //棣栨鏈嶅姟鍚堝悓璧嬪��
-            // var updateResult = sforce.apex.execute("updateFirstServiceContractWebService", "updateFirstContract", {
-            //     mcid: mcid
-            // });
             updateFirstContract({
                 mcid: this.Id
-            }).then(result=>{
-                console.log("updateFirstContract:" + result);
+            }).then(result => {
                 if (result != '1') {
-                    alert(result);
+                    this.ShowToastEvent(result, "error")
+                    // alert(result);
                 }
             });
-            
-            //URF闄愭鍚堝悓2鏈� LY 20220811 start
             this.urfFlag = this.URFContractFC;
             this.rtn1 = '1';
             this.rtn = '1';
             if (this.urfFlag == 'false') {
-                // rtn1 = sforce.apex.execute("MaintenanceContractWebService", "Check_plan", {
-                //     mcidList: mcid
-                // });
                 Check_plan({
                     mcidList: this.Id
-                }).then(result=>{
-                    console.log("Check_plan:" + result);
+                }).then(result => {
                     this.rtn1 = result;
                 });
             }
-            console.log("rtn1" + this.rtn1);
-            //URF闄愭鍚堝悓2鏈� LY 20220811 end
             if (this.rtn1 == '1') {
-                // var rtn = sforce.apex.execute("MaintenanceContractWebService", "up2sap", {
-                //     mcid: mcid
-                // });
                 up2sap({
                     mcid: this.Id
-                }).then(result=>{
-                    console.log("up2sap:" + result);
+                }).then(result => {
                     this.rtn = result;
                 });
-                console.log("rtn" + this.rtn);
                 if (this.rtn == '1') {
-                    alert("涓婁紶SAP鎴愬姛");
+                    this.ShowToastEvent("涓婁紶SAP鎴愬姛", "success")
+                    // alert("涓婁紶SAP鎴愬姛");
                     window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Maintenance_Contract__c/" + this.recordId + "/view");
-                    //window.location.href = "/" + this.Id;
                 } else {
-                    alert(this.rtn);
+                    this.ShowToastEvent(this.rtn, "error")
+                    // alert(this.rtn);
                 }
             } else {
-                alert(this.rtn1);
+                this.ShowToastEvent(this.rtn1, "error")
+                // alert(this.rtn1);
             }
         }
     }
 
+    // 寮圭獥
+    ShowToastEvent(msg, type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1