From 21b0eacc4f61c753fcdd2d6fd60ec1c5a837cebd Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期四, 06 七月 2023 11:03:46 +0800
Subject: [PATCH] 现场统一收货

---
 force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js |   48 +++++++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js b/force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js
index f6ebf2b..1e29534 100644
--- a/force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js
+++ b/force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js
@@ -2,6 +2,7 @@
 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/AllReceivedFseController.init';
 import getRaeSet from '@salesforce/apex/AllReceivedFseController.getRaeSet';
@@ -25,41 +26,50 @@
 		init({
 			recordId: this.recordId
 		}).then(res=>{
-			if(res.LoanerReceivedNgNum == 0){
+			console.log('loanerReceivedNgNum==='+ res.loanerReceivedNgNum);
+			if(res.loanerReceivedNgNum == 0){
 				const evt = new ShowToastEvent({
                         title : '鐜板満宸茬粡鍏ㄩ儴鏀跺埌瀹炵墿浜�',
                         message: '',
-                        variant: 'success'
+                        variant: 'error'
                     });
                 this.dispatchEvent(evt);
+                this.dispatchEvent(new CloseActionScreenEvent());
 			}else{
 				getRaeSet({
 					recordId: this.recordId
 				}).then(res=>{
 					if(res == 'SUCCESS'){
-						const evt = new ShowToastEvent({
-	                        title : '鐜板満宸插叏閮ㄦ敹璐�',
-	                        message: '',
-	                        variant: 'success'
-                    	});
-                    	this.dispatchEvent(new CloseActionScreenEvent());
-                		this.dispatchEvent(evt);
+                		this.showToast('鐜板満宸插叏閮ㄦ敹璐�','success');
+                		return;
 					}else{
-						const errToast = new ShowToastEvent({
-	                        title : res,
-	                        message: '',
-	                        variant: 'error'
-                    	});
-                    	this.dispatchEvent(new CloseActionScreenEvent());
-                		this.dispatchEvent(errToast);
-
-                		console.log(res);
+                		this.showToast(res,'warning');
+                		return;
 					}
 					
 				})
+				.catch(err=>{
+					console.log('getRaeSet==='+err);
+				})
 			}
 		}).catch(err=>{
-			console.log(err);
+			console.log('init==='+err);
 		})
 	}
+
+	showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        if(type == 'success'){
+            this.updateRecordView(this.recordId);
+        }
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1