<apex:page Controller="ArriveGoodsController" tabStyle="ArriveGoodsMain__tab" showHeader="true" sidebar="true" action="{!init}" id="allPage" title="入库/返品">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<script>
function saveJs() {
    blockme();
    save();
}
function searchProductJs() {
    blockme();
    SearchPro();
}

function ArriveGoodsConfimJs(){
    var inventorysizeNum = j$(escapeVfId('consumableInventorysize')).value();
    if (inventorysizeNum > 0) {
        event.returnValue = confirm("确认入库吗？");
        if(event.returnValue == true){
            blockme();
            ArriveGoodsConfim();
        }
    }else{
        blockme();
        ArriveGoodsConfim();
    }
}
function UpdateGoodsOfReturnJs(){
    event.returnValue = confirm("确认返品吗？");
    if(event.returnValue == true){
        blockme();
        UpdateGoodsOfReturn();
    }
}


//用法如下//add by rentx 20210617 start
function cancleKongbai(){
    var aEle=document.getElementById('tableId').getElementsByTagName('td');
    
    for(var i=0;i<aEle.length;i++){
        if(aEle[i].className=='data2Col' || aEle[i].className=='data2Col last')
        {
            aEle[i].style.display = 'none';
        }
    }
};
//用法如下//add by rentx 20210617 end

window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });

