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

---
 force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js |   76 +++++++++++++++++++++++++++-----------
 1 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js b/force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js
index 3aa9239..f3de97b 100644
--- a/force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js
+++ b/force-app/main/default/lwc/lexOLYwinBid/lexOLYwinBid.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-04-13 13:15:52
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-13 13:37:19
+ * @LastEditTime: 2023-10-10 17:38:20
  */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -14,10 +14,13 @@
 import init  from '@salesforce/apex/OpportunityLightingButtonController.initForOLYwinBidButton';
 import updateForOLYwinBidButton  from '@salesforce/apex/OpportunityLightingButtonController.updateForOLYwinBidButton';
 import queryForOLYwinBidButton  from '@salesforce/apex/OpportunityLightingButtonController.queryForOLYwinBidButton';
+import LightningConfirm from 'lightning/confirm';
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
 export default class LexOLYwinBid extends LightningElement {
     @api recordId;
     ifOpenBid;
-    IsLoading = true;
+    IsLoading;
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
@@ -33,7 +36,39 @@
           }
         }
     }
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value',
+        });
+        this.IsLoading = true;
+        console.log(result);
+        if(result){
+            try {
+                updateForOLYwinBidButton({
+                    recordId: this.recordId
+                }).then(result=>{
+                    if (result) {
+                        this.showToast(result,"error");
+                    }else{
+                        this.IsLoading = false;
+                        this.updateRecordView(this.recordId);
+                        this.showToast("鎿嶄綔鎴愬姛锛�","success");
+                    }
+                    this.dispatchEvent(new CloseActionScreenEvent());
+                });  
+                } catch(e) {
+                   console.log(e); 
+                }
+        }else{
+            this.dispatchEvent(new CloseActionScreenEvent()); 
+        }
+    }
     connectedCallback(){
+        Promise.all([
+            loadStyle(this, lwcCSS)
+           ]);
         init({
             recordId: this.recordId
         }).then(result=>{
@@ -66,30 +101,27 @@
             if(flag){
                 this.showToast("鏉′欢涓嶇鍚堬紝涓嶅彲鎿嶄綔","error");
             }else{
-                if (window.confirm('鏄惁纭OLY涓爣锛�')) {
-                    updateForOLYwinBidButton({
-                        recordId: this.recordId
-                    }).then(result=>{
-                        if (result) {
-                            this.showToast(result,"error");
-                        }else{
-                            this.IsLoading = false;
-                            this.updateRecordView(this.recordId);
-                            this.showToast("鎿嶄綔鎴愬姛锛�","success");
-                        }
-                    })  
-                }
+                this.handleConfirmClick('鏄惁纭OLY涓爣锛�');
             }
         });    
     }
     showToast(msg,type) {
-        const event = new ShowToastEvent({
-            title: '',
-            message: msg,
-            variant: type
-        });
-        this.dispatchEvent(event);
-        this.dispatchEvent(new CloseActionScreenEvent());
+        if(type == 'success'){
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+            });
+            this.dispatchEvent(event);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }else{
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+                mode: 'sticky'
+            });
+            this.dispatchEvent(event);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }   
     }
     updateRecordView(recordId) {
         updateRecord({fields: { Id: recordId }});

--
Gitblit v1.9.1