From f0c4f051972b316dcdb9a03f22bfd9f40f6f4464 Mon Sep 17 00:00:00 2001
From: liwentao <1376563863@qq.com>
Date: 星期二, 18 四月 2023 16:06:16 +0800
Subject: [PATCH] 借出备品详情一览:取消,提交延期申请,清空回寄运输单,出库指示(李文涛)
---
force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js | 332 ++++++++++---
force-app/main/default/classes/SelectSubstituteControllerLWT.cls | 633 +++++++++++++++++++++++++++
force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js-meta.xml | 10
force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.html | 5
force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js | 158 ++++++
force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js-meta.xml | 11
/dev/null | 4
force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js | 53 ++
force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.css | 11
force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js-meta.xml | 11
force-app/main/default/classes/SelectSubstituteControllerLWT.cls-meta.xml | 5
force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.html | 5
force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.css | 11
force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js | 107 ++++
force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js-meta.xml | 11
force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.html | 5
16 files changed, 1,275 insertions(+), 97 deletions(-)
diff --git a/.husky/pre-commit b/.husky/pre-commit
deleted file mode 100644
index feac116..0000000
--- a/.husky/pre-commit
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
-npm run precommit
\ No newline at end of file
diff --git a/force-app/main/default/classes/SelectSubstituteControllerLWT.cls b/force-app/main/default/classes/SelectSubstituteControllerLWT.cls
new file mode 100644
index 0000000..e184b48
--- /dev/null
+++ b/force-app/main/default/classes/SelectSubstituteControllerLWT.cls
@@ -0,0 +1,633 @@
+public with sharing class SelectSubstituteControllerLWT {
+ public SelectSubstituteControllerLWT() {
+
+ }
+ @AuraEnabled
+ public static InitData initFromSelectSubstituteButton(String recordId){
+ InitData res = new InitData();
+ try{
+ Rental_Apply_Equipment_Set__c report=[select
+ Id,Rental_Apply__r.Status__c,Rental_Apply__r.Id
+ from Rental_Apply_Equipment_Set__c
+ where Id= :recordId];
+ res.id=report.Id;
+ res.RentalApplyId=report.Rental_Apply__r.Id;
+ res.Status=report.Rental_Apply__r.Status__c;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return res;
+ }
+
+ @AuraEnabled
+ public static Rental_Apply_Equipment_Set__c initFromCustomSubmitButton(String recordId){
+
+ try{
+ Rental_Apply_Equipment_Set__c report=[select
+ Id,Request_extend_day__c
+ ,Extend_request_reason__c
+ ,Rental_End_Date__c,
+ Rental_Apply__c
+ from Rental_Apply_Equipment_Set__c
+ where Id= :recordId];
+
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+ @AuraEnabled
+ public static InitData initFromLoanerArrangedEmailLButton(String recordId){
+ InitData res = new InitData();
+ try{
+ Rental_Apply_Equipment_Set__c report=[select
+ Id,Rental_Apply__r.Status__c,Rental_Apply__c,Rental_Apply__r.Wei_Assigned_Cnt__c,
+ Assigned_Not_Shipment__c,Rental_Apply__r.Bollow_Date__c
+ from Rental_Apply_Equipment_Set__c
+ where Id= :recordId];
+ res.id=report.Id;
+ res.RentalApplyC=report.Rental_Apply__c;
+ res.Status=report.Rental_Apply__r.Status__c;
+ res.WeiAssignedCntC=report.Rental_Apply__r.Wei_Assigned_Cnt__c;
+ res.BollowDateC=report.Rental_Apply__r.Bollow_Date__c;
+ res.AssignedNotShipmentC=report.Assigned_Not_Shipment__c;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return res;
+ }
+
+ @AuraEnabled
+ public static InitData initClearReturnDeliverySlipButton(String recordId){
+ InitData res = new InitData();
+ try{
+ Rental_Apply_Equipment_Set__c report=[select
+ Id,Rental_Apply__r.Status__c,Rental_Apply__c,Rental_Apply__r.Wei_Assigned_Cnt__c,
+ Assigned_Not_Shipment__c,Rental_Apply__r.Bollow_Date__c
+ from Rental_Apply_Equipment_Set__c
+ where Id= :recordId];
+ res.id=report.Id;
+ res.RentalApplyC=report.Rental_Apply__c;
+ res.Status=report.Rental_Apply__r.Status__c;
+ res.WeiAssignedCntC=report.Rental_Apply__r.Wei_Assigned_Cnt__c;
+ res.BollowDateC=report.Rental_Apply__r.Bollow_Date__c;
+ res.AssignedNotShipmentC=report.Assigned_Not_Shipment__c;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return res;
+ }
+
+ @AuraEnabled
+ public static Rental_Apply_Equipment_Set__c selectRentalApplyEquipmentSetByID(String recordId){
+ try{
+ Rental_Apply_Equipment_Set__c report=[select
+ Cancel_Select__c,Irreplaceable_flag__c,RAES_Status__c,Shippment_loaner_time2__c
+ from Rental_Apply_Equipment_Set__c
+ where Id=:recordId];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+ @AuraEnabled
+ public static list<Rental_Apply_Equipment_Set_Detail__c> selectRentalApplyEquipmentSetByRACID(String recordId){
+ try{
+ list<Rental_Apply_Equipment_Set_Detail__c> report=[select Allow_Adjust_Queue_Flag__c
+ from Rental_Apply_Equipment_Set_Detail__c
+ where Rental_Apply__c = :recordId ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+
+ @AuraEnabled
+ public static list<Rental_Apply__c> selectRentalApplyCByName(String recordId){
+ try{
+ list<Rental_Apply__c> report=[select
+ Id,Campaign__c,Repair__c,Status__c, Demo_purpose1__c,Contract_pdf_updated__c,Repair_Final_Inspection_Date_F__c,RC_return_to_office__c
+ from Rental_Apply__c
+ where id=:recordId ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+ @AuraEnabled
+ public static list<Campaign> selectCampaignById(String recordId){
+ 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_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+ @AuraEnabled
+ public static String getSessionId(){
+ return UserInfo.getSessionId();
+ }
+
+
+ @AuraEnabled
+ public static list<Rental_Apply_Equipment_Set__c> selectRaesById1(String recordId){
+ try{
+ list<Rental_Apply_Equipment_Set__c> report=[select Id
+ from Rental_Apply_Equipment_Set__c
+ where Rental_Apply__c = :recordId
+ and Shippment_loaner_time2__c != null
+ and RAES_Status__c != '宸插垎閰�'
+ and RAES_Status__c != '鍙栨秷鍒嗛厤'
+ ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+ @AuraEnabled
+ public static list<Rental_Apply_Equipment_Set__c> selectRaesById2(String recordId){
+ try{
+ list<Rental_Apply_Equipment_Set__c> report=[select Id
+ from Rental_Apply_Equipment_Set__c
+ where Rental_Apply__c = :recordId
+ and RAES_Status__c != '宸插垎閰�'
+ and RAES_Status__c != '鍙栨秷鍒嗛厤'
+ ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+ @AuraEnabled
+ public static list<Rental_Apply__c> selectRacById(String recordId){
+ try{
+ list<Rental_Apply__c> report=[SELECT
+ Id, JingliApprovalManager__c, SalesManager__c
+ , BuchangApprovalManager__c
+ , BuchangApprovalManagerSales__c
+ , ZongjianApprovalManager__c
+ FROM Rental_Apply__c
+ WHERE Id = :recordId
+ ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+ @AuraEnabled
+ public static UpdateResult updateRaesc(
+ String recordId,
+ String JingliApprovalManagerc,
+ String SalesManagerc,
+ String BuchangApprovalManagerc,
+ String BuchangApprovalManagerSalesc,
+ String ZongjianApprovalManagerc,
+ String ExtendStatusc
+ ) {
+ UpdateResult result = new UpdateResult();
+ result.recordId = recordId;
+ try{
+ // 鏇存柊璁板綍骞惰幏鍙栫粨鏋�
+ if(recordId==null) return null;
+ Rental_Apply_Equipment_Set__c rac = new Rental_Apply_Equipment_Set__c( id=recordId);
+
+ if(JingliApprovalManagerc!=null&& JingliApprovalManagerc != ''){
+ rac.JingliApprovalManager__c=JingliApprovalManagerc;
+ }
+ if(SalesManagerc!=null&&SalesManagerc!=''){
+ rac.SalesManager__c=SalesManagerc;
+ }
+ if(BuchangApprovalManagerc!=null&&BuchangApprovalManagerc!=''){
+ rac.BuchangApprovalManager__c=BuchangApprovalManagerc;
+ }
+ if(BuchangApprovalManagerSalesc!=null&&BuchangApprovalManagerSalesc!=''){
+ rac.BuchangApprovalManagerSales__c=BuchangApprovalManagerSalesc;
+ }
+
+ if(ZongjianApprovalManagerc!=null&&ZongjianApprovalManagerc!=''){
+ rac.ZongjianApprovalManager__c=ZongjianApprovalManagerc;
+ }
+ if(ExtendStatusc!=null&&ExtendStatusc!=''){
+ rac.Extend_Status__c=ExtendStatusc;
+ }
+ 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;
+ }
+
+ @AuraEnabled
+ public static UpdateResult updateRaescList(
+ list<Rental_Apply_Equipment_Set_Detail__c> updateList
+ ) {
+ UpdateResult result = new UpdateResult();
+ try{
+ for(Rental_Apply_Equipment_Set_Detail__c item : updateList) {
+ item.Return_DeliverySlip__c = null;
+ item.Asset_return_time__c = null;
+ }
+ update updateList;
+ 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;
+ }
+
+ @AuraEnabled
+ public static list<Rental_Apply_Equipment_Set_Detail__c> selectRaesdcId(String recordId){
+ try{
+ list<Rental_Apply_Equipment_Set_Detail__c> report=[Select
+ Id
+ From Rental_Apply_Equipment_Set_Detail__c
+ Where Return_DeliverySlip__c != null
+ AND Check_lost_Item_F__c = null
+ AND Rental_Apply_Equipment_Set__c = :recordId AND Cancel_Select__c = false
+ ];
+ return report;
+ }catch(Exception e){
+ System.debug(LoggingLevel.INFO,'Rental_Apply_Equipment_Set__c Cancel Error : ' + e);
+ }
+ return null;
+ }
+
+ @AuraEnabled
+ public static String approvalCheck(String rentalApplyId) {
+ // check缁撴灉
+ String returnStr = '';
+
+ //1388 yc 20211021 璺ㄥ尯鍩熷垎閰嶄笉鑳藉嚭搴� start
+ String rasdid = '';
+ system.debug(rentalApplyId+'==');
+ if(String.isNotBlank(rentalApplyId) && rentalApplyId.indexOf(';') >= 0){//璇存槑鏄粠涓�瑙堜笂瑙﹀彂鐨�
+ rasdid = rentalApplyId.subString(rentalApplyId.indexOf(';') + 1);
+ rentalApplyId = rentalApplyId.subString(0, rentalApplyId.indexOf(';'));
+ }
+ //1388 yc 20211021 璺ㄥ尯鍩熷垎閰嶄笉鑳藉嚭搴� end
+ //澶囧搧鍊熷嚭鐢宠
+ Rental_Apply__c[] rentalApply = [select Id,repair__r.Repair_Final_Inspection_Date__c,Bollow_Date__c,repair__r.Return_Without_Repair_Date__c,
+ CreatedDate,Rental_Apply_Equipment_Set_Cnt__c,Prepare_Day__c,Cross_Region_Assign__c,
+ demo_purpose2__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c
+ from Rental_Apply__c
+ where Id = :rentalApplyId];
+ if (rentalApply.size() == 0) {
+ returnStr = '娌℃湁澶囧搧鍊熷嚭鐢宠锛岃纭銆�';
+ return returnStr;
+ }
+ Rental_Apply__c ra = rentalApply[0];
+ if (ra.Rental_Apply_Equipment_Set_Cnt__c <= 0) {
+ returnStr = '娌℃湁鍊熷嚭澶囧搧set涓�瑙堬紝璇风‘璁ゃ��';
+ return returnStr;
+ }
+ //1822 yc 20211111 start
+ if(ra.demo_purpose2__c=='宸茶喘寰呰揣' && ra.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c!= null){
+ returnStr = '宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩锛屼笉鍙嚭搴撴寚绀�';
+ return returnStr;
+ }
+ if(ra.demo_purpose2__c=='绱㈣禂QIS' && ra.next_action__c=='鏃犲伩鏇存崲' && ra.QIS_number__r.ReplaceDeliveryDate__c!= null){
+ returnStr = '绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃ワ紝涓嶅彲鍑哄簱鎸囩ず';
+ return returnStr;
+ }
+ //1822 yc 20211111 end
+
+//*************************Insert 20160826 SWAG-AD59Z6 瓒欏境鑺� Start*************************//
+ if(Ra.repair__r.Repair_Final_Inspection_Date__c != null) {
+ return '淇悊鏈�缁堟娴嬫棩涓嶄负绌猴紝涓嶈兘鍋氬嚭搴撴寚绀�';
+ }
+ if(Ra.repair__c!=null&&Ra.repair__r.Return_Without_Repair_Date__c != null) {
+ return '鏈慨鐞嗗綊杩樻棩涓嶄负绌猴紝涓嶈兘鍋氬嚭搴撴寚绀�';
+ }
+//*************************Insert 20160826 SWAG-AD59Z6 瓒欏境鑺� End***************************//
+
+ //1388 yc 20211021 璺ㄥ尯鍩熷垎閰嶄笉鑳藉嚭搴� start
+ if(String.isNotBlank(ra.Cross_Region_Assign__c)){
+ String soql = 'select Id, Name,Rental_Apply__c,Internal_asset_location_before__c';
+ soql +=' from Rental_Apply_Equipment_Set_Detail__c';
+ soql +=' where Rental_Apply__c = \'' + ra.Id +'\'';
+ soql +=' and Internal_asset_location_before__c !=null and Internal_asset_location_before__c != \'' + ra.Cross_Region_Assign__c+ '\'';
+
+ if(String.isNotBlank(rasdid)){
+ soql +=' and Rental_Apply_Equipment_Set__c = :rasdid';
+ }
+ List<Rental_Apply_Equipment_Set_Detail__c> raesd = Database.query(soql);
+ if(raesd.size()>0){
+ returnStr = '鍒嗛厤鐨勫鍝佷笉鏄偍鎵�灞炲鍝佷腑蹇冪殑澶囧搧锛屼笉鑳藉仛鍑哄簱鎸囩ず';
+ return returnStr;
+ }
+
+ }
+ //1388 yc 20211021 璺ㄥ尯鍩熷垎閰嶄笉鑳藉嚭搴� end
+ // 20220211 ljh add 澶囧搧FY23璇鹃01 start
+ // AggregateResult[] resultsRas = [SELECT Rental_Start_Date__c,count(Id) cnt
+ // FROM Rental_Apply_Equipment_Set__c
+ // WHERE Rental_Apply__c = :rentalApplyId
+ // AND Cancel_Select__c = false
+ // group by Rental_Start_Date__c];
+ // If(resultsRas.size() > 1){
+ // returnStr = '鎵�鏈変竴瑙堝鍝侀璁″嚭璐ф棩搴斾竴鑷达紝涓嶄竴鑷翠笉鑳藉仛鍑哄簱鎸囩ず';
+ // return returnStr;
+ // }
+ // 20220211 ljh add 澶囧搧FY23璇鹃01 end
+
+//bp2 // 澶囧搧鍊熷嚭鍘嗗彶鍙栧緱
+// List<String> equipmentSetList = new List<String>();
+// Rental_Apply_Equipment_Set__c[] raes = [
+// select Id, Name, Equipment_Set__c, Equipment_Set__r.Name, Rental_Start_Date__c, Rental_End_Date__c, Rental_Apply__c
+// from Rental_Apply_Equipment_Set__c
+// where Rental_Apply__c = :rentalApplyId and Cancel_Select__c = false];
+// // 鏃ュ巻鑼冨洿锛屾渶灏忕殑鍊熷嚭寮�濮嬫棩鍒版渶澶х殑鍊熷嚭缁堜簡鏃�
+// Date startDate = Date.today();
+// Date endDate = Date.today();
+// for (Rental_Apply_Equipment_Set__c r : raes) {
+// equipmentSetList.add(r.Equipment_Set__c);
+// if (r.Rental_Start_Date__c != null && r.Rental_Start_Date__c < startDate) {
+// startDate = r.Rental_Start_Date__c;
+// }
+// if (r.Rental_End_Date__c != null && r.Rental_End_Date__c > endDate) {
+// endDate = r.Rental_End_Date__c;
+// }
+// }
+// Integer prepareDay = ra.Prepare_Day__c == null ? Integer.valueOf(System.Label.EquipmentRentalPrepare) : ra.Prepare_Day__c.intValue();
+// Date minDate = getWD_addday(startDate, -1 * prepareDay);
+// Date maxDate = getWD_addday(endDate, prepareDay);
+// // 鍏朵粬澶囧搧鍊熷嚭鐢宠鍘嗗彶
+// Rental_Apply_Equipment_Set__c[] others = [
+// select Id, Name, Rental_Start_Date__c, Rental_End_Date__c, Equipment_Set__c, Rental_Apply__r.Status__c ,Rental_Apply__r.Prepare_Day__c
+// from Rental_Apply_Equipment_Set__c
+// where Rental_Apply__c != :rentalApplyId
+// and Equipment_Set__c in :equipmentSetList
+// and Request_Status__c != '鍙栨秷'
+// and Request_Status__c != '鍒犻櫎'
+// and Cancel_Select__c = false
+// and ((Rental_Start_Date__c >= :minDate and Rental_Start_Date__c <= :maxDate)
+// or (Rental_End_Date__c >= :minDate and Rental_End_Date__c <= :maxDate)
+// or (Rental_Start_Date__c <= :startDate and Rental_End_Date__c >= :endDate))];
+
+// Map<String, List<Rental_Apply_Equipment_Set__c>> othersMap = new Map<String,List<Rental_Apply_Equipment_Set__c>>();
+// for (Rental_Apply_Equipment_Set__c other : others) {
+// if (othersMap.containsKey(other.Equipment_Set__c)) {
+// othersMap.get(other.Equipment_Set__c).add(other);
+// } else {
+// List<Rental_Apply_Equipment_Set__c> l = new List<Rental_Apply_Equipment_Set__c>();
+// l.add(other);
+// othersMap.put(other.Equipment_Set__c, l);
+// }
+// }
+
+// for (Rental_Apply_Equipment_Set__c r : raes) {
+
+// List<Rental_Apply_Equipment_Set__c> other = othersMap.get(r.Equipment_Set__c);
+
+// Map<Date, Map<String, String>> dateMap= new Map<Date, Map<String, String>>();
+// if (other != null) {
+// Date sdate = startDate;
+// Date edate = endDate;
+// for (Rental_Apply_Equipment_Set__c o : other) {
+// if (o.Rental_Start_Date__c != null && (sdate == null || o.Rental_Start_Date__c < sdate)) {
+// sdate = o.Rental_Start_Date__c;
+// }
+// if (o.Rental_End_Date__c != null && (edate == null || o.Rental_End_Date__c > edate)) {
+// edate = o.Rental_End_Date__c;
+// }
+// }
+// if (sdate != null && edate != null) {
+// RentalApplyWebService raws = new RentalApplyWebService();
+// dateMap = raws.getDateMap(sdate, edate, prepareDay);
+// }
+// }
+
+// if (r.Rental_Start_Date__c == null && r.Rental_End_Date__c == null) {
+// // 娓呯┖璇ュ�熷嚭鍘嗗彶鐨勫嚭搴撳拰鍥炴敹鏃堕棿
+// } else if (other == null || other.size() == 0) {
+// // 涓庡叾浠栧�熷嚭鍘嗗彶娌℃湁鍐茬獊
+// } else {
+// Date fromDate = r.Rental_Start_Date__c;
+// Date toDate = r.Rental_End_Date__c;
+// for (Rental_Apply_Equipment_Set__c o : other) {
+// if (o.Rental_Apply__r.Status__c != '鑽夋涓�' && o.Rental_Apply__r.Status__c != '鐢宠涓�' && o.Rental_Apply__r.Status__c != null) {
+// Date startD = o.Rental_Start_Date__c;
+// Date endD = o.Rental_End_Date__c;
+// Integer prepare = prepareDay; //>= o.Rental_Apply__r.Prepare_Day__c || o.Rental_Apply__r.Prepare_Day__c == null ? prepareDay : o.Rental_Apply__r.Prepare_Day__c.intValue();
+// if ((dateMap.containsKey(fromDate) && Date.valueOf(dateMap.get(fromDate).get('Next')) > startD && dateMap.containsKey(endD) && fromDate < Date.valueOf(dateMap.get(endD).get('Next'))) ||
+// (dateMap.containsKey(toDate) && Date.valueOf(dateMap.get(toDate).get('Next')) > startD && dateMap.containsKey(endD) && toDate < Date.valueOf(dateMap.get(endD).get('Next'))) ||
+// (dateMap.containsKey(fromDate) && Date.valueOf(dateMap.get(fromDate).get('Next')) <= startD && dateMap.containsKey(endD) && toDate >= Date.valueOf(dateMap.get(endD).get('Next')))) {
+// returnStr = '澶囧搧' + r.Equipment_Set__r.Name + '鐨勫�熷嚭鏃ヤ笌澶囧搧鍊熷嚭鍘嗗彶' + o.Name + '鏈夊啿绐侊紝璇风‘璁ゃ��';
+// return returnStr;
+// }
+// }
+// }
+// }
+// }
+ return '1';
+ }
+
+ @AuraEnabled
+ public static String setShipment_requests(String raid, String raesid) {
+ Savepoint sp = Database.setSavepoint();
+
+ try {
+ //涓�瑙堟儏鍐典笅妫�绱竴瑙堝搴旂殑鐢宠涔d锛宻oql瀛愭煡璇笉鑳藉拰涓绘煡璇㈡槸鍚屼竴涓〃锛屽崟鐙绱竴娆�
+ if (String.isBlank(raid)) {
+ List<Rental_Apply_Equipment_Set__c> raList = [select Id, Rental_Apply__c from Rental_Apply_Equipment_Set__c where id = :raesid];
+ if (raList.size() > 0) {
+ raid = raList[0].Rental_Apply__c;
+ } else {
+ //搴旇涓嶄細鍒拌繖閲�
+ return '娌℃湁鍙互鍑哄簱鎸囩ず鐨勪竴瑙�';
+ }
+ }
+ String soql = 'SELECT Id'
+ + ' FROM Rental_Apply_Equipment_Set__c '
+ + ' WHERE Shippment_loaner_time2__c <> null '
+ + ' AND Rental_Apply__c = :raid '
+ + ' ORDER BY Id' ;
+ List<Rental_Apply_Equipment_Set__c> shippedRaesList = Database.query(soql);
+ String raesStrShipped = '';
+ for (Rental_Apply_Equipment_Set__c raes : shippedRaesList) {
+ raesStrShipped += raes.Id;
+ }
+
+ //Srring soql = "SELECT Id FROM Rental_Apply_Equipment_Set_Detail__c WHERE Rental_Apply__c = '{!Rental_Apply__c.Id}' AND Cancel_Select__c = false AND Rental_Num__c > 0 AND Rental_Apply_Equipment_Set__r.Wei_Assigned_Cnt__c = 0 AND Rental_Apply_Equipment_Set__r.Yi_Assigned_Cnt__c > 0 AND Shipment_request__c = false";
+ soql = 'SELECT Id, Rental_Apply__c, Rental_Apply_Equipment_Set__c'
+ + ' FROM Rental_Apply_Equipment_Set_Detail__c '
+ + ' WHERE ' + (String.isNotBlank(raesid) ? 'Rental_Apply_Equipment_Set__c = :raesid ' : 'Rental_Apply__c = :raid ')
+ + ' AND Cancel_Select__c = false '
+ + ' AND Rental_Num__c > 0 '
+ + ' AND Rental_Apply_Equipment_Set__r.Wei_Assigned_Cnt__c = 0 '
+ + ' AND Rental_Apply_Equipment_Set__r.Yi_Assigned_Cnt__c > 0 '
+ + ' AND Shipment_request__c = false'
+ + ' ORDER BY Rental_Apply_Equipment_Set__c, Id';
+ List<Rental_Apply_Equipment_Set_Detail__c> raesds = Database.query(soql);
+
+ Map<Id, List<String>> rental_Asset_SerialNumberMap = new Map<Id, List<String>>();
+
+ if (raesds.size() < 1) {
+ return '娌℃湁鍙互鍑哄簱鎸囩ず鐨勪竴瑙�';
+ } else {
+ Set<Id> raesSet = new Set<Id>();
+ String raesStrRequest = '';
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : raesds) {
+ if (false == raesSet.contains(raesd.Rental_Apply_Equipment_Set__c)) {
+ raesSet.add(raesd.Rental_Apply_Equipment_Set__c);
+ raesStrRequest += raesd.Rental_Apply_Equipment_Set__c;
+ }
+ raesd.Shipment_request_time2__c = Datetime.now();
+ raesd.Shipment_request__c = true;
+ }
+ // 鍑哄簱鍚�, 鍐嶆鍋氬嚭搴撴寚绀虹殑涓�瑙�, 涓�瀹氳涓嚭杩囧簱鐨勪竴瑙堜竴鏍�
+ if (false == String.isBlank(raesStrShipped) && raesStrRequest != raesStrShipped) {
+ return '涓嶈兘鍋氬嚭搴撴寚绀猴紝闇�瑕佸垎鍗曞悗鍐嶆搷浣�';
+ }
+ }
+
+ // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 start
+ List<Rental_Apply_Equipment_Set__c> RAESRecords = [
+ SELECT Id,Rental_Start_Date__c
+ FROM Rental_Apply_Equipment_Set__c
+ WHERE Rental_Apply__c = :raid
+ AND Cancel_Select__c = False];
+
+ for (Integer i = 0; i < RAESRecords.size(); i++) {
+ // 澶囧搧棰勮鍑哄簱鏃ヤ笉涓�鑷达紝涓嶅彲鍑哄簱鎸囩ず
+ if (RAESRecords[i].Rental_Start_Date__c != RAESRecords[0].Rental_Start_Date__c) {
+ return '澶囧搧棰勮鍑鸿揣鏃ヤ笉涓�鑷达紝涓嶅彲鍑哄簱鎸囩ず';
+ }
+ }
+ // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 end
+
+ Rental_Apply__c ra = new Rental_Apply__c(Id = raesds[0].Rental_Apply__c, Status__c = '宸插嚭搴撴寚绀�');
+ update ra;
+ Database.SaveResult[] results = Database.update(raesds);
+ Database.SaveResult dmlResult = results[0];
+ if (dmlResult.isSuccess()) {
+ //鏄庣粏鏇存柊鎴愬姛鍚庢墠鏇存柊涓�瑙堢殑Rental_Asset_SerialNumber__c
+ soql = 'SELECT Id, SerialNumber_text__c, Rental_Apply_Equipment_Set__c '
+ +'FROM Rental_Apply_Equipment_Set_Detail__c '
+ +'WHERE Rental_Apply__c = \'' + raesds[0].Rental_Apply__c + '\''
+ +'AND Shipment_request_time2__c != null '
+ +'AND Shipment_request__c = true '
+ +'AND SerialNumber_text__c != null '
+ +'ORDER BY Rental_Apply_Equipment_Set__c ';
+
+
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdSerialNumbers = Database.query(soql);
+
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdSerialNumbers) {
+
+ if (!rental_Asset_SerialNumberMap.containsKey(raesd.Rental_Apply_Equipment_Set__c)) {
+ // Asset__r.SerialNumber + ','
+ rental_Asset_SerialNumberMap.put(raesd.Rental_Apply_Equipment_Set__c, new List<String>());
+ }
+ rental_Asset_SerialNumberMap.get(raesd.Rental_Apply_Equipment_Set__c).add(raesd.SerialNumber_text__c);
+ }
+
+ List<Rental_Apply_Equipment_Set__c> raess = new List<Rental_Apply_Equipment_Set__c>();
+ for (Id key : rental_Asset_SerialNumberMap.keySet()) {
+ raess.add(new Rental_Apply_Equipment_Set__c(Id = key,
+ Rental_Asset_SerialNumber__c = ',' + String.join(rental_Asset_SerialNumberMap.get(key), ',') + ','));
+ }
+ if (!raess.isEmpty()) {
+ update raess;
+ }
+
+ return '鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�';
+ } else {
+ Database.rollback(sp);
+ Database.Error emsg = dmlResult.getErrors()[0];
+ return 'failed to update:' + emsg.getFields() + ' ' + emsg.getMessage();
+ }
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ return ex.getMessage();
+ }
+ }
+
+ @AuraEnabled
+ public static String postponeCheck(String endDate, Integer d) {
+ Date before5day = getWD_addday(date.parse(endDate), d);
+ if (Date.today() > before5day) {
+ return System.Label.EquipmentRentalPostponeOverDeadline;
+ }
+ return 'OK';
+ }
+
+ public static Date getWD_addday(Date d, Integer i) {
+ if (d == Date.valueOf('4000-12-31')) {
+ return d;
+ }
+ if (i >= 0) {
+ List<OlympusCalendar__c> workday = [
+ select Id, Date__c, IsWorkDay__c
+ from OlympusCalendar__c
+ where Date__c >= :d
+ and IsWorkDay__c = 1
+ order by Date__c
+ limit :(i+1)];
+ Date selectDate = workday[i].Date__c;
+ return selectDate;
+ } else {
+ i = Math.abs(i);
+ List<OlympusCalendar__c> workday = [
+ select Id, Date__c, IsWorkDay__c
+ from OlympusCalendar__c
+ where Date__c <= :d
+ and IsWorkDay__c = 1
+ order by Date__c desc
+ limit :(i+1)];
+ Date selectDate = workday[i].Date__c;
+ return selectDate;
+ }
+ }
+
+
+ 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 id;
+ @AuraEnabled
+ public String RentalApplyId;
+ @AuraEnabled
+ public String Status;
+ @AuraEnabled
+ public String RentalApplyC;
+ @AuraEnabled
+ public Decimal WeiAssignedCntC;
+ @AuraEnabled
+ public Date BollowDateC;
+ @AuraEnabled
+ public Decimal AssignedNotShipmentC;
+ }
+}
diff --git a/force-app/main/default/classes/SelectSubstituteControllerLWT.cls-meta.xml b/force-app/main/default/classes/SelectSubstituteControllerLWT.cls-meta.xml
new file mode 100644
index 0000000..d75b058
--- /dev/null
+++ b/force-app/main/default/classes/SelectSubstituteControllerLWT.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/lexCancelSelect/lexCancelSelect.html b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.html
new file mode 100644
index 0000000..08c3ae1
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="Holder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ </div>
+</template>
diff --git a/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js
new file mode 100644
index 0000000..193e3d7
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js
@@ -0,0 +1,53 @@
+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 { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class lexCancelSelect extends LightningElement {
+ @api recordId;
+ IsLoading=true;
+ id;
+ RentalApplyId;
+ Status;
+ @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;
+ }
+ }
+ }
+
+
+
+ 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());
+ });
+ }
+ }).catch(err=>{
+ console.log("error:");
+ console.log(err);
+ }).finally(()=>{
+
+ });
+ }
+
+ async cancelSubmit(){
+ window.open("/apex/EquipmentRentalCancel?raid="+this.RentalApplyId,'cancelSelect','width=500,height=250');
+ }
+}
diff --git a/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js-meta.xml b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js-meta.xml
new file mode 100644
index 0000000..4bb35f7
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSelect/lexCancelSelect.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexCancelSelect">
+ <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>
diff --git a/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.css b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.css
new file mode 100644
index 0000000..e1fe560
--- /dev/null
+++ b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.css
@@ -0,0 +1,11 @@
+.Holder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+
+.container .uiContainerManager{
+ display : none !important;
+}
diff --git a/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.html b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.html
new file mode 100644
index 0000000..be2ae8c
--- /dev/null
+++ b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="Holder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ </div>
+</template>
diff --git a/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js
new file mode 100644
index 0000000..28012eb
--- /dev/null
+++ b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js
@@ -0,0 +1,107 @@
+import { LightningElement,api, track, wire } from 'lwc';
+import {CurrentPageReference} from 'lightning/navigation';
+import { CloseActionScreenEvent } from 'lightning/actions';
+import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId';
+import init from '@salesforce/apex/SelectSubstituteControllerLWT.initClearReturnDeliverySlipButton';
+import updateRaescList from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaescList';
+import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById';
+import selectRaesdcId from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesdcId';
+
+import { loadScript } from 'lightning/platformResourceLoader';
+import { submitForApproval } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+
+export default class lexClearReturnDeliverySlip 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;
+ }
+ }
+ }
+
+
+
+ connectedCallback(){
+ console.log(this.recordId);
+ init({recordId:this.recordId}).then(result=>{
+ console.log(result);
+ if(result!=null){
+ this.Rental_Apply_Equipment_Set__c=result;
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ }
+ }).catch(err=>{
+ console.log("error:");
+ console.log(err);
+ }).finally(()=>{
+
+ });
+ }
+
+
+
+ async cancelSubmit(){
+ console.log("hhh1");
+ var raesId = this.recordId;
+ console.log("hhh2");
+ var result = await selectRaesdcId({recordId:this.recordId});
+ console.log("hhh3");
+ var objs = result;
+ if (objs.length< 1) {
+ // alert('娌℃湁闇�瑕佹竻绌虹殑涓�瑙堟槑缁�');
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:'娌℃湁闇�瑕佹竻绌虹殑涓�瑙堟槑缁�'
+ });
+ this.dispatchEvent(event);
+ } else {
+ console.log("hhh4");
+ var result;
+ console.log("hhh5");
+ await updateRaescList({updateList:objs})
+ .then(res=>{
+ console.log(res);
+ result=res;
+ });
+ console.log("hhh6");
+ if (result.success==true) {
+ console.log("hhh7");
+ // success
+ // alert("鍥炲瘎杩愯緭鍗曚俊鎭凡娓呯┖");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"鍥炲瘎杩愯緭鍗曚俊鎭凡娓呯┖"
+ });
+ this.dispatchEvent(event);
+ setTimeout(function() {
+ location.href = "/"+this.recordId;
+ }, 100);
+ } else {
+ console.log("hhh8");
+ // alert("failed to update:" + result.errors.fields + " " + result[0].errors.message);
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"failed to update:" + result.errors.fields + " " + result[0].errors.message
+ });
+ this.dispatchEvent(event);
+ }
+ }
+ }
+}
diff --git a/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js-meta.xml b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js-meta.xml
new file mode 100644
index 0000000..57176cb
--- /dev/null
+++ b/force-app/main/default/lwc/lexClearReturnDeliverySlip/lexClearReturnDeliverySlip.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexClearReturnDeliverySlip">
+ <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>
diff --git a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.css b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.css
new file mode 100644
index 0000000..e1fe560
--- /dev/null
+++ b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.css
@@ -0,0 +1,11 @@
+.Holder{
+ position: relative;
+ display: inline-block;
+ width: 80px;
+ height: 80px;
+ text-align: center;
+}
+
+.container .uiContainerManager{
+ display : none !important;
+}
diff --git a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.html b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.html
new file mode 100644
index 0000000..e811909
--- /dev/null
+++ b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="Holder" if:true={IsLoading}>
+ <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+ </div>
+</template>
diff --git a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
new file mode 100644
index 0000000..46be221
--- /dev/null
+++ b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
@@ -0,0 +1,158 @@
+import { LightningElement,api, track, wire } from 'lwc';
+import {CurrentPageReference} from 'lightning/navigation';
+import { CloseActionScreenEvent } from 'lightning/actions';
+import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId';
+import init from '@salesforce/apex/SelectSubstituteControllerLWT.initFromCustomSubmitButton';
+import updateRaesc from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaesc';
+import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById';
+import postponeCheck from '@salesforce/apex/SelectSubstituteControllerLWT.postponeCheck';
+
+import { loadScript } from 'lightning/platformResourceLoader';
+import { submitForApproval } from 'lightning/uiRecordApi';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class lexCustomSubmit 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;
+ }
+ }
+ }
+
+
+
+ connectedCallback(){
+ console.log(this.recordId);
+ init({recordId:this.recordId}).then(result=>{
+ console.log(result);
+ if(result!=null){
+ this.Rental_Apply_Equipment_Set__c=result;
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ }
+ }).catch(err=>{
+ console.log("error:");
+ console.log(err);
+ }).finally(()=>{
+
+ });
+ }
+
+
+
+ async cancelSubmit(){
+ console.log("hhh1");
+ if (this.Rental_Apply_Equipment_Set__c.Request_extend_day__c == ""
+ || this.Rental_Apply_Equipment_Set__c.Request_extend_day__c == null
+ || this.Rental_Apply_Equipment_Set__c.Extend_request_reason__c == ""
+ || this.Rental_Apply_Equipment_Set__c.Extend_request_reason__c == null) {
+ // alert("蹇呴』濉啓寤舵湡甯屾湜缁撴潫鏃ワ紝寤舵湡鐢宠鐞嗙敱");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"蹇呴』濉啓寤舵湡甯屾湜缁撴潫鏃ワ紝寤舵湡鐢宠鐞嗙敱"
+ });
+ this.dispatchEvent(event);
+ return;
+ }
+ console.log("hhh2");
+ let rtn;
+ await postponeCheck({
+ endDate:this.Rental_Apply_Equipment_Set__c.Rental_End_Date__c,
+ d:-5
+ }).then(res=>{
+ console.log(res);
+ rtn=res;
+ }).catch(err=>{
+ console.log("err:",err.message);
+ })
+
+ console.log(rtn);
+ if (rtn != "OK") {
+ // alert(rtn);
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:rtn
+ });
+ this.dispatchEvent(event);
+ return;
+ }
+ console.log("hhh3");
+ let resultSet = await selectRacById({recordId:this.Rental_Apply_Equipment_Set__c.Rental_Apply__c})
+ ;
+ let records = resultSet;
+ console.log("hhh4");
+ let result = await updateRaesc({
+ recordId:this.Rental_Apply_Equipment_Set__c.Id,
+ JingliApprovalManagerc:records[0].JingliApprovalManager__c,
+ BuchangApprovalManagerc:records[0].SalesManager__c,
+ BuchangApprovalManagerSalesc:records[0].BuchangApprovalManager__c,
+ ZongjianApprovalManagerc:records[0].BuchangApprovalManagerSales__c,
+ ExtendStatusc:'濉啓瀹屾瘯',
+ });
+ console.log("hhh5");
+ console.log(result);
+ // let messages = getConnectDMLErrorMessages(result);
+ if(result!=null&&result.length>0&&result.errors.length>0){
+ // alert(result.errors[0].split(",")[1]);
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:result.errors[0].split(",")[1]
+ });
+ this.dispatchEvent(event);
+ }
+ 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;
+ // 澶勭悊寮傚父鎯呭喌
+ });
+ }
+}
diff --git a/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js-meta.xml b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js-meta.xml
new file mode 100644
index 0000000..d737898
--- /dev/null
+++ b/force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexCustomSubmit">
+ <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>
diff --git a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
index 3916190..d2dbda3 100644
--- a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
+++ b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
@@ -1,102 +1,258 @@
-import { LightningElement, track, wire, api } from 'lwc';
-import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
+import { LightningElement,api, track, wire } from 'lwc';
+import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
-
-import init from '@salesforce/apex/loanerArrangedEmailController.init';
-import getRentalApplyEquipmentSet from '@salesforce/apex/loanerArrangedEmailController.getRentalApplyEquipmentSet';
-import approvalCheck from '@salesforce/apex/RentalApplyWebService.approvalCheck';
-import setShipment_request from '@salesforce/apex/RentalApplyWebService.approvalCheck';
+import init from '@salesforce/apex/SelectSubstituteControllerLWT.initFromLoanerArrangedEmailLButton';
+import selectRentalApplyCByName from '@salesforce/apex/SelectSubstituteControllerLWT.selectRentalApplyCByName';
+import selectRaesById1 from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesById1';
+import selectRaesById2 from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesById2';
+import getSessionId from '@salesforce/apex/SelectSubstituteControllerLWT.getSessionId';
+import approvalCheck from '@salesforce/apex/SelectSubstituteControllerLWT.approvalCheck';
+import setShipment_requests from '@salesforce/apex/SelectSubstituteControllerLWT.setShipment_requests';
+// import { label } from '@salesforce/label';
+import STATUS_PROCESS_STATE from '@salesforce/label/c.StatusProcessState';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class lexLoanerArrangedEmail extends LightningElement {
- @api recordId;
- IsLoading = true;
+ @api recordId;
+ id;
+ RentalApplyC;
+ Status;
+ Wei_Assigned_Cnt__c;
+ Bollow_Date__c;
+ Assigned_Not_Shipment__c;
+ IsLoading=true;
+ @track statusStringg = STATUS_PROCESS_STATE;
@wire(CurrentPageReference)
- getStateParameters(currentPageReference) {
- if(currentPageReference) {
- const urlValue = currentPageReference.state.recordId;
- if(urlValue) {
- let str = `${urlValue}`;
- this.recordId = str;
+ 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;
}
}
}
- connectedCallback() {
- init({
- recordId: this.recordId
- }).then(result => {
- console.log(this.recordId);
- console.log('result==='+JSON.stringify(result));
- if(result != null) {
- if( result.WeiAssignedCnt > 0 ) {
- alert("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟");
- }else if(result.CampaignStatus == "鍙栨秷") {
- alert("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�");
- }else if (result.RaStatus == "宸插嚭搴撴寚绀�" && result.AssignedNotShipment == 0){
- alert("鎵�鏈夌殑鍊熷嚭澶囧搧Set涓�瑙堥兘杩涜杩囧嚭搴撴寚绀轰簡");
- }else if (result.AssignedNotShipment == 0) {
- alert("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�");
- }else if (result.DemoPurpose1 == "闀挎湡鍊熷嚭" && result.ContractPdfUpdated == 0){
- alert("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功");
- }else if (result.RepairId != '' && (result.RepairFinalInspectionDateF != null && result.RepairFinalInspectionDateF != '') || (result.RCReturnToOffice != null && result.RCReturnToOffice != '')){
- alert("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�");
- }else if (result.IFApproved == "true" && (result.MeetingApprovedNo == null || result.MeetingApprovedNo == "")){
- alert("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��");
- }else if (result.IFApproved == "true" && result.MeetingApprovedNo != "" && result.StatusList.indexOf(records[0].Approved_Status__c) != -1){
- alert("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�");
- }else {
- approvalCheck({
- rentalApplyId: this.recordId
- }).then(res=>{
- if (res != '1') {
- alert(rs1);
- } else {
- //bp2 var rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
- //bp2 if (rs2 != '1') {
- //bp2 alert(rs2);
- //bp2 } else {
- //var rs1 = sforce.apex.execute("RentalApplyWebService", "setShipment_request", {raid : "{!Rental_Apply__c.Id}"});
- setShipment_request({
- raid: this.recordId
- }).then(res=>{
- if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
- alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
- print();
- setTimeout(function() {
- location.href = "/{!Rental_Apply__c.Id}";
- },100);
- }else {
- alert(res);
- }
- }).catch(e=>{
- console.log('approvalCheck==='+e);
- })
- }
- }).catch(e=>{
- console.log('setShipment_request==='+e);
- })
- }
- this.dispatchEvent(new CloseActionScreenEvent());
+
+ connectedCallback(){
+ console.log(this.recordId);
+ init({recordId:this.recordId}).then(result=>{
+ console.log(result);
+ if(result!=null){
+ this.id=result.id;
+ this.RentalApplyC=result.RentalApplyC;
+ this.Status=result.Status;
+ this.Wei_Assigned_Cnt__c=result.WeiAssignedCntC;
+ this.Bollow_Date__c=result.BollowDateC;
+ this.Assigned_Not_Shipment__c=result.AssignedNotShipmentC;
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
}
- })
+ }).catch(err=>{
+ console.log("error:");
+ console.log(err);
+ }).finally(()=>{
+
+ });
}
- print() {
- getRentalApplyEquipmentSet({
- recordId: this.recordId
- }).then(result => {
- window.open("https://ocsm--partial.sandbox.lightning.force.com/apex/FixtureRentalPDF?raid=" + this.recordId + "&page=" + result);
- })
- }
- fixDate(date){
- var Month = fixTime(date.getMonth() + 1);
- var Day = fixTime(date.getDate());
- var UTC = date.toUTCString();
- var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
- var Minutes = fixTime(date.getMinutes());
- var Seconds = fixTime(date.getSeconds());
- return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
+
+ async cancelSubmit(){
+ let campaignStatus = '';
+ let records = null; // 20220217 ljh OBPM甯傚満娲诲姩鑱斿姩
+ console.log("Ff");
+ let statusSting = "{!$Label.StatusProcessState}"; // 20220322 ljh add
+ let statusList = statusSting.split(',');
+ console.log(statusSting);
+ console.log(statusList);
+ console.log(this.statusStringg);
+ let raliveryGood;
+ await selectRentalApplyCByName({recordId:this.RentalApplyC})
+ .then(res=>{
+ console.log(res);
+ if (res!=null) {
+ raliveryGood=res;
+ }
+ }).catch(err=>{
+ console.log("selectRentalApplyCByName err:")
+ console.log(err.message);
+ });
+ console.log(statusSting);
+ console.log(raliveryGood);
+ console.log("ddd");
+ let RentalApply = raliveryGood[0];
+ console.log(RentalApply);
+
+ if(RentalApply.Campaign__c != null&&RentalApply.Campaign__c != '' ) {
+ console.log();
+ let DeliveryGood;
+ // 20220217 ljh update OBPM甯傚満娲诲姩鑱斿姩 start
+ // DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='" + RentalApply.Campaign__c + "'");
+ // let records= DeliveryGood.getArray("records");
+ await selectCampaignById({recordId:RentalApply.Campaign__c}).then(res=>{
+ console.log(res);
+ DeliveryGood=res;
+ });
+ console.log(RentalApply);
+ records = DeliveryGood;
+ console.log(DeliveryGood);
+ // 20220217 ljh update OBPM甯傚満娲诲姩鑱斿姩 end
+
+ campaignStatus = records[0].Status;
+ console.log("hh3");
+ }
+ if(this.Wei_Assigned_Cnt__c > "0") {
+ // alert("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟"
+ });
+ this.dispatchEvent(event);
+ }else if(campaignStatus == '鍙栨秷'){
+ // alert("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�"
+ });
+ this.dispatchEvent(event);
+ }else if (this.Assigned_Not_Shipment__c == "0") {
+ // alert("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�"
+ });
+ this.dispatchEvent(event);
+ } else if (RentalApply.Demo_purpose1__c == "闀挎湡鍊熷嚭" && RentalApply.Contract_pdf_updated__c == "0") {
+ // alert("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功"
+ });
+ this.dispatchEvent(event);
+ } else if(RentalApply.Repair__c != '' && RentalApply.Repair__c != null && (RentalApply.Repair_Final_Inspection_Date_F__c != null && RentalApply.Repair_Final_Inspection_Date_F__c != '') || (RentalApply.RC_return_to_office__c != null && RentalApply.RC_return_to_office__c != '')) {
+ // alert("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�"
+ });
+ this.dispatchEvent(event);
+ // 20220217 ljh add OBPM甯傚満娲诲姩鑱斿姩 start
+ } else if (records != null && records[0].IF_Approved__c == "true" && (records[0].Meeting_Approved_No__c == null || records[0].Meeting_Approved_No__c == "") ) {
+ // alert("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��"
+ });
+ this.dispatchEvent(event);
+ } else if (records != null && records[0].IF_Approved__c == "true" && records[0].Meeting_Approved_No__c != "" && statusList.indexOf(records[0].Approved_Status__c) != -1 ) {
+ // alert("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�"
+ });
+ this.dispatchEvent(event);
+ // 20220217 ljh add OBPM甯傚満娲诲姩鑱斿姩 end
+ } else {
+ console.log("hhhh3");
+ let t=await getSessionId();
+ console.log(t);
+ window.sforce = window.sforce || {};
+ window.sforce.connection = window.sforce.connection || {};
+ window.sforce.connection.sessionId =t;
+ //154p 1388 yc 20211020
+ console.log("hhhh4");
+ let raid = RentalApply.Id+";"+this.id;
+ console.log(raid);
+ let rs1 = await approvalCheck({rentalApplyId:raid});
+ console.log(rs1);
+ if (rs1 != '1') {
+ // alert(rs1);
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:rs1
+ });
+ this.dispatchEvent(event);
+ } else {
+ //bp2 let rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
+ //bp2 if (rs2 != '1') {
+ //bp2 alert(rs2);
+ //bp2 } else {
+ setShipment_requests({raid:null,raesid: this.id}).then(res=>{
+ if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
+ // alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:"鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�"
+ });
+ this.dispatchEvent(event);
+ print().then(res=>{
+ setTimeout(function() {location.href = "/"+this.RentalApplyC;}, 100);
+ });
+ } else {
+ // alert(res);
+ const event = new ShowToastEvent({
+ title: '鎻愮ず淇℃伅',
+ message:res
+ });
+ this.dispatchEvent(event);
+ }
+ })
+ // sforce.apex.execute("RentalApplyWebService", "setRaesShipment_request",
+ // {raesid: this.id}
+ // ,function(res) {
+ // if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
+ // alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
+ // print().then(res=>{
+ // setTimeout(function() {location.href = "/"+this.RentalApplyC;}, 100);
+ // });
+ // } else {
+ // alert(res);
+ // }
+ // });
+ }
+ }
+
+ async function print(){
+ let sqlResult;
+ if(this.Bollow_Date__c != ''){
+ await selectRaesById1({recordId:RentalApply.Id}).then(res=>{
+ sqlResult=res;
+ });
+ }else{
+ await selectRaesById2({recordId:RentalApply.Id}).then(res=>{
+ sqlResult=res;
+ });
+ }
+ let records = sqlResult;
+ let size =records.length;
+ let length = size%10 ==0? size/10 : parseInt(size/10) +1;
+ for(let i =0;i<length;i++){
+ window.open('/apex/FixtureRentalPDF?raid=' + RentalApply.Id + '&page=' + i);
+ }
+ }
+
+
+ // function fixTime(time){
+ // if(time < 10) {time = "0" + time};
+ // return time;
+ // }
+
+ // function fixDate(date){
+ // let Month = fixTime(date.getMonth() + 1);
+ // let Day = fixTime(date.getDate());
+ // let UTC = date.toUTCString();
+ // let Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
+ // let Minutes = fixTime(date.getMinutes());
+ // let Seconds = fixTime(date.getSeconds());
+ // return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
+ // }
}
-}
\ No newline at end of file
+}
diff --git a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js-meta.xml b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js-meta.xml
index e261be9..0efa3b8 100644
--- a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js-meta.xml
+++ b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js-meta.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0"?>
-<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
- <apiVersion>54.0</apiVersion>
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexLoanerArrangedEmail">
+ <apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<targets>
- <target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
+ <target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordAction</target>
</targets>
-</LightningComponentBundle>
\ No newline at end of file
+</LightningComponentBundle>
--
Gitblit v1.9.1