From d77b6353ca9b59a6398df3eae9912f9fd766946d Mon Sep 17 00:00:00 2001
From: zhangzhengmei <zhangzhengmei@prec-tech.com>
Date: 星期六, 05 八月 2023 17:04:22 +0800
Subject: [PATCH] fix: lightning 页面确认

---
 force-app/main/default/lwc/lexTaskLoseBid/lexTaskLoseBid.js |   75 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/lwc/lexTaskLoseBid/lexTaskLoseBid.js b/force-app/main/default/lwc/lexTaskLoseBid/lexTaskLoseBid.js
new file mode 100644
index 0000000..ae14d5d
--- /dev/null
+++ b/force-app/main/default/lwc/lexTaskLoseBid/lexTaskLoseBid.js
@@ -0,0 +1,75 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import  init  from '@salesforce/apex/OppLoseController.init';
+import  taskLoseBid  from '@salesforce/apex/OppLoseController.taskLoseBid';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { updateRecord } from 'lightning/uiRecordApi';
+import LightningConfirm from 'lightning/confirm';
+export default class lexTaskOLYwinBid extends LightningElement {
+    @api recordId;
+    taskStatus;//浠诲姟 鐘舵��
+    OpportunityId;//浠诲姟 ID
+    IsLoading = true;
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference){
+        if(currentPageReference){
+            const urlValue=currentPageReference.state.recordId;
+            if(urlValue){
+                let str=`${urlValue}`;
+                this.recordId=str;
+            }
+        }
+    }
+    connectedCallback(){
+        init({
+            taskId: this.recordId
+        }).then(result => {
+            this.IsLoading = false;
+            console.log(result.OpportunityId,result.taskStatus);
+            this.OpportunityId = result.OpportunityId;
+            this.taskStatus = result.taskStatus;
+            this.taskLoseBid();
+        })      
+    }
+
+    taskLoseBid(){
+        if(this.taskStatus == '04 鍙栨秷'){
+            this.showToast('浠诲姟鍙栨秷锛屼笉鍙搷浣�',"error");
+        }else{
+            LightningConfirm.open({
+                message: '鏄惁纭绔炰簤瀵规墜涓爣锛�',
+                variant: 'headerless',
+                label: 'this is the aria-label value',
+                }).then(res=>{
+                    if(res) {
+                        taskLoseBid({recordId:this.OpportunityId}).then(requst=>{
+                            if(requst == '1'){
+                                this.showToast("鎿嶄綔鎴愬姛锛�","success");
+                                this.updateRecordView();
+                                this.dispatchEvent(new CloseActionScreenEvent());
+                            }
+                            if(requst != "1"){
+                                this.showToast(requst,"error");
+                            }
+                        })
+                    }else{
+                        this.dispatchEvent(new CloseActionScreenEvent());
+                        this.updateRecordView(this.recordId);
+                        return;
+                    }                 
+                });
+        }
+    }
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+    updateRecordView() {
+        updateRecord({fields: { Id: this.OpportunityId }});
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1