zz
2023-05-15 bcc0985ef3c8d65326ad1dfd6fc874427b5049e5
签收单 查看附件和验收确认(医院修改)
4个文件已修改
253 ■■■■■ 已修改文件
force-app/main/default/classes/ESignController.cls 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LightingButtonConstant.cls 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js 156 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/ESignController.cls
@@ -3,20 +3,35 @@
    public static InitData ESignController (String recordId){
        InitData res = new initData();
        try{
            eSignForm__c report = [SELECT Id,Group_purchase_PCL__c,OCM_man_province_cus__c,HPSignUpStatus__c,Sales_Root_Formula__c,HPSignUpDate__c  FROM eSignForm__c WHERE Id = :recordId LIMIT 1];
            eSignForm__c report = [SELECT Id,Group_purchase_PCL__c,OCM_man_province_cus__c,HPSignUpStatus__c,Sales_Root_Formula__c,HPSignUpDate__c,agencyAutoSignUpStatus__c,agencySignUpDate__c  FROM eSignForm__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            // res.RCManagerId = report.RC_ManagerId__c;
            res.GrouppurchasePCL = report.Group_purchase_PCL__c;
            res.OCMManProvinceCus = report.OCM_man_province_cus__c;
            res.HPSignUpStatus = report.HPSignUpStatus__c;
            res.agencyAutoSignUpStatus = report.agencyAutoSignUpStatus__c;
            res.SalesRootFormula = report.Sales_Root_Formula__c;
            res.HPSignUpDate = report.HPSignUpDate__c;
            res.agencySignUpDate = report.agencySignUpDate__c;
            res.profileId = UserInfo.getProfileId();
            res.userId = UserInfo.getUserId();
            res.systemProfileId = getProfileIdByName(LightingButtonConstant.SYSTEM_PROFILE_NAME);
            res.OBA4_sinFor = getProfileIdByName(LightingButtonConstant.OBA4_sinFor);
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static string getProfileIdByName(String name){
        Profile profile = null;
        try {
            profile = [select Id from Profile where Name =:name];
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return profile.Id;
    }
    //检索OCSM管理省 上的营业管理部担当
@@ -38,8 +53,6 @@
    public class InitData{
        @AuraEnabled
        public String Id;
        // @AuraEnabled
        // public String RCManagerId;
        @AuraEnabled
        public Boolean GrouppurchasePCL;
        @AuraEnabled
@@ -47,34 +60,20 @@
        @AuraEnabled
        public String HPSignUpStatus;
        @AuraEnabled
        public String agencyAutoSignUpStatus;
        @AuraEnabled
        public String SalesRootFormula;
        @AuraEnabled
        public Date HPSignUpDate;
        @AuraEnabled
        public String profileId;
    }
        //获取当前登录人的 id
        public Date agencySignUpDate;
        @AuraEnabled
        public static UserResult UserInfo_Owner() {
            UserResult result = new UserResult();
            ID myUserID = UserInfo.getUserId();
            try {
                User tempUser = [select id from user where id = : myUserID ];
                result.id = tempUser.id;
            } catch (exception e) {
                result.result = e.getMessage();
            }
            return result;
        }
        public class UserResult {
            @AuraEnabled
            public string result;
            public UserResult( ) {
                result = 'Success';
            }
            @AuraEnabled
            public string id;
        }
        public String profileId;
        @AuraEnabled
        public String userId;
        @AuraEnabled
        public String systemProfileId;
        @AuraEnabled
        public String OBA4_sinFor;
    }
}
force-app/main/default/classes/LightingButtonConstant.cls
@@ -103,6 +103,7 @@
    public static final String TwoS8_Sales_Administrative_Assistant_Plan = '2S8_销售行政助理(计划仪表板)';
    public static final String TwoS9_Spare = '2S9_备品窗口';
    public static final String OBA1_Tenderee = 'OBA1_招标管理';
    public static final String OBA4_sinFor = 'OBA4_签收管理';
    public static final String OBA7_Enquiry_Tenderee = 'OBA7_询价+招标管理';
    public static final String TwoM4_Marketplace_Manager = '2M4_市场产品本部担当(询价)';
    public static final String SOBJECT_NAME_OF_REPORT_SHARE ='Report__Share';
force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js
@@ -3,23 +3,21 @@
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 {
export default class lexESignAcceptanceHospital 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;
    profileId = '';//当前登录人的权限
    GrouppurchasePCL = null; //是否集采询价
    OCMManProvinceCus = null; //OCSM管理省
    HPSignUpStatus = null; //医院审批状态
    SalesRootFormula = null; // 销售渠道(文本)
    HPSignUpDate = null;// 医院签收日
    userId; // 当前登录人
    systemProfileId;//系统管理员
    OBA4_sinFor;//OBA4_签收管理
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -36,46 +34,32 @@
        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.profileId = result.profileId;
            this.userId = result.userId;
            this.systemProfileId = result.systemProfileId;
            this.OBA4_sinFor = result.OBA4_sinFor;
            this.IsLoading = false;
            this.AcceptanceHospital();
            this.dispatchEvent(new CloseActionScreenEvent());
        })       
    }
    //签收单 验收确认(医院)
    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;
        // }
        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)
            //营业管理部担当id
            var salesManage;
            salesManage = res[0].SalesManage__c;
            //电子签收单id
@@ -86,20 +70,20 @@
            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 (salesManage || this.profileId == this.systemProfileId) {
                if (salesManage != this.userId && this.profileId != this.systemProfileId && this.profileId != this.OBA4_sinFor) {
                    // alert('您只能审批营业管理部担当是自己的签收单!');
                    this.showToast("您只能审批营业管理部担当是自己的签收单!","error");
                    return;
                } else if (status != '申请中') {
                    // alert('您只能审批申请中的签收单!')
                    this.showToast("您只能审批申请中的签收单!","error");
                    return;
                } else if (this.HPSignUpDate == undefined) {
                    // alert('医院签收日为空时,不可以确认!');
                    this.showToast("医院签收日为空时,不可以确认!","error");
                    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');
@@ -107,13 +91,9 @@
                        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({
@@ -121,66 +101,6 @@
            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();
force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js
@@ -1,11 +1,11 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { updateRecord } from 'lightning/uiRecordApi';
import  init  from '@salesforce/apex/ESignController.ESignController';
export default class lexESignFormAttachment extends LightningElement {
    @api recordId;
    id;
    IsLoading = true;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -17,32 +17,15 @@
           }
         }
    }
    //签收单 查看附件
    connectedCallback () {
        this.IsLoading = false;
        this.Attachment();
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    Attachment(){
        window.open( `/apex/eSignFormAttachment?parentId=${this.recordId}`);
    }
    // 弹窗
    ShowToastEvent(msg, type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
        init({
            recordId: this.recordId
        }).then(result => {
            this.IsLoading = false;
            this.id = result.Id
            window.open( `/apex/eSignFormAttachment?parentId=${this.id}`);
            this.dispatchEvent(new CloseActionScreenEvent());
        })
    }
}
// var From= function(){
//     window.open( "/apex/eSignFormAttachment?parentId={!URLENCODE(eSignForm__c.Id)}");
//     }
//     From();