<!-- 20230418 <apex:page controller="RentalFixtureSetDetilSelectController" showHeader="false" sidebar="false" id="allPage" action="{!init}"> -->
<apex:page controller="RentalFixtureSetDetilSelectController" showHeader="false" sidebar="false" id="allPage" action="{!init}" lightningStylesheets="true">
<head>
<title>借出备品配套明细选择</title>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.RentalFixtureSetDetilSelectCss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/><!-- 20230624 ljh lightning  -->
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.RelationListPagingCmpJS)}"/>
<!-- 20230511 ljh lightning start -->
<style type="text/css">
    table.list td  input[type="text"]{width:55%;}

    /*备品智能化项目对应 20231122 by lc Start*/
    .modal {
       display:none;
       position: fixed; /* Stay in place */
       z-index: 10; /* Sit on top */
       left: 0;
       top: 0;
       width: 100%; /* Full width */
       height: 100%; /* Full height */
       overflow: auto; /* Enable scroll if needed */
       background-color: rgb(0,0,0); /* Fallback color */
       background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    }
    span.dateFormat {
        display: none;
    }

    /* Modal Content/Box */
    .modal-content {
       background-color: #fefefe;
       margin-left: 6px;
       margin-top: 100px;
       padding: 20px;
       border: 1px solid #888;
       right: 5%;
       position: absolute;
       /* 20230628 ljh */
       /* width: 200px; */
       width: 300px;
    }
    .modal-content-cancel {
       background-color: #fefefe;
       margin-left: -150px;
       margin-top: 100px;
       padding: 20px;
       border: 1px solid #888;
       left: 50%;
       position: absolute;
       width: 310px;
    }
    .modal-content-cancel select {
        margin-bottom: 8px;
    }
    /*备品智能化项目对应 20231122 by lc End*/
</style>
<!-- 20230511 ljh lightning end -->
<script type="text/javascript">
    var heightAjustment = 120;
    var widthAjustment = 30;

    // 备品智能化项目对应 20231122 by lc Start
    function checkInterventionReason() {
        if ({!isNeedReason}) {
            j$('#inputReason').show();
        } else {
            blockme();
            save();
        }
    }

    function saveInterventionReasonJs() {
        var reason = j$(escapeVfId('allPage:allForm:Intervention_Reason')).value();
        if(reason == "") {
            j$("#errormessage span").html('请输入人工干预理由！');
            j$("#errormessage").css('display', ''); 
        } else {
            j$("#errormessage").css('display', 'none');
            blockme();
            save();
        }
    }
    // 备品智能化项目对应 20231122 by lc End

</script>
</head>
    <apex:form id="allForm">

        <apex:outputPanel id="message">
            <apex:pageMessages />
        </apex:outputPanel>
        <apex:actionFunction name="saveAndSort" action="{!save}" rerender="allForm, checEventFrame" oncomplete="unblockUI();">
            <apex:param name="firstParam" assignTo="{!saveType}" value="" />
            <apex:param name="secondParam" assignTo="{!sortKey}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="save" action="{!save}" rerender="allForm, checEventFrame" oncomplete="unblockUI();" />

        <!-- 备品智能化项目对应 20231122 by lc Start -->
        <div id="inputReason" class="modal">
            <div class="modal-content-cancel">
                <table>
                    <tr style="display: none;" id="errormessage">
                        <td colspan="2">
                            <span style="color: #F00; font-weight:bold"></span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputLabel value="{!$ObjectType.Rental_Apply_Equipment_Set_Detail__c.fields.Intervention_Reason__c.label}" />
                        </td>
                        <td>
                            <apex:inputText value="{!interventionReason}" id="Intervention_Reason" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <apex:commandButton style="margin: 8px 20px;" value="确定" onclick="saveInterventionReasonJs(); return false;" />
                            <apex:commandButton style="margin: 8px 20px;" value="取消" onclick="j$('#inputReason').hide();return false;"/>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <!-- 备品智能化项目对应 20231122 by lc End -->

        <apex:outputPanel id="pageallPanel">
            <apex:pageBlock id="searchBlock" tabStyle="Report">
                <!-- 20230522 ljh lightning start -->
                <!-- <apex:pageBlockButtons location="bottom">
                        <apex:commandButton style="float:left;" action="{!save}" value="確定" onclick="blockme();" rerender="allForm, checEventFrame" oncomplete="unblockUI();" />
                        <apex:commandButton style="float:right;" value="返回上一级" action="{!goBack}"/>
                        <apex:commandButton style="float:right;" value="返回申请单" action="{!cancel}"/>
                </apex:pageBlockButtons>  
                <div style="clear:both;"></div>   -->
                <!-- 20230522 ljh lightning end -->
                <table>
                    <tr>
                        <td style="text-align:right;">{!$ObjectType.Rental_Apply_Equipment_Set__c.fields.Name.label}：</td>
                        <td style="text-align:left;"><apex:outputText value="{!parentObj.Name}" style="width:100px"/></td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">{!$ObjectType.Rental_Apply_Equipment_Set__c.fields.Fixture_Set_Idx__c.label}：</td>
                        <td style="text-align:left;"><apex:outputText value="{!parentObj.Fixture_Set_Idx__c}" style="width:100px"/></td>
                    </tr>
                    <tr>
                        <td style="text-align:right;">{!$ObjectType.Rental_Apply_Equipment_Set__c.fields.Loaner_name_F__c.label}：</td>
                        <td style="text-align:left;"><apex:outputText value="{!parentObj.Loaner_name_F__c}" style="width:100px"/></td>
                    </tr>
