KKbes
2023-04-13 87861ae5f1ed5456685f97f8a8e7625e47b9576d
force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js
New file
@@ -0,0 +1,97 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-03-27 13:53:40
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-10 14:22:27
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import init  from '@salesforce/apex/MonthlyReportController.initForCreateNoteEmailButton';
import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
export default class LexCreateNotesEmail extends LightningElement {
    @api recordId;
    ownerEmail;
    ownerAlias;
    keyIssue;
    feedBack;
    taskFollow;
    otherIssue;
    nextWeekPlan;
    drSumUrl;
    IsLoading = true;
    url;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        console.log(this.recordId);
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.ownerEmail = result.ownerEmail;
                this.ownerAlias = result.ownerAlias;
                this.keyIssue = result.keyIssue;
                this.feedBack = result.feedBack;
                this.taskFollow = result.taskFollow;
                this.otherIssue = result.otherIssue;
                this.nextWeekPlan = result.nextWeekPlan;
                this.drSumUrl = result.drSumUrl;
                this.userEmail = result.userEmail;
                this.createEmail();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
        });
    }
    createEmail() {
        console.log("start");
       window.location.href = ("mailto:"
        + this.ownerEmail
        +"?bcc="
        +   this.userEmail
        +"&subject=【周报:"
        + this.ownerAlias
        + "】" + "&body=先生/女士" + "%0D%0A" + "%0D%0A" + "主要报告事项:"
        + this.keyIssue
        +"%0D%0A" + "下属事项/状态报告:"
        + this.feedBack
        +"%0D%0A" + "课题及对应结果/提案:"
        +  this.taskFollow
        +"%0D%0A" + "其他事项:"
        + this.otherIssue
        +"%0D%0A" + "下周计划:"
        + this.nextWeekPlan
        +"%0D%0A" + "连接:"
        + this.drSumUrl
        +"%0D%0A").substring(0,320).split("<br>").join("%0D%0A");
    }
}