123
chenjingwu
2024-04-12 97984cef6d4494007723eb8e071c35a51bd99581
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
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-06-21 11:23:56
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-07-07 13:29:49
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/lexSolutionProjectRequirementsController.initForClosingCaseFlowButton';
import updateForClosingCaseFlowButton  from '@salesforce/apex/lexSolutionProjectRequirementsController.updateForClosingCaseFlowButton';
import queryForSolutionProgramme  from '@salesforce/apex/lexSolutionProjectRequirementsController.queryForSolutionProgramme';
import queryForAttachments1 from '@salesforce/apex/lexSolutionProjectRequirementsController.queryForAttachments1';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
export default class LexClosingCaseFlow extends LightningElement {
    @api recordId;
    status;
    profileId;
    m2ProfileId;
    IsLoading = true;
    msg;
    connectedCallback(){
        init({
            recordId: this.recordId 
        }).then(result=>{
            this.status = result.status;
            this.profileId = result.profileId;
            this.m2ProfileId = result.m2ProfileId;
            this.closingCase();    
        });
    }
    closingCase(){
        if(this.profileId != this.m2ProfileId){
            this.msg = '只有GIR窗口可以结案';
            this.Isloading = false;
            return;
        }else if(this.status == '07结案'){
            this.msg = '该项目已经结案';
            this.Isloading = false;
            return;
        }else{
            queryForSolutionProgramme({
                recordId: this.recordId
            }).then(result=>{
                var Solprogramme = result;
                if(Solprogramme.length > 0){
                    if(Solprogramme[0].ApprovalClosingProgramme__c != 'true'){
                        this.msg = '结案方案还未通过审批,不能结案';
                        this.Isloading = false;
                        return;
                    }else{
                        queryForAttachments1({
                            recordId: this.recordId
                        }).then(result=>{
                            var records= result; 
                            if(records.length > 0){
                                updateForClosingCaseFlowButton({
                                    recordId: this.recordId
                                }).then(result=>{
                                    if(result){
                                        this.msg = result;
                                        this.Isloading = false;
                                        return;
                                    }
                                    this.closeAction();
                                });
                            }else{
                                this.msg = '结案前请先新建并上传结案附件';
                                this.Isloading = false;
                                return;
                            }
                        });
                    }
                }else{
                    this.msg = '没有结案方案不能结案';
                    this.Isloading = false;
                    return;
                }
            });
            
        }
    }
    closeAction(){
        window.open("/"+this.recordId,'_self');
    }
}