123
chenjingwu
2024-04-15 65a3de8fc057c6550f38d2aef6b5ed7f0e7e2f81
force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
@@ -4,19 +4,25 @@
 * @Author: chen jing wu
 * @Date: 2023-06-20 14:37:24
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-07-07 16:11:12
 * @LastEditTime: 2023-10-11 16:54:13
 */
import { api, wire,LightningElement } from 'lwc';
import { api, wire,LightningElement, track } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import updateSubmitSolutionForApprovalButton  from '@salesforce/apex/lexSolutionProjectRequirementsController.updateSubmitSolutionForApprovalButton';
import init  from '@salesforce/apex/lexSolutionProjectRequirementsController.initSubmitSolutionForApprovalButton';
import queryForAttachments  from '@salesforce/apex/lexSolutionProjectRequirementsController.queryForAttachments';
import { updateRecord } from 'lightning/uiRecordApi';
import { updateRecord,getRecord } from 'lightning/uiRecordApi';
import STATUS_FIELD from "@salesforce/schema/SolutionProjectRequirements__c.Status__c";
import { refreshApex } from '@salesforce/apex';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
export default class LexSubmitSolutionForApproval extends LightningElement {
    @wire(getRecord, { recordId: '$recordId', fields: [STATUS_FIELD] })
    record;
    @api recordId;
    status;
    submitDateYouWant;
@@ -41,12 +47,22 @@
        }
    }
    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());
        }
    }
@@ -55,6 +71,10 @@
    }
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
        ]);
        init({
            recordId: this.recordId
        }).then(result=>{
@@ -79,13 +99,12 @@
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        if(this.submitDateYouWant < this.createdDate + 3){
        this.createdDate.setDate(this.createdDate.getDate() + 3);
        if(this.submitDateYouWant.getTime() < this.createdDate.getTime()){
            this.showToast('希望提交日期不得小于三天,如紧急需求请邮件联络Solution担当','error');
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        console.log("start");
        queryForAttachments({
            Id: this.departmentClassId
        }).then(result=>{
@@ -95,7 +114,7 @@
            var usrname = this.userName;
            var rtn = '';
            console.log("start");
            if(header.includes(usrname)){
            if(header != undefined && header != null && header != '' && header.includes(usrname)){
                rtn = 'Y';
            }else{
                rtn = 'N';
@@ -118,7 +137,7 @@
        const result = await LightningConfirm.open({
            message: msg,
            variant: 'headerless',
            label: 'this is the aria-label value',
            label: 'this is the aria-label value'
        });
        console.log(result);
        if(result){
@@ -129,7 +148,13 @@
                   if(results){
                        this.showToast(results,"error");
                        this.dispatchEvent(new CloseActionScreenEvent());
                   }
                   } else{
                        setTimeout(() => {
                            refreshApex(this.record);
                            this.dispatchEvent(new CloseActionScreenEvent());
                        }, 1000);
                   }
                } catch (error) {
                    if(err.faultstring !=undefined && err.faultstring.indexOf('INVALID_SESSION_ID') != -1) {
                        this.showToast('当前网页已登出,请您重新登录后刷新该网页!','error');
@@ -140,8 +165,6 @@
                    }
                    return;
                }
                this.updateRecordView(this.recordId);
                this.dispatchEvent(new CloseActionScreenEvent());
            });
            // isopd.Id = "{!SolutionProjectRequirements__c.Id}";
            // isopd.Submint_TF__c = true;