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/lexOPDReport/lexOPDReport.js |   67 ++++++++++++++-------------------
 1 files changed, 29 insertions(+), 38 deletions(-)

diff --git a/force-app/main/default/lwc/lexOPDReport/lexOPDReport.js b/force-app/main/default/lwc/lexOPDReport/lexOPDReport.js
index 5ff2566..b59338b 100644
--- a/force-app/main/default/lwc/lexOPDReport/lexOPDReport.js
+++ b/force-app/main/default/lwc/lexOPDReport/lexOPDReport.js
@@ -5,7 +5,8 @@
 import { NavigationMixin } from 'lightning/navigation';
 import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 import init from '@salesforce/apex/ReportController.initForOPDReportButton';
-
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
 export default class LexOPDReport extends NavigationMixin(LightningElement) {
     @api recordId;
     assetReturnDay2;
@@ -36,23 +37,37 @@
         }
     }
     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 }});
     }
 
     connectedCallback(){
+        Promise.all([
+            loadStyle(this, lwcCSS)
+           ]);
         init({
             recordId: this.recordId
         }).then(result=>{
             console.log(result);
+            console.log("start");
             this.assetReturnDay2 = result.assetReturnDay2;
             this.demoPurpose2 = result.demoPurpose2;
             this.followUPOpp = result.followUPOpp;
@@ -74,21 +89,6 @@
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
-
-        //var d = new Date("{!Rental_Apply__c.Asset_return_day2__c}");
-        //var d15 = new Date("{!Rental_Apply__c.Asset_return_day2__c}");
-        //d15.setDate(d.getDate()+7);
-        //if(status == "宸插洖瀵�" && ( new Date()< d || new Date() > d15)){
-        // alert("澶囧搧鍊熷嚭鐘舵��:" + status + "锛屼絾涓嶅湪鍥炲瘎鏃ヤ箣鍚�7澶╀箣鍐咃紝涓嶈兘鍒涘缓鎶ュ憡涔︼紒");
-        // return;
-        //}
-        //2021/7/15 fxk Start
-        // var str;
-        // var url;
-
-        // str='&RecordType=01210000000RLTi';
-        // url = '/a0B/e?retURL=%2Fa0B%2Fo'+str;
-
         //2021/7/15 fxk End
 
         //SWAG-BVW8CW 20201217 璁﹗ser鑷繁閫夋嫨recordtype
@@ -96,6 +96,7 @@
         var demo_purpose2 = this.demoPurpose2;
         // var strs ;
         if(demo_purpose2=='璇曠敤锛堟湁璇环锛�'){
+            console.log('y');
             const defaultValues = encodeDefaultFieldValues({
                 Loaner_request_no1__c: this.recordId, // 鍏宠仈涓昏褰� ID
                 Hospital_Reference__c: this.hospital,
@@ -106,6 +107,7 @@
                 Opportunity_Situation__c: '璺熻繘璇环',
                 
             });
+            console.log('defaultValues = ' + defaultValues);
             this[NavigationMixin.Navigate]({
                 type: 'standard__objectPage',
                 attributes: {
@@ -113,17 +115,15 @@
                     actionName: 'new'
                 },
                 state: {
-                    nooverride: '1',
+                    //nooverride: '1',
                     defaultFieldValues: defaultValues,
                     recordTypeId: this.recordTypeId
                 }
             });
             this.dispatchEvent(new CloseActionScreenEvent());
-            // strs='&CF00N10000002DT68=' + this.followUPOpp +
-            // '&CF00N10000002DT68_lkid=' + this.followUPOppId +
-            // '&00N10000002DHk5=璺熻繘璇环'
             return;
         }
+        console.log('n');
         //Before Update by LiJun 20220321 end
         //After Update by LiJun 20220321 start
         const defaultValues = encodeDefaultFieldValues({
@@ -133,6 +133,7 @@
             Report_OPDPlan__c: this.opdPlan,
             Hospital_Department__c: this.account
         });
+        console.log('defaultValues = ' + defaultValues);
         this[NavigationMixin.Navigate]({
             type: 'standard__objectPage',
             attributes: {
@@ -140,22 +141,12 @@
                 actionName: 'new'
             },
             state: {
-                nooverride: '1',
+                //nooverride: '1',
                 defaultFieldValues: defaultValues,
                 recordTypeId: this.recordTypeId
             }
         });
         this.dispatchEvent(new CloseActionScreenEvent());
-        // url = url + '&CF00N10000004maf3=' + this.name +
-        // '&CF00N10000004maf3_lkid=' + this.recordId +
-        // '&CF00N10000002DPUD=' + this.hospital +
-        // '&CF00N10000002DPUD_lkid=' + this.hospitalId +
-        // '&CF00N10000002Dh0f=' + this.strategicDept +
-        // '&CF00N10000002Dh0f_lkid='+ this.strategicDeptId +
-        // '&CF00N10000008ps6d=' + this.opdPlan +
-        // '&CF00N10000008ps6d_lkid=' + this.opdPlanId +
-        // '&CF00N10000002CWW4=' + this.account +
-        // '&CF00N10000002CWW4_lkid=' + this.accountId;
         //After Update by LiJun 20220321 end
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1