<apex:page standardController="PAE_DecisionRecord__c" extensions="RepPAEDecisionRecordController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="PAE判定记录">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<style  type="text/css">.bPageBlock .pbTitle{width:100%;text-align:center;}</style>
<script>

//插入行
function InsertRows(){
    //解除不可写状态
    blockme();
    InsertRow();
}
// 保存并关闭
function SaveAndCloses(onlySave){
   //  精琢科技   zxk   2021-11-17    start
            var productCount = "{!paedRecordDetailView}";
            //新值
            var PAEJudgeIdStr = '';
            //旧值
            var strJudgejsIdStr = '';
            var falsg = 0;
            //  + ':PAEJudge'
            for (var i = 0; i < productCount.length; i++) {
                var PAEJudgeId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':PAEJudge';
                var strJudgejsId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':strJudgejs';
                PAEJudgeIdStr = j$(escapeVfId(PAEJudgeId)).value();
                strJudgejsIdStr = j$(escapeVfId(strJudgejsId)).value();
                if (PAEJudgeIdStr != '' && PAEJudgeIdStr != strJudgejsIdStr) {
                    falsg = 1;
                    break;
                }
            }
            if (falsg == 1) {
                if (confirm('存在未知或者修改过PAE判定的code  确认保存？')) {
                    blockme();
                    SaveAndClose(onlySave);
                }
            } else {
                blockme();
                SaveAndClose(onlySave);
            }
            //  精琢科技   zxk   2021-11-17    end
        }
//20200107 
function toIntake(){
    blockme();
    toIntake();
}
//20191209 ljh
function InsertMoreRowsJs(productIdx){
    blockme();
    InsertMoreRows(productIdx);

}
// 2021-12-08  zxk   精琢科技  手动赋值逻辑  start
        function checkBoxTf() {
            // alert(lineNumberStr);
            var productCountStr = "{!paedRecordDetailView}";
            var PAEJudgeIdStr = '';
            var strJudgejsIdStr = '';
            var PaeIsSaveIdStr = '';
            var  MonitorPAE = '';
            var falsg = 0; 
            for (var i = 0; i < productCountStr.length; i++) {
                var PAEJudgeId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':PAEJudge';
                var strJudgejsId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':strJudgejs'; 
                var PaeIsSaveId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':PaeIsSave';
                var MonitorPAEId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':MonitorPAE';
                PAEJudgeIdStr = j$(escapeVfId(PAEJudgeId)).value();
                strJudgejsIdStr = j$(escapeVfId(strJudgejsId)).value();
                PaeIsSaveIdStr = j$(escapeVfId(PaeIsSaveId)).value();
                MonitorPAE = j$(escapeVfId(MonitorPAEId)).value();
                 if(PaeIsSaveIdStr != '1'){
                        if (strJudgejsIdStr != PAEJudgeIdStr || (strJudgejsIdStr == '' || strJudgejsIdStr == null)) {
                           j$(escapeVfId('allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':MonitorPAE')).attr('checked',true);
                        }else{
                           j$(escapeVfId('allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':MonitorPAE')).attr('checked',false);

                        }
                }
            }
        }
        // 2021-12-08  zxk   精琢科技  手动赋值逻辑  end
function checkAll() {
    selectedSize = 0;
    var productCount = "{!paedRecordDetailViewCount}";
    if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
        for (var i = 0; i < productCount; i++) {
            var checkId = 'allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':variableinfo' + ':consumablesCountproRowCheckbox';
            if (!j$(escapeVfId(checkId)).attr('disabled')){
                j$(escapeVfId(checkId)).attr('checked',true);
                selectedSize ++;
            }
        }
    } else {
        for (var i = 0; i < productCount; i++) {
            j$(escapeVfId('allPage:allForm:allBlock:unEditable:ConsumableorderdetailsTable:' + i + ':variableinfo' + ':consumablesCountproRowCheckbox')).attr('checked',false);
        }
    }
}
</script>

<style>
    .dateFormat  {
        display: none;
    }
    td.columuslowercolour {
        background-color:red;
        text-align: right;
    }
    td.columuscuperolour {
        background-color: yellow;
        text-align: right;
    }
</style>
    <apex:form id="allForm">
        <apex:actionFunction name="InsertRow" action="{!InsertRow}" rerender="unEditable" onComplete="unblockUI();" >
        </apex:actionFunction>
        <apex:actionFunction name="InsertMoreRows" action="{!InsertMoreRows}" rerender="unEditable,message" onComplete="unblockUI();" >
            <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  start -->

            <apex:param assignto="{!productIdx}" name="productIdx" value="">
            </apex:param>
        <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  end -->
        </apex:actionFunction>
        <apex:actionFunction name="SaveAndClose" action="{!SaveAndClose}" rerender="unEditable,message" onComplete="unblockUI();" >
            <apex:param name="firstParam" assignTo="{!CancelineFlag}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="toIntake" action="{!toIntake}" rerender="unEditable" onComplete="unblockUI();" >
        </apex:actionFunction>
        <apex:actionFunction name="ReturnReportInterface" action="{!ReturnReportInterface}" rerender="unEditable" onComplete="unblockUI();" >
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
            <apex:pageBlock id="allBlock" >
                <apex:pageBlock title="{!IF(RecordTypeName = 'ASRCDecision' , 'Intake universal code 编辑画面', 'Final universal code 编辑画面')}" id="unEditable" rendered="{!editAble}">
                     <table cellspacing="10">
                        <colgroup>  
                            <col width="7%"/>
                            <col width="10%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <col width="7%"/>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}">
                            <col width="15%"/>
                            <col width="10%"/>
                            </apex:outputPanel>
                        </colgroup>
                        <tr>
                            <td align="left" ><apex:outputText id="OrderCode_out"  value="{!$Label.PAE}" /></td>
                            <!-- 2020/07/28 taoqz start -->
                            <!-- PAE判定结果 由选项列表改为经过工作流更新后的文本 -->
                            <td align="left" ><apex:inputField id="OrderStatus_out" value="{!rdRecord.PAEDetail_DetermineResults__c}"/></td>
                            <!-- 2020/07/28 taoqz end -->
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <!-- <th>AS-RC</th> -->
                                <td align="right" > {!$ObjectType.Report__c.fields.Repair_ConfirmationDate__c.label}：</td>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}">
                                <td align="right" > {!$ObjectType.Report__c.fields.OCSM_RC_CordingDate__c.label}：</td>
                            </apex:outputPanel>
                            <td align="left" ><apex:outputField value="{!rdRecord.PAE_ConfirmationDate__c}"/></td>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <!-- <th>AS-RC</th> -->
                                <td align="right" > {!$ObjectType.Report__c.fields.Repair_Authenticator__c.label}：</td>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}">
                                <!-- <th>AS-AC</th> -->
                                <td align="right" >{!$ObjectType.Report__c.fields.OCSM_RC_CordingUser__c.label}：</td>
                            </apex:outputPanel>
                            <td align="left" ><apex:outputField value="{!rdRecord.PAE_Authenticator__c}"/></td>
                       
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}"> 
                                <td align="right" >再现结果确认：</td>

                                <td align="left" style="{!IF(rdRecord.PAE_reappear_confirm__c = '未确认' , 'color: red;font-weight: 800;', '')}" ><apex:outputField value="{!rdRecord.PAE_reappear_confirm__c}"/></td>
                                 <input type="button" value="Intake universal code 编辑