<!--                        <tr>
                        <td colspan="2">{!$ObjectType.Rental_Apply_Equipment_Set__c.fields.Loaner_code__c.label}</td>
                        <td colspan="3"><apex:outputText value="{!parentObj.Loaner_code__c}" style="width:100px"/></td>
                    </tr> -->
                    <!-- <tr>
                        <td colspan="2">{!$ObjectType.Rental_Apply_Equipment_Set__c.fields.Rental_Num__c.label}</td>
                        <td colspan="3"><apex:outputText value="{!parentObj.Rental_Num__c}" style="width:100px"/></td>
                    </tr> -->
<!--TODO  同一附属品：レ -->

                </table>
                <!-- 20230522 ljh lightning start -->
                <div style="width:50%;float:right;">
                        <!-- <apex:commandButton style="float:left;" action="{!save}" value="確定" onclick="blockme();" rerender="allForm, checEventFrame" oncomplete="unblockUI();" /> -->
                        <apex:commandButton style="float:left;" onclick="checkInterventionReason();return false;"  value="確定" />
                        <apex:commandButton style="float:right;" value="返回上一级" action="{!goBack}"/>
                        <apex:commandButton style="float:right;" value="返回申请单" action="{!cancel}"/>
                <div style="clear:both;"></div>
                </div>
                <!-- 20230522 ljh lightning end -->
            </apex:pageBlock>
            <c:RelationListPagingCmp id="cmpid" pgController="{!this}" hasCheckbox="false" noSort="true"/>
        </apex:outputPanel>
    </apex:form>
    <apex:outputPanel id="checEventFrame">
      <script type="text/javascript">
          // 数量添加加减符号
          j$(".dataCellBorder1.col_Rental_Num__c").each(function () {
            //   20230614 ljh lightning start 
              if(!this.firstElementChild.disabled){
                //   j$(this).append('<input type="button" style="width: auto;" class="inc btn" value="+" /><input type="button" style="width: auto;" class="dec btn" value="-" />');
                  j$(this).append('<input type="button" style="width:1.5rem;line-height:1.5rem;" class="inc btn" value="+" /><input type="button" style="width:1.5rem;line-height:1.5rem;" class="dec btn" value="-" />');
                }
              else{
                //   j$(this).append('<input type="button" style="width: auto;" class="dec btn" value="-" />');
                  j$(this).append('<input type="button" style="width:1.5rem;line-height:1.5rem;" class="dec btn" value="-" />');
              }
            //   20230614 ljh lightning end 
          });
          j$(".dataCellBorder1.col_Rental_Num__c input[type=button]").on("click", function() {
              var $button = j$(this);
              var oldValue = $button.parent().find("input[type=text]").val();
              if ($button.val() == "+") {
                  var newVal = parseFloat(oldValue) + 1;
              } else {
                  // Don't allow decrementing below zero
                  if (oldValue > 0) {
                    var newVal = parseFloat(oldValue) - 1;
                  } else {
                    newVal = 0;
                  }
              }
              $button.parent().find("input[type=text]").val(newVal);
          });
      </script>
    </apex:outputPanel>
</apex:page>