From 35910c355f74e736e2068a0ffb7f39ae9615d8e1 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 24 五月 2024 16:29:00 +0800
Subject: [PATCH] 1

---
 force-app/main/default/lwc/lexCancel/lexCancel.js |   69 ++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/lwc/lexCancel/lexCancel.js b/force-app/main/default/lwc/lexCancel/lexCancel.js
index d98fdef..be1d3d5 100644
--- a/force-app/main/default/lwc/lexCancel/lexCancel.js
+++ b/force-app/main/default/lwc/lexCancel/lexCancel.js
@@ -1,3 +1,11 @@
+/*
+ * @Description: 
+ * @version: 
+ * @Author: chen jing wu
+ * @Date: 2023-03-27 13:47:21
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-10-10 17:31:25
+ */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
@@ -9,7 +17,23 @@
     @api recordId;
     status;
     IsLoading = true;
-   
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+            console.log(111);
+            console.log(currentPageReference);
+
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            console.log("str");
+            console.log(str);
+            this.recordId = str;
+          }
+        }
+    }
+
+
 
     connectedCallback(){
         console.log(this.recordId);
@@ -18,28 +42,34 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.status = result.status;
                 console.log(this.status);
                 this.cancel();
-
             }
         }).catch(error => {
             console.log("error");
             console.log(error);
-        }).finally(() => {
-            
         });
 
     }
 
     showToast(msg,type) {
-        const event = new ShowToastEvent({
-            title: '',
-            message: msg,
-            variant: type
-        });
-        this.dispatchEvent(event);
+        if(type == 'success'){
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type
+            });  
+            this.dispatchEvent(event);
+        }else{
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+                mode: 'sticky'
+            });
+            this.dispatchEvent(event);
+        }
+        
+        
     }
 
 
@@ -49,30 +79,35 @@
 
     cancel () {
         if (this.status == "鍙栨秷") {
-            ShowToastEvent("宸茬粡鍙栨秷锛�","error");
+            this.showToast("宸茬粡鍙栨秷锛�","error");
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
             }
         if (this.status == "鎵瑰噯") {
-            ShowToastEvent("宸茬粡鎵瑰噯锛屼笉鑳藉垹闄わ紒","error");
+            this.showToast("宸茬粡鎵瑰噯锛屼笉鑳藉垹闄わ紒","error");
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
         if (this.status == "瀹屾瘯") {
-            ShowToastEvent("宸茬粡瀹屾瘯锛屼笉鑳藉垹闄わ紒","error");
+            this.showToast("宸茬粡瀹屾瘯锛屼笉鑳藉垹闄わ紒","error");
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
         if (this.status == "鎻愪氦") {
-            ShowToastEvent("宸茬粡鎻愪氦锛屼笉鑳藉垹闄わ紒","error");
+            this.showToast("宸茬粡鎻愪氦锛屼笉鑳藉垹闄わ紒","error");
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
         updateForCancelButton({
             recordId: this.recordId
         }).then(result =>{
-            this.showToast("鍙栨秷鎴愬姛锛�","success");
-            this.updateRecordView(this.recordId);
+            if(result){
+                this.showToast(result,"error");
+            }else{
+                this.showToast("鍙栨秷鎴愬姛锛�","success");
+                this.updateRecordView(this.recordId);
+            }
+            this.IsLoading = false;
             this.dispatchEvent(new CloseActionScreenEvent());
         });
     }

--
Gitblit v1.9.1