liwentao
2023-07-19 f8bd322b4f93f8a04743078bccf89e08e01bf51f
营业
任务按钮:
询价失单
3个文件已修改
255 ■■■■ 已修改文件
force-app/main/default/classes/LexInvalidDelegationController.cls 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OppLoseController.cls 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/oppLoseButton/oppLoseButton.js 191 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexInvalidDelegationController.cls
@@ -1,6 +1,6 @@
public with sharing class LexInvalidDelegationController {
    public LexInvalidDelegationController() {
    }
    @AuraEnabled
    public static InitData init(String recordId){
@@ -33,9 +33,9 @@
    }
    @AuraEnabled
    public static UpdateResult updateTask(
    public static UpdateResult updateTask(
        String recordId,
        String Status
    ) {
@@ -65,7 +65,7 @@
        return result;
    }
    @AuraEnabled
    public static UpdateResult updateLead(
    public static UpdateResult updateLead(
        String recordId,
        String LatestQuotationEntrustmentC
    ) {
@@ -93,7 +93,7 @@
        return result;
    }
    @AuraEnabled
    public static UpdateResult updateQuoteIraiC(
    public static UpdateResult updateQuoteIraiC(
        String recordId,
        String QuoteIraiStatusC
    ) {
@@ -140,4 +140,4 @@
        @AuraEnabled
        public String AnswerC{get;set;}
    }
}
}
force-app/main/default/classes/OppLoseController.cls
@@ -4,12 +4,13 @@
    public static InitData init(String taskId){
        InitData res = new initData();
        try{
            task__c task = [SELECT id, OpportunityId__c
            task__c task = [SELECT id, OpportunityId__c , taskStatus__c
                            FROM task__c
                            WHERE Id =: taskId 
                            LIMIT 1];
            res.task = task;
            res.taskStatus = task.taskStatus__c;
            res.OpportunityId = task.OpportunityId__c;
            Opportunity opp =  [SELECT Sales_owner_buchangID__c,Manager_name__c,Sales_owner_buchang__c,
@@ -32,24 +33,61 @@
            res.Sales_manager_departmentID = opp.Sales_manager_departmentID__c;
            res.Sales_owner_buchang = opp.Sales_owner_buchang__c;
            res.Sales_owner_buchangID = opp.Sales_owner_buchangID__c;
            RecordType re=[select Id from recordType where name='询价失单报告'];
            res.reId=re.Id;
            res.opp = opp;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    }
    public class ReturnData{
    }
    //OLY中标
    @AuraEnabled
    public static String taskOLYwinBid(String recordId) {
        String messageText = '';
       try {
        Opportunity opp = [SELECT Id,ConfirmationofAward__c FROM Opportunity WHERE Id = :recordId LIMIT 1];
        opp.Id = recordId;
        opp.ConfirmationofAward__c = LightingButtonConstant.STATUS_OLYwinBid;
        messageText = '1';
        update opp;
        System.debug(LoggingLevel.INFO, '*** winBid: ' + opp);
        return messageText;
       } catch (Exception ex) {
        System.debug(LoggingLevel.INFO, '*** winBidXu: ' + ex);
        messageText = ex.getMessage();
        return messageText;
       }
    }
    //竞争对手中标
    @AuraEnabled
    public static String taskLoseBid(String recordId) {
        String messageText = '';
        try {
        Opportunity opp = [SELECT Id,ConfirmationofAward__c FROM Opportunity WHERE Id = :recordId LIMIT 1];
        opp.Id = recordId;
        opp.ConfirmationofAward__c = LightingButtonConstant.STATUS_Bid_LoseBid;
        messageText = '1';
        update opp;
        System.debug(LoggingLevel.INFO, '*** winBid: ' + opp);
        return messageText;
        } catch (Exception ex) {
        System.debug(LoggingLevel.INFO, '*** winBidXu: ' + ex);
        messageText = ex.getMessage();
        return messageText;
        }
    }
    public class InitData{
        //询价数据
        @AuraEnabled
        public Opportunity opp;
        @AuraEnabled
        public String stageName;
        public String StageName;
        @AuraEnabled
        public Boolean SAP_Send_OK;
        @AuraEnabled
@@ -73,7 +111,11 @@
        @AuraEnabled
        public String OpportunityId;
        @AuraEnabled
        public String taskStatus;
        @AuraEnabled
        public task__c task;
        @AuraEnabled
        public String reId;
    }
}
force-app/main/default/lwc/oppLoseButton/oppLoseButton.js
@@ -3,84 +3,151 @@
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import  init  from '@salesforce/apex/OppLoseController.init';
export default class OppLoseButton extends LightningElement {
    @api
    taskId;
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
export default class OppLoseButton extends NavigationMixin(LightningElement) {
    @api recordId;
    opp;
    stageName;
    SAP_Send_OK;
    Cnt_Lost_cancel_report;
    Name;
    Sales_assistant_name;
    Sales_assistant_ID;
    Manager_name;
    Sales_manager_departmentID;
    Sales_owner_buchang;
    Sales_owner_buchangID;
    OpportunityId;
    StageName; //阶段
    SAP_Send_OK;//SAP上传(WIN)
    Cnt_Lost_cancel_report;//累计汇总 (COUNT 询价失单/取消报告)
    Name;//    业务机会名
    Sales_assistant_name;//询价助理
    Sales_assistant_ID;//询价助理ID
    Manager_name;//询价所有人的CL6 经理级
    Sales_manager_departmentID;//询价所有人的CL6 经理级ID
    Sales_owner_buchang;//询价所有人的 CL5 总监级
    Sales_owner_buchangID;//询价所有人的CL5 经理级ID
    OpportunityId; //任务 询价
    task;
    taskStatusOne;
    reId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        if(currentPageReference){
            const urlValue=currentPageReference.state.recordId;
            if(urlValue){
                let str=`${urlValue}`;
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        console.log(this.taskId);
        console.log(this.recordId);
        init({
            taskId: this.taskId
            taskId: this.recordId
        }).then(result => {
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.opp = result.opp;
                this.stageName = result.stageName;
                this.SAP_Send_OK = result.SAP_Send_OK;
                this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
                this.Name = result.Name;
                this.Sales_assistant_name = result.Sales_assistant_name;
                this.Sales_assistant_ID = result.Sales_assistant_ID;
                this.Manager_name = result.Manager_name;
                this.Sales_manager_departmentID = result.Sales_manager_departmentID;
                this.Sales_owner_buchang = result.Sales_owner_buchang;
                this.Sales_owner_buchangID = result.Sales_owner_buchangID;
                this.OpportunityId = result.OpportunityId;
                this.task = result.task;
                this.changeContractType();
                this.dispatchEvent(new CloseActionScreenEvent());
                // window.location.reload();
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
            this.IsLoading = false;
            this.opp = result.opp;
            this.StageName = result.StageName;
            this.SAP_Send_OK = result.SAP_Send_OK;
            this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
            this.Name = result.Name;
            this.Sales_assistant_name = result.Sales_assistant_name;
            this.Sales_assistant_ID = result.Sales_assistant_ID;
            this.Manager_name = result.Manager_name;
            this.Sales_manager_departmentID = result.Sales_manager_departmentID;
            this.Sales_owner_buchang = result.Sales_owner_buchang;
            this.Sales_owner_buchangID = result.Sales_owner_buchangID;
            this.OpportunityId = result.OpportunityId;
            this.taskStatusOne = result.taskStatusOne;
            this.task = result.task;
            this.reId=result.reId;
            this.changeContractType();
        })
    }
    changeContractType(){
        if(this.StageName != '引合' && this.StageName != '询价'){
            alert('状态1: '+ this.StageName + '、不能做 失单 了!');
            // alert('状态1: '+ this.StageName + '、不能做 失单 了!');
            this.showToast("状态1:" + this.StageName + "、不能做 失单 了!","error");
            return;
        }
        else if(this.SAP_Send_OK == '1'){
            alert('已经上传SAP、不能做 失单 了!');
            // alert('已经上传SAP、不能做 失单 了!');
            this.showToast("已经上传SAP、不能做 失单 了!","error");
            return;
        }
        else if(this.Cnt_Lost_cancel_report__c > 0){
            alert('询价已经有 取消/失单报告 了!');
        else if(this.Cnt_Lost_cancel_report > 0){
            // alert('询价已经有 取消/失单报告 了!');
            this.showToast("询价已经有 取消/失单报告 了!","error");
            return;
             // window.location.reload();
        }else{
            location.href =
            '/a1U/e?retURL=%2F' + this.OpportunityId +
            '&RecordType=01210000000R4hM' +
            '&CF00N10000004lbGT={!URLENCODE('+this.Name+')}' +
            '&CF00N10000004lbGT_lkid=' + this.OpportunityId +
            const defaultValues = encodeDefaultFieldValues({
                Opportunity__c:this.OpportunityId,
                Sales_assistant__c:this.Sales_assistant_ID,
                Manager_sales__c:this.Sales_manager_departmentID,
                Buchang_sales__c:this.Sales_owner_buchangID
            });
            this[NavigationMixin.Navigate]({
                type: 'standard__objectPage',
                attributes: {
                    objectApiName: 'Lost_cancel_report__c',
                    actionName: 'new'
                },
                state: {
                    nooverride: '1',
                    defaultFieldValues: defaultValues
                }
            });
            '&CF00N10000006QShg={!URLENCODE('+this.Sales_assistant_name+')}' +
            '&CF00N10000006QShg_lkid={!URLENCODE('+this.Sales_assistant_ID+')}' +
            '&CF00N10000006QShq={!URLENCODE('+this.Manager_name+')}' +
            '&CF00N10000006QShq_lkid={!URLENCODE('+this.Sales_manager_departmentID+')}' +
            '&CF00N10000006QShb={!URLENCODE('+this.Sales_owner_buchang+')}' +
            '&CF00N10000006QShb_lkid={!URLENCODE('+this.Sales_owner_buchangID+')}' +
            '';
            // location.href =
            // '/a1U/e?retURL=%2F' + this.OpportunityId +
            // '&RecordType=' + this.reId+
            // // '&CF00N10000004lbGT='+ this.Name +
            // '&Opportunity__c=' + this.OpportunityId +
            // // '&CF00N10000006QShg='+this.Sales_assistant_name+
            // '&Sales_assistant__c='+this.Sales_assistant_ID +
            // // '&CF00N10000006QShq='+this.Manager_name +
            // '&Manager_sales__c='+this.Sales_manager_departmentID +
            // // '&CF00N10000006QShb='+this.Sales_owner_buchang +
            // '&Buchang_sales__c='+this.Sales_owner_buchangID +
            // '';
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}
}
// var sql = "select Sales_owner_buchangID__c,Manager_name__c,Sales_owner_buchang__c,Sales_manager_departmentID__c,name,Sales_assistant_name__c,Sales_assistant_ID__c,id,StageName,SAP_Send_OK__c,Cnt_Lost_cancel_report__c,Bidding_Project_Name_Bid__c from Opportunity where id = '{!task__c.OpportunityIdId__c}'";
// var opp_recourd = sforce.connection.query(sql);
// var opp = opp_recourd.getArray("records")[0];
// if (opp.StageName != '引合'
// && opp.StageName != '询价'
// ) {
// alert("状态1:" + opp.StageName + "、不能做 失单 了!");
// }
// else if (opp.SAP_Send_OK__c == '1') {
// alert("已经上传SAP、不能做 失单 了!");
// }
// else if (opp.Cnt_Lost_cancel_report__c > 0) {
// alert("询价已经有 取消/失单报告 了!");
// }
// else {
// location.href =
// '/a1U/e?retURL=%2F{!task__c.OpportunityIdId__c}' +
// '&RecordType=01210000000R4hM' +
// '&CF00N10000004lbGT={!URLENCODE('+opp.name+')}' +
// '&CF00N10000004lbGT_lkid={!task__c.OpportunityIdId__c}' +
// '&CF00N10000006QShg={!URLENCODE('+opp.Sales_assistant_name__c+')}' +
// '&CF00N10000006QShg_lkid={!URLENCODE('+opp.Sales_assistant_ID__c+')}' +
// '&CF00N10000006QShq={!URLENCODE('+opp.Manager_name__c+')}' +
// '&CF00N10000006QShq_lkid={!URLENCODE('+opp.Sales_manager_departmentID__c+')}' +
// '&CF00N10000006QShb={!URLENCODE('+opp.Sales_owner_buchang__c+')}' +
// '&CF00N10000006QShb_lkid={!URLENCODE('+opp.Sales_owner_buchangID__c+')}' +
// '';
// }