From 83fc8696324a49a9206ad8d69f9295bdd76d422c Mon Sep 17 00:00:00 2001
From: liwentao <1376563863@qq.com>
Date: 星期三, 12 四月 2023 17:09:56 +0800
Subject: [PATCH] 备品借出申请:提交待审批(李文涛)

---
 force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js-meta.xml |   11 
 force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.css         |   11 
 force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js          |  659 ++++++++++++++++++++++++++++++++++++++
 force-app/main/default/classes/RentalApplyControllerLWT.cls          |  290 +++++++++++++++++
 force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.html        |    5 
 force-app/main/default/classes/RentalApplyControllerLWT.cls-meta.xml |    5 
 6 files changed, 981 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/RentalApplyControllerLWT.cls b/force-app/main/default/classes/RentalApplyControllerLWT.cls
new file mode 100644
index 0000000..ea1812a
--- /dev/null
+++ b/force-app/main/default/classes/RentalApplyControllerLWT.cls
@@ -0,0 +1,290 @@
+public with sharing class RentalApplyControllerLWT {
+    public RentalApplyControllerLWT() {
+        
+    }
+    @AuraEnabled
+    public static Rental_Apply__c initFromCancelSubmitButton(String recordId){
+        InitData res = new InitData();
+        try{
+            Rental_Apply__c report=[select 
+             Status__c,Yi_loaner_arranged__c,Id,RA_Status__c,
+            demo_purpose2__c,Follow_UP_Opp__c,Statu_Achievements__c,Statu_Achievements_ID__c,
+            Request_shipping_day__c,Demo_purpose1__c,Repair__c,RecordTypeId,SupplementCreated__c,
+            OPDPlan__c,Campaign__c,QIS_number__c,OwnerId,
+            // QIS_numberId__c,CampaignId__c,applyUserId__c锛�
+            Re_repair__c,
+            QIS_ID_Line__c,
+            applyUser__c
+             from Rental_Apply__c where Id= :recordId];
+            return report;
+            // res.StatusC=report.Status__c;
+            // res.Id=report.Id;
+            // res.YiLoanerArrangedC=report.Yi_loaner_arranged__c;
+            // res.RAStatusC=report.RA_Status__c;
+            // res.DemoPurpose2C=report.demo_purpose2__c;
+            // res.FollowUPOppC=report.Follow_UP_Opp__c;
+            // res.StatuAchievementsC=report.Statu_Achievements__c;
+            // res.StatuAchievementsIDC=report.Statu_Achievements_ID__c;
+            // res.RequestShippingDayC=report.Request_shipping_day__c;
+            // res.DemoPurpose1C=report.Demo_purpose1__c;
+            // res.RepairC=report.Repair__c;
+            // res.RecordTypeId=report.RecordTypeId;
+            // res.SupplementCreatedC=report.SupplementCreated__c;
+            // res.OPDPlanC=report.OPDPlan__c;
+            // res.CampaignC=report.Campaign__c;
+            // res.QISNumberC=report.QIS_number__c;
+            // res.QISNumberIdc=report.QIS_numberId__c;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+
+    @AuraEnabled
+    public static list<Rental_Apply_Equipment_Set_Detail__c> selectRentalApplyEquipmentSetDetailByRacId(String recordId){
+        InitData res = new InitData();
+        try{
+            list<Rental_Apply_Equipment_Set_Detail__c> report=[select 
+            Id, Fixture_Model_No_F__c, Product_Status_Flag_F__c 
+            from Rental_Apply_Equipment_Set_Detail__c where Rental_Apply__c = :recordId]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static list<QIS_Report__c> selectQISReportById(String recordId){
+        InitData res = new InitData();
+        try{
+            list<QIS_Report__c> report=[select 
+            Id, nonyushohin__r.Product2.Fixture_Model_No_T__c 
+            from QIS_Report__c 
+            where id = :recordId
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+    
+    @AuraEnabled
+    public static list<Repair__c> selectRepairById(String recordId){
+        InitData res = new InitData();
+        try{
+            list<Repair__c> report=[select Id, Repair_Rank__c, DW_Sign_Txt__c, FSE_ApplyForRepair_Day__c, Delivered_Product__r.Product2.Fixture_Model_No_T__c
+                 , ReRepairObject_F__c,Status1__c,Agreed_Date__c,Repair_Estimated_date_formula__c,Repair_Ordered_Date__c
+                 , IfCheckFixture__c
+                 , Repair_Final_Inspection_Date__c,Repair_Shipped_Date__c,Number_of_EffectiveContract__c, NewProductGuaranteeObject__c, Delivered_Product__r.Product2.Asset_Model_No__c
+                 from Repair__c where id = :recordId
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static list<Campaign> selectCampaignById(String recordId){
+        InitData res = new InitData();
+        try{
+            list<Campaign> report=[select 
+            Status, Rental_Apply_Flag__c ,IF_Approved__c,Meeting_Approved_No__c,Approved_Status__c 
+            from Campaign where id =:recordId
+
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+    @AuraEnabled
+    public static list<Rental_Apply_Equipment_Set__c> selectRentalApplyEquipmentSetByRacId(String recordId){
+        InitData res = new InitData();
+        try{
+            list<Rental_Apply_Equipment_Set__c> report=[select Id 
+                from Rental_Apply_Equipment_Set__c 
+                where RetalFSetDetail_Cnt__c = 0 AND Rental_Apply__c = :recordId
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static list<Rental_Apply__c> selectRentalApplyById(String recordId){
+        InitData res = new InitData();
+        try{
+            list<Rental_Apply__c> report=[select 
+            id,OPDPlan__c,OPDPlan__r.SalesManager_Txt__c,OPDPlan__r.BuchangApprovalManagerSales_Txt__c 
+            from Rental_Apply__c where id = :recordId
+
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static list<User> selectUserById(String recordId){
+        InitData res = new InitData();
+        try{
+            list<User> report=[select 
+            id,JingliEquipmentManager__c,JingliEquipmentManager__r.Name,Buzhang_Equipment_Manager__c,
+            Buzhang_Equipment_Manager__r.Name 
+            from User where id = :recordId
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static list<QIS_report__c> selectQISreportById2(String recordId){
+        InitData res = new InitData();
+        try{
+            list<QIS_report__c> report=[select id,next_action__c 
+            from QIS_report__c where id =:recordId
+            ]; 
+            return report;
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
+        }
+        return null;
+    }
+
+         
+    @AuraEnabled
+    public static String getUserId(){
+        
+        return UserInfo.getUserId();
+    }
+
+    @AuraEnabled
+    public static String getProfileId(){
+        return UserInfo.getProfileId();
+    }   
+
+    @AuraEnabled
+    public static String setSObjectShare(String sobjectName, String rowCause, String parentId, List<String> userAccess, String ownerId) {
+
+        try {
+            List<SObject> sObjList = new List<SObject>();
+            for (String ua : userAccess) {
+                String userid = ua.split('_')[0];
+                String access = ua.split('_')[1];
+                SObject sObj = Schema.getGlobalDescribe().get(sobjectName).newSObject();
+                if (String.isBlank(userid) == false && userid.substring(0, 15) != ownerId.substring(0, 15)) {
+                    sObj.put('RowCause', rowCause);
+                    sObj.put('ParentId', parentId);
+                    sObj.put('UserOrGroupId', userid);
+                    sObj.put('AccessLevel', access);
+                    sObjList.add(sObj);
+                }
+            }
+            if (sObjList.size() > 0) insert sObjList;
+            return 'OK';
+        } catch (Exception e) {
+            return e.getMessage();
+        }   
+    }
+
+    @AuraEnabled
+    public static UpdateResult updateRentalApplyC(        
+        String recordId,
+        String SalesManagerSubmitC,
+        String StatusC,
+        String OPDManagerApproverC,
+        String BuchangApprovalManagerSalesSubmitC,
+        String OPDBuchangApproverC
+    ) {
+        UpdateResult result = new UpdateResult();
+        result.recordId = recordId;
+        try{
+            // 鏇存柊璁板綍骞惰幏鍙栫粨鏋�
+            if(recordId==null) return null;
+            Rental_Apply__c rac = new Rental_Apply__c( id=recordId);
+
+            if(SalesManagerSubmitC!=null&& SalesManagerSubmitC != ''){
+                rac.SalesManagerSubmit__c=SalesManagerSubmitC;
+            }
+            if(StatusC!=null&&StatusC!=''){
+                rac.Status__c=StatusC;
+            }
+            if(OPDManagerApproverC!=null&&OPDManagerApproverC!=''){
+                rac.OPDManagerApprover__c=OPDManagerApproverC;
+            }
+            if(BuchangApprovalManagerSalesSubmitC!=null&&BuchangApprovalManagerSalesSubmitC!=''){
+                rac.BuchangApprovalManagerSalesSubmit__c=BuchangApprovalManagerSalesSubmitC;
+            }
+            if(OPDBuchangApproverC!=null&&OPDBuchangApproverC!=''){
+                rac.OPDBuchangApprover__c=OPDBuchangApproverC;
+            }
+            if(rac.id==null)return null;
+            update rac;
+            result.success = true;
+            result.errors = new List<String>();
+            return result;
+        }catch(Exception e){
+            result.success = false;
+            result.errors = new List<String>();
+            result.errors.add(e.getMessage());
+            System.debug(LoggingLevel.INFO,'Rental_Apply__c update Error : ' + e);
+        }
+        return result;
+    }
+
+    public class UpdateResult {
+        @AuraEnabled public String recordId {get;set;}
+        @AuraEnabled public Boolean success {get;set;}
+        @AuraEnabled public List<String> errors {get;set;}
+    }
+    public class InitData{
+        @AuraEnabled
+        public String StatusC;
+        @AuraEnabled
+        public Decimal YiLoanerArrangedC;
+        @AuraEnabled
+        public String Id;
+        @AuraEnabled
+        public String RAStatusC;
+
+        @AuraEnabled
+        public String DemoPurpose2C;
+        @AuraEnabled
+        public String FollowUPOppC;
+        @AuraEnabled
+        public String StatuAchievementsC;
+        @AuraEnabled
+        public String StatuAchievementsIDC;
+        @AuraEnabled
+        public Date RequestShippingDayC;
+        @AuraEnabled
+        public String DemoPurpose1C;
+        @AuraEnabled
+        public String RepairC;
+        @AuraEnabled
+        public String RecordTypeId;
+        @AuraEnabled
+        public Boolean SupplementCreatedC;
+        @AuraEnabled
+        public String OPDPlanC;
+        @AuraEnabled
+        public String CampaignC;
+        @AuraEnabled
+        public String QISNumberC;
+        @AuraEnabled
+        public String QISNumberIdc;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/RentalApplyControllerLWT.cls-meta.xml b/force-app/main/default/classes/RentalApplyControllerLWT.cls-meta.xml
new file mode 100644
index 0000000..d75b058
--- /dev/null
+++ b/force-app/main/default/classes/RentalApplyControllerLWT.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>51.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.css b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.css
new file mode 100644
index 0000000..af18c76
--- /dev/null
+++ b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.css
@@ -0,0 +1,11 @@
+.Holder{
+	position: relative;
+	display: inline-block;
+	width: 80px;
+	height: 80px;
+	text-align: center;
+}
+
+.container .uiContainerManager{
+	display : none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.html b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.html
new file mode 100644
index 0000000..960b41d
--- /dev/null
+++ b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.html
@@ -0,0 +1,5 @@
+<template>
+      <div class="Holder" if:true={IsLoading}>
+              <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+      </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js
new file mode 100644
index 0000000..91a23a0
--- /dev/null
+++ b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js
@@ -0,0 +1,659 @@
+import { LightningElement,api, track, wire } from 'lwc';
+import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId';
+import getProfileId from '@salesforce/apex/RentalApplyControllerLWT.getProfileId';
+import init from '@salesforce/apex/RentalApplyControllerLWT.initFromCancelSubmitButton';
+import selectRentalApplyEquipmentSetDetailByRacId from '@salesforce/apex/RentalApplyControllerLWT.selectRentalApplyEquipmentSetDetailByRacId';
+import selectQISReportById from '@salesforce/apex/RentalApplyControllerLWT.selectQISReportById';
+import selectRepairById from '@salesforce/apex/RentalApplyControllerLWT.selectRepairById';
+import selectCampaignById from '@salesforce/apex/RentalApplyControllerLWT.selectCampaignById';
+import selectRentalApplyEquipmentSetByRacId from '@salesforce/apex/RentalApplyControllerLWT.selectRentalApplyEquipmentSetByRacId';
+import selectRentalApplyById from '@salesforce/apex/RentalApplyControllerLWT.selectRentalApplyById';
+import selectUserById from '@salesforce/apex/RentalApplyControllerLWT.selectUserById';
+import selectQISreportById2 from '@salesforce/apex/RentalApplyControllerLWT.selectQISreportById2';
+import setSObjectShare from '@salesforce/apex/RentalApplyControllerLWT.setSObjectShare';
+import updateRentalApplyC from '@salesforce/apex/RentalApplyControllerLWT.updateRentalApplyC';
+import {CurrentPageReference} from 'lightning/navigation';
+import { CloseActionScreenEvent } from 'lightning/actions';
+import STATUS_PROCESS_STATE from '@salesforce/label/c.StatusProcessState';
+export default class rentalApplyLWT extends LightningElement {
+
+    contactFirstName = 'Yan';
+    contactLastName = 'Khang';
+    opportunityName = 'Possible deal';
+    clickedButtonLabel;
+
+    @api recordId;
+    @track StatusProcessState=STATUS_PROCESS_STATE;
+    Rental_Apply__c;
+    Status__c;
+    Id;
+    Yi_loaner_arranged__c;
+    RA_Status__c;
+    IsLoading=true;
+    demo_purpose2__c;
+    Follow_UP_Opp__c;
+    Statu_Achievements__c;
+    Statu_Achievements_ID__c;
+    Request_shipping_day__c;
+    Demo_purpose1__c;
+    Repair__c;
+    RecordTypeId;
+    SupplementCreated__c;
+    OPDPlan__c;
+    Campaign__c;
+    QIS_number__c;
+	RepairId__c;
+    @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;
+			}
+		}
+	}
+
+
+	async connectedCallback(){
+		console.log(this.recordId);
+		await init({recordId:this.recordId}).then(result=>{
+			console.log(result);
+			if(result!=null){
+				this.Rental_Apply__c=result;
+				this.Status__c=result.Status__c;
+				this.Yi_loaner_arranged__c=result.Yi_loaner_arranged__c;
+				this.Id=result.Id;
+				this.RA_Status__c=result.RA_Status__c;
+			    // this.Rental_Apply__c.demo_purpose2__c=result.DemoPurpose2C;
+			    // this..Follow_UP_Opp__c=result.FollowUPOppC;
+			    // this.Rental_Apply__c.Statu_Achievements__c=result.StatuAchievementsC;
+			    // this.Rental_Apply__c.Statu_Achievements_ID__c=result.StatuAchievementsIDC;
+			    // this.Rental_Apply__c.Request_shipping_day__c=result.RequestShippingDayC;
+			    // this.Rental_Apply__c.Demo_purpose1__c=result.DemoPurpose1C;
+			    // this.Rental_Apply__c.Repair__c=result.RepairC;
+			    // this.Rental_Apply__c.RecordTypeId=result.RecordTypeId;
+			    // this.Rental_Apply__c.SupplementCreated__c=result.SupplementCreatedC;
+			    // this.Rental_Apply__c.OPDPlan__c=result.OPDPlanC;
+			    // this.Rental_Apply__c.Campaign__c=result.CampaignC;
+			    // this.Rental_Apply__c.QIS_number__c=result.QISNumberC;
+				
+				this.sumit().then(res=>{
+					console.log("鍏抽棴绐楀彛");
+					this.IsLoading=false;
+					this.dispatchEvent(new CloseActionScreenEvent());
+				}).catch(err=>{
+					console.log("error:");
+					console.log(err.message);
+					alert("鎿嶄綔澶辫触,閿欒淇℃伅:"+err.message);
+				});
+				console.log("end");
+			}
+		}).catch(err=>{
+			console.log("error:");
+			console.log(err.message);
+			console.log("鎶ラ敊缁撴潫");
+		}).finally(()=>{
+			console.log("finally");
+			
+		});
+		
+	}
+
+
+    handleClick(event) {
+        this.clickedButtonLabel = event.target.label;
+    }
+    handleContactFirstNameInputChange(event) {
+        this.contactFirstName = event.target.value;
+    }
+    cancelSubmit(){
+    	console.log('djwaijd');
+    	if (this.Rental_Apply__c.Status__c == "鍙栨秷") {
+			alert("宸茬粡鍙栨秷锛�");
+			console.log('1');
+			return;
+		}
+		if (this.Rental_Apply__c.Status__c == "鍒犻櫎") {
+			alert("宸茬粡鍒犻櫎锛�");
+			console.log('2');
+			return;
+		}
+		if(this.RA_Status__c == "宸插嚭搴�" || this.Yi_loaner_arranged__c > 0) {
+			alert("澶囧搧宸茬粡鍑哄簱锛屼笉鑳藉彇娑堬紒");
+			console.log('2');
+			return;
+		}
+		let raid = this.Id;
+		window.open("/apex/RentalApplyCancel?objId="+raid, 'RentalApplyCancel', 'width=500,height=250');
+	}
+
+	
+
+	async sumit(){
+		let buttons = document.getElementsByName('submit_approval_process'.toLowerCase());
+		for (let i=0; i<buttons.length; i++) {
+			buttons[i].className = "btnDisabled";
+			buttons[i].disabled = true;
+		}
+		//kk
+		if (!confirm("涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵")) {
+			return;
+		}
+		//1540 you 璇曠敤锛堟棤璇环锛夌洰鐨勭殑澶囧搧鐢宠鍗曪紝涓嶈兘鍏宠仈璇环淇℃伅锛�
+		if(this.Rental_Apply__c.demo_purpose2__c == '璇曠敤锛堟棤璇环锛�' && this.Rental_Apply__c.Follow_UP_Opp__c !=null && this.Rental_Apply__c.Follow_UP_Opp__c != ''){
+			alert('璇曠敤锛堟棤璇环锛夌洰鐨勭殑澶囧搧鐢宠鍗曪紝涓嶈兘鍏宠仈璇环淇℃伅锛�');
+			return;
+		}
+		// 宸茶喘寰呰揣鐨勭敵璇峰崟瀹℃壒鏃讹紝闇�瑕乧heck娉ㄦ畫鐨勭姸鎬�
+		if (this.Rental_Apply__c.Statu_Achievements__c!=null&&this.Rental_Apply__c.Statu_Achievements__c!='') {
+
+			let SaID=this.Rental_Apply__c.Statu_Achievements_ID__c;
+			let rtn = sforce.apex.execute("RentalApplyWebService","RentalApplyCheckForSAoneEle",{SaID:SaID});
+			if(rtn!='Fin'){
+				alert(rtn);
+				return;
+			}
+		}
+		// 甯屾湜鍒拌揣鏃ヤ笉鑳芥棭浜庣敵璇锋彁浜ゆ棩-0418杩藉姞
+		let d=new Date();
+		if (this.Rental_Apply__c.Request_shipping_day__c < d ) {
+			alert('甯屾湜鍒拌揣鏃ヤ笉鑳芥棭浜庣敵璇锋彁浜ゆ棩');
+			return;
+		}
+		let raesdList = new Array();
+		await selectRentalApplyEquipmentSetDetailByRacId({recordId:this.recordId}).then(result=>{
+			console.log(result);
+			if(result!=null){
+				raesdList=result;
+				let modelSet = new Set();
+				let stoppedSet = new Set();
+				for(let i=0;i<raesdList.length;i++){
+					modelSet.add(raesdList[i].Fixture_Model_No_F__c);
+					if('false' == raesdList[i].Product_Status_Flag_F__c
+					&& (this.Rental_Apply__c.demo_purpose2__c == '璇曠敤锛堟湁璇环锛�' || this.Rental_Apply__c.demo_purpose2__c == '璇曠敤锛堟棤璇环锛�')){
+						stoppedSet.add(raesdList[i].Fixture_Model_No_F__c);
+					}
+				}
+				if(stoppedSet.size> 0) {
+					alert( Array.from(stoppedSet).join('锛�') + ' 浜у搧娉ㄥ唽璇佺姸鎬佷负鍋滄锛屼笉鍙敵璇�');
+					return;
+				}
+			}
+		}).catch(err=>{
+			console.log("selectRentalApplyEquipmentSetDetailByRacId error:");
+			console.log(err.message);
+			console.log("鎶ラ敊缁撴潫");
+		}).finally(()=>{
+		});
+
+
+
+		if(this.Rental_Apply__c.demo_purpose2__c == '绱㈣禂QIS'){
+			let DeliveryGood = new Array();
+			await selectQISReportById({recordId:this.Rental_Apply__c.QIS_number__c}).then(result=>{
+				console.log(result);
+				DeliveryGood=result;	
+			}).catch(err=>{
+				console.log("selectQISReportById error:");
+				console.log(err.message);
+			}).finally(()=>{
+			});
+			console.log(DeliveryGood);	
+			let records= DeliveryGood;
+			if(records.length == 0 || !modelSet.has(records[0].nonyushohin__r.Product2.Fixture_Model_No_T__c)){
+				alert('鐢宠鐨勫瀷鍙峰繀椤讳笌QIS鐢宠鍨嬪彿涓�鑷�');
+				return;
+			}
+		}
+		if(this.Rental_Apply__c.Repair__c==null){
+			console.log("Repair__c涓虹┖")
+		}else{
+			if( this.Rental_Apply__c.Repair__c != ''){
+				console.log("hhh7.1.1");
+				let DeliveryGood ;
+				let records;
+				await selectRepairById({recordId:this.Rental_Apply__c.Repair__c}).then(result=>{
+					console.log(result);
+					DeliveryGood=result;	
+					records=result;
+				}).catch(err=>{
+					console.log("selectRepairById error:");
+					console.log(err.message);
+				}).finally(()=>{
+				});
+				if(records==null||records.length==0){
+					console.log("records涓虹┖");
+				}else{
+					if(this.Rental_Apply__c.Demo_purpose1__c == '缁翠慨浠g敤' && this.Rental_Apply__c.demo_purpose2__c != '绱㈣禂QIS') {
+						if(!modelSet.has(records[0].Delivered_Product__r.Product2.Fixture_Model_No_T__c)){
+							alert('鐢宠鐨勫瀷鍙峰繀椤讳笌閫佷慨鐨勫瀷鍙蜂竴鑷�');
+							return;
+						}
+					}
+					if(this.Rental_Apply__c.Demo_purpose1__c==null){
+						console.log("Demo_purpose1__c涓虹┖");
+					}else if(this.Rental_Apply__c.Demo_purpose1__c == '缁翠慨浠g敤' && this.Rental_Apply__c.demo_purpose2__c == '涓�鑸敤鎴�' ){
+						if (records[0].Repair_Estimated_date_formula__c == null) {
+							alert('涓�鑸淮淇棤鎶ヤ环鏃ワ紝涓嶅彲鍊熺敤澶囧搧');
+							return;
+						}
+
+						else if (records[0].Repair_Estimated_date_formula__c < '2019-07-01' && records[0].Agreed_Date__c == null) {
+							alert('鎶ヤ环鏃ュ湪2019/7/1涔嬪墠涓旀埛鍚屾剰鏃ヤ负绌猴紝涓嶅彲鍊熺敤澶囧搧');
+							return;
+						}
+						//20210608 ljh SFDC-C3CCN4 start
+						if(records[0].Repair_Rank__c == '' || records[0].Repair_Rank__c == null){
+							alert('鎶ヤ环绛夌骇涓虹┖涓嶈兘鐢宠澶囧搧');
+							return;
+						}else{
+							if(records[0].DW_Sign_Txt__c == 'false' && records[0].Repair_Rank__c == 'DW'){
+								alert('DW鎶ヤ环绛夌骇涓嬫鍨嬪彿涓嶇鍚堝鍝佺敵璇峰�熺敤鏉′欢');
+								return;
+							}
+							if(records[0].Repair_Rank__c == 'D1'
+								||records[0].Repair_Rank__c == 'D2'
+								||records[0].Repair_Rank__c == 'D3'
+								||records[0].Repair_Rank__c == 'E2'){
+								alert('鎶ヤ环绛夌骇涓嶇鍚堝鍝佺敵璇峰�熺敤鏉′欢');
+								return;
+							}
+						}
+					//20210608 ljh SFDC-C3CCN4 end
+					}
+					if(this.Rental_Apply__c.Demo_purpose1__c ==null){
+						console.log("Demo_purpose1__c涓虹┖");
+					}else if(this.Rental_Apply__c.Demo_purpose1__c == '缁翠慨浠g敤' && this.Rental_Apply__c.demo_purpose2__c == '甯傚満澶氬勾淇濅慨' ){
+						if (records[0].FSE_ApplyForRepair_Day__c == null) {
+							alert('甯傚満澶氬勾淇濅慨锛屾病鏈塠FSE淇悊鐢宠鏃锛屼笉鍙�熺敤澶囧搧');
+							return;
+						}
+					}
+					if(this.Rental_Apply__c.Demo_purpose1__c == '缁翠慨浠g敤' && this.Rental_Apply__c.demo_purpose2__c == '鏁呴殰鎺掓煡' ){
+						if (records[0].FSE_ApplyForRepair_Day__c == null) {
+							alert('鏁呴殰鎺掓煡锛屾病鏈塠FSE淇悊鐢宠鏃锛屼笉鍙�熺敤澶囧搧');
+							return;
+						}
+						if(records[0].Repair_Ordered_Date__c != null) {
+							alert('鏁呴殰鎺掓煡锛孾4.淇悊鍝丷C鍙楃悊鏃蹇呴』涓虹┖');
+							return;
+						}
+						if(records[0].IfCheckFixture__c == 'false'){
+							alert('涓嶆弧瓒虫晠闅滄帓鏌ョ洰鐨�');
+							return;
+						}
+					}
+					let profileId="";
+					await getProfileId().then(result=>{
+						console.log(result);
+						profileId=result;	
+					}).catch(err=>{
+						console.log("getProfileId error:");
+						console.log(err.message);
+					}).finally(()=>{
+					});
+					if(this.Rental_Apply__c.RecordTypeId==null){
+						console.log("RecordTypeId涓虹┖");
+					}else if (this.Rental_Apply__c.RecordTypeId != "01210000000RHIn"
+						&& profileId != '00e10000000Y3o5'
+						&& records[0].NewProductGuaranteeObject__c == '8: 甯傚満澶氬勾淇濅慨'
+						&& this.Rental_Apply__c.demo_purpose2__c != '甯傚満澶氬勾淇濅慨') {
+						alert('鏃犲伩鍖哄埆鏍囧織涓�8: 甯傚満澶氬勾淇濅慨锛屽繀椤婚�夋嫨甯傚満澶氬勾淇濅慨銆�');
+					}
+					if(records[0].Repair_Final_Inspection_Date__c != null){
+						alert('瀛樺湪淇悊鏈�缁堟娴嬫棩锛屼笉鍙�熺敤澶囧搧');
+						return;
+					}
+					if(records[0].Repair_Shipped_Date__c != null){
+						alert('瀛樺湪RC淇悊杩旈�佹棩锛屼笉鍙�熺敤澶囧搧');
+						return;
+					}
+					if(records[0].Status1__c =='0.鍒犻櫎' ||records[0].Status1__c =='0.鍙栨秷' ||records[0].Status1__c =='5.瀹屾瘯' ){
+						alert('淇悊宸茬粡缁撴潫锛屼笉鑳界敵璇峰鍝�');
+						return;
+					}
+					if ( this.Rental_Apply__c.demo_purpose2__c == '鍐嶄慨鐞�' && records[0].ReRepairObject_F__c == 'false') {
+						alert('涓嶅睘浜庡啀鍙楃悊鍙傝�冨璞★紝涓嶅彲鍊熺敤澶囧搧');
+						return;
+					}
+					if (this.Rental_Apply__c.RecordTypeId != '01210000000RHIn'
+						&& this.Rental_Apply__c.demo_purpose2__c != '淇濅慨鐢ㄦ埛'
+						&& this.Rental_Apply__c.demo_purpose2__c != '甯傚満澶氬勾淇濅慨'
+						&& records[0].Number_of_EffectiveContract__c == '鏈�' ) {
+						alert('鏈夌淮淇悎鍚�,蹇呴』閫夋嫨淇濅慨鐢ㄦ埛.');
+						return;
+					}
+					let AssetModelNo = records[0].Delivered_Product__r.Product2.Asset_Model_No__c;
+					if (this.Rental_Apply__c.RecordTypeId != '01210000000RHIn' && records[0].Number_of_EffectiveContract__c == '鏃�'
+						&& (records[0].NewProductGuaranteeObject__c == '2: 鏈嶅姟澶氬勾淇濅慨'
+						&& (AssetModelNo == 'LTF-190-10-3D' || AssetModelNo == 'LTF-S190-5' || AssetModelNo == 'CYF-VHA' || AssetModelNo == 'CYF-VA2' || AssetModelNo == 'CYF-5A'|| AssetModelNo == 'LTF-S190-10'|| AssetModelNo == 'OER-AW'|| AssetModelNo == 'URF-V'|| AssetModelNo == 'URF-V2'|| AssetModelNo == 'URF-P6'))
+						&& this.Rental_Apply__c.demo_purpose2__c != '淇濅慨鐢ㄦ埛' ) {
+						alert('姝よ澶囧瀷鍙峰骞翠繚淇紝璇烽�夋嫨淇濅慨鐢ㄦ埛.');
+						return;
+					}
+
+					if (this.Rental_Apply__c.RecordTypeId != '01210000000RHIn'
+						&& records[0].NewProductGuaranteeObject__c == '2: 鏈嶅姟澶氬勾淇濅慨'
+						&& (AssetModelNo == 'CV-V1' || AssetModelNo == 'CV-V1(A)' || AssetModelNo == 'CV-V1(B)' || AssetModelNo == 'GIF-LV1' || AssetModelNo == 'CF-LV1L' || AssetModelNo == 'CF-LV1I' || AssetModelNo == 'MAJ-1910')
+						&& (this.Rental_Apply__c.demo_purpose2__c == '涓�鑸敤鎴�' || this.Rental_Apply__c.demo_purpose2__c == '鍐嶄慨鐞�')
+						) {
+							alert('濂ヨ緣璁惧锛屼繚淇湡鍐呬笉鎻愪緵澶囧搧.');
+							return;
+					}
+				}
+				
+			}
+		} 
+
+		if(this.Rental_Apply__c.SupplementCreated__c==null){
+			console.log("SupplementCreated__c涓虹┖");
+		}else if (this.Rental_Apply__c.SupplementCreated__c == '1' && this.Rental_Apply__c.OPDPlan__c != '') {
+			let raId = this.Id;
+			//kk
+			let raesCountCheck = sforce.apex.execute("OpdPlanWebService", "raesCountCheck", {rentalApplyId: raId});
+			if(raesCountCheck != 'OK'){
+				alert(raesCountCheck);
+				return;
+			}
+		}
+		console.log("hhh10");
+		if(this.Rental_Apply__c.Campaign__c==null){
+			console.log("Campaign__c涓虹┖");
+		}else if( this.Rental_Apply__c.Campaign__c != ''){
+			let DeliveryGood = new Array();
+			// 20220324 ljh obpm update start
+			//kk1
+			let statusSting = this.StatusProcessState;
+			let statusList = statusSting.split(',');
+			// DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='{!Rental_Apply__c.Campaign__c}'");
+			// DeliveryGood = await selectCampaignById(this.Rental_Apply__c.Campaign__c);
+			await selectCampaignById({recordId:this.Rental_Apply__c.Campaign__c}).then(result=>{
+				console.log(result);
+				DeliveryGood=result;	
+			}).catch(err=>{
+				console.log("selectCampaignById error:");
+				console.log(err.message);
+			}).finally(()=>{
+			});
+			// 20220324 ljh obpm update start
+			//kk
+			let records= DeliveryGood;
+
+			let interval = records[0].Status;
+			let records_Date = records[0].Rental_Apply_Flag__c;
+			if (interval==null ) {
+				alert("璇风‘璁ゅ浼氱姸鎬�");
+				return;
+			}
+			else if (interval == '鑽夋涓�') {
+				alert('瀛︿細鐘舵�佷负鑽夋涓紝涓嶈兘鎻愪氦');
+				return;
+			}
+			else if (interval == '鐢宠涓�') {
+				alert('瀛︿細鐘舵�佷负鐢宠涓紝涓嶈兘鎻愪氦');
+				return;
+			}
+			else if (interval == '宸茬粨鏉�') {
+				alert('瀛︿細鐘舵�佷负宸茬粨鏉燂紝涓嶈兘鎻愪氦');
+				return;
+			}
+			else if (interval == '宸叉彁浜ゆ姤鍛�') {
+				alert('瀛︿細鐘舵�佷负宸叉彁浜ゆ姤鍛婏紝涓嶈兘鎻愪氦');
+				return;
+			}
+			else if (interval == '鍙栨秷鐢宠涓�') {
+				alert('瀛︿細鐘舵�佷负鍙栨秷鐢宠涓紝涓嶈兘鎻愪氦');
+				return;
+			}
+			else if (interval == '鍙栨秷') {
+				alert('瀛︿細鐘舵�佷负鍙栨秷锛屼笉鑳芥彁浜�');
+				return;
+			}
+			//kk
+			if(this.Rental_Apply__c.Request_shipping_day__c==null){
+				alert("璇风‘璁ゅ笇鏈涘埌璐ф棩鏈�");
+				return;
+			}else{
+				if (d >= this.Rental_Apply__c.Request_shipping_day__c -7) {
+					alert("蹇呴』鎻愬墠浜庡笇鏈涘埌璐ф棩7澶╀互涓婃彁浜ょ敵璇�");
+					return;
+				}
+				// 20220324 ljh obpm add start
+				if (records != null && records[0].IF_Approved__c == "true" && (records[0].Meeting_Approved_No__c == null || records[0].Meeting_Approved_No__c == "") ) {
+					alert("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��");
+					return;
+				}
+				if (records != null && records[0].IF_Approved__c == "true" && records[0].Meeting_Approved_No__c != "" && statusList.indexOf(records[0].Approved_Status__c) != -1 && records[0].Approved_Status__c != '鑽夌' ) {
+					alert("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�");
+					return;
+				}
+			}
+			
+			// 20220324 ljh obpm add end
+		}
+
+		if (this.Rental_Apply__c.QIS_number__c == null) {
+			console.log("QIS_number__c 鏄┖鐨�");
+		}else{
+			if( this.Rental_Apply__c.QIS_number__c != ''){
+				let DeliveryGood = new Array();
+				// DeliveryGood =await selectQISreportById2(this.Rental_Apply__c.QIS_ID_Line__c);
+				await selectQISreportById2({recordId:this.Rental_Apply__c.QIS_ID_Line__c}).then(result=>{
+					console.log(result);
+					DeliveryGood=result;	
+				}).catch(err=>{
+					console.log("selectQISreportById2 error:");
+					console.log(err.message);
+				}).finally(()=>{
+				});
+				let records= DeliveryGood;
+				let interval = records[0].next_action__c;
+				if (interval == '閫佸洖') {
+					alert("QIS 宸查�佸洖锛屼笉鑳藉啀鐢宠澶囧搧浜�");
+					return;
+				}
+			}
+		}
+		// share
+		let userAccess = new Array();
+		//kk
+		let t=this.Rental_Apply__c.applyUser__c+'_Edit';
+		userAccess.push(t);
+		let rtn ;
+		await setSObjectShare({sobjectName:'Rental_Apply__Share',rowCause:'ApplyUserShare__c',parentId:this.Rental_Apply__c.Id,userAccess:userAccess,ownerId:this.Rental_Apply__c.OwnerId}).then(result=>{
+			console.log(result);
+			rtn=result;	
+		}).catch(err=>{
+			console.log("setSObjectShare error:");
+			console.log(err.message);
+		}).finally(()=>{
+		});
+
+		if(rtn==null){
+			alert("rtn涓虹┖");
+			return;
+		}else{
+			if (rtn != 'OK') {
+				alert(rtn);
+				return;
+			}	
+		}
+		if(this.Rental_Apply__c.Status__c == null){
+			alert('璇峰鍝佺敵璇风姸鎬佺‘璁わ紝涓嶈兘涓虹┖');
+			return;
+		}else{
+			if (this.Rental_Apply__c.Status__c == '濉啓瀹屾瘯' ||
+				this.Rental_Apply__c.Status__c == '鐢宠涓�' ||
+				this.Rental_Apply__c.Status__c == '宸叉壒鍑�' ||
+				//鐜板湪鐢宠涔︾殑Status__c宸茬粡娌℃湁寮曞綋瀹屼簡鐘舵�併�傛墍浠ヨ繖閲屼笉闇�瑕佸垽鏂�
+				//'{!Rental_Apply__c.Status__c}' == '寮曞綋瀹屼簡' ||
+				this.Rental_Apply__c.Status__c == '宸插嚭搴撴寚绀�' ||
+				this.Rental_Apply__c.Status__c == '鍒犻櫎' ||
+				this.Rental_Apply__c.Status__c == '鍙栨秷' ) {
+					alert('璇峰鍝佺敵璇风姸鎬佺‘璁わ紝宸茬粡鎻愪氦杩囩殑鐢宠锛屼笉鑳介噸澶嶆彁浜�');
+					return;
+			}
+		}
+			// 娌℃湁鏄庣粏鐨勪竴瑙坈heck
+		let raesList = new Array();
+		// raesList = selectRentalApplyEquipmentSetByRacId(this.recordId);
+		await selectRentalApplyEquipmentSetByRacId({recordId:this.recordId}).then(result=>{
+			console.log(result);
+			raesList=result;	
+		}).catch(err=>{
+			console.log("selectRentalApplyEquipmentSetByRacId error:");
+			console.log(err.message);
+		}).finally(()=>{
+		});
+		let records= raesList;
+
+		if(records.length > 0){
+			alert('鏈夋病鏈夋槑缁嗙殑鍊熷嚭澶囧搧閰嶅涓�瑙堬紝涓嶈兘鎻愪氦');
+			return;
+		}
+		
+		let racs ;
+		await selectRentalApplyById({recordId:this.recordId}).then(result=>{
+			console.log(result);
+			racs=result;	
+		}).catch(err=>{
+			console.log("selectRentalApplyById error:");
+			console.log(err.message);
+		}).finally(()=>{
+		});
+		let racNew = racs[0];
+		let id=this.Rental_Apply__c.Id;
+		let Status__c="濉啓瀹屾瘯";
+		let userId;
+		await getUserId().then(result=>{
+			console.log(result);
+			userId=result;	
+		}).catch(err=>{
+			console.log("getUserId error:");
+			console.log(err.message);
+		}).finally(()=>{
+		});
+		let manageUsers;
+		await selectUserById({recordId:userId}).then(result=>{
+			console.log(result);
+			manageUsers=result;	
+		}).catch(err=>{
+			console.log("selectUserById error:");
+			console.log(err.message);
+		}).finally(()=>{
+		});
+		let SalesManagerSubmit__c;
+		let OPDManagerApprover__c;
+		let BuchangApprovalManagerSalesSubmit__c;
+		let OPDBuchangApprover__c;
+		if(manageUsers[0].JingliEquipmentManager__c != null){
+			SalesManagerSubmit__c = manageUsers[0].JingliEquipmentManager__r.Name;
+		// 20220930 ljh SWAG-CJR8S7 start
+			if(racNew.OPDPlan__c != null){
+				OPDManagerApprover__c = SalesManagerSubmit__c == racNew.OPDPlan__r.SalesManager_Txt__c?SalesManagerSubmit__c:' ';
+			}
+		// 20220930 ljh SWAG-CJR8S7 end
+		}
+		if(manageUsers[0].Buzhang_Equipment_Manager__c != null){
+			BuchangApprovalManagerSalesSubmit__c = manageUsers[0].Buzhang_Equipment_Manager__r.Name; //2022-07-22 zyh
+		// 20220930 ljh SWAG-CJR8S7 start
+			if(racNew.OPDPlan__c != null){
+				OPDBuchangApprover__c = BuchangApprovalManagerSalesSubmit__c == racNew.OPDPlan__r.BuchangApprovalManagerSales_Txt__c?BuchangApprovalManagerSalesSubmit__c:' ';
+			}
+		// 20220930 ljh SWAG-CJR8S7 end
+		}
+		let resultt;
+		await updateRentalApplyC({
+			recordId:id,
+			SalesManagerSubmitC:SalesManagerSubmit__c,
+			StatusC:Status__c,
+			OPDManagerApproverC:OPDManagerApprover__c,
+			BuchangApprovalManagerSalesSubmitC:BuchangApprovalManagerSalesSubmit__c,
+			OPDBuchangApproverC:OPDBuchangApprover__c
+		}).then(res=>{
+			console.log(res);
+			if(res!=null&&res.success==false){
+				resultt=res;
+				let messages ="";
+				messages=resultt.errors[0].split(',')[1];
+				if (messages!=null&&messages!="") {
+					console.log("hhh26");
+					alert("鎿嶄綔澶辫触,閿欒淇℃伅:"+messages);
+					return;
+				}
+			}
+		}).catch(err=>{
+			console.log("updateRentalApplyC error:");
+			console.log(err.message);
+		}).finally(()=>{
+			console.log("finally");
+			console.log(resultt);
+		});
+
+		this.dispatchEvent(new CloseActionScreenEvent());
+	};
+
+	getConnectDMLErrorMessages (results) {
+		console.log("in 1");
+		console.log(results);
+		let messages = [];
+		let	i = 0;
+		let	len = results.length;
+		let	r;
+		console.log("in 1.1");
+		for (; i < len; i++) {
+			console.log("in 1.2");
+			r = results[i];
+			console.log("in 1.3");
+			if (r.success==false) {
+				console.log("in 1.4");
+				messages = messages.concat(this.getConnectDMLMessagesOfAResult(r));
+			}
+		}
+		console.log("in 1");
+		console.log("1缁撴灉");
+		console.log(messages);
+		return messages;
+	};
+	getConnectDMLMessagesOfAResult(res) {
+		console.log("in 2");
+		console.log(res);
+		let messages = [];
+		let	errors = res.errors;
+		let	i = 0;
+		let	len = errors.length;
+		let	e;
+		for (; i < len; i++) {
+			e = errors[i];
+			console.log("in 2.1");
+			messages.push(e + " " + this.getConnectDMLErrorFields(errors));
+			console.log("3缁撴灉");
+			console.log(this.getConnectDMLErrorFields(errors));
+			console.log("in 2.2");
+		}
+		console.log("in 2");
+		console.log("2缁撴灉");
+		console.log(messages);
+		return messages;
+	};
+	
+	getConnectDMLErrorFields (error) {
+		console.log("in 3");
+		console.log(error);
+		let fields = error;
+		if (fields.length > 0) {
+			console.log("in 3");
+			return "[" + fields + ",]"
+		} 
+		else {
+			console.log("in 3");
+			return "";
+		}
+
+	};
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js-meta.xml b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js-meta.xml
new file mode 100644
index 0000000..9ac5a4a
--- /dev/null
+++ b/force-app/main/default/lwc/rentalApplyLWT/rentalApplyLWT.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="rentalApplyLWT">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__AppPage</target>
+        <target>lightning__RecordPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1