<apex:page controller="NotReceivingNoteWaitingReceiptController" showHeader="false" action="{!init}" id="allPage">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.ReceivingNotePageCss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.ReceivingNotePageJS)}"/>
    <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
    <apex:form >
        <!-- 此处隐式生成二维码图片，防止PDF页上的二维码崩坏 -->
        <!-- <apex:includeScript value="{!URLFOR($Resource.qrcode)}"/> -->
        <apex:includeScript value="/soap/ajax/40.0/connection.js"/>
        <apex:includeScript value="/soap/ajax/40.0/apex.js"/>
        <div id="qrcode" hidden="true"></div>
        <script type="text/javascript">
        </script>
    </apex:form>

    <apex:form id="allForm">
        <style>
            table.headTable td   {
                /*min-width:150px;*/
            }
            .left20 {
                margin-left: 20px;
            }

            body .pbBody table.list tr.headerRow td.colViewing {
              background-image:url('{!URLFOR($Resource.IconResizeMinus_5)}') ;
              background-repeat:no-repeat;
            }
            body .pbBody table.list tr.headerRow td.colUnHideIcon {
              background-image:url('{!URLFOR($Resource.IconResizePlus_5)}');
              background-repeat:no-repeat;
            }
            td.deleted {
                background-color: #ccc;
            }
            td.newed {
                color: #f00 !important;
            }
        </style>
        <script type="text/javascript">
            var heightAjustment = 120;
            var widthAjustment = 30;
            j$(document).ready(function(){
            //       blockme();
            //       init();
              // windowResize();
            });
            function runSFDCAddRemote(MetadataConnectionWarning) {
                if (MetadataConnectionWarning) SFDCAddRemote('{!$Api.Session_ID}');
            }
            function sortTableJs(key) {
              // blockme();
              sortTablefunc(key);
            }

            j$(function() {
                var tableWidth = 0;
                j$('body .pbBody table#tableHeader tr.headerRow td').each(function() {
                    var colClass = getColClassName(this);
                    if (colClass != 'col_Scroll') {
                        var headerCol = j$('body .pbBody table.list tr.headerRow td.' + colClass);
                        tableWidth += headerCol.width();
                    }
                });
                j$('table#tableData').css('width', (tableWidth + 2) + 'px');
                j$('table#tableHeader').css('width', (tableWidth + 2) + 'px');

                // list の headerRow の tdに toggleWidth() を追加
                bindTdToggleWidth();
            });
            windowResize();


            function closeCurrentPage() {
                const ua = window.navigator.userAgent;
                if (ua.indexOf('MSIE') > 0) {
                    if (ua.indexOf('MSIE 6.0') > 0) {
                        window.opener = null;
                        window.close();
                    } else {
                        window.open('', '_top');
                        window.top.close();
                    }
                } else {
                    window.opener = null;
                    window.open('', '_self', '');
                    window.close();
                }
            }
            function checkMessage() {
                if (j$(escapeVfId('allPage:allForm:done_flg')).val() == 'true') {
                    alert("保存成功");
                }
            }
        </script>
        <apex:pageMessages />
        <apex:inputHidden value="{!done_flg}" id="done_flg"/>
        <apex:outputPanel id="pageallPanel">
            <apex:pageBlock id="searchBlock">
                    <table class="headTable" style="width:100%">
                        <tr>
                            <td>
                                <span style="font-weight:bold;">
                                备品存放地&nbsp;
                                </span>
                                {!pageB.rn.Internal_asset_location__c}
                            </td>
                            <td>
                                <span style="font-weight:bold;">
                                合同编码&nbsp;
                                </span>
                                {!pageB.rn.Sales_order_number__c}
                            </td>
                            <td>
                                <span class="left20" style="font-weight:bold;">
                                订单编码&nbsp;
                               </span>
                               {!pageB.rn.OrderCode__c}
                            </td>
                            <td>
                                <span class="left20" style="font-weight:bold;">
                                采购申请决裁号&nbsp;
                               </span>
                               {!pageB.rn.ApprovalNumber__c}
                            </td>
                            <td>
                                <span class="left20" style="font-weight:bold;">
                                发货日&nbsp;
                                </span>
                                <apex:outputText value="{0, date, yyyy'-'MM'-'dd}">
                                    <apex:param value="{!pageB.rn.DateOfDelivery__c}" />
                                </apex:outputText>
                            </td>
                            <td>
                                <span class="left20" style="font-weight:bold;">
                                收货申请单NO&nbsp;
                               </span>
                               {!pageB.rn.ReceivingNoteNo_New__c}
                            </td>
                            <td>
                                <span class="left20" style="font-weight:bold;">
                                收货清单状态&nbsp;
                               </span>
                               {!pageB.rn.RN_Status__c}
                            </td>
                        </tr>
                    </table>
                    <table class="searchTable" style="width:100%">
                        <tr>
                            <td>
                                <span>
                                    收货状态:
                                    <apex:selectList value="{!pageB.status}" size="1">
                                        <apex:selectOptions value="{!StatusOps}"/>
                                    </apex:selectList>
                                </span>
                                <span class="left20">
                                    备品配套明细型号:
                                    <apex:inputText value="{!pageB.fixture_Model_No}"/>
                                </span>
                                <span class="left20">
                                    <apex:selectList value="{!showCount}" size="1" style="width:60px">
                                        <apex:selectOptions value="{!ShowCountOps}"/>
                                    </apex:selectList>
                                </span>
                                <span style="margin-left: 50px;">
                                    <apex:commandButton value="检索" action="{!search}" onclick="blockme();" reRender="allForm"  oncomplete="unblockUI();"/>
                                </span>
                            </td>
                            <td>
                                <span style="margin-left: 50px;float: right;">
                                    <apex:commandButton style="" value="数据确认" action="{!defineSaveRecord}" onclick="blockme();" reRender="allForm"  oncomplete="unblockUI();checkMessage();"/>
                                    <apex:commandButton style="" value="保存" action="{!saveRecord}" onclick="blockme();" reRender="allForm"  oncomplete="unblockUI();checkMessage();"/>
                                    <apex:commandButton value="返回" onclick="closeCurrentPage();"/>
                                </span>
                            </td>
                        </tr>
                    </table>
                    <div style="background-color: black; height: 1px; width: 100%;"/>
                </apex:pageBlock>
                <apex:pageBlock id="dataBlock">

                <apex:inputHidden id="currentPageRecordCnt" value="{!pageB.currentPageRecordCnt}"/>
                <div>
                    <apex:commandButton reRender="allForm" onclick="blockme();" disabled="{!canBefore = false}" action="{!beforePage}" value="back" oncomplete="unblockUI();"/>
                    {!nowPage}/{!maxPage}
                    <apex:commandButton reRender="allForm" onclick="blockme();" disabled="{!canNext = false}" action="{!nextPage}" value="next" oncomplete="unblockUI();"/>
                </div>
            <div id="out_Div_L" style="width: 100%;">
                <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableHeader_L">
                    <tr class="headerRow" height="30px">
                        <td class="col_chk" align="center">
                            <input type='checkbox' onClick='checkAll()' id="checker" />
                        </td>
                        <apex:repeat value="{!inputFieldList}" var="info">
                            <td class="col_{!info.value}">
                               {!info.label}
                            </td>
                        </apex:repeat>
                    </tr>
                </table>
            </div>
            <div style="clear:both;"/>
            <div id="in_Div_L" style="width: 100%;overflow: auto;">
                <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableData_L">
                    <apex:variable value="{!0}" var="Cnt" />
                        <apex:repeat id="dataline_L" value="{!pageB.showBList}" var="var">
                            <tr class="dataRow" id="tableData_L_{!Cnt}">
                                <td class="dataCellBorder1 col_Chk {!IF(var.rnd['Change_Point__c']=='删除','deleted',IF(var.rnd['Change_Point__c']!=NULL,'newed',''))}" align="center">
                                    <apex:inputCheckbox rendered="{!var.rnd['Change_Point__c']!='删除' && var.canChange}" styleClass="rowchkcls" value="{!var.checked}" id="rowCheck"/>
                                </td>
                                <apex:repeat value="{!inputFieldList}" var="info">
                                    <td class="dataCellBorder1 col_{!info.value} {!IF(var.rnd['Change_Point__c']=='删除','deleted',IF(var.rnd['Change_Point__c']!=NULL,'newed',''))}" align="center" style="{!IF(info.value == 'ReceivingNoteDetailNo__c' && var.haveAsset, 'background-color: #6eb9ef;', '')}">
                                        <apex:outputPanel rendered="{!IF(info.value = 'SerialNumber__c',TRUE,FALSE)}">
                                            <apex:inputField value="{!var.rnd[info.value]}" onchange="setChangeFlg('{!var.lineNo}')"  ignoreEditPermissionForRendering="true"/>
                                        </apex:outputPanel>

                                        <apex:outputPanel rendered="{!IF(info.value = 'SerialNumber__c',FALSE,TRUE)}">
                                            <apex:outputField value="{!var.rnd[info.value]}"/>
                                        </apex:outputPanel>
                                    </td>
                                </apex:repeat>
                            </tr>
                        <apex:variable value="{!Cnt+1}" var="Cnt" />
                    </apex:repeat>
                </table>
            </div>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>