yumenghui
2023-08-07 75550e1bd16611d11ffac577f14ba743c6711338
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
import init  from '@salesforce/apex/SubmitAndRefreshController.init';
import submitApproval from '@salesforce/apex/AddSubmitApprovalProcessController.submitApproval';
 
export default class LexSampleInventory extends LightningElement {
    @api recordId;
    IsLoading=true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
 
    connectedCallback(){
        init({Id:this.recordId}).then(result=>{
            console.log('init result==========',result);
            if(result!=null){
                if (result.Isuploadfile == '0') {
                    this.showToast('请上传客户变更申请信息附件','error');
                    return;
                }
                var accname=result.HospitalName.substr(-2,2);
                if((accname =='公司' || accname =='集团') && result.AttributeType !='企业集团'){
                    this.showToast('客户为公司或集团,医院性质不是企业集团,请核实医院性质,确认是否提交?','error');
                }
                if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
                    return;
                }
                submitApproval({recordId:this.recordId}).then(res => {
                    console.log(res,'<======res')
                }).catch(err => {
                    console.log(err,'<======err')
                    this.showToast(err,'error')
                })
            }
        });
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.IsLoading = false;
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}