123
chenjingwu
2024-04-12 b72e78329b825f8a22230cbaf0c8a7e2a57ca5d1
force-app/main/default/lwc/lexAssignTaskButton/lexAssignTaskButton.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-05-15 11:14:32
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-06-05 14:01:14
 * @LastEditTime: 2023-09-21 17:13:37
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -12,7 +12,10 @@
import init from '@salesforce/apex/OpportunityLightingButtonController.initForAssignTaskButtonButton';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
export default class LexAssignTaskButton extends LightningElement {
import RECORD_TYPE_NAME_BY_INQUIRY_FOLLOW_UP from '@salesforce/label/c.RECORD_TYPE_NAME_BY_INQUIRY_FOLLOW_UP';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
export default class LexAssignTaskButton extends NavigationMixin(LightningElement) {
    @api recordId;
    accountName;
    accountId;
@@ -34,13 +37,16 @@
         }
     }
     connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
           ]);
        init({
            recordId: this.recordId
        }).then(result=>{
            this.accountId = result.accountId;
            this.accountName = result.accountName;
            this.oppName = result.name;
            this.recordTypeId = result.recordTypeId;
            this.recordTypeId = RECORD_TYPE_NAME_BY_INQUIRY_FOLLOW_UP;
            this.assignTask();
        }).catch(error=>{
            console.log("error");
@@ -71,19 +77,28 @@
            account__c: this.accountId,
            OpportunityId__c: this.recordId,
            taskStatus__c: '01 分配',
            taskDifferent__c: '上级分配任务'
            taskDifferent__c: '上级分配任务',
            Name: '*'
        });
        let states =
                {
                    nooverride: '1',
                    navigationLocation: 'LIST_VIEW',
                    // backgroundContext: '/lightning/o/Account/list?filterName=Recent&0.source=alohaHeader',
                    backgroundContext: '/lightning/r/Opportunity/'+this.recordId+'/view',
                    defaultFieldValues: defaultValues,
                };
            // states['recordTypeId'] =  this.recordTypeId;
        states['useRecordTypeCheck'] =  true;
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Task',
                objectApiName: 'task__c',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: defaultValues,
                recordTypeId: this.recordTypeId
            }
            state: states
        });
        this.dispatchEvent(new CloseActionScreenEvent());
     }