KKbes
2023-07-19 ccd7b0b9f89d2b2538eb5bcdb21eec413061942b
OPD计划
16个文件已添加
724 ■■■■■ 已修改文件
force-app/main/default/classes/LexOPDPostPoneController.cls 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexOPDPostPoneController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexOPDSupplementaryController.cls 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexOPDSupplementaryController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexOPDPostPoneController.cls
New file
@@ -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;
    }
}
force-app/main/default/classes/LexOPDPostPoneController.cls-meta.xml
New file
@@ -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>
force-app/main/default/classes/LexOPDSupplementaryController.cls
New file
@@ -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;
    }
}
force-app/main/default/classes/LexOPDSupplementaryController.cls-meta.xml
New file
@@ -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>
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="Attachment" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js
New file
@@ -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: '无询价OPD申请将审批到副总裁',
            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 )
    }
}
force-app/main/default/lwc/lexOPDPlanCommitNeedApproval/lexOPDPlanCommitNeedApproval.js-meta.xml
New file
@@ -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>
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="Attachment" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js
New file
@@ -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 ,
              }
    });
    }
}
force-app/main/default/lwc/lexOPDReapply/lexOPDReapply.js-meta.xml
New file
@@ -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>
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="Attachment" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js
New file
@@ -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:
                    "请转至OPD计划原单进行申请",
                    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 ,
              }
        });
    }
}
force-app/main/default/lwc/lexOPDSupplementaryApplication/lexOPDSupplementaryApplication.js-meta.xml
New file
@@ -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>
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="Attachment" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js
New file
@@ -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
              }
        });
    }
}
force-app/main/default/lwc/lexPostPoneReport/lexPostPoneReport.js-meta.xml
New file
@@ -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>