1
chenjingwu
2024-05-24 ab5a982874f88556b72e02177fa88dedc2d56fe8
force-app/main/default/lwc/lexRequestDB/lexRequestDB.js
@@ -4,8 +4,11 @@
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForRequestDBButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LexRequestDB extends LightningElement {
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
export default class LexRequestDB extends NavigationMixin(LightningElement) {
    @api recordId;
    stageName;
    sapSendOK;
@@ -21,6 +24,7 @@
    systemProfileId;
    s1ProfileId;
    s4ProfileId;
    recordTypeId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
@@ -37,6 +41,9 @@
        }
    }
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
           ]);
        init({
            recordId: this.recordId
        }).then(result=>{
@@ -55,6 +62,7 @@
            this.systemProfileId = result.systemProfileId == undefined ? '' : result.systemProfileId;
            this.s1ProfileId = result.s1ProfileId == undefined ? '' : result.s1ProfileId;
            this.s4ProfileId = result.s4ProfileId == undefined ? '' : result.s4ProfileId;
            this.recordTypeId = result.recordTypeId == undefined ? '' : result.recordTypeId;
            this.requestDB();
        })
    }
@@ -77,36 +85,65 @@
            this.showToast("询价已经有取消/失单报告了!","error");
        }
        else {
        location.href = '/a2C/e?retURL=%2F' +
            encodeURI(this.recordId) +
            '&RecordType=01210000000RNXi' +
            '&CF00N10000006QdJz=' +
            encodeURI(this.agency1) +
            '&CF00N10000006QdJz_lkid=' +
            encodeURI(this.agency1Id) +
            '&CF00N10000006QdKn=' +
            encodeURI(this.name) +
            '&CF00N10000006QdKn_lkid=' +
            encodeURI(this.recordId) +
            '&00N10000006QdK4=' +
            encodeURI(this.name) +
            '&00N10000006QdYB=' +
            encodeURI(this.bidPlannedDate) +
            '&CF00N10000006QdZT=' +
            encodeURI(this.salesAssistantName) +
            '&CF00N10000006QdZT_lkid=' +
            encodeURI(this.salesAssistantID) +
            '';
        };
        // location.href = '/a2C/e?retURL=%2F' +
        //     encodeURI(this.recordId) +
        //     '&RecordType=01210000000RNXi' +
        //     '&CF00N10000006QdJz=' +
        //     encodeURI(this.agency1) +
        //     '&CF00N10000006QdJz_lkid=' +
        //     encodeURI(this.agency1Id) +
        //     '&CF00N10000006QdKn=' +
        //     encodeURI(this.name) +
        //     '&CF00N10000006QdKn_lkid=' +
        //     encodeURI(this.recordId) +
        //     '&00N10000006QdK4=' +
        //     encodeURI(this.name) +
        //     '&00N10000006QdYB=' +
        //     encodeURI(this.bidPlannedDate) +
        //     '&CF00N10000006QdZT=' +
        //     encodeURI(this.salesAssistantName) +
        //     '&CF00N10000006QdZT_lkid=' +
        //     encodeURI(this.salesAssistantID) +
        //     '';
            const defaultValues = encodeDefaultFieldValues({
                Bid_distributor__c: this.agency1Id,
                Prospect_name__c: this.recordId,
                Product_discription__c: this.name,
                Tedner_date__c: this.bidPlannedDate,
                Request_target__c: this.salesAssistantID
            });
            this[NavigationMixin.Navigate]({
                type: 'standard__objectPage',
                attributes: {
                    objectApiName: 'Request_tedner_doc__c',
                    actionName: 'new'
                },
                state: {
                    nooverride: '1',
                    defaultFieldValues: defaultValues,
                    RecordTypeId: this.recordTypeId,
                }
            });
        }
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode: 'sticky'
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    updateRecordView(recordId) {
      updateRecord({fields: { Id: recordId }});