liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * @Author: zhangchunxu
 * @Date: 2023-08-16 16:24:52
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-12-26 14:29:34
 * 
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init from '@salesforce/apex/HosipitalToDeptController.init';
import submitApproval from '@salesforce/apex/HosipitalToDeptController.submitApproval';
import LightningConfirm from 'lightning/confirm';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';        
import {loadStyle} from 'lightning/platformResourceLoader'    
export default class LexSubmitAndRefreshAccount 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}`;
                console.log('str');
                console.log(str);
                this.recordId=str;
            }
        }
    }
 
    connectedCallback(){
        Promise.all([            
            loadStyle(this, lwcCSS)            
        ]);    
        init({recordId:this.recordId}).then(res => {
            console.log(res,'<========res')
            if(res.giMain == ''){
                this.showToast('请填写GI主担当','error');
            }else if(res.bfowner == ''){
                this.showToast('请填写BF主担当','error');
            }else if(res.etowner == ''){
                this.showToast('请填写ET主担当','error');
            }else if(res.spmain == ''){
                this.showToast('请填写GS主担当','error');
            }else if(res.uroownerID == ''){
                this.showToast('请填写URO主担当','error');
            }else if(res.gynowner == ''){
                this.showToast('请填写GYN主担当','error');
            }else if(res.entownerID == ''){
                this.showToast('请填写ENT主担当','error');
            }
            if (res.isuploadfile == undefined || res.isuploadfile == false) {
                this.showToast('请上传医院信息附件','error');
                return;
            }
            var accname=res.name.substr(-2,2);
            if((accname =='公司' || accname =='集团') && res.attributeType !='企业集团'){
                LightningConfirm.open({
                    message: "客户为公司或集团,医院性质不是企业集团,请核实医院性质,确认是否提交?",
                    variant: 'headerless',
                    label: '提示信息',
                    // setting theme would have no effect
                }).then(res => {
                    if(!res){
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                    }else{
                        this.submit()
                    }
                })
            }else{
               this.submit()
            }
            
        })
    
    }
    submit(){
        LightningConfirm.open({
            message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?",
            variant: 'headerless',
            label: '提示信息',
            // setting theme would have no effect
        }).then(res => {
            if(!res){
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }else{
                submitApproval({recordId:this.recordId}).then(rep => {
                    //chenjingwu 20231225 start
                    if(rep.includes('未找到适用批准流程')){
                        this.showToast('未找到适用批准流程。','error');
                        return;
                    }
                    //chenjingwu 20231225 end
                    this.IsLoading = false
                    console.log(rep);
                    this.showToast('提交审批成功','success');
                }).catch(err => {
                    this.showToast(err,'error');
                })
            }
        })
    }
    showToast(msg, type) {
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
            // window.location.href = '/lightning/r/Account/'+this.recordId+'/view';
            setTimeout(()=>{
                window.location = '/'+this.recordId
            },200);
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode:'Sticky'
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
}