liwentao
2023-07-17 07a70391092d0b1e3f8e2a14e972070404b81d86
营业
任务按钮:
授权委托更新完毕
报价委托更新完毕
无效委托
17个文件已添加
822 ■■■■■ 已修改文件
force-app/main/default/classes/LexInvalidDelegationController.cls 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexInvalidDelegationController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexRequestCloseController.cls 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexRequestCloseController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexTaskCloseController.cls 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexTaskCloseController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexInvalidDelegation/lexInvalidDelegation.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexInvalidDelegation/lexInvalidDelegation.js 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexInvalidDelegation/lexInvalidDelegation.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestClose/lexRequestClose.css 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestClose/lexRequestClose.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestClose/lexRequestClose.js 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRequestClose/lexRequestClose.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTaskClose/lexTaskClose.css 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTaskClose/lexTaskClose.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTaskClose/lexTaskClose.js 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTaskClose/lexTaskClose.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexInvalidDelegationController.cls
New file
@@ -0,0 +1,143 @@
public with sharing class LexInvalidDelegationController {
    public LexInvalidDelegationController() {
    }
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res=new InitData();
        try{
            Task task=[SELECT Status,Id,QuoteIraiId__c,Answer__c FROM Task where id = :recordId];
            res.Id=task.Id;
            res.Status=task.Status;
            res.QuoteIraiIdC=task.QuoteIraiId__c;
            res.AnswerC=task.Answer__c;
            return res;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'LexInvalidDelegationController init Error : ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static QuoteIrai__c getQuoteIraiC(String recordId){
        try{
            QuoteIrai__c res=[select id,Lead__r.LatestQuotationEntrustment__c,Lead__r.QuotationDelegationStatus__c, Lead__c from QuoteIrai__c where id = :recordId];
            return res;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'LexInvalidDelegationController init Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static UpdateResult updateTask(
        String recordId,
        String Status
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            Task rac = new Task( id=recordId);
            if(String.isNotBlank(Status)){
                rac.Status=Status;
            }
            rac.Request_completed_time__c=System.now();
            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,'updateTask update Error : ' + e);
        }
        return result;
    }
    @AuraEnabled
    public static UpdateResult updateLead(
        String recordId,
        String LatestQuotationEntrustmentC
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            Lead rac = new Lead( id=recordId);
            if(String.isNotBlank(LatestQuotationEntrustmentC)){
                rac.LatestQuotationEntrustment__c=LatestQuotationEntrustmentC;
            }
            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,'updateLead update Error : ' + e);
        }
        return result;
    }
    @AuraEnabled
    public static UpdateResult updateQuoteIraiC(
        String recordId,
        String QuoteIraiStatusC
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            QuoteIrai__c rac = new QuoteIrai__c( id=recordId);
            if(String.isNotBlank(QuoteIraiStatusC)){
                rac.QuoteIrai_Status__c=QuoteIraiStatusC;
            }
            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,'updateQuoteIraiC update Error : ' + e);
        }
        return result;
    }
    @AuraEnabled
    public static String getProfileId(){
        return UserInfo.getProfileId();
    }
    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 Status{get;set;}
        @AuraEnabled
        public String Id{get;set;}
        @AuraEnabled
        public String QuoteIraiIdC{get;set;}
        @AuraEnabled
        public String AnswerC{get;set;}
    }
}
force-app/main/default/classes/LexInvalidDelegationController.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/LexRequestCloseController.cls
New file
@@ -0,0 +1,65 @@
public with sharing class LexRequestCloseController {
    public LexRequestCloseController() {
    }
    @AuraEnabled
    public static Rental_Apply__c init(String recordId){
        try{
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static UpdateResult updateTask(
        String recordId,
        String Status
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            Task rac = new Task( id=recordId);
            if(String.isNotBlank(Status)){
                rac.Status=Status;
            }
            rac.Request_completed_time__c=System.now();
            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 String getProfileId(){
        return UserInfo.getProfileId().substring(0,15);
    }
    @AuraEnabled
    public static List<String> getProfileIds(){
        List<Profile> res=[SELECT id FROM Profile where name='OBA2_询价管理' OR name='OBA7_询价+招标管理'];
        List<String> ids=new List<String>();
        for (Profile p:res ) {
            String idd=p.Id;
            ids.add(idd.substring(0,15));
        }
        return ids;
    }
    public class UpdateResult {
        @AuraEnabled public String recordId {get;set;}
        @AuraEnabled public Boolean success {get;set;}
        @AuraEnabled public List<String> errors {get;set;}
    }
}
force-app/main/default/classes/LexRequestCloseController.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/LexTaskCloseController.cls
New file
@@ -0,0 +1,125 @@
public with sharing class LexTaskCloseController {
    public LexTaskCloseController() {
    }
    @AuraEnabled
    public static Task init(String recordId){
        try{
            Task res=[SELECT QuoteIraiId__c from Task where id= :recordId];
            return res;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static QuoteIrai__c getQuoteIraic(String recordId) {
       try{
            QuoteIrai__c res=[select id,Lead__c from QuoteIrai__c where id = :recordId];
            return res;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static UpdateResult updateLead(
        String recordId,
        String LatestQuotationEntrustmentc
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            Lead rac = new Lead( id=recordId);
            if(String.isNotBlank(LatestQuotationEntrustmentc)){
                rac.LatestQuotationEntrustment__c=LatestQuotationEntrustmentc;
            }
            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 updateQuoteIraic(
        String recordId,
        String QuoteIraiStatusc
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            QuoteIrai__c rac = new QuoteIrai__c( id=recordId);
            if(String.isNotBlank(QuoteIraiStatusc)){
                rac.QuoteIrai_Status__c=QuoteIraiStatusc;
            }
            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,'updateQuoteIraic update Error : ' + e);
        }
        return result;
    }
    @AuraEnabled
    public static UpdateResult updateTask(
        String recordId,
        String Status
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
            if(recordId==null) return null;
            Task rac = new Task( id=recordId);
            if(String.isNotBlank(Status)){
                rac.Status=Status;
            }
            rac.Request_completed_time__c=System.now();
            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 String getProfileId(){
        return UserInfo.getProfileId();
    }
    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 QuoteIraiId {get;set;}
    }
}
force-app/main/default/classes/LexTaskCloseController.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/lexInvalidDelegation/lexInvalidDelegation.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="exampleHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexInvalidDelegation/lexInvalidDelegation.js
New file
@@ -0,0 +1,177 @@
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
import init from '@salesforce/apex/LexInvalidDelegationController.init';
import getQuoteIraiC from '@salesforce/apex/LexInvalidDelegationController.getQuoteIraiC';
import updateTask from '@salesforce/apex/LexInvalidDelegationController.updateTask';
import updateLead from '@salesforce/apex/LexInvalidDelegationController.updateLead';
export default class lexInvalidDelegation extends LightningElement {
    @api recordId;
    @api isDoneRendering;
    IsLoading=true;
    isShow=true;
    Id;
    Status;
    QuoteIraiIdC;
    AnswerC;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        this.dispatchEvent(new CloseActionScreenEvent());
        this.isDoneRendering=false;
        init({recordId:this.recordId}).then(result=>{
            this.Id=this.recordId;
            this.Status=result.Status;
            this.QuoteIraiIdC=result.QuoteIraiIdC;
            this.AnswerC=result.AnswerC;
            this.cancelSubmit().then(res=>{
                this.isShow=false;
                this.IsLoading=false;
                this.dispatchEvent(new CloseActionScreenEvent());
                this.isDoneRendering=false;
                const passOneEvent = new CustomEvent('closem', {
                detail: '111'
              });
              this.dispatchEvent(passOneEvent);
            });
        }).catch(err=>{
            // console.log("error:");
            // console.log(err.message);
        }).finally(()=>{
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
    async cancelSubmit(){
        var flag=false;
        if(this.Status == '未着手'||this.Status == '進行中'){
            this.isDoneRendering=true;
            if(this.AnswerC ==null || this.AnswerC==''){
                // alert('请填写回答内容');
                const event = new ShowToastEvent({
                    title: '提示信息',
                    message:"操作失败:"+'请填写回答内容',
                });
                this.dispatchEvent(event);
                this.isDoneRendering=true;
                return;
            }else{
                var Id = this.recordId;
                var Status = "无效委托";
                await updateTask({
                    recordId:Id,
                    Status:Status
                }).then(res=>{
                    console.log(res);
                    if(res!=null&&res.success==false){
                        var messages=res.errors[0];
                        if (messages!=null&&messages!="") {
                            const event = new ShowToastEvent({
                                title: '提示信息',
                                message:"操作失败:"+messages,
                            });
                            this.dispatchEvent(event);
                            flag=true;
                            return;
                        }
                    }
                }).catch(err=>{
                    // console.log("updateTask error:");
                    // console.log(err.message);
                });
                if (flag) {return;}
                var messages2 = '';
                if(this.QuoteIraiIdC != null&&this.QuoteIraiIdC !='') {
                    // 获得报价委托
                    var sqlResult2 = await getQuoteIraiC({recordId:this.QuoteIraiIdC});
                    if(sqlResult2!=null&&sqlResult2.Lead__c!=null){
                        //alert(sqlResult2.Lead__r.LatestQuotationEntrustment__c + '|' + sqlResult2.Lead__r.QuotationDelegationStatus__c);
                        if(!sqlResult2.Lead__r.LatestQuotationEntrustment__c || (sqlResult2.Lead__r.LatestQuotationEntrustment__c && sqlResult2.Lead__r.QuotationDelegationStatus__c != '已有询价' && sqlResult2.Lead__r.QuotationDelegationStatus__c != '更新完毕')){
                            // Lead更新
                            await updateLead({
                                recordId:Id,
                                LatestQuotationEntrustmentC:sqlResult2.Lead__r.LatestQuotationEntrustment__c
                            }).then(res=>{
                                if(res!=null&&res.success==false){
                                    var messages=res.errors[0];
                                    if (messages!=null&&messages!="") {
                                        const event = new ShowToastEvent({
                                            title: '提示信息',
                                            message:"操作失败:"+messages,
                                        });
                                        this.dispatchEvent(event);
                                        flag=true;
                                        return;
                                    }
                                }
                            }).catch(err=>{
                                // console.log("updateLead error:");
                                // console.log(err.message);
                            });
                        }
                    }
                    if(flag)return;
                    var id = this.QuoteIraiIdC;
                    var QuoteIrai_Status__c = '无效委托';
                    await updateLead({
                        recordId:id,
                        QuoteIraiStatusC:QuoteIrai_Status__c
                    }).then(res=>{
                        if(res!=null&&res.success==false){
                            var messages=res.errors[0];
                            if (messages!=null&&messages!="") {
                                const event = new ShowToastEvent({
                                    title: '提示信息',
                                    message:"操作失败:"+messages,
                                });
                                this.dispatchEvent(event);
                                flag=true;
                                return;
                            }else{
                                const event = new ShowToastEvent({
                                    title: '提示信息',
                                    message:'更新已完成',
                                });
                                this.dispatchEvent(event);
                                return;
                                //发送成功后,希望自动刷新画面。
                                window.location.reload();
                            }
                        }
                    }).catch(err=>{
                        // console.log("updateLead error:");
                        // console.log(err.message);
                    });
                    if (flag) {return;}
                }
            }
        }else{
            // alert('任务已结束,如需修改请联系管理员');
            const event = new ShowToastEvent({
                title: '提示信息',
                message:"操作失败:"+'任务已结束,如需修改请联系管理员',
            });
            this.dispatchEvent(event);
        }
    }
}
force-app/main/default/lwc/lexInvalidDelegation/lexInvalidDelegation.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="lexInvalidDelegation">
    <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>
force-app/main/default/lwc/lexRequestClose/lexRequestClose.css
New file
@@ -0,0 +1,11 @@
.Holder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display : none !important;
}
force-app/main/default/lwc/lexRequestClose/lexRequestClose.html
New file
@@ -0,0 +1,5 @@
<template>
      <div class="Holder" if:true={IsLoading} >
              <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
      </div>
</template>
force-app/main/default/lwc/lexRequestClose/lexRequestClose.js
New file
@@ -0,0 +1,95 @@
import { LightningElement,api, track, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
import init from '@salesforce/apex/LexRequestCloseController.init';
import getProfileId from '@salesforce/apex/LexRequestCloseController.getProfileId';
import updateTask from '@salesforce/apex/LexRequestCloseController.updateTask';
import getProfileIds from '@salesforce/apex/LexRequestCloseController.getProfileIds';
export default class lexRequestClose extends LightningElement {
    @api recordId;
    @api isDoneRendering;
    IsLoading=true;
    isShow=true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        this.dispatchEvent(new CloseActionScreenEvent());
        console.log(this.recordId);
        init({recordId:this.recordId}).then(result=>{
            // this.dispatchEvent(new CloseActionScreenEvent());
            this.cancelSubmit().then(res=>{
                this.isShow=false;
                this.IsLoading=false;
                this.dispatchEvent(new CloseActionScreenEvent());
                const passOneEvent = new CustomEvent('closem', {
                detail: '111'
              });
              this.dispatchEvent(passOneEvent);
            });
        }).catch(err=>{
            // console.log("error:");
            // console.log(err.message);
        }).finally(()=>{
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
    async cancelSubmit(){
        var pro = await getProfileId();
        var fag = true;
        var ids = await getProfileIds();
        // pro='00e10000000s3Jp';
        if( ids.indexOf(pro) == -1 ){
            fag=false;
            const event = new ShowToastEvent({
                title: '提示信息',
                message:'不需要做授权确认',
            });
            this.dispatchEvent(event);
        }
        if(fag){
            var Id = this.recordId;
            var Status = "完了";            await updateTask({
                recordId:Id,
                Status:Status
            }).then(res=>{
                if(res!=null&&res.success==false){
                    var messages=res.errors[0];
                    if (messages!=null&&messages!="") {
                        const event = new ShowToastEvent({
                            title: '提示信息',
                            message:"操作失败,提示信息:"+messages,
                        });
                        this.dispatchEvent(event);
                        return;
                    }
                }
                else this.dispatchEvent(new CloseActionScreenEvent());
            }).catch(err=>{
                // console.log("updateRentalApplyC error:");
                // console.log(err.message);
            });
            window.location.reload();
        }
    }
}
force-app/main/default/lwc/lexRequestClose/lexRequestClose.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="lexRequestClose">
    <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>
force-app/main/default/lwc/lexTaskClose/lexTaskClose.css
New file
@@ -0,0 +1,11 @@
.Holder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display : none !important;
}
force-app/main/default/lwc/lexTaskClose/lexTaskClose.html
New file
@@ -0,0 +1,5 @@
<template>
      <div class="Holder" if:true={IsLoading} >
              <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
      </div>
</template>
force-app/main/default/lwc/lexTaskClose/lexTaskClose.js
New file
@@ -0,0 +1,132 @@
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
import init from '@salesforce/apex/LexTaskCloseController.init';
import getProfileId from '@salesforce/apex/LexTaskCloseController.getProfileId';
import updateQuoteIraic from '@salesforce/apex/LexTaskCloseController.updateQuoteIraic';
import updateTask from '@salesforce/apex/LexTaskCloseController.updateTask';
import getQuoteIraic from '@salesforce/apex/LexTaskCloseController.getQuoteIraic';
export default class lexTaskClose extends LightningElement {
    @api recordId;
    @api isDoneRendering;
    IsLoading=true;
    QuoteIraiId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        this.dispatchEvent(new CloseActionScreenEvent());
        init({recordId:this.recordId}).then(result=>{
            this.QuoteIraiId=result.Id;
            this.cancelSubmit().then(res=>{
                this.IsLoading=false;
                const passOneEvent = new CustomEvent('closem', {
                detail: '111'
              });
              this.dispatchEvent(passOneEvent);
            });
        }).catch(err=>{
            // console.log("error:");
            // console.log(err.message);
        }).finally(()=>{
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
    async cancelSubmit(){
        var re = await getQuoteIraic({recordId:this.QuoteIraiId});
        if(re!=null&&re.Lead__c){
            // Lead作成
            var Id = re.Lead__c;
            if(this.QuoteIraiId != '') {
                var LatestQuotationEntrustment__c=this.QuoteIraiId;
                // Lead更新
                await updateLead({
                    recordId:Id,
                    LatestQuotationEntrustmentc:LatestQuotationEntrustment__c
                }).then(res=>{
                    console.log(res);
                    if(res!=null&&res.success==false){
                        var messages=res.errors[0];
                        if (messages!=null&&messages!="") {
                            const event = new ShowToastEvent({
                                title: '提示信息',
                                message:"操作失败,提示信息:"+messages,
                            });
                            this.dispatchEvent(event);
                            return;
                        }
                    }
                }).catch(err=>{
                    // console.log("updateLead error:");
                    // console.log(err.message);
                });
            }
        }
        if(this.QuoteIraiId != '') {
            var id =this.QuoteIraiId;
            var QuoteIrai_Status__c = '更新完毕';
            await updateQuoteIraic({
                recordId:Id,
                QuoteIraiStatusc:QuoteIrai_Status__c
            }).then(res=>{
                console.log(res);
                if(res!=null&&res.success==false){
                    var messages=res.errors[0];
                    if (messages!=null&&messages!="") {
                        const event = new ShowToastEvent({
                            title: '提示信息',
                            message:"操作失败,提示信息:"+messages,
                        });
                        this.dispatchEvent(event);
                        return;
                    }
                }
            }).catch(err=>{
                // console.log("updateLead error:");
                // console.log(err.message);
            });
        }
        var Id = this.recordId;
        var Status = "完了";
        await updateTask({
            recordId:Id,
            Status:Status
        }).then(res=>{
            console.log(res);
            if(res!=null&&res.success==false){
                var message=res.errors[0];
                if (messages!=null&&messages!="") {
                    const event = new ShowToastEvent({
                        title: '提示信息',
                        message:"操作失败,提示信息:"+messages,
                    });
                    this.dispatchEvent(event);
                    return;
                }
            }
        }).catch(err=>{
            // console.log("updateLead error:");
            // console.log(err.message);
        });
        window.location.reload();
    }
}
force-app/main/default/lwc/lexTaskClose/lexTaskClose.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="lexTaskClose">
    <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>