<!-- <apex:page controller="AccessoryAddController" showHeader="false" sidebar="false" id="allPage" action="{!init}"> -->
<apex:page controller="AccessoryAddController" showHeader="false" sidebar="false" id="allPage" action="{!init}" lightningStylesheets="true">
<head>
<title>附属品追加</title>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.AccessoryAddCss)}"/>
<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)}"/>

<!-- 20230426 zq add style -->
<style>
    body .bPageBlock .detailList .labelCol {
        width: auto;
    }
    body input.btn {
        /* padding: 2px 3px; */
        margin-left: 55px;
    }
    /* 20230602 ljh  */
    body .message{
        margin: 0rem 0!important;
    }
    body .pbBottomButtons{
        margin: 0rem 0rem 0;
        width: 99%;
    }
    /*20231115 ljh 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;
    }
    /*20231115 ljh end*/
</style>
<script type="text/javascript">
    var heightAjustment = 120;
    var widthAjustment = 30;

    // 备品智能化项目对应 20231122 by lc Start
    function checkInterventionReason() {
        // 其他目的以外的，主体未分配时，附属品不可以进行操作
        if ({!parentObj.Rental_Apply__r.Demo_purpose1__c != '其他' 
            && !isMainAssign 
            && !parentObj.Rental_Apply__r.Manually_Flag__c 
            && parentObj.Rental_Apply__r.Cross_Region_Assign__c == ''}) {
            alert("请在主体分配后再处理！");
        } else {
            //检查是否需要输入人工干预理由
            // 协议借用的附属品不走自动分配，所以附属品的人工干预，只有产品试用和维修代用才需要
            if ({!parentObj.Rental_Apply__r.Manually_Flag__c 
                || parentObj.Rental_Apply__r.Cross_Region_Assign__c != ''
                || (parentObj.Rental_Apply__r.Demo_purpose1__c != '产品试用' && parentObj.Rental_Apply__r.Demo_purpose1__c != '维修代用')}) {
                blockme();
                save();
            } else if ({!sonObj.Intervention_Reason__c != ''}) {
                blockme();
                save();
            } else if ({!sonObj.Asset__c == '' && sonObj.Intervention_Reason__c == ''}) {
                j$("[id*='Intervention_Reason']").val('附属品不全');
                blockme();
                save();
            } else {
                j$('#inputReason').show();
            }
        }
    }

    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:actionFunction name="save" action="{!save}" rerender="allForm" 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:inputField value="{!sonObj.Intervention_Reason__c}" 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">
                <apex:pageBlockSection title="附属品追加">
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Name}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Demo_purpose1__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Owner.Name}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.demo_purpose2__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Salesdept__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Product_category__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.WorkPlace__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Equipment_Type_F__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Internal_asset_location_F__c}" />
                    <apex:outputText />
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Request_shipping_day__c}"/>
                    <apex:outputField value="{!parentObj.Rental_Apply__r.Request_return_day__c}"/>
                    <apex:outputField value="{!parentObj.Fixture_Set__r.Fixture_Set_Body_Model_No__c}"/>
                    <apex:outputField value="{!parentObj.Irreplaceable_flag__c}"/>
                    <apex:outputField value="{!parentObj.Fu_Shu_Pin_Fen_Pei_Jia__c}"/>
                    <apex:outputText />
                    <apex:outputField value="{!parentObj.Rental_Start_Date__c}"/>
                    <apex:outputField value="{!parentObj.Rental_End_Date__c}"/>
                    <!-- 20230602 ljh start -->
                    <!-- <apex:pageBlockSectionItem >
                        <apex:outputPanel >
                            <apex:outputText value="关键字" style="width:50px"/>
                            <apex:inputText value="{!keyword}" style="width:200px;margin-left: 50px;"/>
                        </apex:outputPanel>
                        <apex:commandButton value="检索" action="{!searchOpp}" onclick="blockme();" rerender="allForm" oncomplete="unblockUI();" />
                    </apex:pageBlockSectionItem> -->
                    <!-- 20230602 ljh end -->
                </apex:pageBlockSection>
                 <table>
                    <tr>
                        <td width="20px"/>
                        <!--20230426 zq <td width="200px"> -->
                        <td width="220px">
                          <apex:outputLabel for="bieCunFangDi" value="备品存放地" />
                          <!-- <apex:outputText value="{!bieCunFangDi}"/> -->
                          <apex:selectList value="{!bieCunFangDi}" size="1" style="margin-left: 20px; width:110px" id="bieCunFangDi">
                            <apex:selectOptions value="{!bieCunFangDiOps}"/>
                            <!-- #OLY_OCM-659 备品存放地 选项变化时，本部 选项值随之发生变化 -->
                            <apex:actionSupport event="onchange" reRender="bieBenBu"/>
                          </apex:selectList>
                        </td>
                        <td width="10px"></td>
                        <!-- #OLY_OCM-654 因为MA本部和产品培训本部还是需要检索条件,所以需要别本部的检索条件 Start -->
                        <td width="180px">
                          <apex:outputLabel for="bieBenBu" value="本部" />
                          <apex:selectList value="{!bieBenBu}" size="1" style="margin-left: 20px; width:110px" id="bieBenBu">
                            <apex:selectOptions value="{!bieBenBuOps}"/>
                          </apex:selectList>
                        </td>
                        <!-- #OLY_OCM-654 因为MA本部和产品培训本部还是需要检索条件,所以需要别本部的检索条件 End -->
                        <!-- 20230602 ljh start -->
                        <td width="80px" align ="right">关键字：</td>
                        <td width="200px" align ="left">
                            <apex:inputText value="{!keyword}" style="width:200px;"/>
                        </td>
                        <td width="180px"><apex:commandButton value="检索" action="{!searchOpp}" onclick="blockme();" rerender="allForm" oncomplete="unblockUI();" /></td>
                        <!-- 20230602 ljh start -->
                    </tr>
                </table>
                <!-- 20230602 ljh start  -->
                <!-- <apex:pageBlockButtons location="bottom">
                    <apex:commandButton style="float:left;" action="{!save}" onclick="blockme();" value="保存" rerender="allForm" oncomplete="unblockUI();" />
                    <apex:commandButton style="float:right;" action="{!cancel}" value="返回" rerender="allForm"/>
                </apex:pageBlockButtons>
                <div style="clear:both;"></div>

                <apex:outputPanel id="message">
                    <apex:pageMessages />
                </apex:outputPanel> -->
                <!-- 20230602 ljh end  -->
            </apex:pageBlock>
            <!-- 20230602 ljh start  -->
            <apex:outputPanel id="message">
                <apex:pageMessages />
            </apex:outputPanel>
            <apex:pageBlock >
            <apex:pageBlockButtons location="bottom" style="margin:0;padding:0;"> 
                <!-- <apex:commandButton style="float:left;" action="{!save}" onclick="blockme();" value="保存" rerender="allForm" oncomplete="unblockUI();" /> -->
                <apex:commandButton style="float:left;" onclick="checkInterventionReason();return false;"  value="保存" />
                <apex:commandButton style="float:right;" action="{!cancel}" value="返回" rerender="allForm"/>
            </apex:pageBlockButtons>
            <div style="clear:both;"></div>
            </apex:pageBlock>
            <!-- 20230602 ljh end  -->
            <c:RelationListPagingCmp id="cmpid" pgController="{!this}" hasCheckbox="true" isRadio="true" />
        </apex:outputPanel>
    </apex:form>
</apex:page>