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/lexCustomSubmit/lexCustomSubmit.js |   62 ++++++++++++-------------------
 1 files changed, 24 insertions(+), 38 deletions(-)

diff --git a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
index 413f6af..2d72fb1 100644
--- a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
+++ b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
@@ -6,6 +6,7 @@
 import updateRaesc from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaesc';
 import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById';
 import postponeCheck from '@salesforce/apex/SelectSubstituteControllerLWT.postponeCheck';
+import submitApprovalRequest from '@salesforce/apex/SelectSubstituteControllerLWT.submitApprovalRequest';
 
 import { loadScript } from 'lightning/platformResourceLoader';
 import { submitForApproval } from 'lightning/uiRecordApi';
@@ -72,15 +73,16 @@
 		}
 		console.log("hhh2");
 		let rtn;
+		let d=-5;
 		await postponeCheck({
 			endDate:this.Rental_Apply_Equipment_Set__c.Rental_End_Date__c,
-			d:-5
+			i:d
 		}).then(res=>{
 			console.log(res);
 			rtn=res;
 		}).catch(err=>{
 			console.log("err:",err.message);
-		})
+		});
 
 		console.log(rtn);
 		if (rtn != "OK") {
@@ -115,44 +117,28 @@
 	            message:result.errors[0].split(",")[1]
 	        });
 	        this.dispatchEvent(event);
+	        return;
 		}
 		console.log("hhh7");
 
-		// let request = new sforce.ProcessSubmitRequest();
-		// request.objectId = this.recordId;
-		// let processResults = sforce.connection.process([request]);
-		console.log("hhh8");
-		// submitForApproval(this.Rental_Apply_Equipment_Set__c.Id).then(result => {
-        // 	console.log(result);
-        // 	if (processResults[0].errors != null) {
-		// 		alert(processResults[0].errors.message);
-		// 		return;
-		// 	}
-		// 	console.log("hhh9");
-		// 	window.location.reload();
-        // })
-        // .catch(error => {
-        //   console.error('Error submitting record for approval:', error.message);
-        // });
-
-        // await submitForApproval(this.recordId);
-	    const fields = {}
-	    const recordInput = { fields };
-		updateRecord({ fields: recordInput, recordId: this.recordId })
-	      .then(() => {
-	        console.log("鏇存柊鎴愬姛");
-	      })
-	      .catch(error => {
-	      	console.log(error.message);
-	      	console.log(error);
-	      	// alert(error.body.message);
-			const event = new ShowToastEvent({
-	            title: '鎻愮ず淇℃伅',
-	            message:error.body.message
-	        });
-	        this.dispatchEvent(event);
-			return;
-	        // 澶勭悊寮傚父鎯呭喌
-	      });
+        await submitApprovalRequest({recordId:this.recordId}).then(res=>{
+  			console.log(res);
+  			if(res!=null&&res!=''){
+  				const event = new ShowToastEvent({
+		            title: '鎻愮ず淇℃伅',
+		            message:res
+		        });
+		        this.dispatchEvent(event);
+				return;
+  			}else{
+  				const event = new ShowToastEvent({
+		            title: '鎻愮ず淇℃伅',
+		            message:"鏇存柊鎴愬姛"
+		        });
+		        this.dispatchEvent(event);
+				return;
+  			}
+  		})
+	
 	}
 }
\ No newline at end of file

--
Gitblit v1.9.1