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
/*
 * @Author: zhangchunxu
 * @Date: 2023-05-14 16:07:05
 * @LastEditors: zhangchunxu
 * @LastEditTime: 2023-09-14 10:41:42
 * 
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/ESignController.ESignController';
import  OcsmResult  from '@salesforce/apex/ESignController.OcsmResult';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
//lightning 上线问题修改 fy start
import OBA9_PSI from '@salesforce/label/c.OBA9_PSI_Id';
//lightning 上线问题修改 fy end
import {loadStyle} from 'lightning/platformResourceLoader';
export default class lexESignAcceptanceFranchiser extends LightningElement {
    @api recordId;//OwnerId
    IsLoading = true;
    profileId = '';//当前登录人的权限
    GrouppurchasePCL = null; //是否集采询价
    OCMManProvinceCus = null; //OCSM管理省
    agencyAutoSignUpStatus = null; //经销商状态
    agencySignUpDate = null;// 经销商签收日
    userId; // 当前登录人
    systemProfileId;//系统管理员
    OBA4_sinFor;//OBA4_签收管理
    OBA8_Hospital_construction_tender;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             this.recordId = str;
           }
         }
     }
    
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
        ]);
 
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result.agencyAutoSignUpStatus);
            this.GrouppurchasePCL = result.GrouppurchasePCL;
            this.OCMManProvinceCus = result.OCMManProvinceCus;
            this.agencyAutoSignUpStatus = result.agencyAutoSignUpStatus;
            this.agencySignUpDate = result.agencySignUpDate;
            this.profileId = result.profileId;
            this.userId = result.userId;
            this.systemProfileId = result.systemProfileId;
            this.OBA4_sinFor = result.OBA4_sinFor;
            this.OBA8_Hospital_construction_tender = result.OBA8_Hospital_construction_tender;
            this.IsLoading = false;
            this.AcceptanceFranchiser();
        })       
    }
    //签收单 验收确认(经销商)
    AcceptanceFranchiser(){
    var Group_purchase_PCL ;
    if(this.GrouppurchasePCL == 1){
        Group_purchase_PCL = '集采课';
    }else{
        Group_purchase_PCL = this.OCMManProvinceCus;
    }
    //检索OCSM管理省 上的营业管理部担当
    OcsmResult({GrouppurchasePCL:Group_purchase_PCL}).then(res=>{
        //营业管理部担当id
        var salesManage;
        console.log(res[0].SalesManage__c);
        salesManage = res[0].SalesManage__c;
        //电子签收单id
        var id = this.recordId
        //new 一个对象
        var eSignForm;
        //经销商状态
        var status = this.agencyAutoSignUpStatus;
        if (salesManage || this.profileId == this.systemProfileId) {
            //lightning 上线问题修改 fy start
            console.warn('OBA9_PSI'+OBA9_PSI);
            console.warn('profileId'+this.profileId);
            // if (salesManage != this.userId && this.profileId != this.systemProfileId && this.profileId != this.OBA4_sinFor && this.profileId != this.OBA8_Hospital_construction_tender) {
                if (salesManage != this.userId && this.profileId != this.systemProfileId && this.profileId != this.OBA4_sinFor && this.profileId != this.OBA8_Hospital_construction_tender && this.profileId != OBA9_PSI) {
            //lightning 上线问题修改 fy end
                // alert('您只能审批营业管理部担当是自己的签收单!');
                this.showToast("您只能审批营业管理部担当是自己的签收单!","error");
                return;
            } else if (status != '申请中') {
                // alert('您只能审批申请中的签收单!')
                this.showToast("您只能审批申请中的签收单!","error");
                return;
            } else if (this.agencySignUpDate == undefined || this.agencySignUpDate == null || this.agencySignUpDate == "") {
                // alert('经销商签收日为空时,不可以确认!');
                this.showToast("经销商签收日为空时,不可以确认!","error");
                return;
            }else{
                window.open ('/apex/AgencyConfirmPage?id='+this.recordId, '经销商确认',
                'height=440, width=1260, top=170, left=40, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }
    })
    }
    showToast(msg,type) {
        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());
        }
    }
}