" style="margin-left:30px;float:right;{!IF(rdRecord.PAE_reappear_confirm__c = '未确认','color: red;','')}"  onclick="toIntake();return false;"  class="btn" />
                                   
                            </apex:outputPanel>
                            
                        </tr>   

                    </table>
                    <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision'&& rdRecord.PAE_reappear_confirm__c = '未确认',false , true)}">
                    <table style="width:100%; {!IF(RecordTypeName = 'ASACDecision'&& rdRecord.PAE_reappear_confirm__c = '未确认', 'display: none;', '')}" >                       
                        <tr>
                            <td>
                            
                            <apex:commandButton value="关闭"  style="margin-left:30px;width:80px;float:right"  onclick="ReturnReportInterface();return false;"  rerender="unEditable,message" oncomplete="unblockUI();"/>
                            <apex:commandButton value="保存"  disabled="{!IF((editFlag) && savebuton == false && !(RecordTypeName='ASRCDecision'&&OCSM_QARA='1'),true,false)}" style="margin-left:30px;width:80px;float:right"  onclick="SaveAndCloses(1);return false;"  rerender="unEditable,message" oncomplete="unblockUI();"/>
                            <apex:commandButton value="保存并关闭" disabled="{!editFlag}"  rendered="{!IF(repa != null && RecordTypeName = 'ASACDecision',true,false)}" style="margin-left:30px;width:80px;float:right"  onclick="SaveAndCloses(2);return false;"  rerender="unEditable,message" oncomplete="unblockUI();" />
                            
                            <!-- OCSM QARA screen  [确定并关闭] -->
                            <!-- update by rentx 2020-10-26 start -->

                            <apex:commandButton rendered="{!IF((OCSM_QARA == '1' && RecordTypeName = 'ASRCDecision' && repa != null) || (RecordTypeName = 'ASRCDecision' && ReportId != null),true,false)}" value="确定并关闭"  disabled="{!editFlag}" style="margin-left:30px;width:100px;float:right"  onclick="SaveAndCloses(2);return false;"  rerender="unEditable,message" oncomplete="unblockUI();" />

                            <!-- update by rentx 2020-10-26 start -->
                            <apex:commandButton value="插入行" disabled="{!IF((RecordTypeName = 'ASRCDecision' && OCSM_QARA = '0') && ((RecordTypeName='ASACDecision'&&OCSM_Cording='0')||(editFlag)),true,false)}" style="margin-left:30px;width:60px;float:right" onclick="InsertRows();return false;" rerender="unEditable,message" oncomplete="unblockUI();"/>
                            <apex:commandButton value="取消行" disabled="{!IF((RecordTypeName = 'ASRCDecision' && OCSM_QARA = '0') && ((RecordTypeName='ASACDecision'&&OCSM_Cording='0')||(editFlag)),true,false)}" style="margin-left:30px;width:60px;float:right" onclick="SaveAndCloses(3);return false;"  rerender="unEditable,message" oncomplete="unblockUI();"/>
                            <!-- update by rentx 2020-10-26 end -->

                            </td>
                        </tr>
                    </table>
                    </apex:outputPanel>
                    <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision'&& rdRecord.PAE_reappear_confirm__c = '未确认',true , false)}">
                    <p style="text-align: right;padding-bottom: 10px;width:100%;font-weight: 800;">再现结果未确认,请点击Intake universal code 编辑 按钮前去确认</p>
                    </apex:outputPanel>

                        <apex:outputPanel id="message">
                            <apex:pageMessages />
                        </apex:outputPanel>
                    
                    <table class="list" border="0" cellpadding="0" cellspacing="0">
                        <tr class="headerRow">
                            <apex:variable var="v" value="" rendered="{!editAble}">
                                <th><input type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                            </apex:variable>

                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}">
                                <th>Location Group </th>
                                <th>Location </th>
                                <th>Final universal description / Phenomenon </th>
                            </apex:outputPanel>

                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <th>Intake universal description</th>
                            </apex:outputPanel>

                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <th>Intake universal code</th>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' , true, false)}">
                                <th>Final universal code </th>
                            </apex:outputPanel>
                            <!-- <th>AS-RC</th> -->
                            <!-- <th width="7%">PAE判定</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAE_Judge__c.label}</th>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                            <!-- <th width="7%">再现結果</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_Reappear_Result__c.label}</th>
                            <!-- <th width="15%">intake 页面 Final universal Code</th> -->
                            <th width="15%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.Final_universal_code__c.label}</th>
                            </apex:outputPanel>
                            <!-- <th width="7%">状态</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_Status__c.label}</th>
                            <!-- <th width="7%">确认日</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_ConfirmationDate__c.label}</th>
                            <!-- <th width="7%">确认者</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_Affirmant__c.label}</th>
                            <!-- <th width="7%">取消日</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_CancellationDate__c.label}</th>
                            <!-- <th width="7%">取消者</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_Nullifier__c.label}</th>
                            <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                            <!-- <th width="7%">不再現結果確認日</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_ResultConfirmationDate__c.label}</th>
                            <!-- <th width="7%">不再現結果確認者</th> -->
                            <th width="7%">{!$ObjectType.PAE_DecisionRecordDetail__c.fields.PAED_ResultAffirmant__c.label}</th> 
                            </apex:outputPanel>
                            <!-- <th width="7%">手动修改</th> -->
                            <th width="7%">
                                {!$ObjectType.PAE_DecisionRecordDetail__c.fields.Monitor_PAE__c.label}
                            </th> 
                        </tr>
                        <apex:repeat value="{!paedRecordDetailView}" var="paedRdV" id="ConsumableorderdetailsTable">
                            <tr class="dataRow">
                                <!-- //复选框 -->
                                <apex:variable var="v" value="" rendered="{!editAble}" id="variableinfo">
                                    <td>
                                        <apex:inputCheckbox value="{!paedRdV.check}" onclick="CheckSize(this);" id="consumablesCountproRowCheckbox" disabled="{!paedRdV.canSelect}"/>
                                            <apex:inputCheckbox value="{!paedRdV.oldCheck}" id="proRowOldCheckbox" style="display:none"/>
                                        <apex:inputCheckbox id="isReadOnly" value="{!paedRdV.canSelect}" style="display:none" />    
                                    </td>
                                 </apex:variable>

                                <!-- QIS read only; always blank-->
                                <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' && repa != null , true, false)}">
                                    <td class="dataCell"></td>
                                </apex:outputPanel>

                                <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASACDecision' && repa != null, true, false)}">
                                    <td class="dataCell"></td>
                                    <td class="dataCell"></td>
                                    <td class="dataCell"></td>
                                </apex:outputPanel>
                                <td class="dataCell">
                                    <apex:outputPanel layout="none" rendered="{!IF(paedRdV.paedrdd.PAE_is_save__c !='1' || paedRdV.paedrdd.isedit__c = true, true,false)}">
                                        <apex:outputPanel layout="none" rendered="{!IF((RecordTypeName = 'ASACDecision'&& rdRecord.PAE_reappear_confirm__c = '未确认')||(OCSM_QARA='0' &&RecordTypeName = 'ASRCDecision'), false, true)}">

                                        <apex:InputField id="PAEDManagementCode" value="{!paedRdV.paedrdd.PAED_ManagementCode__c}" onblur="InsertMoreRowsJs(this.value);return false;"/>
                                        
                                        </apex:outputPanel>
                                    </apex:outputPanel>
                                    <apex:outputPanel layout="none" rendered="{!IF(!(paedRdV.paedrdd.PAE_is_save__c !='1' || paedRdV.paedrdd.isedit__c = true),true , false)}">
                                        <apex:outputField value="{!paedRdV.paedrdd.PAED_ManagementCode__c}" />
                                    </apex:outputPanel>
                                </td>    
                                <td class="dataCell">
                                 <apex:outputPanel layout="none" rendered="{!IF(paedRdV.paedrdd.PAE_is_save__c ='1',false, true)}">
                                    <apex:outputPanel layout="none" rendered="{!IF((RecordTypeName = 'ASACDecision'&& rdRecord.PAE_reappear_confirm__c = '未确认')||(OCSM_QARA='0'&&RecordTypeName = 'ASRCDecision'), false, true)}">
                                        <apex:InputField id="PAEJudge" onchange="checkBoxTf();" value="{!paedRdV.paedrdd.PAE_Judge__c}"/>
                                    </apex:outputPanel>
                                    </apex:outputPanel>
                                        <apex:outputPanel layout="none" rendered="{!IF(paedRdV.paedrdd.PAE_is_save__c ='1',true , false)}">
                                        <apex:outputField id="PAEJudge1" value="{!paedRdV.paedrdd.PAE_Judge__c}"/>
                                    </apex:outputPanel>
                                     <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  start -->

                                    <apex:inputhidden id="strJudgejs" value="{!paedRdV.strJudge}">
                                    </apex:inputhidden>
                                    <apex:inputhidden id="Monitor_PAE__c" value="{!paedRdV.paedrdd.Monitor_PAE__c}">
                                    </apex:inputhidden>
                                    <apex:inputhidden id="PaeIsSave" value="{!paedRdV.paedrdd.PAE_is_save__c }">
                                    </apex:inputhidden>
                                    <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  end -->
                                </td>
                                <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <td class="dataCell">
                                    <apex:outputPanel layout="none" rendered="{!IF(OCSM_Cording != '1', true, false)}">
                                    <apex:outputField value="{!paedRdV.paedrdd.PAED_Reappear_Result__c}"/>
                                    </apex:outputPanel>
                                    <apex:outputPanel layout="none" rendered="{!IF(OCSM_Cording='1', true, false)}">
                                    <apex:InputField value="{!paedRdV.paedrdd.PAED_Reappear_Result__c}"/>
                                    </apex:outputPanel>


                                </td>
                                <td class="dataCell">
                                    <apex:outputField value="{!paedRdV.paedrdd.Final_universal_code__c}"/>  
                                </td>
                                </apex:outputPanel>
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_Status__c}"/>
                                </td>
                                <td class="dataCell">
                                    <!-- Gzw 20200826 修改 Final 信息没有时，显示修理上内容 -->
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_ConfirmationDate_F__c}"/>
                                  
                                </td>
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_Affirmant_F__c}"/>
                                    
                                </td>
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_CancellationDate__c}" rendered="{!IF(paedRdV.paedrdd.PAED_CancellationDate__c != null, true, false)}"/>
                                    
                                </td>
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_Nullifier__r.Name}"/>
                                </td>
                                <apex:outputPanel layout="none" rendered="{!IF(RecordTypeName = 'ASRCDecision' , true, false)}">
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_ResultConfirmationDate__c}"/>
                                </td>
                                <td class="dataCell">
                                    <apex:OutputField value="{!paedRdV.paedrdd.PAED_ResultAffirmant_new__c}"/>
                                </td>
                                 
                                </apex:outputPanel>
                                <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  start -->
                                    <td class="dataCell">
                                        <apex:inputcheckbox id="MonitorPAE" value="{!paedRdV.monitorPAE}" disabled="true">
                                        </apex:inputcheckbox>
                                        <apex:inputhidden id="MonitorPAEhidden" value="{!paedRdV.monitorPAE}">
                                        </apex:inputhidden>
                                    </td>
                                    <!-- // 2021-12-08  zxk   精琢科技  手动赋值逻辑  end -->
                            </tr>
                        </apex:repeat>
                    </table>
                </apex:pageBlock>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>