From 9f5874fcd8657ade15b4fc73c924813684f3a9a8 Mon Sep 17 00:00:00 2001
From: LiJinHuan <lijinhuan@prec-tech.com>
Date: 星期二, 08 八月 2023 19:19:35 +0800
Subject: [PATCH] 备品最近优化代码
---
force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js | 137 ++++++++++++++++++++-------------------------
1 files changed, 61 insertions(+), 76 deletions(-)
diff --git a/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js b/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
index 753abc5..d081272 100644
--- a/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
+++ b/force-app/main/default/lwc/lexSelectSubstitute/lexSelectSubstitute.js
@@ -1,94 +1,79 @@
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
-import init from '@salesforce/apex/SelectSubstituteControllerLWT.initFromSelectSubstituteButton';
-import selectRentalApplyEquipmentSetByID from '@salesforce/apex/SelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByID';
-import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import init from '@salesforce/apex/LexSelectSubstituteControllerLWT.initFromSelectSubstituteButton';
+import selectRentalApplyEquipmentSetByID from '@salesforce/apex/LexSelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByID';
+import selectRentalApplyCByName from '@salesforce/apex/LexSelectSubstituteControllerLWT.selectRentalApplyCByName';
+
export default class selectSubstituteLWC extends LightningElement {
@api recordId;
id;
- RentalApplyId;
- Status;
IsLoading=true;
- @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;
- }
- }
- }
+ IsShow=false;
+ @api rentalApplyEquipmentSetIds;
+ msg;
-
+ // @wire(CurrentPageReference)
+ // getStateParameters(currentPageReference){
+ // 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=>{
+ console.log('rentalApplyEquipmentSetIds'+this.rentalApplyEquipmentSetIds);
+ this.IsLoading = false;
+ if(this.rentalApplyEquipmentSetIds == undefined || this.rentalApplyEquipmentSetIds.length<1){
+ this.IsShow = true;
+ this.msg = "璇烽�夋嫨涓�鏉″�熷嚭澶囧搧涓�瑙堣褰�";
+ return;
+ }else if(this.rentalApplyEquipmentSetIds.length>1){
+ this.IsShow = true;
+ this.msg = "鍙兘閫夋嫨涓�鏉¤褰�";
+ return;
+ }else{
+ selectRentalApplyEquipmentSetByID({
+ recordId: this.rentalApplyEquipmentSetIds[0]
+ }).then(res=>{
+ result.Status = '宸叉壒鍑�';
+ res.RAES_Status__c = '宸叉壒鍑�';
+ if(result.Status !='宸叉壒鍑�' && result.Status!= '宸插嚭搴撴寚绀�'){
+ this.IsShow = true;
+ this.msg = '鐢宠涔︾姸鎬佷笉绗﹀悎鍒嗛厤浠f浛鍝佹潯浠讹紝璇风‘璁ょ敵璇风殑鐘舵��';
+ return;
+ }else{
+ if(res.RAES_Status__c == '鑽夋涓�' || res.RAES_Status__c == '鐢宠涓�' || res.Shippment_loaner_time2__c != null){
+ this.IsShow = true;
+ this.msg = "涓�瑙堢殑鐘舵�佷笉绗﹀悎鍒嗛厤鏇夸唬鍝佹潯浠�";
+ return;
+ }else if(res.Irreplaceable_flag__c == true){
+ this.IsShow = true;
+ this.msg = "鐢宠浜哄嬀閫変簡浠f浛鍝佷笉鍙�";
+ return;
+ }else{
+ window.open("/apex/RentalFixtureSetSelect?pt_recid="+ this.recordId +"&raesid="+this.rentalApplyEquipmentSetIds[0]);
+ this.closeAction();
+ }
+ }
+ })
}
}).catch(err=>{
- console.log("error:");
- console.log(err);
- }).finally(()=>{
-
- });
+ console.log("error:"+err);
+ })
}
+ closeAction() {
+ //杩斿洖褰撳墠鐨勫鍝佺敵璇�
+ window.open("/"+this.recordId,'_self');
+ }
-
- 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);
- }
- });
-
- }
- }
}
\ No newline at end of file
--
Gitblit v1.9.1