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
import { LightningElement, track, wire, api } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import init from '@salesforce/apex/lexRentalFixtureSetAssignController.init';
import assignBtn from '@salesforce/apex/RentalApplyWebService.AssignBtn';
 
import TradeComplianceStatusFlagBP from '@salesforce/label/c.TradeComplianceStatusFlagBP';
import IFTradeComplianceAlertBP from '@salesforce/label/c.IFTradeComplianceAlertBP';
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName'; // wyl 贸易合规2期 add
import tradeTempleSend from '@salesforce/apex/SendEmailUtil.tradeTempleSend';        //贸易合规二期 发邮件20240130
export default class lexRentalFixtureSetAssign extends LightningElement {
    @api recordId
    msg;
    IsLoading = true;
    IsShow = false;
    IsShow2 = false;// WYL add 提示红色
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
 
    connectedCallback(){
        init({
            recordId:this.recordId
        }).then(result =>{
            this.IsLoading = false;
            let res = result.ra;
            console.log("res==="+JSON.stringify(res));
            // WYL 贸易合规2期 update start
            // if(TradeComplianceStatusFlagBP){
            //     if(res.AccDealerBlacklist__c == '1'){
            //         this.IsShow = true;
            //         this.msg = IFTradeComplianceAlertBP;
            //         return;
            //     }
            // }
            if (result.IFTradeComplianceIntercept2 == '1') {
                this.IsShow2 = true;
                this.msg = '医院在黑名单中,存在贸易合规风险,无法分配画面,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。';
                tradeTempleSend({rentalId: this.recordId, stepName:'分配画面'});
                return;
            }else if (result.IFTradeComplianceIntercept2 == '2') {
                this.IsShow2 = true;
                this.msg = '医院在冻结清单中,可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法分配画面,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。';
                tradeTempleSend({rentalId: this.recordId, stepName:'分配画面'});
                return;
            }
            // WYL 贸易合规2期 update end
 
            if(res.Campaign__c != '' || res.Campaign__c != undefined){
                if(res.CampaignStatus == '取消'){
                    this.IsShow = true;
                    this.msg = '学会取消,不可分配';
                    return;
                }
            }
            if(res.Repair__c != '' || res.Repair__c != undefined){
                if(res.Repair_Final_Inspection_Date_F__c != null && res.Repair_Final_Inspection_Date_F__c !='' || 
                    (res.RC_return_to_office__c!=null && res.RC_return_to_office__c != '')){
                    this.IsShow = true;
                    this.msg = '修理有最终检测日或修理品返送日,不可分配';
                    return;
                }
            }
 
            assignBtn({
                Rid: this.recordId
            }).then(resultMsg=>{
                if(res.Status__c == '取消' && res.Rental_Apply_Equipment_Set_Cnt__c != 0){
                    window.open("/apex/RentalFixtureSetAssign?pt_recid=" + this.recordId); 
                    this.closeAction();
                }else if((res.demo_purpose2__c == '学会展会' || res.demo_purpose2__c == '课题研究' || res.demo_purpose2__c == '培训中心')
                    && res.Status__c == '草案中'){
                    this.IsShow = true;
                    this.msg = "不能分配,请确认申请的状态";
                    return
                }else if((res.demo_purpose2__c =='试用(无询价)' || res.demo_purpose2__c == '试用(有询价)' || res.demo_purpose2__c =='动物实验' 
                    || res.demo_purpose2__c == '一般维修代用' || res.demo_purpose2__c== '保修合同用户维修代用' || res.demo_purpose2__c == '已购待货') 
                    && res.Status__c != '已批准' && res.Status__c != '已出库指示'){
                    this.IsShow = true;
                    this.msg = "不能分配,请确认申请的状态";
                    return;
                }else if(resultMsg == 'Fin'){
                    window.open("/apex/RentalFixtureSetAssign?pt_recid=" + this.recordId); 
                    this.closeAction();
                }else{
                    this.IsShow = true;
                    this.msg = resultMsg;
                    return;
                }
            })
        })
    }
 
    closeAction() {
        //返回当前的备品申请
        window.open("/"+this.recordId,'_self');
    }
}