<!-- tabStyle -->
<apex:page controller="UpdAccountExamineController"  lightningstylesheets="true">
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.AccessorySelectCss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.RelationListPagingCmpJS)}"/>
   <script type="text/javascript">
   
        //机构类型j_id0:j_id8:alltable:j_id18:j_id46:InsType
        //医院类型j_id0:j_id8:alltable:j_id18:j_id48:HosType
        //是否为有风险通过j_id0:j_id8:alltable:j_id18:j_id50:Risk
        //评论j_id0:j_id8:alltable:j_id18:j_id52:j_id54
        var isadmin = {!loginUser.ProfileId == $Label.ProfileId_SystemAdmin};
        var isdealers = {!loginUser.ProfileId == $Label.ProfileId_2J3};
        window.onload = function(){ 
            if (!isadmin && !isdealers) {
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:RejectionReason')).attr('disabled',true);
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:InsType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',true);
            }else if(isadmin && !isdealers){
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:RejectionReason')).attr('disabled',false);
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:InsType')).attr('disabled',false);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',true);
                // document.getElementById("j_id0:j_id2:alltable:j_id12:j_id42:AssociatedHospital").disabled = "true";
                // document.getElementById("j_id0:j_id2:alltable:j_id12:j_id44:InsType").disabled = "false";
                // document.getElementById("j_id0:j_id2:alltable:j_id12:j_id46:HosType").disabled = "true";
                // document.getElementById("j_id0:j_id2:alltable:j_id12:j_id48:Risk").disabled = "true";
            }else if (isdealers) {
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:RejectionReason')).attr('disabled',true);
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:InsType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',false);
            }
        }
          function changeReasonJs(){
                // var RejectionReason = j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:RejectionReason')).value();
                // if(RejectionReason != null && RejectionReason == '重复'){
                //    j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',false);
                // }else{
                //    j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',true); 
                // }
                if (isdealers) {
                   j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',false);
                }else{
                   j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',true);
                }  

            }
           function changeReasonJs1(){
                var InsType = j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:InsType')).value();
                if(InsType != null && InsType == '非医疗机构'){
                   j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',false);
                }else{
                    j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',true);
                }
                if (isdealers) {
                   j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',false);
                }else{
                   j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',true);
                }
            }

            function changeReasonJs2(){
                if (isdealers) {
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:RejectionReason')).attr('disabled',true);
                // j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:AssociatedHospital')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id46:InsType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id48:HosType')).attr('disabled',true);
                j$(escapeVfId('j_id0:j_id8:alltable:j_id18:j_id50:Risk')).attr('disabled',false);
            }
            }
            function saveJs() {
              blockme();
           }

   </script>
   <apex:form >
   <apex:sectionHeader title="批准请求" subtitle="{!objAcc.Name}"/>
   <apex:actionFunction name="Approval1" action="{!Approval}" />
   <apex:pageBlock id="alltable" title="批准/拒绝批准请求">
       <apex:pageBlockButtons location="bottom"> 
           <apex:commandButton value="批准"  onclick="saveJs()" action="{!Approval}" reRender="alltable" oncomplete="changeReasonJs(),changeReasonJs1(),changeReasonJs2(),unblockUI()">
                   <apex:param name="approve" value="Approve" assignTo="{!ApprovalAction}"/>
           </apex:commandButton>
           <apex:commandButton value="拒绝"  onclick="saveJs()" action="{!Approval}" reRender="alltable" oncomplete="changeReasonJs(),changeReasonJs1(),unblockUI()">
                   <apex:param name="reject" value="Reject" assignTo="{!ApprovalAction}"/>
           </apex:commandButton>
           <apex:commandButton value="取消" action="{!Approval}" reRender="alltable">
                   <apex:param name="cancel" value="Cancel" assignTo="{!ApprovalAction}"/>
           </apex:commandButton>
       </apex:pageBlockButtons>   
       <apex:pageBlockSection columns="1">
       	   <apex:pageBlockSectionItem >
               <apex:pageMessages />
           </apex:pageBlockSectionItem>
          

           <!-- <apex:pageBlockSectionItem >
               驳回理由 <font color="red"></font><apex:inputField id="RejectionReason" value="{!objAcc.RejectionReason__c}" style="width:170px;" onchange="changeReasonJs();"/>
           </apex:pageBlockSectionItem> -->
           <!-- <apex:pageBlockSectionItem >
               关联医院 <font color="red"></font><apex:inputField id="AssociatedHospital" value="{!objAcc.AssociatedHospital__c}"/>
           </apex:pageBlockSectionItem> -->
           <!-- onchange="ShowHidden()"   display:none; -->
           <apex:pageBlockSectionItem >
               机构类型 <font color="red"></font>
               <apex:inputField id="InsType" value="{!objAcc.InstitutionalType__c}" style="width:170px;"  onchange="changeReasonJs1();"
               />
           </apex:pageBlockSectionItem>
           <apex:pageBlockSectionItem >
               医院类型 <font color="red"></font>
               <apex:inputField id="HosType" value="{!objAcc.HospitalType__c}" style="width:170px;"
                />
           </apex:pageBlockSectionItem>
           <apex:pageBlockSectionItem >
               是否为有风险通过 <font color="red"></font>
               <apex:inputField id="Risk" value="{!objAcc.WhetherRiskPassing__c}" style="width:170px;"/>
           </apex:pageBlockSectionItem>
           <apex:pageBlockSectionItem >
              评论 <font color="red"></font> <apex:inputTextArea value="{!Comments}" rows="5" cols="100"/>
           </apex:pageBlockSectionItem>
       </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
</apex:page>