<apex:page standardController="OPDPlan__c"   extensions="OPDNoReportApplicationController" showHeader="false" sidebar="false" id="allPage" title="无报告申请" action="{!init}"  docType="html-5.0"  lightningStylesheets="true">
    <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)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.StyleUtilColorCss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.SelectFieldJs)}"/>
    <apex:includeLightning />
    <apex:outputPanel id="checkForm">
        <script text="text/javascript">
            var  approvalFlag='{!approvalFlag}';
            var  noAttachment='{!noAttachment}';
            var  saveFlag = '{!saveFlag}';
            //提交待审批后提示信息
            function alertforApproval(){
                changeStatus();
                 console.log('approvalFlag:'+approvalFlag);
                 console.log('noAttachment:'+noAttachment);
                if(approvalFlag == 'true'){
                    alert('已提交待审批！');
                    
                }else if(noAttachment == 'true'){
                    alert('请您上传附件！');
                }
                else if(approvalFlag == 'false'){
                    alert('审批流报错，请查看错误后关闭本网页再提交待审批!');
                }
                //初始化页面 
                    init();
                
            }

            //保存后提示信息并初始化加载附件list table
            function alertforSave(){
                changeStatus();
                if(saveFlag == 'true'){
                   alert('保存好了！');
                   //初始化页面
                   init();
                }else if(saveFlag == 'false'){
                    alert('保存失败！');
                }
                
            }

        
        
        // //输入框id
        // let inputFieldId='allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport';
        // //存储值id，inputHidden,用于接收返回数值
        // let inputHiddenId='allPage:allForm:AdditionalSupportTest2';
        // //输入框的值
        // let accountValue = '{!opdPlan.AdditionalSupport__c}';

        // //查询对象api
        // let ObjectType = 'OPDPlan__c';
        // //查询结果字段名称
        // let FieldNameList = 'OPD计划No.,Id';
        // //查询结果字段Api，与上列对应
        // let FieldApiNameList = 'Name,Id';
        // //查询查询条件名称
        // let QueryFieldName = 'OPD计划No.';
        // //查询查询条件api
        // let QueryFieldApiName = 'Name';
        // //筛选器
        // let QuertLimit='';

        </script>
        <style>
            #auraErrorMessage{
            display: none
            }
            .slds-scope .slds-has-error .slds-form-element__help {
            display: none;
            }
            body .bPageBlock .pbSubheader h3{
            font-size: 13px;
            }
            body .pbTitle .mainTitle{
            font-weight: 700;
            font-size: 15px;
            }
        </style>
    </apex:outputPanel>
    <apex:outputPanel id="reloadForm">
        <script type="text/javascript">
            changeStatus();
            //dialog 弹窗 start 
            var popupBox;
                popupBox = new SimpleDialog("SpeedDialogId", false);  // 不可拖动
                popupBox.createDialog();

            //是否上传文件
            var IsUpload = false;
            //是否有附件
            var IsHavFile = '{!IsHavFile}';

           

            //精琢技术 2021/02/08 start
            function openFile(){
                //获取出借目的
                var RentalResonTemp = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem:RentalResonTemp__c')).val();
                var status = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem0:noReportStatus')).text();
                if(status == '提交'){
                    alert('无报告申请已提交，无须上传文件证明！');
                }else{
                    if(RentalResonTemp == '演示' ||RentalResonTemp =='无法进入手术室'){
                        popupBox.setTitle("请上传文件证明！");
                        popupBox.importContentNode(document.getElementById("allPage:allForm:popupBox"));
                        popupBox.show(document.getElementById("allPage:allForm:popupBox"));
                        document.getElementById("allPage:allForm:popupBox").style.display = 'block';
                    }else{
                        alert('该出借目的不可上传文件证明！');
                        return false;
                    }
                }
                
                
                
            }
            //dialog 弹窗 end 
            //  精琢技术 wql 2021/02/09 end 
            function save(){
                //获取状态
                var status = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem0:noReportStatus')).text();

                var id = j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeId")).val();

                var modelId = j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingCodeId")).val();

                //wangweipeng     出借目的不能为空        2021/10/19          start
                //下拉框
                var selectO = j$(escapeVfId("allPage:allForm:allBlock:BlockSection:SectionItem:RentalResonTemp__c")).val();
                //wangweipeng     出借目的不能为空        2021/10/19          end

                //状态为提交时，不可再保存
                if(status=='提交'){
                    alert("该无报告申请已提交待审批！");
                    return false;
                }else if(status=='计划中'){
                    alert("该无报告申请已审批！");
                    return false;
                }
                //wangweipeng     出借目的不能为空        2021/10/19          start
                else if(selectO == '--无--'){
                    alert("出借目的不能为空！");
                    return false;
                }
                //wangweipeng     出借目的不能为空        2021/10/19          end
                else{

                    var checkFlag = checkList ();
                    if(checkFlag){
                        blockme();
                        var idNew = '';
                        var modelIdNew = '';
                        if(id){
                            idNew = id;
                        }
                        if(modelId){
                            modelIdNew =modelId;
                        }
                        Save(IsUpload,idNew,modelIdNew);
                    }
                    
                }

                
            }
            //触发审批流
            function ApprovalButton(){
                //获取状态
                var status = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem0:noReportStatus')).text();

                //wangweipeng     出借目的不能为空        2021/10/19          start
                //下拉框
                var selectO = j$(escapeVfId("allPage:allForm:allBlock:BlockSection:SectionItem:RentalResonTemp__c")).val();
                //wangweipeng     出借目的不能为空        2021/10/19          end
                
                if(status == '提交'){
                    alert("该无报告申请已经提交待审批！");
                    return false;
                }else if(status=='计划中'){
                    alert("该无报告申请已审批！");
                    return false;
                }
                //wangweipeng     出借目的不能为空        2021/10/19          start
                else if(selectO == '--无--'){
                    alert("出借目的不能为空！");
                    return false;
                }
                //wangweipeng     出借目的不能为空        2021/10/19          end
                else{
                    //check 验证
                    var checkFlag = checkList ();
                    if(checkFlag){
                        blockme();
                        CommitNeedApproval(IsUpload);
                    }
                    
                }
                
            }
            //check 验证
            function checkList (){
                var RentalResonTemp = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem:RentalResonTemp__c')).val();
                //模型出借产品型号
                var ModelLendingProductCode = j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode')).val();
                //对应修理维修NO
                var CorrespondingRepairNo = j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNo')).val();
                //追加配套
                var AdditionalSupport = j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport')).val();

                if(!IsUpload&&(RentalResonTemp == '演示' ||RentalResonTemp =='无法进入手术室')&&!IsHavFile){
                    alert('请您上传文件证明后，再保存！');
                    return false;
                }else if(RentalResonTemp == '模型出借' && !ModelLendingProductCode){
                    alert('请您填写1.模型出借产品型号！');
                    return false;
                }else if(RentalResonTemp == '对应修理' &&!CorrespondingRepairNo){
                    alert('请您填写2.对应修理维修NO！');
                    return false;
                }else if(RentalResonTemp == '追加配套'&&!AdditionalSupport){
                        alert('请您填写4.追加配套！');
                        return false;
                    
                }else{
                    return true;
                }
            }
            
            //模型出借型号点击 带参跳转 自定义搜索页面
            function lookUpUrl(){
                //① 需要带入输入框的值 
                var code = j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode')).val();
                //②需要传 哪个对象
                var SObjectName = 'ModelLendingProduct__c';

                var url = '/apex/LookupPage?SObjectName='+SObjectName+'&searchLike='+code;
                window.open (url, '自定义检索',
                'height=300, width=600, top=100, left=300, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
            }
            //提交待审批和审批后 页面只读
            function PageReadOnly(){
                //①模型出借
                j$('#inMCodeDIV').hide();
                j$('#outMCodeDIV').show();
                //②对应修理
                j$('#inCRNoDIV').hide();
                j$('#outCRNoDIV').show();
                //出借目的
                j$('#inRReasonDIV').hide();
                j$('#outRReasonDIV').show();
                //③追加配套 
                j$('#inAdsDIV').hide();
                j$('#outAdsDIV').show();
            }
            //模型出借 页面展示
            function MCodeShow(){
                j$('#inMCodeDIV').show();
                j$('#outMCodeDIV').hide();
            }
            //模型出借 页面只读
            function MCodeHide(){
                j$('#inMCodeDIV').hide();
                j$('#outMCodeDIV').show();
            }
            //对应修理 页面展示
            function CRNoDIVShow(){
                j$('#inCRNoDIV').show();
                //单独设置输入框样式 避免与放大镜样式重叠
                j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNo"))[0].className="inputTextStyle";
                j$('#outCRNoDIV').hide();

            }
            //对应修理 页面只读
            function CRNoDIVHide(){
                j$('#inCRNoDIV').hide();
                j$('#outCRNoDIV').show();
            }
            //追加配套 页面展示
            function ADSDIVShow(){
                j$('#inAdsDIV').show();
                //单独设置输入框样式 避免与放大镜样式重叠
                j$(escapeVfId("allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport"))[0].className="inputTextStyle";
                j$('#outAdsDIV').hide();
            }
            //追加配套 页面隐藏
            function ADSDIVHide(){
                j$('#inAdsDIV').hide();
                j$('#outAdsDIV').show();
            }
            //模型出借 清空输入框
            function clearMCode(){
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode')).val('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCode')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeTest')).val('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeTest')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingProductCodeId')).val('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem1:ModelLendingCodeId')).val('');

            }
            //对应修理 清空输入框
            function clearCRNo(){
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNo')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNo')).val('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNoTest')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNoTest')).val('');
            }
            //追加配套 清空输入框
            function clearADS(){
                
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport')).val('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupportTest')).text('');
                j$(escapeVfId('allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupportTest')).val('');
            }
            //初始化页面状态 $().hide();方式是因为不知道为什么js动态不能给标签赋值css样式
            function changeStatus(){
                //隐藏上传文件证明 text版 只有提交审批后会使用 即只有状态为计划中才会使用
                //j$(escapeVfId('outUpLoadBuDIV'))[0].style.display="none";
                j$('#outUpLoadBuDIV').hide();
                //获取页面上的出借目的
                var RentalResonTemp = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem:RentalResonTemp__c')).val();
                //获取状态
                var status = j$(escapeVfId('allPage:allForm:allBlock:BlockSection:SectionItem0:noReportStatus')).text();
                
                if(status =='计划中'){
                    //保存、提交待审批隐藏
                    //j$('#ButtonGroup').hide();
                    //上传文件证明按钮隐藏
                    j$('#inUpLoadBuDIV').hide();
                    j$('#outUpLoadBuDIV').show();
                    PageReadOnly();
                }
                else if(status =='提交'){
                    PageReadOnly();
                }else{
                    //草案中 已保存 状态时隐藏只读 出借目的
                    j$('#outRReasonDIV').hide();

                    if(RentalResonTemp =='模型出借'){
                        
                        //20211027 lt add 出借目的 隐藏按钮(上传文件)
                        j$('#inUpLoadBuDIV').hide();//20211027 lt add

                        //①模型出借
                        MCodeShow();
                        //②对应修理
                        CRNoDIVHide();
                        //③追加配套
                        ADSDIVHide();
                        //清空其它输入框的值
                        clearCRNo();
                        clearADS();


                    }else if(RentalResonTemp =='对应修理'){
                        
                        //20211027 lt add 出借目的 隐藏按钮(上传文件)
                        j$('#inUpLoadBuDIV').hide();//20211027 lt add

                        //①对应修理
                        CRNoDIVShow();
                        //②模型出借
                        MCodeHide();
                        //③追加配套
                        ADSDIVHide();
                        //清空其它输入框的值
                        clearMCode();
                        clearADS();

                    }else if(RentalResonTemp == '演示' ||RentalResonTemp =='无法进入手术室'){
                        //SWAG-C85BUN  20211027  lt  start
                        //lt  只在出借目的是演示与无法进入手术室时，显示上传文件证明的提交框。
                        j$('#inUpLoadBuDIV').show();
                        //SWAG-C85BUN  20211027  lt  end

                        //①上传证明

                        //②模型出借
                        MCodeHide();
                        //③对应修理
                        CRNoDIVHide();
                        //④追加配套
                        ADSDIVHide();
                        //清空其它输入框的值
                        clearMCode();
                        clearCRNo();
                        clearADS();

                    }else if(RentalResonTemp == '追加配套'){
                        //①上传证明
                        j$('#inUpLoadBuDIV').hide();//20211027 lt add
                        //②模型出借
                        MCodeHide();
                        //③对应修理
                        CRNoDIVHide();
                        //④追加配套
                        ADSDIVShow();
                        //清空其它输入框的值
                        clearMCode();
                        clearCRNo();
                        
                    }else{
                        //①上传证明
                        j$('#inUpLoadBuDIV').hide();//20211027 lt add
                         //②模型出借
                        MCodeHide();
                        //③对应修理
                        CRNoDIVHide();
                        //④追加配套
                        ADSDIVHide();
                        //清空其它输入框的值
                        clearMCode();
                        clearCRNo();
                        clearADS();
                    }
                }
                
            }
            //上传图片
            function saveAttachment(){
                 var maxFileSize = 4350000;      //Base64 编码以后最大的文件字节数
                 var attachmentBody;                //附件内容
                 var attachmentName;                //附件名称
                 var attachmentType;                //附件名称
                 var attachmentSize;    
                 blockme();   
                //附件大小
                 var fbody = document.getElementById("file_input").files[0];
                 if(fbody != undefined) {
                    if(fbody.size <= maxFileSize) {
                        attachmentName = fbody.name;
                        attachmentType = fbody.type;
                        var fileReader = new FileReader();
                        fileReader.onload = function(e) {
                            
                            attachmentBody = window.btoa(this.result);  //Base 64 encode the file
                             fileSize = attachmentBody.length;
                             //使用RemoteAction上传附件
                             Visualforce.remoting.Manager.invokeAction(
                               '{!$RemoteAction.OPDNoReportApplicationController.testAddAttachment}',
                               attachmentName,
                               attachmentType,
                               attachmentBody,
                               '{!OPDPlan__c.id}',
                               function(result,event) {
                                unblockUI();
                                 
                                 if(result == '您已上传文件成功！'){                            
                                    alert(result);
                                    IsUpload = true;
                                    save();
                                    popupBox.hide();
                                 }else{
                                    alert(result);
                                    IsUpload = false;
                                 }


                               });

                        }
                        //取消上传文件不成功时的背景黑幕  kk 20231105  start 优化
                        fileReader.onerror = function(e) {
                            unblockUI();
                           alert("上传失败，请重新尝试");
                        }
                         fileReader.onabort = function(e) {
                            unblockUI();
                           alert("上传失败，请重新尝试");
                         }
                
                        fileReader.readAsBinaryString(fbody);  
                    }else{
                        unblockUI();
                        alert("Base64 编码最大允许4.3M文件");
                    }
                 }else{
                    unblockUI();
                    //取消上传文件不成功时的背景黑幕  kk 20231105  end 优化
                     alert("请先选择一个附件上传。");
                 }

            }
            //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;
             }

        </script>
    </apex:outputPanel>
    <style type="text/css">
        /* 自定义 搜索框 input样式*/
        .SearchClass{
            margin: 0;height: 28px;
            width: 150px;
            background-color: #ffffff;
            border: 1px solid #cccccc;
            box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
            transition: border linear .2s,box-shadow linear .2s;
            display: inline-block;
            padding: 4px 6px;
            vertical-align: middle;
            border-radius: 4px;
            box-sizing: border-box;
            font-family: DSCDefaultFontRegular;
            -webkit-writing-mode: horizontal-tb !important;
            text-rendering: auto;
            color: initial;
            letter-spacing: normal;
            word-spacing: normal;
            text-transform: none;
            text-indent: 0px;
            text-shadow: none;
            text-align: start;
            -webkit-appearance: textfield;
            -webkit-rtl-ordering: logical;
            cursor: text;
            font: 400 13.3333px Arial;
        }
        /* 标准查找字段 搜索框 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);
        }
        /* 放大镜 鼠标放上的样式 */
        .lookupIconOn{
            background-image:url(/img/func_icons/util/lookup20.gif);
            background-position:0 0;
            width:20px;
            height:20px;
            background-position:top right ;
            vertical-align: middle;
        }
        /* 放大镜 init初始化样式 */
        .lookupIcon{
            background-image:url(/img/func_icons/util/lookup20.gif);
            background-position:0 0;
            width:20px;
            height:20px;
            background-position:top left;
            vertical-align: middle;
        }
    </style>
    <apex:form id="allForm" >
        <!-- <apex:inputHidden id="AdditionalSupportTest" value="{!opdPlan.AdditionalSupport__c}"/> -->
        <apex:inputHidden id="AdditionalSupportTest2"/>
        <!-- 保存 -->
        <apex:actionFunction name="Save" action="{!Save}" reRender="allForm,checkForm" oncomplete="unblockUI();alertforSave();changeStatus()">
            <apex:param assignTo="{!IsUpload}" name="IsUpload" value=""/>
            <apex:param assignTo="{!ModelLendingProductId}" name="ModelLendingProductId" value=""/>
            <apex:param assignTo="{!ModelLendingCodeId}" name="ModelLendingCodeId" value=""/>
        </apex:actionFunction>
        <!-- 提交待审批 -->
        <apex:actionFunction name="CommitNeedApproval" action="{!CommitNeedApproval}" reRender="allForm,checkForm" oncomplete="unblockUI();alertforApproval();changeStatus();">
            <apex:param assignTo="{!IsUpload}" name="IsUpload" value=""/>
        </apex:actionFunction>
        <!-- 初始化 -->
        <apex:actionFunction name="init" action="{!init}" reRender="allForm" oncomplete="unblockUI();changeStatus();">
        </apex:actionFunction>
        <apex:pageBlock id="allBlock" title="无报告申请" mode="edit">
            <!-- 20230920 ljh update start-->
            <!-- <apex:outputPanel id="message" >
                <apex:messages />
            </apex:outputPanel> -->
            <!-- kk   不要背景色 -->