</script>
<apex:form id="allForm">
        <apex:actionFunction name="SearchPro" action="{!SearchPro}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1,ConsumabledetailsofReturn,productInventorydetails, message,detailsSummary" onComplete="unblockUI();cancleKongbai();">
        </apex:actionFunction>
        <apex:actionFunction name="ArriveGoodsConfim" action="{!ArriveGoodsConfim}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1,ConsumabledetailsofReturn,productInventorydetails,message,EDCline_1,orderinfo,messageText" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:actionFunction name="UpdateGoodsOfReturn" action="{!UpdateGoodsOfReturn}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1,ConsumabledetailsofReturn,productInventorydetails,message" oncomplete="unblockUI();">
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
             <apex:outputPanel id="messageText">
                <table>
                        <tr>
                            <td>
                            <div id="ErrorName" style="color: red;font-weight: bold;" >{!alertMessage}</div>
                            </td>
                        </tr>
                </table>
            </apex:outputPanel>
                <apex:outputPanel id="message">
                    <apex:pageMessages />
                </apex:outputPanel>
            <apex:pageBlock title="入库/返品" id="allBlock">
             <apex:pageBlock id="EDCline_1" >
                    <apex:commandButton onclick="ArriveGoodsConfimJs();return false;"   rendered="{!!ReturnFLGbln}" value="到货确认" style="width:150px" rerender="dummy" disabled="{!saveFLGbln}"/>
                    <apex:commandButton onclick="UpdateGoodsOfReturnJs();return false;"  rendered="{!ReturnFLGbln}"  value="登录返品" style="width: 150px" rerender="dummy"/>
            </apex:pageBlock>
            <apex:pageBlock rendered="{!IF(ESetId !='', true, false)}" title="订单信息" id="orderinfo">
                    <table>
                    <colgroup>
                            <col width="150px"/>
                            <col width="150px"/>
                            <col width="100px"/>
                            <col width="100px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="120px"/>
                            <col width="150px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                        <tr>
                            <!-- <td align="right">订单名称</td>
                            <td><apex:outputLink value="/{!coc.Id}" target="LINK_{!coc.Id}"><apex:outputField value="{!coc.Name}" style="width:100px"/></apex:outputLink></td>
                            <td/> -->
                             <td align="right">订单名称：</td>
                            <td><apex:outputField value="{!coc.Name}" style="width:100px"/></td>
                            <td/>
                            <td align="right">{!$ObjectType.Consumable_order__c.fields.Total_num__c.label}：</td>
                            <td><apex:outputField value="{!coc.Total_num__c}" style="width:100px"/></td>
                            <td/>
                            <td align="right">{!$ObjectType.Consumable_order__c.fields.OrderNumber_arrived__c.label}：</td>
                            <td><apex:outputField value="{!coc.OrderNumber_arrived__c}" style="width:100px"/></td>
                            <td/>
                            <td align="right">{!$ObjectType.Consumable_order__c.fields.OrderNumber_notarrive__c.label}：</td>
                            <td><apex:outputField value="{!coc.OrderNumber_notarrive__c}" style="width:100px"/></td>
                            <td/>
                        </tr>
                    </table>
                </apex:pageBlock> 
                <apex:pageBlock title="BarCode录入">
                    <table>
                        <colgroup>
                            <col width="160px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                        <tr>
                            <td align="right">BarCode号</td>
                            <td><apex:inputTextarea id="BarCodeArea"  value="{!barcode}" style="width:600px"/></td>
                            <td/>
                            <td align="right"></td>
                            <td><apex:commandButton value="获取明细" style="width: 150px;" onclick="searchProductJs(); return false;" /></td>
                            <td/>
                        </tr>
                        <tr>
                            <td></td>
                        </tr>
                    </table>
                </apex:pageBlock>

                 <apex:outputPanel id="message">
                    <apex:pageMessages />
                 </apex:outputPanel>
                 <apex:pageBlock title="本次到货产品汇总" rendered="{!!ReturnFLGbln}">
                     <apex:pageblocksection columns="1" id="detailsSummary">
                        <apex:pageblocktable value="{!detailsSummary}" var="records" id="detailsSummaryTable">
                             <apex:column width="80">
                                 <apex:facet name="header">产品型号</apex:facet>
                                 <apex:outputField value="{!records.Prod.Asset_Model_No__c}"/>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">产品名称</apex:facet>
                                 <apex:outputField value="{!records.Prod.Name__c}"/>
                             </apex:column>
                             <apex:column width="80" style="text-align:right;">
                                 <apex:facet name="header">到货数量</apex:facet>
                                 <apex:outputText value="{!records.arrivedCount}"/>
                             </apex:column>
                             <apex:column width="80" style="text-align:right;">
                                 <apex:facet name="header">到货金额</apex:facet>
                                 <apex:outputText value="{!records.arriveAmount}"/>
                             </apex:column>
                        </apex:pageblocktable>
                    </apex:pageblocksection>
                </apex:pageBlock>
                 <apex:pageBlock title="到货明细" rendered="{!!ReturnFLGbln}" id="ConsumableorderdetailsSection">
                     <!-- <apex:pageblocksection columns="1" id="ConsumableorderdetailsSection">add by rentx CHAN-C3K4ZQ 20210618 -->
                     <table class="list"  border="0" cellpadding="0" cellspacing="0" id="tableId" >
                        <colgroup>
                            <col width="160px"/>
                            <col width="160px"/>
                            <col width="160px"/>
                            <col width="160px"/>
                            <col width="160px"/>
                            <col width="160px"/>
                            <col width="200px"/>
                        </colgroup>

                        <tr class="headerRow">
                            <th width="16%">消耗品名称</th>
                            <th width="16%">规格</th>
                            <th width="16%">CFDA状态</th>
                            <th width="16%">注册证编码号</th>
                            <th width="16%">注册证效期</th>
                            <th width="20%">BarCode</th>
                        </tr>
                        <apex:repeat value="{!ConsumableorderdetailsRecordsview}" var="records" id="ConsumableorderdetailsTableOuter" >
                            <apex:repeat value="{!records}" var="item" id="ConsumableorderdetailsTable">
                                <tr class="dataRow">
                                    <td> {!item.Prod.Name__c} </td>
                                    <td> {!item.esd.ProductPacking_list_manual__c} </td>
                                    <td> {!item.esd.CFDA_Status__c} </td>
                                    <td> {!item.esd.Report_Product_Approbation__c} </td>
                                    <td> {!item.ReportProductExpirationDate} </td>
                                    <td> {!item.esd.Bar_Code__c} </td>
                                </tr>
                            </apex:repeat>
                        </apex:repeat>
                    </table>
                    <!-- add by rentx CHAN-C3K4ZQ 20210618 -->

                     <!-- //add by rentx CHAN-C3K4ZQ 20210602 start 注释by rentx start 20210618 -->
                        <!-- <apex:repeat value="{!ConsumableorderdetailsRecordsview}" var="records" id="ConsumableorderdetailsTableOuter" > -->
                     <!-- //add by rentx CHAN-C3K4ZQ 20210602 end -->
                     <!-- //update by rentx CHAN-C3K4ZQ 20210602 start -->
                            <!-- <apex:pageblocktable value="{!records}" var="records" id="ConsumableorderdetailsTable"> -->
                            <!-- <apex:pageblocktable value="{!records}" var="records" id="ConsumableorderdetailsTable"> -->
                     <!-- //update by rentx CHAN-C3K4ZQ 20210602 end -->
                                 <!-- <apex:column width="80"> -->
                                     <!-- <apex:facet name="header">消耗品名称</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.Prod.Name__c}"/> -->
                                 <!-- </apex:column> -->
                                 <!-- <apex:column width="80" style="text-align: center;"> -->
                                     <!-- <apex:facet name="header">规格</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.esd.ProductPacking_list_manual__c}"/> -->
                                 <!-- </apex:column> -->
                                 <!-- <apex:column width="80"> -->
                                     <!-- <apex:facet name="header">CFDA状态</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.esd.CFDA_Status__c}"/> -->
                                 <!-- </apex:column> -->
                                 <!-- <apex:column width="80"> -->
                                     <!-- <apex:facet name="header">注册证编码号</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.esd.Report_Product_Approbation__c}"/> -->
                                 <!-- </apex:column> -->
                                 <!-- <apex:column width="80"> -->
                                     <!-- <apex:facet name="header">注册证效期</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.esd.Report_Product_Expiration__c}"/> -->
                                 <!-- </apex:column> -->
                                  <!-- <apex:column width="80"> -->
                                     <!-- <apex:facet name="header">BarCode</apex:facet> -->
                                     <!-- <apex:outputField value="{!records.esd.Bar_Code__c}"/> -->
                                 <!-- </apex:column> -->
                                <!-- <apex:column width="80">
                                     <apex:facet name="header">发货日期</apex:facet>
                                     <apex:outputField value="{!records.esd.Deliver_date__c}"/>
                                 </apex:column>
                                 <apex:column width="80">
                                     <apex:facet name="header">{!$ObjectType.Consumable_order_details__c.fields.IsArrival__c.label}</apex:facet>
                                     <apex:outputField value="{!records.esd.IsArrival__c}"/>
                                 </apex:column> -->
                            <!-- </apex:pageblocktable> -->
                        <!-- </apex:repeat> -->
                    <!-- </apex:pageblocksection> 注释byrentx end 20210618 end-->
                </apex:pageBlock>

                <apex:pageBlock title="返品明细" rendered="{!ReturnFLGbln}" id="returnTable">
                    <apex:pageBlockSection columns="1" id="ConsumabledetailsofReturn">
                        <apex:pageBlockTable id="ConsumabledetailsofReturnTable" value="{!ShowGoodsofReturnList}" var="ShowGR">
                            <apex:column width="80">
                                <apex:facet name="header">
                                    出库单
                                </apex:facet>
                                <apex:outputLink value="/summonsCreat?ESetid={!IF(ShowGR.esd.Consumable_Shipment_order__c=='', ShowGR.esd.Consumable_Sale_order__c, ShowGR.esd.Consumable_Shipment_order__c)}" target="_blank">
                                    <apex:outputText value="{!IF(ShowGR.esd.Consumable_Shipment_order__c=='', ShowGR.esd.Consumable_Sale_order__r.Name, ShowGR.esd.Consumable_Shipment_order__r.Name)}"/>
                                <!-- <apex:outputLink value="/summonsCreat?ESetid={!ShowGR.esd.Consumable_ZS_order__c}" target="_blank">
                                    <apex:outputText value="{!ShowGR.esd.Consumable_ZS_order__r.Name}"/> -->
                                </apex:outputLink>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    出库日
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.Product_OutDate__c}"/>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    消耗品名称
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.Prod.Name__c}"/>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    出库目的
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.SummonsForDirction_det__c}"/>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    客户名
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.HospItal_Name__c}"/>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    经销商
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.Order_Dealer_Info__c}"/>
                            </apex:column>
                          <apex:column width="80">
                                <apex:facet name="header">
                                    BarCode
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.Bar_Code__c}"/>
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    使用期限
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.Sterilization_limit__c}"/>
                            </apex:column>
                            <apex:column width="80" style="text-align: center;">
                                <apex:facet name="header">
                                    单位
                                </apex:facet>
                                <apex:outputField value="{!ShowGR.esd.Box_Piece__c}"/>
                            </apex:column>
                            <apex:column width="80" style="text-align: center;">
                                <apex:facet name="header">
                                    返品数量
                                </apex:facet>
                                <apex:outputField style="width:80px;"  value="{!ShowGR.esd.Rrturn_count__c}"  rendered="{!IF(ShowGR.esd.Box_Piece__c='盒',true,false)}" />
                                <apex:inputField style="width:80px;"  value="{!ShowGR.esd.Rrturn_count__c}" onchange="if ({!ShowGR.canEdit}){this.value='1'}" rendered="{!IF(ShowGR.esd.Box_Piece__c='个',true,false)}" />
                            </apex:column>
                            <apex:column width="80">
                                <apex:facet name="header">
                                    返品原因
                                </apex:facet>
                                <apex:inputField value="{!ShowGR.esd.Return_reason__c}"/>
                            </apex:column>
                        </apex:pageBlockTable>
                    </apex:pageBlockSection>
                </apex:pageBlock>


                <apex:pageBlock title="入库明细"  id="inTable">
                     <apex:pageblocksection columns="1" id="productInventorydetails">
                     <input type="hidden" id="consumableInventorysize" value="{!inventorysize}" />
                        <apex:pageblocktable value="{!consumableInventory}" var="records" id="productInventorydetailsTable">
                             <apex:column width="160">
                                 <apex:facet name="header">消耗品名称</apex:facet>
                                 <apex:outputField value="{!records.Prod.Name__c}"/>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">BarCode</apex:facet>
                                 <apex:outputText value="{!records.barCodeNo}"/>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">使用期限</apex:facet>
                                 <apex:outputText value="{0, date, yyyy/MM/dd}">
                                    <apex:param value="{!records.sterilizationlimitDate}" />
                                </apex:outputText>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">serialNoorLotNo</apex:facet>
                                 <apex:outputText value="{!records.serialNoorLotNo}"/>
                             </apex:column>
                             <apex:column width="80">
                                 <apex:facet name="header">tracingCode</apex:facet>
                                 <apex:outputText value="{!records.tracingCodeNo}"/>
                             </apex:column>
                             <apex:column width="80" rendered="{!ReturnFLGbln}">
                                <apex:facet name="header">
                                    返品原因
                                </apex:facet>
                                <apex:inputText value="{!records.ReturnReason}"/>
                            </apex:column>
                        </apex:pageblocktable>
                    </apex:pageblocksection>
                </apex:pageBlock>


                <apex:pageBlock title="错误明细" id="ConsumableorderdetailsSection1">
                    <table class="list" border="0" cellpadding="0" cellspacing="0">
                        <tr class="headerRow">
                            <th>消耗品订单</th>
                            <th>消耗品名称</th>
                            <th>BarCode</th>
                            <th>单位</th>
                            <th>数量</th>
                            <th>错误原因</th>
                        </tr>
                    <apex:repeat value="{!ConsumableorderdetailsRecordserror}" var="records" id="ConsumableorderdetailsTable1">
                        <tr class="dataRow">
                            <td Class="dataCell">
                                <apex:outputField value="{!records.esd.Consumable_order_minor__c}"/>
                            </td>
                            <td Class="dataCell">
                                <apex:outputField value="{!records.Prod.Name__c}"/>
                            </td>
                            <td Class="dataCell">
                                <apex:outputField value="{!records.esd.Bar_Code__c}"/>
                            </td>
                            <td Class="dataCell" style="text-align: center;">
                                <apex:outputField value="{!records.esd.Box_Piece__c}"/>
                            </td>
                            <td Class="dataCell" style="text-align: center;">
                                <apex:outputText value="{!records.intMark}"/>
                            </td>
                            <td Class="dataCell">
                                <apex:outputText value="{!records.ErrorReason}"/>
                            </td>
                        </tr>
                    </apex:repeat>
                    </table>

<!--
                    <apex:pageblocktable value="{!ConsumableorderdetailsRecordserror}" var="records" id="ConsumableorderdetailsTable1">
                         <apex:column width="80">
                             <apex:facet name="header">消耗品订单</apex:facet>
                             <apex:outputField id="consumablesCount11" value="{!records.esd.Consumable_order_minor__c}"/>
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">消耗品名称</apex:facet>
                             <apex:outputField value="{!records.Prod.Name__c}"/>
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">BarCode</apex:facet>
                             <apex:outputField value="{!records.esd.Bar_Code__c}"/>
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">单位</apex:facet>
                             <apex:outputField value="{!records.esd.Box_Piece__c}" />
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">数量</apex:facet>
                             <apex:outputText value="{!records.intMark}" />
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">错误原因</apex:facet>
                             <apex:outputText value="{!records.ErrorReason}" />
                         </apex:column>
                    </apex:pageblocktable>-->
                    <table class="list" cellpadding="0" cellspacing="0" border="none">
                        <tr>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;"></td>
                            <td style="border: none;text-align: center;"><apex:outputText id="sumPrice_buttom" value="合计：{!errorsize}"/></td>
                            <td style="border: none;"></td>
                        </tr>
                    </table>
                </apex:pageBlock>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>