<apex:page controller="LookupController" id="pg" showheader="false" sidebar="false"  title="{!title}" >
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.clipboardminjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <script type="text/javascript">

        //搜索跳转
        function clearSearch(){
            //清空值
            j$(escapeVfId('pg:formId:txtSearch'))[0].value = '';
        }

        //js取参
        function GetQueryValue(queryName) {
              var query = decodeURI(window.location.search.substring(1));
              var vars = query.split("&");
             for (var i = 0; i < vars.length; i++) {
                 var pair = vars[i].split("=");
                 if (pair[0] == queryName) { return pair[1]; }
             }
             return null;
         }
         //强制 不同部分之间刷新的先后顺序
        function loadPage(){
            //初始化去掉默认样式
            removeButtonStyle();
            loadPage();
        }
    </script>
    <style type="text/css">
        /* 标准查找字段 搜索框 input样式*/
        .inputTextStyle{
            height: 28px;
            width: 150px;
            box-sizing: border-box;
            border-radius: 4px;
            border: 1px solid #cccccc;
            box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
        }
        .wrapper {
            cursor: pointer;
            border-radius: 5em;
            color: #fff;
            background: linear-gradient(to right, #34becd, #7740fb5c);
            border: 0;
            padding-left: 20px;
            padding-right: 20px;
            padding-bottom: 5px;
            padding-top: 3px;
            font-family: 'Ubuntu', sans-serif;
            /* margin-left: 5%; */
            font-size: 13px;
            box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.04);
          }
          /*分页按钮用*/
          .wrapperPage {
            cursor: pointer;
            border-radius: 5em;
            color: #fff;
            /*background: linear-gradient(to right, #34becd, #7740fb5c);*/
            border: 0;
            padding-left: 20px;
            padding-right: 20px;
            padding-bottom: 5px;
            padding-top: 3px;
            font-family: 'Ubuntu', sans-serif;
            /* margin-left: 5%; */
            font-size: 13px;
            box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.04);
          }
          .buttonDisabled{
            background-position: 0 -90px;
            border-color: #c4c4c4;
            color: #909090;
          }
          
    </style>
    <!-- form 表单 -->
    <apex:form id="formId">
        <!-- 定义后台方法 js 调用   精琢技术 wql 2021/04/01  start-->
        <apex:actionFunction action="{!loadPage}" name="loadPage" reRender="pnlSearchResults" oncomplete="removeButtonStyle()">
        </apex:actionFunction>
        <apex:actionFunction action="{!search}" name="search" reRender="pnlSearchResults" oncomplete="removeButtonStyle()">
        </apex:actionFunction>
        <!-- 定义后台方法 js 调用   精琢技术 wql 2021/04/01  end-->
        <apex:outputpanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:tabpanel id="tabbedPanel" selectedtab="name1" switchtype="client">
                <!-- SEARCH TAB -->
                <apex:tab id="tabOne" label="{!title}" name="tab1">
                    <apex:actionregion id="actionOne">

                        <!-- 搜索列 模糊检索  精琢技术 wql 2021/04/01-->
                        <apex:outputpanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
                            <apex:outputlabel for="txtSearch" style="font-weight:Bold;padding-right:10px;" value="{!searchLabel}" id="searchLabel">
                            </apex:outputlabel>
                            <apex:inputtext id="txtSearch" value="{!searchString}" styleClass="inputTextStyle">
                            </apex:inputtext>
                            <span style="padding-left:5px" id="ClearSearch">
                                <apex:commandbutton id="btnGoClear" action="{!Search}" rerender="searchResults" value="清空" oncomplete="loadPage(); "  styleClass="wrapper" onClick="clearSearch();" >
                                </apex:commandbutton>
                            </span>
                            <span style="padding-left:5px" id="searchButton">
                                <apex:commandbutton action="{!Search}" id="btnGo" rerender="searchResults" value="搜索" oncomplete="loadPage();" styleClass="wrapper" >
                                </apex:commandbutton>
                            </span>
                        </apex:outputpanel>

                        <!-- 表格列+分页按钮列  一同刷新 精琢技术 wql 2021/04/01  -->
                        <apex:outputpanel id="pnlSearchResults" layout="block" style="margin:10px;height:350px;overflow-Y:auto;">
                            <!-- table 表格列  精琢技术 wql 2021/04/01 start-->

                            <apex:pageblock id="searchResults">
                                
                                <!-- PleaseJudge 下次调用时，需判断 -->
                                <apex:outputpanel rendered="{!IF(SObjectName == 'ModelLendingProduct__c', true, false)}">
                                    <apex:pageblocktable id="tblResults" value="{!ModelCode}" var="a">
                                        <apex:column >
                                            <apex:facet name="header">
                                                <apex:outputpanel >
                                                    备品配套明细型号
                                                </apex:outputpanel>
                                            </apex:facet>
                                            <apex:outputlink value="{!a.Lid}" onclick="setParentList('{!a.Lid}','{!a.LName}','{!a.id}');return false;">
                                                {!a.Name}
                                            </apex:outputlink>
                                        </apex:column>
                                    </apex:pageblocktable>
                                </apex:outputpanel>
                                <!-- PleaseJudge 下次调用时，需判断 -->
                                <apex:outputpanel rendered="{!IF(SObjectName == 'ModelLendingProduct__c', false, true)}">
                                     <apex:pageblocktable id="tblResults2" value="{!ModelCode}" var="a">
                                        <apex:column >
                                            <apex:facet name="header">
                                                <apex:outputpanel >
                                                    ID
                                                </apex:outputpanel>
                                            </apex:facet>
                                            <apex:outputlink value="{!a.id}" onclick="">
                                                {!a.id}
                                            </apex:outputlink>
                                        </apex:column>
                                        <apex:column >
                                            <apex:facet name="header">
                                                <apex:outputpanel >
                                                    Name
                                                </apex:outputpanel>
                                            </apex:facet>
                                            <apex:outputlink value="{!a.name}" onclick="">
                                                {!a.name}
                                            </apex:outputlink>
                                        </apex:column>
                                    </apex:pageblocktable>
                                </apex:outputpanel>
                            </apex:pageblock>
                            <!-- table 表格列  精琢技术 wql 2021/04/01 end-->

                            <!-- table 分页按钮列  精琢技术 wql 2021/04/01 start-->
                            <!-- 首页 -->
                            <apex:commandbutton action="{!FirstPage}" disabled="{!prev}" rerender="pnlSearchResults" value="首页" id="FirstPage" styleClass="wrapper" oncomplete="removeButtonStyle()">
                            </apex:commandbutton>
                            <!-- 上一页 -->
                            <apex:commandbutton action="{!previous}" disabled="{!prev}" rerender="pnlSearchResults" value="上一页" id="previous" styleClass="wrapper" oncomplete="removeButtonStyle()">
                            </apex:commandbutton>
                            当前页/总页数 {!pageNumber} of {!totalPages}
                            <!-- 下一页 -->
                            <apex:commandbutton action="{!next}" disabled="{!nxt}" rerender="pnlSearchResults" status="Status" value="下一页" id="next" styleClass="wrapper" oncomplete="removeButtonStyle()">
                            </apex:commandbutton>
                            <!-- 尾页 -->
                            <apex:commandbutton action="{!LastPage}" disabled="{!nxt}" rerender="pnlSearchResults" value="尾页" id="LastPage" styleClass="wrapper" oncomplete="removeButtonStyle()">
                            </apex:commandbutton>
                            <!-- table 分页按钮列  精琢技术 wql 2021/04/01 end-->

                        </apex:outputpanel>
                    </apex:actionregion>
                </apex:tab>
            </apex:tabpanel>
        </apex:outputpanel>
    </apex:form>
    <script type="text/javascript">
        //初始化去掉默认按钮样式
        function removeButtonStyle(){
            //去掉上方 模型出借型号 样式
            if(j$(escapeVfId('pg:formId:tabOne_lbl'))[0]){
                j$(escapeVfId('pg:formId:tabOne_lbl'))[0].classList.remove("rich-tab-header");
                j$(escapeVfId('pg:formId:tabOne_lbl'))[0].classList.remove("rich-tab-active");
                j$(escapeVfId('pg:formId:tabOne_lbl'))[0].style.backgroundColor = "#f1f1f1";
            }
            //去掉上方 清空 样式

            if(j$(escapeVfId('pg:formId:btnGoClear'))[0]){
                j$(escapeVfId('pg:formId:btnGoClear'))[0].classList.remove("btn");
            }
            //去掉 搜索按钮
            if(j$(escapeVfId('pg:formId:btnGo'))[0]){
                j$(escapeVfId('pg:formId:btnGo'))[0].classList.remove("btn");
            }
            //首页
            //先判断是否有该元素
            if(j$(escapeVfId('pg:formId:FirstPage'))[0]){
                //如果按钮是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:FirstPage'))[0].className.indexOf('btnDisabled')==0){
                    j$(escapeVfId('pg:formId:FirstPage'))[0].classList.remove("btnDisabled");
                    j$(escapeVfId('pg:formId:FirstPage'))[0].classList.add("buttonDisabled");
                    j$(escapeVfId('pg:formId:FirstPage'))[0].classList.remove("wrapper");
                    j$(escapeVfId('pg:formId:FirstPage'))[0].classList.add("wrapperPage");

                }
                //如果按钮不是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:FirstPage'))[0].className.indexOf('btn')==0){
                    j$(escapeVfId('pg:formId:FirstPage'))[0].classList.remove("btn");
                }  

            }
            //上一页
            if(j$(escapeVfId('pg:formId:previous'))[0]){
                //如果按钮是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:previous'))[0].className.indexOf('btnDisabled')==0){
                    j$(escapeVfId('pg:formId:previous'))[0].classList.remove("btnDisabled");
                    j$(escapeVfId('pg:formId:previous'))[0].classList.add("buttonDisabled");
                    j$(escapeVfId('pg:formId:previous'))[0].classList.remove("wrapper");
                    j$(escapeVfId('pg:formId:previous'))[0].classList.add("wrapperPage");
                }
                //如果按钮不是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:previous'))[0].className.indexOf('btn')==0){
                    j$(escapeVfId('pg:formId:previous'))[0].classList.remove("btn");
                }  
            }
            //下一页
            if(j$(escapeVfId('pg:formId:next'))[0]){
                //如果按钮是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:next'))[0].className.indexOf('btnDisabled')==0){
                    j$(escapeVfId('pg:formId:next'))[0].classList.remove("btnDisabled");
                    j$(escapeVfId('pg:formId:next'))[0].classList.add("buttonDisabled");
                    j$(escapeVfId('pg:formId:next'))[0].classList.remove("wrapper");
                    j$(escapeVfId('pg:formId:next'))[0].classList.add("wrapperPage");
                }
                //如果按钮不是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:next'))[0].className.indexOf('btn')==0){
                    j$(escapeVfId('pg:formId:next'))[0].classList.remove("btn");
                }  
            }
            //尾页
            if(j$(escapeVfId('pg:formId:LastPage'))[0]){
                //如果按钮是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:LastPage'))[0].className.indexOf('btnDisabled')==0){
                    j$(escapeVfId('pg:formId:LastPage'))[0].classList.remove("btnDisabled");
                    j$(escapeVfId('pg:formId:LastPage'))[0].classList.add("buttonDisabled");
                    j$(escapeVfId('pg:formId:LastPage'))[0].classList.remove("wrapper");
                    j$(escapeVfId('pg:formId:LastPage'))[0].classList.add("wrapperPage");
                }
                //如果按钮不是disabled 则去掉默认样式 添加新的disabled样式
                if(j$(escapeVfId('pg:formId:LastPage'))[0].className.indexOf('btn')==0){
                    j$(escapeVfId('pg:formId:LastPage'))[0].classList.remove("btn");
                }  
            }
        }

        //点击行项目 带值到父页面
        function setParentList(id,name,modelId){
            //赋值到无报告页面
            if(window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode"))){
                 window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode")).val(name);
            }
            //赋值到无报告页面
            if(window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeId"))){
                window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeId")).val(id);
            }
            
            //赋值到无报告页面
            if(window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingCodeId"))){
                window.opener.j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingCodeId")).val(modelId);
            }

            window.close();
        }
        //初始化去掉默认样式
        removeButtonStyle();
    </script>
</apex:page>