<!--             <apex:outputPanel id="message">
                <apex:pageMessages />
            </apex:outputPanel> -->
            <!-- 20230920 ljh update end-->
            <div id="ButtonGroup">
                <apex:pageBlockButtons id="buttons">
                    <apex:commandButton id="SaveButton"  value="保存"   reRender="allForm" onclick="save();return false;"/>
                    <apex:commandButton id="ApprovalButton"  value="提交待审批"  reRender="allForm" onclick="ApprovalButton();return false;"/>
                </apex:pageBlockButtons>
            </div>
            <apex:pageBlockSection title="基本信息录入" id="BlockSection">

                <!-- 出借目的列 -->
                <apex:pageBlockSectionItem id="SectionItem">
                      
                      <apex:outputLabel >出借目的: </apex:outputLabel>
                      <apex:panelGroup >
                            <div id="inRReasonDIV" >
                                 <apex:selectList style="margin-right:3px;margin-left:3px" size="1" id="RentalResonTemp__c" value="{!opdPlan.RentalResonTemp__c}" onchange="changeStatus();">
                                            <apex:selectOptions value="{!RentalReson}"/>
                                 </apex:selectList>
                            </div>
                            <div id="outRReasonDIV" hidden="hidden">
                                 <apex:outputText id="RentalResonTempTest" value="{!opdPlan.RentalResonTemp__c}" />
                            </div>
                      </apex:panelGroup>
                 </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem id="SectionItem0" >
                    <apex:outputLabel value="状态: " for="noReportStatus"/>
                    
                    <apex:outputField id="noReportStatus" value="{!opdPlan.noReportStatus__c}" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="对应原因" columns="1" id="tableListQ"  collapsible="false" dir="LTR" >
                <!-- 模型出借产品型号列 -->
                <!-- dataStyle="display:none" -->
                <apex:pageBlockSectionItem id="SectionItem1" dir="LTR"  dataStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 55%;padding-left: 10%;" labelStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 30%;padding-left: 10%;">
                    
                        <apex:outputLabel >1.模型出借产品型号:</apex:outputLabel>
                        <apex:panelGroup >
                            <div id="inMCodeDIV" hidden="hidden">
                             <apex:inputText id="ModelLendingProductCode" value="{!ModelLendingProductCode}"  html-placeholder="Search" styleClass="SearchClass"/>

                                 <!-- <input id="st-search-input" type="text" placeholder="Search" autocomplete="off" class="inputSearch" /> -->
                                   <image src="/img/s.gif" alt="模型出借产品型号 查找（新窗口）" class="lookupIcon" title="模型出借产品型号 查找（新窗口）" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onClick ="lookUpUrl();" ></image>
                            </div>
                            <div id="outMCodeDIV">
                             <apex:outputText id="ModelLendingProductCodeTest" value="{!ModelLendingProductCode}" />
                             <apex:inputHidden id="ModelLendingProductCodeId" value="{!ModelLendingProductId}"/>
                             <apex:inputHidden id="ModelLendingCodeId" value="{!ModelLendingCodeId}"/>
                            </div>
                        </apex:panelGroup>
                </apex:pageBlockSectionItem>
                <!-- 对应修理维修NO列 -->
                <apex:pageBlockSectionItem id="SectionItem2" dir="LTR" dataStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 55%;padding-left: 10%;" labelStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 30%;padding-left: 10%;">
                    
                        <apex:outputLabel >2.对应修理维修NO:</apex:outputLabel>
                        <apex:panelGroup >
                            <div id="inCRNoDIV" hidden="hidden">
                             <apex:inputField id="CorrespondingRepairNo" value="{!opdPlan.CorrespondingRepairNo__c}" html-placeholder="Search" styleClass=""/>
                          <!--    <div id="lightningPage1" style="height:50px;width: 250px;padding-top: 8px;" onchange="openPage()" onmouseout="openPage()" onclick="openPage()" onmousemove="openPage()"></div> -->
                            </div>
                            <div id="outCRNoDIV" >
                             <apex:outputField id="CorrespondingRepairNoTest" value="{!opdPlan.CorrespondingRepairNo__c}"/>
                            </div>
                        </apex:panelGroup>
                </apex:pageBlockSectionItem>
                <!-- 演示/疫情原因列 -->
                <apex:pageBlockSectionItem id="SectionItem3" dir="LTR" dataStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 55%;padding-left: 10%;" labelStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 30%;padding-left: 10%;">
                    
                        <apex:outputLabel >3.演示/无法进入手术室证明文件:</apex:outputLabel>
                        <apex:panelGroup >
                            <!-- 20211027 lt add (hidden="hidden")-->
                             <div id="inUpLoadBuDIV" hidden="hidden" >
                             <apex:commandButton id="upLoad" onclick="openFile(); return false;" value="上传文件证明" />
                             </div>
                             <div id="outUpLoadBuDIV" hidden="hidden">
                                 <apex:outputText id="uploadText" value="文件证明如下附件列表！" />
                             </div>
                        </apex:panelGroup>
                </apex:pageBlockSectionItem>
                <!-- 追加配套 -->
                <apex:pageBlockSectionItem id="SectionItem4" dir="LTR" dataStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 55%;padding-left: 10%;" labelStyle="text-align:left;color: #4a4a56;white-space: nowrap;font-size: 91%;width: 30%;padding-left: 10%;">
                    
                        <apex:outputLabel >4.追加配套:</apex:outputLabel>
                        <apex:panelGroup >
                            <div id="inAdsDIV" hidden="hidden">
                                <apex:inputField id="AdditionalSupport" value="{!opdPlan.AdditionalSupport__c}" html-placeholder="Search" styleClass=""/>

                                <!-- <div id="lightningPage" style="height:50px;width: 250px;padding-top: 8px;display: none;" onchange="openPage()" onmouseout="openPage()" onclick="openPage()" onmousemove="openPage()"></div> -->
                            </div>
                            <div id="outAdsDIV" >
                                <apex:outputField id="AdditionalSupportTest" value="{!opdPlan.AdditionalSupport__c}"/>
                            </div>
                        </apex:panelGroup>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <!-- 附件页面 -->
            <apex:pageBlockSection title="附件" id="tableListH"  collapsible="false" dir="LTR" >
                <apex:pageBlockTable value="{!attachmentinfo}" var="a" style="margin-left: 50%; width: 150%;">
                <apex:column headerValue="标题" style="width: 50%">
                    <!-- // zzm 20231114 修改ap0 start -->
                   <!--  <apex:outputLink value="https://ocsm--stagefull--c.documentforce.com/servlet/servlet.FileDownload?file={!a.Id}" target="_self">  -->
                    <apex:outputLink value="/sfc/servlet.shepherd/document/download/{!a.Id}" target="_self">
                    <!-- https://ocsm--c.ap0.content.force.com/servlet/servlet.FileDownload?file -->
                    <!-- https://ocsm--stagefull--c.documentforce.com/servlet/servlet.FileDownload?file= -->
                    <!-- // zzm 20231114 修改ap0 end -->
                          {!a.Title}
                    </apex:outputLink>
                </apex:column>
                <apex:column headerValue="创建人">
                    <apex:outputField value="{!a.OwnerId}"/>
                </apex:column>
            </apex:pageBlockTable> 
            </apex:pageBlockSection>
        </apex:pageBlock>
            <apex:outputPanel id="popupBox" layout="block" style="display:none">
                <input type="file" id="file_input" name="attFile"/><br/>
                <center style="margin-top : 30px">
                    <apex:commandButton value="确认" onclick="saveAttachment(); return false;" style="width: 20%; vertical-align: middle;" />
                    <apex:commandButton value="取消" onclick="popupBox.hide();" style="width: 20%; vertical-align: middle;" />
                </center>
            </apex:outputPanel>
        
    </apex:form>
    <script>
         function formatDate (d) {
           var date = new Date(d);
           var YY = date.getFullYear() + '-';
           var MM =
             (date.getMonth() + 1 < 10
               ? '0' + (date.getMonth() + 1)
               : date.getMonth() + 1) + '-';
           var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
           return YY + MM + DD;
         }



        function initOpenPage(){
            let SelectFieldParamList=[ 
                { 
                    //原apex:inputField的id值，需要在页面上获取 

                    inputFieldId : 'allPage:allForm:allBlock:tableListQ:SectionItem4:AdditionalSupport', 

                    //查找字段所在对象 

                    ObjectType : 'OPDPlan__c', 

                    //查找字段的api名称 

                    QueryFieldApiName : 'AdditionalSupport__c', 

                    //查找字段的查找对象 

                    SelectObj : 'OPDPlan__c', 

                    //搜索时使用的字段 

                    SelectFld : 'Name', 

                    // setVal: ''

                    // FilterSql: ' Account_Laboratory__c  = \\\''+ '{!opdPlan.AdditionalSupport__r.Account_Laboratory__c}' + '\\\''+
                    //             ' And  Status__c =\\\'完毕\\\''+
                    //             ' And  OPDPlan_ImplementDate__c = \\\''+ '{!opdPlan.AdditionalSupport__r.OPDPlan_ImplementDate__c}'+'\\\''+
                    //             ' And Id != \\\'' + '{!opdPlan}' +'\\\''

                    FilterSql:  ' Status__c =\\\'完毕\\\''+
                                ' And Id != \\\'' + '{!opdPlan}' +'\\\''

                }, 

                { 

                    //原apex:inputField的id值，需要在页面上获取 

                    inputFieldId : 'allPage:allForm:allBlock:tableListQ:SectionItem2:CorrespondingRepairNo', 

                    //查找字段所在对象 

                    ObjectType : 'Repair__c', 

                    //查找字段的api名称 

                    QueryFieldApiName : 'Id', 

                    //查找字段的查找对象 

                    SelectObj : 'Repair__c', 

                    //搜索时使用的字段 

                    SelectFld : 'Name', 

                }, 
            ] 
            console.log('{!opdPlan.AdditionalSupport__c}');
            console.log('{!opdPlan.Account_Laboratory__c}');
            console.log('{!opdPlan.OPDPlan_ImplementDate__c}');
            let i1='{!opdPlan.Account_Laboratory__c}';
            let i2='{!opdPlan.OPDPlan_ImplementDate__c}';
            i2=this.formatDate(i2);
            console.log('i2=   '+i2);
            if(i1){
                SelectFieldParamList[0].FilterSql+= ' And Account_Laboratory__c  = \\\''+ i1 + '\\\'';
            }
            if(i2){
                SelectFieldParamList[0].FilterSql+= ' And OPDPlan_ImplementDate__c  = '+ i2 ;
            }
            // SelectFieldParamList[0].FilterSql='';
            console.log('sql:  '+SelectFieldParamList[0].FilterSql);
            resetOpenPage(SelectFieldParamList);
        }

        initOpenPage();
        //标准控件修改 end
        //页面加载后 设置禁用状态
        changeStatus();
    </script>
    
</apex:page>