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/lexCancelReport/lexCancelReport.js |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js
index 7deae00..7adca35 100644
--- a/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js
+++ b/force-app/main/default/lwc/lexCancelReport/lexCancelReport.js
@@ -7,7 +7,9 @@
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 import { NavigationMixin } from 'lightning/navigation';
 import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
-import ConSent from '@salesforce/apex/BidAnnouncementController.ConSent';
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
+import queryCancelReport  from '@salesforce/apex/OpportunityLightingButtonController.queryCancelReport';
 export default class LexCancelReport extends NavigationMixin(LightningElement) {
     @api recordId;
     stageName;
@@ -24,6 +26,7 @@
     salesOwnerBuchang;
     salesOwnerBuchangID;
     recordTypeId;
+    haveLostReport;
     IsLoading = true;
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -41,6 +44,10 @@
         }
     }
     connectedCallback(){
+        Promise.all([
+            loadStyle(this, lwcCSS)
+           ]);
+           
         init({
             recordId: this.recordId
         }).then(result=>{
@@ -59,20 +66,35 @@
             this.salesOwnerBuchang = result.salesOwnerBuchang == undefined ? '' : result.salesOwnerBuchang;
             this.salesOwnerBuchangID = result.salesOwnerBuchangID == undefined ? '' : result.salesOwnerBuchangID;
             this.recordTypeId = result.recordTypeId;
-            this.cancelReport();
+            queryCancelReport({
+                recordId: this.recordId
+            }).then(result=>{
+                this.haveLostReport = result;
+                this.cancelReport();
+            });
+            
         }).catch(error=>{
             console.log("error");
             console.log(error);
         });
     }
     showToast(msg,type) {
-        const event = new ShowToastEvent({
-            title: ' ',
-            message: msg,
-            variant: type,
-            mode: 'sticky'
-        });
-        this.dispatchEvent(event);
+        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 }});
@@ -95,7 +117,7 @@
             else if (this.sapSendOK == '1') {
                 this.showToast("宸茬粡涓婁紶SAP銆佷笉鑳藉仛 鍙栨秷 浜嗭紒","error");
             }
-            else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
+            else if (this.haveLostReport) {
                 this.showToast("璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒","error");
             }
             else if (this.jobCategory == '鏀彺') {

--
Gitblit v1.9.1