buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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  UserInfo_Owner  from '@salesforce/apex/ESignController.UserInfo_Owner';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class Submit extends LightningElement {
    @api recordId;//OwnerId
    ownerId;//所有人id
    id;//返回值的id
    IsLoading = true;
    profileId = '';
    arrMessage = [];
    RCManagerId = null;
    GrouppurchasePCL = null;
    OCMManProvinceCus = null;
    HPSignUpStatus = null;
    SalesRootFormula = null;
    HPSignUpDate = null;
    salesManage = null;
 
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             this.recordId = str;
           }
         }
     }
    
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result);
            // this.RCManagerId = result.RCManagerId;
            this.GrouppurchasePCL = result.GrouppurchasePCL;
            this.OCMManProvinceCus = result.OCMManProvinceCus;
            this.HPSignUpStatus = result.HPSignUpStatus;
            this.SalesRootFormula = result.SalesRootFormula;
            this.HPSignUpDate = result.HPSignUpDate;
            this.profileId = result.profileId.slice(0,15);
            this.IsLoading = false;
            this.AcceptanceHospital();
        })       
    }
    AcceptanceHospital(){
        //先判断是否为集采课
        // var Group_purchase_PCL ;
        // var Group_purchase_PCLFlag = "{!eSignForm__c.Group_purchase_PCL__c}";
        // if(Group_purchase_PCLFlag == 1){
        // Group_purchase_PCL = '集采课';
        // }else{
        // Group_purchase_PCL = "{!eSignForm__c.OCM_man_province_cus__c}";
        // }
        console.log(this.GrouppurchasePCL,this.OCMManProvinceCus,'111111111')
        var Group_purchase_PCL ;
        // if(this.GrouppurchasePCL == 1){
        // Group_purchase_PCL = '集采课';
        // }else{
        Group_purchase_PCL = this.OCMManProvinceCus;
        // }
        //检索OCSM管理省 上的营业管理部担当
        // var sql = "select id, Name, SalesManage__c from OCM_Management_Province__c where Name = "+"\'"+Group_purchase_PCL+"\'";
        // var ocsmResult = sforce.connection.query(sql);
        // var ocsm = ocsmResult.getArray("records");
        // //营业管理部担当id
        // var salesManage;
        // if (ocsm) {
        // salesManage = ocsm[0].SalesManage__c;
        // }
        console.log(Group_purchase_PCL,this.profileId,'77777777777')
        OcsmResult({GrouppurchasePCL:Group_purchase_PCL}).then(res=>{
            console.log(res)
            var salesManage;
            salesManage = res[0].SalesManage__c;
            //电子签收单id
            var id = this.recordId
            //new 一个对象
            var eSignForm;
            //医院状态
            var status = this.HPSignUpStatus;
            //销售渠道
            var sales_Root_Formula = this.SalesRootFormula;
            if (salesManage || this.profileId == '00e10000000Y3o5') {
                UserInfo_Owner().then(res => {
                    var userId = '';
                    userId = res.id;
                    if (salesManage != userId && this.profileId != '00e10000000Y3o5' && this.profileId != '00e10000000s2cp') {
                        alert('您只能审批营业管理部担当是自己的签收单!');
                        return;
                    } else if (status != '申请中') {
                        alert('您只能审批申请中的签收单!')
                        return;
                    } else if (this.HPSignUpDate) {
                        alert('医院签收日为空时,不可以确认!');
                        return;
                    }else{
                    if(sales_Root_Formula == 'OCM直接販売'){
                        window.open ('/apex/HPDirectSalesConfirmPage?id='+this.recordId, '医院确认',
                        'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
                    }else{
                        window.open ('/apex/HPConfirmPage?id='+this.recordId, '医院确认',
                        'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
                    }
                    }
                })
            }
        })
    }
    updateRecordView() {
        updateRecord({fields: { Id: this.recordId }});
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        if(type == 'success'){
            this.updateRecordView();
        }
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}
 
// var foo = function() {
//     //当前用户登录id
//     var userId = "{!CASESAFEID($User.Id)}";
//     //当前用户简档id
//     var ProfileId = "{!$Profile.Id}";
//     // var RC_Manager = "{!eSignForm__c.RC_ManagerId__c }";
//     //先判断是否为集采课
//     var Group_purchase_PCL ;
//     var Group_purchase_PCLFlag = "{!eSignForm__c.Group_purchase_PCL__c}";
//     if(Group_purchase_PCLFlag == 1){
//     Group_purchase_PCL = '集采课';
//     }else{
//     Group_purchase_PCL = "{!eSignForm__c.OCM_man_province_cus__c}";
//     }
//     //检索OCSM管理省 上的营业管理部担当
//     var sql = "select id, Name, SalesManage__c from OCM_Management_Province__c where Name = "+"\'"+Group_purchase_PCL+"\'";
//     var ocsmResult = sforce.connection.query(sql);
//     var ocsm = ocsmResult.getArray("records");
//     //营业管理部担当id
//     var salesManage;
//     if (ocsm) {
//     salesManage = ocsm[0].SalesManage__c;
//     }
    
//     //电子签收单id
//     var id = "{!eSignForm__c.Id}";
//     //new 一个对象
//     var eSignForm;
//     //医院状态
//     var status = "{!eSignForm__c.HPSignUpStatus__c}";
//     //销售渠道
//     var sales_Root_Formula = "{!eSignForm__c.Sales_Root_Formula__c}";
    
//     if (salesManage || ProfileId == '00e10000000Y3o5') {
//     if (salesManage != userId && ProfileId != '00e10000000Y3o5' && ProfileId != '00e10000000s2cp') {
//     alert('您只能审批营业管理部担当是自己的签收单!');
//     return;
//     } else if (status != '申请中') {
//     alert('您只能审批申请中的签收单!')
//     return;
//     } else if (!'{!eSignForm__c.HPSignUpDate__c}') {
//     alert('医院签收日为空时,不可以确认!');
//     return;
//     }else{
//     if(sales_Root_Formula == 'OCM直接販売'){
//     window.open ('/apex/HPDirectSalesConfirmPage?id='+"{!eSignForm__c.Id}", '医院确认',
//     'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
//     }else{
//     window.open ('/apex/HPConfirmPage?id='+"{!eSignForm__c.Id}", '医院确认',
//     'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
//     }
    
//     }
//     }
//     }
//     foo();