123
chenjingwu
2024-04-23 3affb8b01f55f90cc047d3048e4ec04aad249e9d
force-app/main/default/pages/MaintenanceProductData.page
@@ -877,8 +877,13 @@
    }    
    function FilesUploadJs(){
        //上传文件
        FilesUpload();
    }
    function openUplod(){
        window.open('/lightning/n/LexUploadPage?0.recordId='+'{!id}');
    }
    //提交待审批
    function SubmitmpdJs() {
        blockme();
@@ -897,6 +902,8 @@
        </apex:actionFunction>
        <apex:actionFunction name="UpdateSave" action="{!UpdateSave}" rerender="edmpdDetails,message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:actionFunction name="refreshFile" action="{!refreshFile}" rerender="mpdataSection,edmpdDetails,message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:actionFunction name="deleteMpdd" action="{!deleteMpdd}" rerender="mpdDetailsSection, edmpdDetails,message" onComplete="unblockUI();">
        <apex:param name="firstParam" assignTo="{!mpddId}" value="" />
        </apex:actionFunction>
@@ -913,7 +920,8 @@
        <apex:pageBlock id="EDCline_1" >
            <apex:commandButton onclick="EditMpd();"   value="编辑" style="margin-left:30px;width:180px" rerender="mpdDetailsSection,edmpdDetails,message" rendered="{!!editAble }" disabled="{!IF(mpd.Status__c ='草案中'||mpd.Status__c='已驳回'||!editDisabled,false,true)}"/>
            <apex:commandButton onclick="FilesUploadJs();" value="上传文件" style="margin-left:30px;width:180px" rerender="mpdDetailsSection,message" rendered="{!!(EditDelCommitBtnDisabled||editAble)}" disabled="{!IF(mpd.Status__c ='草案中'||mpd.Status__c='已驳回'||!editDisabled,false,true)}"/>
            <!-- <apex:commandButton onclick="FilesUploadJs();" value="上传文件" style="margin-left:30px;width:180px" rerender="mpdDetailsSection,message" rendered="{!!(EditDelCommitBtnDisabled||editAble)}" disabled="{!IF(mpd.Status__c ='草案中'||mpd.Status__c='已驳回'||!editDisabled,false,true)}"/> -->
            <apex:commandButton onclick="openUplod();" value="上传文件" style="margin-left:30px;width:180px" rerender="mpdDetailsSection,message" rendered="{!!(EditDelCommitBtnDisabled||editAble)}" disabled="{!IF(mpd.Status__c ='草案中'||mpd.Status__c='已驳回'||!editDisabled,false,true)}"/>
           <apex:commandButton onclick="SubmitmpdJs();"    value="提交待审批" style="margin-left:30px;width:180px" rerender="unEditable" rendered="{!!(EditDelCommitBtnDisabled||editAble)}" disabled="{!IF(mpd.Status__c ='草案中'||mpd.Status__c='已驳回',false,true)}"/>
            <apex:commandButton onclick="Update();" value="保存维护记录" style="margin-left:30px;width:180px" rerender="edmpdDetails" rendered="{!IF(editAble,true,false)}" />
@@ -1282,6 +1290,9 @@
                                </apex:variable>
                                <th>产品名称</th>
                                <th>产品编码</th> 
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='ImportantProduct',true,false)}">
                                <th>产品预留</th>
                                </apex:variable>
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
                                <th>多年保修类型</th> 
                                </apex:variable>                          
@@ -1298,6 +1309,9 @@
                                </apex:variable>
                                <th style="min-width: 130px;">产品名称</th>
                                <th style="min-width: 130px;">产品编码</th> 
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='ImportantProduct',true,false)}">
                                <th style="min-width: 130px;">产品预留</th>
                                </apex:variable>
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
                                <th>多年保修类型</th> 
                                </apex:variable>                          
@@ -1323,6 +1337,12 @@
                                <td class="dataCell" rowspan="{!IF(editAble,1,2)}">
                                    <apex:outputText value="{!aa.mpded.ProductCode_Ext__c}" /> 
                                </td> 
                                <!-- kk  lastbuy  add  -->
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='ImportantProduct',true,false)}">
                                <td>
                                    <apex:InputField value="{!aa.mpded.LastbuyProductFLG__c}" id="lastbuyPreStorageCheckBox" />
                                 </td>
                                </apex:variable>
                                <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
                                <td class="dataCell" rowspan="{!IF(editAble,1,2)}" >
                                    <apex:outputText value="{!aa.mpded.GuranteeTypeP__c }" /> 
@@ -1359,9 +1379,12 @@
                                <td><apex:outputField value="{!aa.mpded[c[0]]}"/></td>
                                </apex:repeat>
                            </tr>
                            </apex:variable>
                        </apex:repeat>
                    </table>
                    <input type="hidden" id="ProductCnt1" value="{!mpdDetailsRecords}"/>
                </apex:outputLabel>
                </apex:pageblocksection>
                <!-- !(RecordTypeName='GuranteeMain'&&mpd.Status__c='服务填写') -->
