<apex:page controller="RentalApplyJumpController" action="{!init}" showHeader="false" id="allPage">
    <head>
      <title>备品借出一览插队申请</title>
      <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
      <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
      <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    </head>
    <apex:form id="allForm">
        <script type="text/javascript">
            function back() {
                window.opener.parent.location.href = "/{!RaId}";
                top.window.close();
            }
            function alertSuccess() {
                var saveStatus = document.getElementById('{!$Component.allForm.saveStatus}').value;
                if (saveStatus == 'ok') {
                    alert('保存成功！');
                }
            }
            function checkSaveStatus() {
                var saveStatus = document.getElementById('{!$Component.allForm.saveStatus}').value;
                if (saveStatus == 'ok') {
                    window.open("/{!objId}");    
                    top.window.close();
                }
            }
            function checkAll() {
			    j$("table td.col_chk input").each(function(){
			        if(!this.disabled) {
			            this.checked = j$("input#checker").prop('checked');
			        }
			    })
			}
			function syJs() {
	            var cnt = j$("#infoListSize").value();
	            console.log(cnt);
                var Loaner_jump_Remarks = j$("#jumpReason").value();
                console.log(Loaner_jump_Remarks);
                for (var i = 0; i < cnt; i++) {
                  var lock = j$(escapeVfId('allPage:allForm:searchBlock:raesdLists:' + i + ':rowCheck'));
                  if(lock.prop('checked') == true){
                    j$(escapeVfId('allPage:allForm:searchBlock:raesdLists:' + i + ':jumpReason_row')).val(Loaner_jump_Remarks);
                  }
                }
        	}
        </script>
        <apex:pageMessages />
        <input type="hidden" id="infoListSize" value="{!infoListSize}" />
        <apex:inputHidden value="{!saveStatus}" id="saveStatus"/>
        <div style="margin: 10px 15px;">
	    	<table>
                <tr>
                	<td  align="left">
                        插队原因：
                    </td>
                	<td align="left">
                        <textarea rows="2" cols="60" name="jumpReason"  id= "jumpReason" ></textarea>
                    </td>
                    <td  align="left">
                         <apex:commandButton style="margin: 0 0;" value="适用" onclick="syJs();return false;" rerender="allForm"/>
                    </td>
                </tr>
            </table>
        <!-- j$('#AllSplitModal').hide();blockme(); -->
        </div> 
        <apex:pageBlock id="searchBlock" tabStyle="Report">
            <apex:dataTable value="{!infoList}" var="info" id="raesdLists" border="1" cellpadding="5">
				<apex:column html-class="col_chk">
					<apex:facet name="header">全选<input type='checkbox' onClick='checkAll();' id="checker"/></apex:facet>
					<apex:inputCheckbox value="{!info.isSelect}" id="rowCheck"/>
				</apex:column>
				<apex:column >
					<apex:facet name="header">借出备品配套一览No.</apex:facet>
					<apex:outputField value="{!info.raesd.Rental_Apply_Equipment_Set__c}" />
				</apex:column>
				<apex:column >
					<apex:facet name="header">借出配套型号</apex:facet>
					<apex:outputField value="{!info.raesd.Fixture_Model_No__c}" />
				</apex:column>
				<apex:column >
					<apex:facet name="header">借出备品配套一览明细状态</apex:facet>
					<apex:outputField value="{!info.raesd.RAESD_Status__c}" />
				</apex:column>
                <!-- <apex:column >
                    <apex:facet name="header">是否允许插队</apex:facet>
                    <apex:inputField value="{!info.raesd.Allow_Adjust_Queue_Flag__c}" id="Allow_Adjust_Queue_Flag"/>
                </apex:column> -->
				<apex:column >
					<apex:facet name="header">插队原因</apex:facet>
					<apex:inputField value="{!info.raesd.jumpReason__c}" id="jumpReason_row"/>
				</apex:column>
            </apex:dataTable>
            <div style="height: 15px"></div>
            <apex:commandButton value="确认插队" action="{!saveJump}" oncomplete="alertSuccess();checkSaveStatus();unblockUI();" onclick="blockme();" rerender="allForm" />
            <apex:commandButton value="返回" onclick="back(); return false;" rerender="allForm" oncomplete="unblockUI();" />
          </apex:pageBlock>
        </apex:form>
</apex:page>