<apex:page Controller="TransferEquipmentSetSRListController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="调拨配套一览" lightningStylesheets="true">
<head>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
</head>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<script>
var standalone = window.navigator.standalone,
    userAgent = window.navigator.userAgent.toLowerCase(),
    safari = /safari/.test( userAgent ),
    ios = /iphone|ipod|ipad/.test( userAgent );
function checkAll(ele) {
    var ckd = j$(ele).attr("checked") ? true : false;
    j$('input[type="checkbox"]').prop("checked", ckd);
}
function go() {
    var type = j$(escapeVfId('allPage:allForm:allBlock:type')).value();
    var disabled = j$(escapeVfId('allPage:allForm:allBlock:type')).prop('disabled');
    var typeStr = j$(escapeVfId('allPage:allForm:allBlock:type')).children(':selected').text();
    var raesIds = j$('#checkRAES:checked').next().map(function() { return j$(this).val(); } ).get();
    var raesIdsStr = raesIds.join(',');
    if(disabled) {
        alert('当前用户不可操作');
        return
    }
    if (raesIdsStr == '') {
        alert('请选择至少一条备品一览');
        return
    }
    if (type == '无') {
        alert('请选择一种方式');
    } else {
        setType();
    }
}

function changePage() {
    var type = j$(escapeVfId('allPage:allForm:allBlock:type')).value();
    var typeStr = j$(escapeVfId('allPage:allForm:allBlock:type')).children(':selected').text();
    var raesIds = j$('#checkRAES:checked').next().map(function() { return j$(this).val(); } ).get();
    var raesIdsStr = raesIds.join(',');
    var url = '';
    if('{!showDown}'=='false' && (typeStr == '下架' || typeStr == '发货检测' || typeStr == '发货')) {
        alert('不可以操作下架相关画面!');
        return;
    }
    if('{!showUp}'=='false' && (typeStr == '欠品' || typeStr == '入库检测' || typeStr == '上架')) {
        alert('不可以操作上架相关画面!');
        return;
    }
    if (typeStr == '下架') {
        type = "Shippment";
        url = 'TransferShippmentReceived1';
    } else if (typeStr == '发货检测') {
        type = "Shippment";
        url='TransferShippmentReceived2'
    } else if (typeStr == '发货') {
        type = "Shippment";
        url='TransferShippmentReceived3'
    } else if (typeStr == '欠品') {
        type = "Received";
        url='TransferShippmentReceived4'
    } else if (typeStr == '入库检测') {
        type = "Received";
        url='TransferShippmentReceived5'
    } else if (typeStr == '上架') {
        type = "Received";
        url = 'TransferShippmentReceived6';
    }
    if (!standalone && !safari && ios) {
        window.location.href="/apex/"+url+"?id=" + raesIdsStr + "&type=" + type + "&open=web";
    } else {
        window.open("/apex/"+url+"?id=" + raesIdsStr + "&type=" + type + "&open=web",'id');
    }
}

</script>
<style type="text/css">
    .mainTitle {
        font-size: 23px !important;
    }
</style>
<apex:form id="allForm">
    <apex:pageBlock title="调拨配套一览" id="allBlock" rendered="true">
        <apex:actionFunction name="setType" action="{!setType}" oncomplete="changePage();"/>
        <apex:outputPanel id="message">
            <apex:pageMessages />
        </apex:outputPanel>

        <div style="font-size: 22px;">
            <table>
            <!-- 20210331 you WLIG-BV8CHF start-->
                <tr>
                    <td>
                        申请单号:
                        <c:PDFWbr targetStr="{!sr_apply_no}"/><input type="hidden" id="apply_no" value="{!sr_id}"/>
                    </td>
                    <td>
                        &nbsp;&nbsp;出库/入库:
                        <apex:selectList disabled="{!NOT(canSelect)}" id="type" value="{!selectedType}" size="1" style="height: 35px; font-size: 22px;">
                            <apex:selectOptions value="{!typeList}"/>
                        </apex:selectList>
                    </td>
                    <td>
                        <apex:commandButton style="font-size: 22px; margin-left: 1%;" value="确定" onclick="go(); return false;"/>
                    </td>
                </tr>
                <tr>
                    <td>调拨前地区：<c:PDFWbr targetStr="{!sr_FromLocation}"/></td>
                    <td>&nbsp;&nbsp;调拨至地区：<c:PDFWbr targetStr="{!sr_ToLocation}"/></td>
                </tr>
                <!-- 20210331 you WLIG-BV8CHF end-->
            </table>
        </div>

        <table border="1" style="border-collapse: collapse; font-size:23px;">
            <tr>
                <th style="text-align:center;"><input type="checkbox" checked="checked" onchange="checkAll(this)" />全选</th>
                <th style="text-align:center;">{!$ObjectType.TransferApply__c.fields.Name.label}</th>
                <th style="text-align:center;white-space:normal;">{!$ObjectType.Asset.fields.Fixture_Model_No_F__c.label}</th>
                <th style="text-align:center;">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
                <th style="text-align:center;">{!$ObjectType.Asset.fields.Fixture_QRCode__c.label}</th>
                <th style="text-align:center;white-space:normal;">{!$ObjectType.TransferApplySummary__c.fields.TAS_Status__c.label}</th>
            </tr>
            <apex:repeat value="{!resList}" var="res" id="resList">
                <tr>
                    <td><input type="checkbox" id="checkRAES" checked="checked" /><input type="hidden" value="{!res.Id}"/></td>
                    <td style="text-align:center;"><a href="/apex/TransferEquipmentSetSRList?id={!res.TransferApply__r.Name}">{!res.TransferApply__r.Name}</a></td>
                    <td style="text-align:center;">{!res.First_TAD__r.Asset__r.Fixture_Model_No_F__c}</td>
                    <td style="text-align:center;">{!res.First_TAD__r.Asset__r.SerialNumber}</td>
                    <td style="text-align:center;">{!res.First_TAD__r.Asset__r.Fixture_QRCode__c}</td>
                    <td style="text-align:center;">{!res.TAS_Status__c}</td>
                </tr>
            </apex:repeat>
        </table>

    </apex:pageBlock>
</apex:form>
</apex:page>