@@ -1379,6 +1402,9 @@
                            </apex:variable> 
                            <th>产品名称</th>
                            <th>产品编码</th>
                            <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='ImportantProduct',true,false)}">
                            <th>产品预留</th>
                            </apex:variable>
                            <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
                            <th>多年保修类型</th> 
                            </apex:variable>                         
@@ -1401,6 +1427,11 @@
                            <td class="dataCell">
                                <apex:outputText value="{!records.Prod.ProductCode_Ext__c}" /> 
                            </td> 
                            <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='ImportantProduct',true,false)}">
                            <td>
                                <apex:InputField value="{!records.Prod.LastbuyProductFLG__c}" id="lastbuyPreStorageCheckBox" />
                             </td>
                            </apex:variable>
                            <apex:variable var="type" value="" rendered="{!IF(RecordTypeName='GuranteePrice',true,false)}"> 
                            <td class="dataCell">
                                <apex:outputText value="{!records.Prod.GuranteeType__c }" /> 
@@ -1423,6 +1454,7 @@
                                </td>
                            </apex:repeat>
                        </tr>
                        </apex:repeat>
                        
                    </table>
@@ -1491,11 +1523,41 @@
            var SelectObj = 'Product2';
            var SelectFld = 'Name';
            console.log('xxx');
            console.log('2344');
            var cnt = j$(escapeVfId('ProductCnt1')).val();
            if(cnt){
                cnt = cnt.length;
            }
            for (var i = 0; i < cnt; i++) {
                inputFieldId = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:4:edvariable:edtheValue';
                inputFieldId_lktp = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:4:edvariable:edtheValue_lktp';
                baseURL = '/apex/SearchContactPageLWC?ObjectType=' + ObjectType + '&QueryFieldApiName=' + QueryFieldApiName +'&QueryFieldApiName=' + QueryFieldApiName +'&ObjectType=' + ObjectType +'&inputFieldId=' + inputFieldId +'&SelectObj=' + SelectObj +'&SelectFld=' + SelectFld;
                var obj = document.getElementById('allPage:allForm:allBlock:edmpdDetails:bb:' + i + ':edtheRepeat:4:edvariable:edtheValue_lkwgt');
                if (obj != null) {
                    obj.setAttribute('href', 'javascript:%20openLookup%28%27' + baseURL + '%26lktp%3D%27%20%2B%20getElementByIdCS%28%27' + inputFieldId_lktp + '%27%29.value%2C670%2C%271%27%2C%27%26lksrch%3D%27%20%2B%20escapeUTF%28getElementByIdCS%28%27' + inputFieldId + '%27%29.value.substring%280%2C%2080%29%29%29');
                }
            }
        // 复杂组件 end
    }
    function refreshinput4(){
    // 复杂组件 start
    var baseURL = '';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var QueryFieldApiName = 'Default_Fixture_Arrival_Product__c';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var inputFieldId = '';
            var inputFieldId_lktp = '';
            var SelectObj = 'Product2';
            var SelectFld = 'Name';
            console.log('xxx');
            console.log('123');
            var cnt = j$(escapeVfId('ProductCnt')).val();
            console.log('count=' + cnt);
            for (var i = 0; i < cnt; i++) {
                inputFieldId = 'allPage:allForm:allBlock:mpdDetailsSection:save:maintenanceProductDatadetailsTable:'+ i +':theRepeat:4:variable:theValue';
                console.log('inputFieldId======' + inputFieldId);
                inputFieldId_lktp = 'allPage:allForm:allBlock:mpdDetailsSection:save:maintenanceProductDatadetailsTable:'+ i +':theRepeat:4:variable:theValue_lktp';
                baseURL = '/apex/SearchContactPageLWC?ObjectType=' + ObjectType + '&QueryFieldApiName=' + QueryFieldApiName +'&QueryFieldApiName=' + QueryFieldApiName +'&ObjectType=' + ObjectType +'&inputFieldId=' + inputFieldId +'&SelectObj=' + SelectObj +'&SelectFld=' + SelectFld;
                var obj = document.getElementById('allPage:allForm:allBlock:mpdDetailsSection:save:maintenanceProductDatadetailsTable:' + i + ':theRepeat:4:variable:theValue_lkwgt');
@@ -1505,11 +1567,104 @@
            }
        // 复杂组件 end
    }
    function refreshinput5(){
    // 复杂组件 start
    var baseURL = '';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var QueryFieldApiName = 'Service_Category6__c';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var inputFieldId = '';
            var inputFieldId_lktp = '';
            var SelectObj = 'Service_Category6__c';
            var SelectFld = 'Name';
            var cnt = j$(escapeVfId('ProductCnt1')).val();
            cnt = cnt.length;
            for (var i = 0; i < cnt; i++) {
                inputFieldId = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:13:edvariable:edtheValue';
                inputFieldId_lktp = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:13:edvariable:edtheValue_lktp';
                baseURL = '/apex/SearchContactPageLWC?ObjectType=' + ObjectType + '&QueryFieldApiName=' + QueryFieldApiName +'&QueryFieldApiName=' + QueryFieldApiName +'&ObjectType=' + ObjectType +'&inputFieldId=' + inputFieldId +'&SelectObj=' + SelectObj +'&SelectFld=' + SelectFld;
                var obj = document.getElementById('allPage:allForm:allBlock:edmpdDetails:bb:' + i + ':edtheRepeat:13:edvariable:edtheValue_lkwgt');
                if (obj != null) {
                    obj.setAttribute('href', 'javascript:%20openLookup%28%27' + baseURL + '%26lktp%3D%27%20%2B%20getElementByIdCS%28%27' + inputFieldId_lktp + '%27%29.value%2C670%2C%271%27%2C%27%26lksrch%3D%27%20%2B%20escapeUTF%28getElementByIdCS%28%27' + inputFieldId + '%27%29.value.substring%280%2C%2080%29%29%29');
                }
            }
        // 复杂组件 end
    }
    function refreshinput6(){
    // 复杂组件 start
    var baseURL = '';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var QueryFieldApiName = 'Service_Category7__c';
            var ObjectType = 'Maintenance_Product_Data_Details__c';
            var inputFieldId = '';
            var inputFieldId_lktp = '';
            var SelectObj = 'Service_Category7__c';
            var SelectFld = 'Name';
            var cnt = j$(escapeVfId('ProductCnt1')).val();
            cnt = cnt.length;
            for (var i = 0; i < cnt; i++) {
                inputFieldId = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:14:edvariable:edtheValue';
                inputFieldId_lktp = 'allPage:allForm:allBlock:edmpdDetails:bb:'+ i +':edtheRepeat:14:edvariable:edtheValue_lktp';
                baseURL = '/apex/SearchContactPageLWC?ObjectType=' + ObjectType + '&QueryFieldApiName=' + QueryFieldApiName +'&QueryFieldApiName=' + QueryFieldApiName +'&ObjectType=' + ObjectType +'&inputFieldId=' + inputFieldId +'&SelectObj=' + SelectObj +'&SelectFld=' + SelectFld;
                var obj = document.getElementById('allPage:allForm:allBlock:edmpdDetails:bb:' + i + ':edtheRepeat:14:edvariable:edtheValue_lkwgt');
                if (obj != null) {
                    obj.setAttribute('href', 'javascript:%20openLookup%28%27' + baseURL + '%26lktp%3D%27%20%2B%20getElementByIdCS%28%27' + inputFieldId_lktp + '%27%29.value%2C670%2C%271%27%2C%27%26lksrch%3D%27%20%2B%20escapeUTF%28getElementByIdCS%28%27' + inputFieldId + '%27%29.value.substring%280%2C%2080%29%29%29');
                }
            }
        // 复杂组件 end
    }
    refreshinput1();
    refreshinput2();
    refreshinput3();
    refreshinput4();
    refreshinput5();
    refreshinput6();
    </script>
                </apex:pageBlock>
                <!-- chenjingwu 20240417    start -->
                <apex:pageblocksection title="{!IF(editAble,'延保信息维护','延保信息维护(蓝色为新值)')}" id="exmpdDetails" rendered="{!IF(mpdDetailsRecordsCount >0,true,false)}" html-style="width: 100%;max-height:210px;;overflow:auto;">
                    <table class="list" border="0" cellpadding="0" cellspacing="0">
                        <tr class="headerRow">
                            <th>产品名称</th>
                            <th>延保年限</th>
                            <th>延保金额</th>
                            <th>计提金额</th>
                            <th>操作</th>
                        </tr>
                        <apex:repeat value="{!muMap}" var="key" id="bb1">
                            <tr>
                                <td rowspan="{!muMap[key].size}">
                                    <apex:outputText value="{!amuMap[key][0].ProductName__c}"/>
                                </td>
                                <td>
                                    <apex:outputText value="{!muMap[key][0].AgeLimit__c}"/>
                                </td>
                                <td>
                                    <apex:outputText value="{!muMap[key][0].MultiOneYearWarrantyPrice__c}"/>
                                </td>
                                <td>
                                    <apex:outputText value="{!muMap[key][0].AmountWithheld__c}"/>
                                </td>
                                <td></td>
                            </tr>
                            <apex:repeat value="muMap[key]" var="mu" id="bb2" first="1">
                                <td>
                                    <apex:outputText value="{!mu.AgeLimit__c}"/>
                                </td>
                                <td>
                                    <apex:outputText value="{!mu.MultiOneYearWarrantyPrice__c}"/>
                                </td>
                                <td>
                                    <apex:outputText value="{!mu.AmountWithheld__c}"/>
                                </td>
                                <td></td>
                            </apex:repeat>
                        </apex:repeat>
                    </table>
                </apex:pageblocksection>
                <!-- chenjingwu 20240417 end -->
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
@@ -1606,5 +1761,13 @@
    //初始化 
    
    resetOpenPage(SelectFieldParamList); 
    document.addEventListener('visibilitychange', () => {
      if (document.visibilityState == "visible") {
        console.log('当前页面进入用户视野,执行当前方法!');
        refreshFile();
      } else {
        console.log('当前页面退出用户视野,执行另一个方法!');
      }
    })
    </script>
</apex:page>