From 63f4c248149d330215d2da44d3f9de08fdb3c0ef Mon Sep 17 00:00:00 2001
From: zhangchunxu <1842059105@qq.com>
Date: 星期五, 14 七月 2023 10:24:52 +0800
Subject: [PATCH] “营业管理自定义”左侧栏和”新建意向“vf跳转

---
 force-app/main/default/lwc/lexPreContractSubmit/lexPreContractSubmit.js |   77 +++++++++++++++++++++++++-------------
 1 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/force-app/main/default/lwc/lexPreContractSubmit/lexPreContractSubmit.js b/force-app/main/default/lwc/lexPreContractSubmit/lexPreContractSubmit.js
index ed6e02c..c441754 100644
--- a/force-app/main/default/lwc/lexPreContractSubmit/lexPreContractSubmit.js
+++ b/force-app/main/default/lwc/lexPreContractSubmit/lexPreContractSubmit.js
@@ -11,6 +11,11 @@
 } from 'lightning/actions';
 import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
 import processResults from '@salesforce/apex/otherButtonMaintenanceContractCtl.processResults';
+import {
+    ShowToastEvent
+} from 'lightning/platformShowToastEvent';
+import LightningConfirm from 'lightning/confirm';
+
 
 export default class LexPreContractSubmit extends LightningElement {
     @api recordId;
@@ -41,7 +46,6 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.oldIsRecognitionModelC = result.oldIsRecognitionModelC;
                 this.uploadToRMTimeC = result.uploadToRMTimeC;
                 this.IsRecognitionModelTrueC = result.IsRecognitionModelTrueC;
@@ -50,53 +54,72 @@
                 this.Id = result.Id;
 
                 this.preContractSubmit();
-                this.dispatchEvent(new CloseActionScreenEvent());
             }
         }).catch(error => {
             console.log(error);
-        }).finally(() => {
-
-        });
+        })
     }
 
+    // 鍚堝悓澶嶆牳
     preContractSubmit() {
-        //update wangweipeng 2022/01/04 start
-        //鍒ゆ柇鏄惁闇�瑕佸厛涓婁紶璁ゆ鍚堝悓鍚楋紝濡傛灉闇�瑕侀偅涔堝垽鏂粬鏄惁宸茬粡涓婁紶锛屽鏋滀笂浼狅紝閭d箞鍒ゆ柇浠栨槸鍚﹀畬鎴愯娆撅紝濡傛灉閮芥弧瓒筹紝閭d箞鎵嶈兘姝e父璧版帴鍙d笂浼燬AP
-        //鍒ゆ柇鏄娆惧悎鍚屽悧
         if (this.oldIsRecognitionModelC) {
-            if (this.uploadToRMTimeC == null) { //鍒ゆ柇鏄惁宸茬粡涓婁紶璁ゆ鍚堝悓
-                alert('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘澶嶆牳銆�');
+            if (this.uploadToRMTimeC == null) {
+                this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘澶嶆牳銆�', "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             } else {
-                //鍒ゆ柇鏄惁瀹屾垚璁ゆ
                 if (!this.IsRecognitionModelTrueC) {
-                    alert('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳借繘琛屽鏍搞��');
+                    this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳借繘琛屽鏍搞��', "error");
+                    this.dispatchEvent(new CloseActionScreenEvent());
                     return;
                 }
             }
         }
-        //update wangweipeng 2022/01/04 end
         var status = this.MCApprovalStatusC;
         if (status != 'Draft' && status != 'Reject' && status != undefined) {
-            alert('澶嶆牳宸茬粡鎻愪氦锛岃纭鐘舵�併��');
+            this.ShowToastEvent('澶嶆牳宸茬粡鎻愪氦锛岃纭鐘舵�併��', "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
         var con_no = this.ContractprintCompletedC;
-        if (con_no == '') {
-            alert('鍚堝悓鐩栫珷瀹屾瘯涓虹┖锛屼笉鑳芥彁浜ゅ悎鍚屽鏍哥敵璇枫��');
+        if (con_no == undefined) {
+            this.ShowToastEvent('鍚堝悓鐩栫珷瀹屾瘯涓虹┖锛屼笉鑳芥彁浜ゅ悎鍚屽鏍哥敵璇枫��', "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
-        if (!confirm("涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵")) {
-            return;
+        this.handleConfirmClick("涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵");
+    }
+
+    // 寮圭獥
+    ShowToastEvent(msg, type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+    }
+
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value'
+        });
+
+        if (result) {
+            processResults({
+                recordId: this.Id
+            }).catch(error => {
+                if (error.body.pageErrors[0] != null) {
+                    var errmsg = error.body.pageErrors[0].message.toString();
+                    this.ShowToastEvent(errmsg, "error");
+                    this.dispatchEvent(new CloseActionScreenEvent());
+                    return;
+                }
+            })
+        } else {
+            this.dispatchEvent(new CloseActionScreenEvent());
         }
-        processResults({
-            recordId: this.recordId
-        }).catch(error => {
-            if (error.body.pageErrors[0] != null) {
-                var errmsg = error.body.pageErrors[0].message.toString();
-                alert(errmsg + '_sys');
-                return;
-            }
-        })
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1