<apex:page controller="MoreMaintenanceContractController"  action="{!init}"  showHeader="false"   sidebar="true" id="allPage"  title="经销商对医院修理价格录入" 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.CommonUtilJs)}"/>
<style type="text/css">
    .bPageBlock .pbTitle{
        width: 50%;
    }
    /* 0. 显示滚动条2注释掉这个打开 */
    /*.table-head{padding-right:17px;color:#000;}*/
    /* 1. 给tbody的表格固定高度（也可以flex:1）, 并添加overflow-y:scroll */
    .table-body {max-height: 350px;overflow-y: scroll;}
    .table-body table tr:nth-child(2n){background-color:#f2f2f2;}
    /* 2. 隐藏滚动条 */
    .table-body::-webkit-scrollbar {display: none}
    /* 3. 使上下表格对齐（宽度一致） */
    .table-head tr th:nth-of-type(1),
    .table-body tr td:nth-of-type(1) {
        width: 20%;
    }

    .table-head tr th:nth-of-type(2),
    .table-body tr td:nth-of-type(2) {
        width: 10%;
    }

    .table-head tr th:nth-of-type(3),
    .table-body tr td:nth-of-type(3) {
        width: 20%;
    }

    .table-head tr th:nth-of-type(4),
    .table-body tr td:nth-of-type(4) {
        width: 10%;
    }

    .table-head tr th:nth-of-type(5),
    .table-body tr td:nth-of-type(5) {
        width: 10%;
    }
    .table-head tr th:nth-of-type(6),
    .table-body tr td:nth-of-type(6) {
        width: 10%;
    }
    .table-head tr th:nth-of-type(7),
    .table-body tr td:nth-of-type(7) {
        width: 20%;
    }
</style>
<script type="text/javascript">
    function BackMc(){
        blockme();
        var id ="{!id}";
        window.location.href="/"+id;
    }
    function RefreshPriceJs(){
        blockme();
        RefreshPrice();
    }
    function JsHQSum(){
        blockme();
        HQSum();
    }
    function SaveJs(go){
        //经销商对医院修理价格不为空才可以保存
        //allPage:allForm:MoreMaintenanceContract:theRepeat:1:hospitalQuotationText
        var repairLCount = j$(escapeVfId('repairLCount')).value();
        var IsEmpty = false;
        for (var i = 0; i < repairLCount; i++) {
            var tempValue = j$(escapeVfId('allPage:allForm:MoreMaintenanceContract:theRepeat:'+i+':hospitalQuotationText')).value();
            var tempValued = j$(escapeVfId('allPage:allForm:MoreMaintenanceContract:theRepeat:'+i+':hospitalQuotationTextd')).value();
            var hospitalQuotationTextValue = tempValue;
            if(tempValue==null||tempValue==""||tempValue.replace(/(^\s*)|(\s*$)/g, "")==""){
                hospitalQuotationTextValue = tempValued;
            }
            //console.log(tempValue);
            if(hospitalQuotationTextValue==null||hospitalQuotationTextValue==""||hospitalQuotationTextValue.replace(/(^\s*)|(\s*$)/g, "")==""){
                IsEmpty = true;
            }
        }
        if(IsEmpty){
            //alert('经销商对医院修理价格不能为空，可以为0');
            if(confirm('修理价格存在空项，请确认是否保存')){
                if (confirm("请确认所输信息正确，保存后将无法自行更改。【确定】进行保存，【取消】可进行确认信息")) {
                    blockme();
                    Save(go);
                }
            }
        }else{
            if (confirm("请确认所输信息正确，保存后将无法自行更改。【确定】进行保存，【取消】可进行确认信息")) {
                blockme();
                Save(go);
            }
        }  
    }
</script>

<apex:form id="allForm">

<apex:actionFunction name="RefreshPrice" action="{!RefreshPrice}" rerender="message,MoreMaintenanceContract"  onComplete="unblockUI();">
</apex:actionFunction>
<apex:actionFunction name="HQSum" action="{!HQSum}" rerender="message,MoreMaintenanceContract"  onComplete="unblockUI();">
</apex:actionFunction>
<apex:actionFunction name="Save" action="{!Save}" rerender="message" onComplete="unblockUI();" >
    <apex:param name="firstParam" assignTo="{!GoFlag}" value="" />
</apex:actionFunction>
<apex:outputPanel id="message">
    <apex:pageMessages />
</apex:outputPanel>

<table style="width:100%;">
    <colgroup>
        <col width="5%"/>
        <col width="9%"/>
        <col width="1%"/>
        <col width="10%"/>
        <col width="20%"/>
        <col width="10%"/>
        <col width="10%"/>
        <col width="10%"/>
        <col width="5%"/>
        <col width="10%"/>
        <col width="5%"/>
        <col width="5%"/>
    </colgroup>
    <tr>
        <td></td>
        <td align="left" style="font-weight: 800;"><h2>维修合同信息</h2></td><td></td>
        <td align="right" >维修合同名称：</td>
        <td align="left" ><apex:outputField id="name"  value="{!mc.Name}"/></td>
        <td align="right" >合同询价编码：</td>
        <td align="left" ><apex:outputField id="Management_Code" value="{!mc.Management_Code__c}"/></td>
        <td align="right" >记录类型：</td>
        <td align="left" ><apex:outputField id="RecordType" value="{!mc.RecordType.Name}"/>
        </td>
        <td align="right" >状 态：</td>
        <td align="left" ><apex:outputField id="Status" value="{!mc.Status__c}"/>
        </td>
        <td></td>
    </tr>
</table>
<apex:pageBlock title="经销商对医院修理价格录入（以下信息将作为报告书上传金额信息显示）" id="MoreMaintenanceContract" rendered="true">
    <div>
        <ul>
            <li> 
                <apex:outputText rendered="{!!isVM}"> 经销商对医院签约价格：</apex:outputText>
                <apex:outputText rendered="{!isVM}"> 对医院合同金额（手填）：</apex:outputText>
                <apex:outputPanel layout="none" rendered="{!IF(HATextEdit,true , false)}"><apex:InputField value="{!mc.HospitalAmountText__c}"  id="HospitalAmountText"  style="max-width: 120px;"/></apex:outputPanel><apex:outputPanel layout="none" rendered="{!IF(HATextEdit,false , true)}"><apex:outputField value="{!mc.HospitalAmountText__c}"  id="HospitalAmountText1"  style="max-width: 120px;"/></apex:outputPanel> </li>
            <li>
                <apex:outputText rendered="{!!isVM}">经销商对医院修理价格调整比例:</apex:outputText>
                <apex:outputText rendered="{!isVM}">对医院修理价格调整比例：</apex:outputText>
                <apex:Inputtext value="{!proportion}"  id="proportion"  style="max-width: 60px;"/>% <apex:commandButton onclick="RefreshPriceJs();return false;" id="RefreshPrice"  value="刷新价格" style="margin-left:10px;width:100px" /></li>
        </ul>
    </div>
    <input type="hidden" id="repairLCount" value="{!repairLCount}" />
    <div class="table-head">
        <table  class="list" >
            <thead>
                <tr class="headerRow" border="0" cellpadding="0" cellspacing="0" >
                    <th>修理受付番号</th>
                    <th>状态1</th>
                    <th>设备型号</th>
                    <th>机身号码</th>
                    <th>修理原价</th>
                    <th>报价等级</th>
                    <th><apex:outputText rendered="{!!isVM}">经销商对医院修理价格</apex:outputText>
                        <apex:outputText rendered="{!isVM}">对医院维修价格</apex:outputText></th>
                </tr>
            </thead>
        </table>
    </div>
    <div class="table-body" id="tableBody">
        <table class="list" border="0" cellpadding="0" cellspacing="0" >
            <tbody>
                <apex:repeat value="{!repairL}" var="rl" id="theRepeat" >
                    <tr>
                        <td><apex:outputText value="{!rl.rr.Name}"/></td>
                        <td><apex:outputText value="{!rl.rr.Status1__c}"/></td>
                        <td><apex:outputText value="{!rl.rr.Delivered_Product__r.Name}"/></td>
                        <td><apex:outputText value="{!rl.rr.SerialNumber__c}"/></td>
                        <td><apex:outputText value="{!rl.rr.Repair_List_Price_formula__c}"/></td>
                        <td><apex:outputText value="{!rl.rr.Repair_Rank__c}"/></td>
                        <td>
                            <!-- <apex:InputField value="{!rl.rr.hospitalQuotationText__c}"  id="hospitalQuotationText"  /> -->
                            <apex:outputPanel layout="none" rendered="{!IF(rl.edit=false&&rl.rr.hospitalQuotationText__c !=null,true , false)}">
                                <apex:outputField value="{!rl.rr.hospitalQuotationText__c}"  id="hospitalQuotationTextd"/>
                            </apex:outputPanel>
                            <apex:outputPanel layout="none" rendered="{!IF(rl.edit=false&&rl.rr.hospitalQuotationText__c !=null,false , true)}">
                                <apex:InputField value="{!rl.rr.hospitalQuotationText__c}"  id="hospitalQuotationText" onblur="JsHQSum()"/>
                            </apex:outputPanel>
                        </td>
                    </tr>
                </apex:repeat>
            </tbody>
        </table>
    </div>
    <div id="hospitalQuotationTextSum">
        <ul>
            <li>合同期间修理金额（上传）: <apex:outputText value="{!mc.hospitalQuotationTextSum__c}"  id="hospitalQuotationTextSum"/> </li> 
        </ul>
    </div>
</apex:pageBlock>
<apex:commandButton onclick="BackMc();return false;" value="返  回
" style="margin-left:30px;width:180px"  rendered="true" onComplete="unblockUI();" />
<apex:commandButton onclick="SaveJs(0);return false;" value="保  存
" style="margin-left:30px;width:180px"  rendered="true" />
<apex:commandButton onclick="SaveJs(1);return false;" value="保存并登录PBI报告书页面
" style="margin-left:30px;width:180px"  rendered="true" />
</apex:form>
</apex:page>