From 07390e2fcb4adf27c928335bf27ae7939c5a80ad Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 23 五月 2023 11:28:12 +0800
Subject: [PATCH] bakcup20230523

---
 force-app/main/default/lwc/lexSubmitExtensionApprovalProcess/lexSubmitExtensionApprovalProcess.js |   53 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/force-app/main/default/lwc/lexSubmitExtensionApprovalProcess/lexSubmitExtensionApprovalProcess.js b/force-app/main/default/lwc/lexSubmitExtensionApprovalProcess/lexSubmitExtensionApprovalProcess.js
index eefc389..a78c32f 100644
--- a/force-app/main/default/lwc/lexSubmitExtensionApprovalProcess/lexSubmitExtensionApprovalProcess.js
+++ b/force-app/main/default/lwc/lexSubmitExtensionApprovalProcess/lexSubmitExtensionApprovalProcess.js
@@ -1,6 +1,8 @@
 import { LightningElement, track, wire, api } from 'lwc';
 import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
 import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { updateRecord } from 'lightning/uiRecordApi';
 
 import init from '@salesforce/apex/SubmitExtensionApprovalProcessController.init';
 import extension_approval_processCheck from '@salesforce/apex/RentalApplyWebService.extension_approval_processCheck'
@@ -23,43 +25,46 @@
 	connectedCallback(){
 		init({
 			recordId:this.recordId
-		}).then(result=>{
-			console.log(result);
+		}).then(res=>{
+			console.log('res==='+JSON.stringify(res));
 			var today = new Date();
 			//杩藉姞澶囧搧鐢宠鐘舵�佺‘璁わ紝宸茬粡鎻愪氦杩囩殑鐢宠锛屼笉鑳介噸澶嶆彁浜tatus__c 
-			if(result.ExtensionStatus == '濉啓瀹屾瘯' || result.ExtensionStatus == '鐢宠涓�') {
-				alert('璇风‘璁ゅ欢鏈熺敵璇风姸鎬侊紝宸茬粡鎻愪氦杩囩殑鐢宠锛屼笉鑳介噸澶嶆彁浜�');
+			if(res.extensionStatus == '濉啓瀹屾瘯' || res.extensionStatus == '鐢宠涓�') {
+				this.showToast('璇风‘璁ゅ欢鏈熺敵璇风姸鎬侊紝宸茬粡鎻愪氦杩囩殑鐢宠锛屼笉鑳介噸澶嶆彁浜�','error');
 				return; 
 			}
-			extension_approval_processCheck({rentalApplyId:this.recordId}).then( result =>{
+			extension_approval_processCheck({rentalApplyId:this.recordId}).then(result =>{
+				console.log('result==='+result);
 				if(result != '1'){
 					if(result == '2'){
 						//杩斿洖鍊间负2锛屽垽鏂叆鍙d负浠庡崟杩樻槸涓诲崟锛屽鏋滄槸浠庡崟锛岄偅涔堝氨闇�瑕佽烦鍘熸潵鐨勫崟涓欢鏈熼〉闈� 
-						if(result.RootRentalApply == '' || result.RootRentalApply == null){
+						if(result.rootRentalApply == '' || result.rootRentalApply == null){
 							window.open("/apex/RentalApplyMultiPostpone?parentId=" + this.recordId); 
 						}else {
 							window.open("/apex/RentalApplyExtensions?parentId=" + this.recordId); 
 						}
 					}else{
-						alert(result);
-						this.dispatchEvent(new CloseActionScreenEvent());
+						this.showToast(result,'error');
 						return
 					}
 				}else{
-					if(result.demoPurpose2 == '鍗忚鍊熺敤'){
-						alert('璇峰湪[闄勪欢]鍐呬笂浼犳柊鐨勫悎鍚岄檮浠讹紝骞朵緷鎹悎鍚屽唴鏈熼檺杩涜鏃ユ湡濉啓锛屼箣鍚庢彁浜ゅ鎵�'); 
+					if(res.demoPurpose2 == '鍗忚鍊熺敤'){
+						this.showToast('璇峰湪[闄勪欢]鍐呬笂浼犳柊鐨勫悎鍚岄檮浠讹紝骞朵緷鎹悎鍚屽唴鏈熼檺杩涜鏃ユ湡濉啓锛屼箣鍚庢彁浜ゅ鎵�','error'); 
 						return;
 					}
-					if(result.AgreementBorrowingExtensionDate =='' || result.AgreementBorrowingExtensionDate == null){
-						alert('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戜笉鑳戒负绌�'); 
+					console.log('typeof'+typeof(res.agreementBorrowingExtensionDate));
+					if(res.agreementBorrowingExtensionDate =='' || res.agreementBorrowingExtensionDate == null){
+						this.showToast('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戜笉鑳戒负绌�','error'); 
 						return;
 					}
-					if(result.AgreementBorrowingExtensionDate <= result.ReturnDadelineFinal){
-						alert('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戝繀椤诲ぇ浜庢渶鏂伴瀹氬綊杩樻棩');
+					typeof(res.agreementBorrowingExtensionDate) == 'string' ? res.agreementBorrowingExtensionDate = new Date(res.agreementBorrowingExtensionDate) : '';
+					typeof(res.returnDadelineFinal) == 'string' ? res.returnDadelineFinal = new Date(res.returnDadelineFinal) : '';
+					if(res.agreementBorrowingExtensionDate <= res.returnDadelineFinal){
+						this.showToast('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戝繀椤诲ぇ浜庢渶鏂伴瀹氬綊杩樻棩','error'); 
 						return; 
 					}
-					if(result.AgreementBorrowingExtensionDate <= today ){
-						alert('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戝繀椤诲ぇ浜庝粖澶�');
+					if(res.agreementBorrowingExtensionDate <= today ){
+						this.showToast('鍗忚鍊熺敤鐨勫欢鏈熺敵璇风殑銆愬崗璁�熺敤寤舵湡鏃ユ湡銆戝繀椤诲ぇ浜庝粖澶�','error'); 
 						return; 
 					}
 				}
@@ -73,4 +78,20 @@
 			console.log('error====>'+err);
 		})
 	}
+
+	showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        if(type == 'success'){
+            this.updateRecordView();
+        }
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1