From 89c6a02c36153a85b15e016650526fa795a551bf Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 23 五月 2023 11:37:45 +0800
Subject: [PATCH] signfunctionbackup

---
 force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js |  110 ++++++++++++++++++++++--------------------------------
 1 files changed, 45 insertions(+), 65 deletions(-)

diff --git a/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js b/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
index 753abc5..c8361ac 100644
--- a/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
+++ b/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
@@ -8,87 +8,67 @@
 
 	@api recordId;
     id;
-    RentalApplyId;
-    Status;
     IsLoading=true;
+    @api rentalApplyEquipmentSetIds;
+
     @wire(CurrentPageReference)
 	getStateParameters(currentPageReference){
-		console.log("杩涘叆椤甸潰");
-		console.log(currentPageReference);
-		if(currentPageReference){
-			const urvalue=currentPageReference.state.recordId;
-			if(urvalue){
-				let str=`${urvalue}`;
-				console.log('str');
-				console.log(str);
-				this.recordId=str;
+		if(currentPageReference) {
+			const urlValue = currentPageReference.state.recordId;
+			if(urlValue) {
+				let str = `${urlValue}`;
+		        this.recordId = str;
 			}
 		}
 	}
 
-
-
 	connectedCallback(){
 		console.log(this.recordId);
-		init({recordId:this.recordId}).then(result=>{
-			console.log(result);
-			if(result!=null){
-				this.id=result.id;
-			    this.RentalApplyId=result.RentalApplyId;
-			    this.Status=result.Status;
-				this.cancelSubmit().then(res=>{
-					this.IsLoading=false;
-					this.dispatchEvent(new CloseActionScreenEvent());
-				});	
+		init({
+			recordId:this.recordId
+		}).then(result=>{
+			if(rentalApplyEquipmentSetIds.length<1){
+				this.showToast("璇烽�夋嫨涓�鏉″�熷嚭澶囧搧涓�瑙堣褰�",'warning');
+			}else if(rentalApplyEquipmentSetIds.length>1){
+				this.showToast("鍙兘閫夋嫨涓�鏉¤褰�",'warning');
+			}else{
+
 			}
 		}).catch(err=>{
 			console.log("error:");
 			console.log(err);
 		}).finally(()=>{
-
+			selectRentalApplyEquipmentSetByID({
+				recordId: rentalApplyEquipmentSetIds[0]
+			}).then(res=>{
+				if(res.Status__c !='宸叉壒鍑�' &&  res.Status__c!= '宸插嚭搴撴寚绀�'){
+					this.showToast('鐢宠涔︾姸鎬佷笉绗﹀悎鍒嗛厤浠f浛鍝佹潯浠讹紝璇风‘璁ょ敵璇风殑鐘舵��','warning');
+				}else{
+					if(res.Status__c == '鑽夋涓�' || res.Status__c == '鐢宠涓�' || res.Shippment_loaner_time2__c != null){
+						this.showToast("涓�瑙堢殑鐘舵�佷笉绗﹀悎鍒嗛厤鏇夸唬鍝佹潯浠�",'warning'); 
+					}else if(res.Irreplaceable_flag__c == true){
+						this.showToast("鐢宠浜哄嬀閫変簡浠f浛鍝佷笉鍙�",'warning');
+					}else{
+						window.open("/apex/RentalFixtureSetSelect?pt_recid="+ this.recordId +"&raesid="+rentalApplyEquipmentSetIds[0]); 
+					}
+				}
+			})
 		});
 	}
 
+	showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        if(type == 'success'){
+            this.updateRecordView();
+        }
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
 
- 
-    async cancelSubmit(){
-		// 鍙垎閰嶄唬鏇垮搧鍓嶆彁1 -- 澶囧搧鍊熷嚭鐢宠鐨勭姸鎬侊細鈥滃凡鎵瑰噯鈥濆埌鈥滃凡鍑哄簱鎸囩ず鈥�
-		if(this.Status != '宸叉壒鍑�' && this.Status != '宸插嚭搴撴寚绀�') {
-			// alert('鐢宠涔︾姸鎬佷笉绗﹀悎鍒嗛厤浠f浛鍝佹潯浠讹紝璇风‘璁ょ敵璇风殑鐘舵��');
-	        const event = new ShowToastEvent({
-	            title: '鎻愮ず淇℃伅',
-	            message:'鐢宠涔︾姸鎬佷笉绗﹀悎鍒嗛厤浠f浛鍝佹潯浠讹紝璇风‘璁ょ敵璇风殑鐘舵��'
-	        });
-	        this.dispatchEvent(event);
-		} else {
-			// 鍙垎閰嶄唬鏇垮搧鍓嶆彁2 -- 鎵�閫夊�熷嚭澶囧搧閰嶅涓�瑙堢殑鐘舵�侊細鈥樺凡鎵瑰噯鈥欏埌鈥樺嚭搴撳墠宸叉娴嬧��
-			var soqlRecord ;
-			await selectRentalApplyEquipmentSetByID({recordId:this.recordId})
-			.then(res=>{
-				soqlRecord=res;
-				var status = soqlRecord.RAES_Status__c;
-				var irreplaceable = soqlRecord.Irreplaceable_flag__c;
-				var shipTime = soqlRecord.Shippment_loaner_time2__c;
-
-				if(status == "鑽夋涓�" || status == "鐢宠涓�" || shipTime != null) {
-					// alert("涓�瑙堢殑鐘舵�佷笉绗﹀悎鍒嗛厤鏇夸唬鍝佹潯浠�");
-			        const event = new ShowToastEvent({
-			            title: '鎻愮ず淇℃伅',
-			            message:"涓�瑙堢殑鐘舵�佷笉绗﹀悎鍒嗛厤鏇夸唬鍝佹潯浠�"
-			        });
-			        this.dispatchEvent(event);
-				} else if(irreplaceable=="true") {
-					// alert("鐢宠浜哄嬀閫変簡浠f浛鍝佷笉鍙�");
-			        const event = new ShowToastEvent({
-			            title: '鎻愮ず淇℃伅',
-			            message:"鐢宠浜哄嬀閫変簡浠f浛鍝佷笉鍙�"
-			        });
-			        this.dispatchEvent(event);
-				} else {
-					window.open("/apex/RentalFixtureSetSelect?pt_recid="+this.RentalApplyId+"&raesid="+this.recordId);
-				}
-			});
-			
-		}
-	}
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1