From ccd7b0b9f89d2b2538eb5bcdb21eec413061942b Mon Sep 17 00:00:00 2001
From: KKbes <1620284052@qq.com>
Date: 星期三, 19 七月 2023 14:20:31 +0800
Subject: [PATCH] OPD计划

---
 force-app/main/default/classes/LexOPDPostPoneController.cls-meta.xml                                 |    5 
 force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml     |   11 
 force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html                                          |    5 
 force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml |   11 
 force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js              |  139 ++++++++++
 force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js                                    |  122 +++++++++
 force-app/main/default/classes/LexOPDSupplementaryController.cls                                     |   99 +++++++
 force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js                                            |  116 ++++++++
 force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml                                   |   11 
 force-app/main/default/classes/LexOPDPostPoneController.cls                                          |   27 ++
 force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js          |  147 +++++++++++
 force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml                           |   11 
 force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html        |    5 
 force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html            |    5 
 force-app/main/default/classes/LexOPDSupplementaryController.cls-meta.xml                            |    5 
 force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html                                  |    5 
 16 files changed, 724 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/LexOPDPostPoneController.cls b/force-app/main/default/classes/LexOPDPostPoneController.cls
new file mode 100644
index 0000000..0d842f4
--- /dev/null
+++ b/force-app/main/default/classes/LexOPDPostPoneController.cls
@@ -0,0 +1,27 @@
+public with sharing class LexOPDPostPoneController {
+    @AuraEnabled
+    public static OPDPlan__c init(String recordId){
+        OPDPlan__c res = new OPDPlan__c();
+        try{
+                res = [Select Id,Status__c,Name from OPDPlan__c WHERE Id=:recordId];
+
+        }
+        catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+
+    @AuraEnabled
+    public static  List<RecordType> findRecordId(){
+        try{
+            List<RecordType> RecordTypes = [Select Id from RecordType where Name = '鏀规湡' limit 1];
+
+            return RecordTypes;
+        }
+        catch (Exception e) {
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexOPDPostPoneController.cls-meta.xml b/force-app/main/default/classes/LexOPDPostPoneController.cls-meta.xml
new file mode 100644
index 0000000..70f89f4
--- /dev/null
+++ b/force-app/main/default/classes/LexOPDPostPoneController.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>
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexOPDSupplementaryController.cls b/force-app/main/default/classes/LexOPDSupplementaryController.cls
new file mode 100644
index 0000000..efd40d3
--- /dev/null
+++ b/force-app/main/default/classes/LexOPDSupplementaryController.cls
@@ -0,0 +1,99 @@
+public with sharing class LexOPDSupplementaryController {
+    @AuraEnabled
+    public static OPDPlan__c init(String recordId){
+        try{
+            OPDPlan__c res = [SELECT id,OPDPlan_ImplementDate__c,Status__c,
+            OriginalOpdPlanRental__c,Rental_Apply2__c,Account_Laboratory__c,Related_Opportunity1_ID__c,
+            PlanProdDetail__c,Cnt_OPD_LastYear__c,Cnt_OPD_ThisYear__c,Cnt_Rentals__c,
+            lastMonth_Plan__c,SalesManager__c,OPDType__c,OriginalOpdPlanApplication__c,
+            BuchangApprovalManagerSales__c,SalesManager_Txt__c,
+            Name,supplementaryApplication__c 
+                FROM OPDPlan__c
+                    Where Id = : recordId];
+            return res;
+        }
+        catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return null;
+    }
+
+    @AuraEnabled
+    public static OPDPlan__c getTheOPDPlan(String Id){
+        try{
+            OPDPlan__c res = [Select Id, Name,supplementaryApplication__c 
+                FROM OPDPlan__c 
+                    WHERE supplementaryApplication__c = true 
+                    AND OriginalOpdPlanApplication__c = :Id];
+            return res;
+        }
+        catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return null;
+    }
+
+
+    @AuraEnabled
+    public static OPDPlan__c init2(String recordId){
+        try{
+            OPDPlan__c res = [SELECT id,Status__c,RentalReson__c,AttachmentCertificate__c,
+            NeedReport__c,PlanProdDetail__c,Related_Opportunity1_ID__c,Related_Opportunity2_ID__c
+                FROM OPDPlan__c
+                    Where Id = : recordId];
+            return res;
+        }
+        catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return null;       
+
+    }
+
+    @AuraEnabled
+    public static void NewAndUpdateOPDStatus(String Id){
+    try{
+        OPDPlan__c res =new OPDPlan__c();
+        res.Id = Id;
+        res.Status__c='鎻愪氦';
+        update res;
+    }
+    catch (Exception e) {
+        System.debug(LoggingLevel.INFO, '*** e: ' + e);
+    }
+    }
+
+    @AuraEnabled
+    public static OPDPlan__c init3(String recordId){
+        OPDPlan__c res = new OPDPlan__c();
+        try{ 
+            res = [SELECT Id,Name,Status__c,DelayCancel_Reason__c
+            ,Account_Laboratory__c,OPDType__c,RentalReson__c,
+            Related_Opportunity1_ID__c,
+            CorrespondingRepairNo__c,AdditionalSupport__c,Campaign__c,
+            NoOpp_Reason__c,ModelLending__c,ModelLendingProduct__c,
+            PlanProdDetail__c 
+                FROM  OPDPlan__c  WHERE Id = :recordId];
+
+        }
+        catch(Exception e){
+        System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+
+    }
+
+    @AuraEnabled
+    public static OPDPlan__c reapplyFindOPD(String Id){
+        OPDPlan__c res =new OPDPlan__c();
+        try{
+            res =[SELECT Id, Name,Reapply__c 
+                    FROM OPDPlan__c 
+                        WHERE Reapply__c = true AND OriginalOpdPlan__c = :Id];
+        }
+        catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexOPDSupplementaryController.cls-meta.xml b/force-app/main/default/classes/LexOPDSupplementaryController.cls-meta.xml
new file mode 100644
index 0000000..70f89f4
--- /dev/null
+++ b/force-app/main/default/classes/LexOPDSupplementaryController.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>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html
new file mode 100644
index 0000000..c444cc3
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="Attachment" 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/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js
new file mode 100644
index 0000000..440a698
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js
@@ -0,0 +1,139 @@
+// author:kkbes  OPDPlanc_c   鎻愪氦寰呭鎵�
+import LightningConfirm from 'lightning/confirm';
+import { LightningElement, track, wire,api } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+import init  from '@salesforce/apex/LexOPDSupplementaryController.init2';
+import NewAndUpdateOPDStatus  from '@salesforce/apex/LexOPDSupplementaryController.NewAndUpdateOPDStatus';
+
+
+
+const event1 = new ShowToastEvent({
+	            	message:
+	                "鍙湁鑽夋涓墠鍙互杩涜鎻愪氦瀹℃壒!",
+	                variant : 'error'
+});
+const event2 = new ShowToastEvent({
+
+	            	message:
+	                "璇蜂笂浼犳枃浠惰瘉鏄庯紒",
+	                 variant : 'error'
+});
+const event3 = new ShowToastEvent({
+
+	            	message:
+	                "璁″垝鍑哄�熷鍝佷俊鎭繀椤诲~鍐�!",
+	                 variant : 'error'
+});
+
+export default class lexOPDPlanCommitNeedApproval extends LightningElement {
+	@api recordId;
+	OPDPlan;
+	IsLoading=true;
+
+
+	@wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            this.recordId = str;
+          }
+        }
+    }
+
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            if (result != null) {
+                this.OPDPlan = result;
+                this.commitNeedApproval().then(result=>{
+                	this.IsLoading=false;
+                	this.dispatchEvent(new CloseActionScreenEvent());
+                });
+            }
+        }).catch(error => {
+			const eventInItError = new ShowToastEvent({
+
+	           	message:
+	            error.message,
+	            variant : 'error'
+        	});
+        	this.dispatchEvent(eventInItError);
+        });
+
+    }
+
+    async commitNeedApproval(){
+		//0.褰撳墠鐘舵��(鍙湁鑽夋涓墠鍙互杩涜瀹℃壒)
+		var NowStatus = this.OPDPlan.Status__c;
+		//鑾峰彇鍑哄�熺洰鐨�
+		var RentalReson__c = this.OPDPlan.RentalReson__c;
+		//鑾峰彇闄勪欢璇佹槑
+		var AttachmentCertificate__c = this.OPDPlan.AttachmentCertificate__c;
+		//鑾峰彇鏄惁闇�瑕佸~鍐欐姤鍛婁功
+		var NeedReport = this.OPDPlan.NeedReport__c;
+		if(NowStatus != "鑽夋涓�"){
+			this.dispatchEvent(event1);
+			return;
+		}
+		if((RentalReson__c == '婕旂ず'||RentalReson__c == '鏃犳硶杩涘叆鎵嬫湳瀹よ窡鍙�') && !AttachmentCertificate__c && NeedReport=='鍚�'){
+			this.dispatchEvent(event2);
+			return;
+		}
+		// 璁″垝鍑哄�熷鍝佷俊鎭繀椤诲~鍐�
+		var PlanProdDetail = this.OPDPlan.PlanProdDetail__c;
+		if(PlanProdDetail == '' || PlanProdDetail == undefined){
+			this.dispatchEvent(event3);
+			return;
+		}
+		//2.鎻愮ず
+		const result1 = await LightningConfirm.open({
+            message: '涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵',
+            variant: 'headerless',
+            label: 'this is the aria-label value',
+        });
+        if(!result1){
+        	return;
+        }
+		//2022-07-20 zyh
+		var RentalReson = this.OPDPlan.RentalReson__c;
+		var Related_Opportunity1_ID = this.OPDPlan.Related_Opportunity1_ID__c;
+		var Related_Opportunity2_ID = this.OPDPlan.Related_Opportunity2_ID__c;
+		if (RentalReson == "OPD" && (Related_Opportunity1_ID == undefined || Related_Opportunity1_ID == "" ) && (Related_Opportunity2_ID == undefined || Related_Opportunity2_ID == "" ) ){
+			const result2 = await LightningConfirm.open({
+            message: '鏃犺浠稯PD鐢宠灏嗗鎵瑰埌鍓�昏',
+            variant: 'headerless',
+            label: 'this is the aria-label value',
+        	});
+        	if(!result2){
+        		return;
+       		}
+		}
+		//2022-07-20 zyh
+		await NewAndUpdateOPDStatus({Id : this.OPDPlan.Id}).catch(error=>{
+			const eventError = new ShowToastEvent({
+	           	message:
+	            error.message,
+	            error
+        	});
+        	this.dispatchEvent(eventError);
+		});
+
+
+		//4. 杩涚▼鐢熸垚鍣�
+
+		//5. 閲嶆柊鍒锋柊椤甸潰
+		setTimeout(function(){
+		window.location.href = window.location;
+		}, 1500 )
+
+
+    }
+
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml
new file mode 100644
index 0000000..1550a69
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexOPDPlanCommitNeedApproval">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__RecordPage</target>
+        <target>lightning__AppPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html
new file mode 100644
index 0000000..c444cc3
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="Attachment" 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/lexOPDReapply/lexOPDReapply.js b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js
new file mode 100644
index 0000000..d45789a
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js
@@ -0,0 +1,116 @@
+import { LightningElement, track, wire,api } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+
+import init  from '@salesforce/apex/LexOPDSupplementaryController.init3';
+import reapplyFindOPD  from '@salesforce/apex/LexOPDSupplementaryController.reapplyFindOPD';
+const event1 = new ShowToastEvent({
+	            	message:
+	                "鍙湁OPD璁″垝鐘舵�佷负鍙栨秷锛屽苟涓斿欢鏈熷彇娑堢悊鐢变负澶囧搧涓嶈冻鏃舵墠鑳藉啀鐢宠OPD璁″垝",
+	                variant : 'error'
+});
+const event2 = new ShowToastEvent({
+	            	message:
+	                "OPD璁″垝宸茶繘琛岃繃鍐嶇敵璇凤紝鏃犳硶鍐嶆杩涜鍐嶇敵璇�",
+	                variant : 'error'
+});
+export default class lexOPDReapply extends NavigationMixin(LightningElement)  {
+
+	@api recordId;
+	IsLoading=true;
+	OPDPlan;
+	TheOPDPlan;
+
+	@wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            this.recordId = str;
+          }
+        }
+    }
+
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            if (result != null) {
+                this.OPDPlan = result;
+                this.Reapply().then(result=>{
+                	this.IsLoading=false;
+                	this.dispatchEvent(new CloseActionScreenEvent());
+                });
+            }
+        }).catch(error => {
+			const event3 = new ShowToastEvent({
+	           	message:
+	            error.message,
+	            variant : 'error'
+        	});
+        	this.dispatchEvent(event3);
+        });
+
+    }
+
+    async Reapply(){
+	//鐘舵��
+	var status = this.OPDPlan.Status__c;
+	//鍙栨秷寤舵湡鐞嗙敱
+	var dr = this.OPDPlan.DelayCancel_Reason__c;
+	var Opportunity1_ID = this.OPDPlan.Related_Opportunity1_ID__c;
+	if(status != '鍙栨秷' || dr != '澶囧搧涓嶈冻' ){
+		this.dispatchEvent(event1);
+		return;
+	}
+	reapplyFindOPD({Id : this.OPDPlan.Id}).then(result=>{
+		if (result!=null) {
+			this.TheOPDPlan = result;
+		}
+		
+	}).catch(error=>{
+		const eventError = new ShowToastEvent({
+	       	message:
+	        error.message,
+	        variant : 'error'
+        });
+        this.dispatchEvent(eventError);		
+	})
+	if(this.TheOPDPlan != null && this.TheOPDPlan.length > 0){
+		this.dispatchEvent(event2);
+		return;
+	}
+	const defaultFieldValues = encodeDefaultFieldValues({
+		Account_Laboratory__c : this.OPDPlan.Account_Laboratory__c ,
+		OPDType__c : this.OPDPlan.OPDType__c,
+		RentalReson__c : this.OPDPlan.RentalReson__c,
+		OriginalOpdPlan__c : this.OPDPlan.Id,
+		Related_Opportunity1_ID__c : this.OPDPlan.Related_Opportunity1_ID__c,
+		CorrespondingRepairNo__c : this.OPDPlan.CorrespondingRepairNo__c,
+		AdditionalSupport__c : this.OPDPlan.AdditionalSupport__c,
+		Campaign__c : this.OPDPlan.Campaign__c,
+		NoOpp_Reason__c : this.OPDPlan.NoOpp_Reason__c,
+		ModelLending__c : this.OPDPlan.ModelLending__c,
+		ModelLendingProduct__c : this.OPDPlan.ModelLendingProduct__c,
+		PlanProdDetail__c : this.OPDPlan.PlanProdDetail__c
+
+	    })
+	this.IsLoading=false;
+    this.dispatchEvent(new CloseActionScreenEvent());
+   	this[NavigationMixin.Navigate]({
+	          type: 'standard__objectPage',
+	          attributes: {
+	            objectApiName: 'OPDPlan__c',
+	            actionName: 'new'
+	          },
+	          state: {
+	          	nooverride: '1',
+	            defaultFieldValues: defaultFieldValues ,
+	          }
+	});
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml
new file mode 100644
index 0000000..b1fb5a9
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexOPDReapply">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__RecordPage</target>
+        <target>lightning__AppPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html
new file mode 100644
index 0000000..c444cc3
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="Attachment" 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/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js
new file mode 100644
index 0000000..9359cc6
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js
@@ -0,0 +1,147 @@
+import { LightningElement, track, wire,api } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+
+import init  from '@salesforce/apex/LexOPDSupplementaryController.init';
+import dataCheck  from '@salesforce/apex/OpdPlanWebService.dataCheck';
+import getTheOPDPlan  from '@salesforce/apex/LexOPDSupplementaryController.getTheOPDPlan';
+
+const event1 = new ShowToastEvent({
+	            	message:
+	                "鍙湁OPD璁″垝鐘舵�佷负璁″垝涓紝鎵嶈兘杩涜OPD琛ュ厖鐢宠",
+	                variant : 'error'
+});
+const event2 = new ShowToastEvent({
+	            	message:
+	                "OPD璁″垝鏃犳硶杩涜琛ュ厖鐢宠",
+	                variant : 'error'
+});
+const event3 = new ShowToastEvent({
+	            	message:
+	                "璇疯浆鑷砄PD璁″垝鍘熷崟杩涜鐢宠",
+	                variant : 'error'
+});
+const event4 = new ShowToastEvent({
+	            	message:
+	                "OPD璁″垝宸茶繘琛岃繃琛ュ厖鐢宠锛屾棤娉曞啀娆¤繘琛岃ˉ鍏呯敵璇�",
+	                variant : 'error'
+});
+export default class lexOPDSupplementaryApplication extends NavigationMixin(LightningElement) {
+
+	@api recordId;
+	IsLoading=true;
+	OPDPlan;
+	TheOPDPlan;
+
+	@wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            this.recordId = str;
+          }
+        }
+    }
+
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            if (result != null) {
+                this.OPDPlan = result;
+                this.SupplementaryApplication().then(result=>{
+                	this.IsLoading=false;
+                	this.dispatchEvent(new CloseActionScreenEvent());
+                });
+            }
+        }).catch(error => {
+			const event3 = new ShowToastEvent({
+	           	message:
+	            error.message,
+	            variant : 'error'
+        	});
+        	this.dispatchEvent(event3);
+        });
+
+    }
+
+
+    async SupplementaryApplication(){
+		var status = this.OPDPlan.Status__c;
+		if(status != '璁″垝涓�'){
+			this.dispatchEvent(event1);
+			return;
+		}
+		//琛ュ厖鐢宠
+		var supplementaryApplication = this.OPDPlan.supplementaryApplication__c;
+		if(supplementaryApplication == '1'){
+			this.dispatchEvent(event2);
+			return;
+		}
+		var rental = this.OPDPlan.OriginalOpdPlanRental__c;
+		if(rental != '' && rental !=undefined){
+			this.dispatchEvent(event3);
+			return;
+		}
+		var raId = this.OPDPlan.Rental_Apply2__c;
+		var datacheck = await dataCheck({rentalApplyId: raId});
+		console.log(datacheck);
+		if(datacheck != 'OK'){
+			const event = new ShowToastEvent({
+	           	message:
+	            datacheck,
+	            variant : 'error'
+        	});
+        	this.dispatchEvent(event);
+			return;
+		}
+		await getTheOPDPlan({Id : this.OPDPlan.Id}).then(result=>{
+			this.TheOPDPlan = result;
+		}).catch(error=>{
+			console.log(error.message);
+		});
+		if(this.TheOPDPlan != null && this.TheOPDPlan > 0){
+			this.dispatchEvent(event4);
+			return;
+		}
+		const defaultFieldValues = encodeDefaultFieldValues({
+    	Name : this.OPDPlan.Name ,
+    	Status__c : '鑽夋涓�',
+    	RentalReson__c : '杩藉姞閰嶅' ,
+    	OPDPlan_ImplementDate__c : this.OPDPlan.OPDPlan_ImplementDate__c ,
+    	Account_Laboratory__c : this.OPDPlan.Account_Laboratory__c ,
+    	Related_Opportunity1_ID__c :this.OPDPlan.Related_Opportunity1_ID__c ,
+    	PlanProdDetail__c  : this.OPDPlan.PlanProdDetail__c,
+    	Cnt_OPD_LastYear__c : this.OPDPlan.Cnt_OPD_LastYear__c,
+    	Cnt_OPD_ThisYear__c : this.OPDPlan.Cnt_OPD_ThisYear__c,
+    	Cnt_Rentals__c : this.OPDPlan.Cnt_Rentals__c,
+    	lastMonth_Plan__c : this.OPDPlan.lastMonth_Plan__c,
+    	SalesManager__c : this.OPDPlan.SalesManager__c,
+    	OPDType__c : this.OPDPlan.OPDType__c,
+    	OriginalOpdPlanApplication__c :this.OPDPlan.Id,
+    	BuchangApprovalManagerSales__c :this.OPDPlan.BuchangApprovalManagerSales__c,
+    	SalesManager_Txt__c   :   this.OPDPlan.SalesManager_Txt__c 
+
+	    })
+		this.IsLoading=false;
+        this.dispatchEvent(new CloseActionScreenEvent());
+	    this[NavigationMixin.Navigate]({
+	          type: 'standard__objectPage',
+	          attributes: {
+	            objectApiName: 'OPDPlan__c',
+	            actionName: 'new'
+	          },
+	          state: {
+	          	nooverride: '1',
+	            defaultFieldValues: defaultFieldValues ,
+	          }
+	    });
+
+    }
+
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml
new file mode 100644
index 0000000..aef2480
--- /dev/null
+++ b/force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexOPDSupplementaryApplication">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__RecordPage</target>
+        <target>lightning__AppPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html
new file mode 100644
index 0000000..c444cc3
--- /dev/null
+++ b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="Attachment" 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/lexPostPoneReport/lexPostPoneReport.js b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js
new file mode 100644
index 0000000..e34d785
--- /dev/null
+++ b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js
@@ -0,0 +1,122 @@
+//author : kkbes  add  LexOPDPostPoneController
+import { LightningElement, track, wire,api } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+
+import init  from '@salesforce/apex/LexOPDPostPoneController.init';
+import findRecordId  from '@salesforce/apex/LexOPDPostPoneController.findRecordId';
+import changeTrade  from '@salesforce/apex/OpdPlanWebService.changeTrade';
+
+
+const event1 = new ShowToastEvent({
+	            	title: '鐘舵�侀敊璇�',
+	            	message:
+	                "OPD璁″垝鐨勭姸鎬佷负鍙栨秷鎴栧畬姣曟椂锛屼笉鑳芥敼鏈�!",
+});
+export default class lexPostPoneReport extends  NavigationMixin(LightningElement) {
+
+	@api recordId;
+	IsLoading=true;
+	OPDPlan;
+	RecordType;
+
+	@wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            this.recordId = str;
+          }
+        }
+    }
+
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            if (result != null) {
+                this.OPDPlan = result;
+                this.PostPoneReport().then(result=>{
+                	this.IsLoading=false;
+        			this.dispatchEvent(new CloseActionScreenEvent());
+                });
+            }
+        }).catch(error => {
+			const event3 = new ShowToastEvent({
+	           	title: '椤甸潰鍒濆鍖栭敊璇�',
+	           	message:
+	            error.message,
+        	});
+        	this.dispatchEvent(event3);
+        });
+
+    }
+
+
+
+    async PostPoneReport(){
+		var Status = this.OPDPlan.Status__c;
+		if(Status == '鍙栨秷' || Status == '瀹屾瘯' ){
+			this.dispatchEvent(event1);
+			return;
+		}
+		var opdplanid = this.OPDPlan.Id;
+		var rtn =await changeTrade({opdplanId:opdplanid})
+		if (rtn != 'OK') {
+			const event = new ShowToastEvent({
+	           	title: '澶辫触',
+	           	message:
+	            rtn,
+        	});
+        	this.dispatchEvent(event);
+			return;
+		}	
+		await findRecordId().then(result=>{
+			if(result!=null){
+				this.RecordType = result[0];
+			}
+			else{
+				const eventIdIsNull = new ShowToastEvent({
+	           	message:
+	            '璇峰強鏃惰仈绯荤鐞嗗憳',
+	            variant : 'error'
+        		});
+        		this.dispatchEvent(eventIdIsNull);
+			}
+			
+		}).catch(error=>{
+			console.log(error.message);
+		});	
+	    this.navigateToNewObjectPage();
+	}
+
+
+
+	navigateToNewObjectPage() {
+		this.IsLoading=false;
+        this.dispatchEvent(new CloseActionScreenEvent());
+		const defaultFieldValues = encodeDefaultFieldValues({
+    	CancelOPDPlan__c : this.OPDPlan.Id ,
+    	Status__c : '寤舵湡鎶ュ憡'
+	    })
+	    this[NavigationMixin.Navigate]({
+	          type: 'standard__objectPage',
+	          attributes: {
+	            objectApiName: 'CancelPostponePlan__c',
+	            actionName: 'new'
+	          },
+	          state: {
+	          	nooverride: '1',
+	            defaultFieldValues: defaultFieldValues ,
+	            recordTypeId : this.RecordType.Id
+	          }
+	    });
+
+
+	}
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml
new file mode 100644
index 0000000..2f5efd9
--- /dev/null
+++ b/force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexPostPoneReport">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__RecordPage</target>
+        <target>lightning__AppPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1