buli
2022-04-06 2d4a8d2dcad5a17127d2c73c48ddc4b67ec79448
force-app/main/default/pages/OFSInsReportLayout.page
@@ -8,6 +8,7 @@
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <style type="text/css">
        table#AssetTable select {
            width: 98%;
@@ -127,6 +128,147 @@
    
}
//add by rentx 20210809 全选功能 end
AWSService.sfSessionId = '{!GETSESSIONID()}';
var staticResource = JSON.parse('{!staticResource}');
var aws_data = {};
var txid = null;
function Encrypt(callback){
    blockme();
    //callback();return;
    //<input type="hidden" value="{!ir.Id}" id="IrId"/>
    //<input type="hidden" value="{!ir.Responsible_Person_Encrypted__c}" id="Responsible_Person_Encrypted__c"/>
    //<input type="hidden" value="{!ir.phone_Encrypted__c}" id="phone_Encrypted__c"/>
    let e_id = document.getElementById("IrId");
    let url = staticResource.newUrl;
    aws_data = {
        "phone":j$("[field-api='phone__c']").val(),
        "responsiblePerson":j$("[field-api='Responsible_Person__c']").val(),
    };
    if(e_id && e_id.value){
        url = staticResource.updateUrl;
        aws_data.dataId = document.getElementById("Page:Form:Block:AWS_Data_Id__c").value;
    }
    AWSService.post(url, JSON.stringify([aws_data]), function(data){
        if (!(data && data.object && data.object.length)) {
            console.log('AWSService.post failed');
            return;
        }
        let aws_data1 = data.object[0];
        txid = data.txId;
        document.getElementById("Page:Form:Block:AWS_Data_Id__c").value = aws_data1.dataId;
        j$("[field-api='phone__c']").val(aws_data1.phone);
        document.getElementById("Page:Form:Block:phone_Encrypted__c").value = aws_data1.phoneEncrypt;
        j$("[field-api='Responsible_Person__c']").val(aws_data1.responsiblePerson);
        document.getElementById("Page:Form:Block:Responsible_Person_Encrypted__c").value = aws_data1.responsiblePersonEncrypt;
        if (callback) {
            callback();
        }
    }, staticResource.token);
}
function saveBtnJs(){
    Encrypt(saveBtn);
}
function submitJs(){
    Encrypt(submit);
}
function showPDFJs(){
    Encrypt(showPDF);
}
function afterSaveBtnJs(){
    Trans();
}
function afterSubmitJs(){
    Trans();
}
function afterShowPDFJs(){
    Trans(function(){
        if (!HasError()) {
            window.location.href = '/apex/InsReportPDFOuter?id=' + document.getElementById("IrId").value;
        }
    });
}
function HasError(){
    // if (IsAddmessage) {
    //     return true;
    // }
    let e = document.getElementById("Page:Form:MessageP");
    if (!e) {
        return false;
    }
    let divs = j$(e).find("div.message");
    for (let i = 0; i < divs.length; i++) {
        for (let j = 0; j < divs[i].classList.length; j++) {
            for(let clsi in divs[i].classList){let cls=divs[i].classList[clsi];
                if (cls.indexOf('error')>-1) {
                    return true;
                }
            }
        }
    }
    return false;
}
function Decrypt(data){
    j$("[field-api='phone__c']").val(data.phone);
    j$("[field-api='Responsible_Person__c']").val(data.responsiblePerson);
}
function Trans(callback){
    let payload = {
        "txId":txid,
        "sfRecordId":document.getElementById("IrId").value,
        "isSuccess":(txid && !HasError()) ? 1 : 0
    };
    AWSService.post(staticResource.transactionUrl, JSON.stringify(payload), function(result){
        Decrypt(aws_data);
        if(callback)callback();
        unblockUI();
    }, staticResource.token);
}
function Query(){
    let ele = document.getElementById("Page:Form:Block:AWS_Data_Id__c");
    if (ele && ele.value) {
        blockme();
        AWSService.query(staticResource.queryUrl, ele.value, function(data){
            if (data && data.object) {
                Decrypt(data.object);
            }
            unblockUI();
        }, staticResource.token);
    }
}
j$(function(){
    Query();
})
</script>
<title>{!ir.Name}</title>
</head>
@@ -138,6 +280,9 @@
    // 保存後、新規の報告書IDを取得
    tmpinsid = '{!ir.Id}';
    tmpinsn = '{!JSENCODE(ir.Name)}';
    //var IsAddmessage = {IsAddmessage};
    var isPDF = {!isPDF};
</script>
<apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,UnCheckSection" onComplete="unblockUI();"></apex:actionFunction>
@@ -149,9 +294,14 @@
<apex:actionFunction name="saveByRepair" action="{!saveBtn}" rerender="Form" onComplete="unblockUI();openRepair();"/>
<apex:actionFunction name="saveBtn" action="{!saveBtn}" rerender="Form" onComplete="afterSaveBtnJs();"/>
<apex:actionFunction name="submit" action="{!submit}" rerender="Form" onComplete="afterSubmitJs();"/>
<apex:actionFunction name="showPDF" action="{!showPDF}" rerender="Form" onComplete="afterShowPDFJs();"/>
<apex:outputPanel id="MessageP">
<apex:pageMessages />
</apex:outputPanel>
<div><apex:pageBlock mode="maindetail" Id="Block" rendered="{!initFlag}">
    <div style="position: relative;top:0;width:100%;">
@@ -162,10 +312,10 @@
                    <apex:outputLabel value="{!$ObjectType.Inspection_Report__c.fields.Name_Manual__c.Label}" for="Name_Manual"/>)
                    <apex:inputField value="{!ir.Name}" id="Ir_Name" html-disabled="disabled" style="border-width:0px;font-size:18px;font-weight:bold;padding-right:20px;-webkit-text-fill-color:black;"/>
                </td>
                <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="保存" action="{!saveBtn}" onclick="blockme();" rerender="Form" onComplete="unblockUI();"/></td>
                <td style="text-align: center;padding-right: 100px;"><apex:commandButton value="提交" action="{!submit}" onclick="blockme();" style="width:80px" rerender="Form" id="submitButton" onComplete="unblockUI();"/></td>
                <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" style="width:80px;" value="保存" action="" onclick="saveBtnJs();" rerender="Form" onComplete="unblockUI();"/></td>
                <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" value="提交" action="" onclick="submitJs();" style="width:80px" rerender="Form" id="submitButton" onComplete="unblockUI();"/></td>
                <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="关闭窗口" onclick="location.href='/apex/OFSWindowClose';return false;" id="closeButton"/></td>
                <td style="text-align: center;"><apex:commandButton style="width:80px;" value="PDF" action="{!showPDF}" onclick="blockme();" rerender="Form" onComplete="unblockUI();"/></td>
                <td style="text-align: center;"><input class="btn" type="Button" style="width:80px;" value="PDF" action="" onclick="showPDFJs();" rerender="Form" onComplete="unblockUI();"/></td>
            </tr>
        </table>
        <apex:pageBlockSection title="{!sectionList[0].title}" columns="{!sectionList[0].column}" showHeader="{!sectionList[0].showHeader}" rendered="{!sectionList.size>0}">
@@ -207,11 +357,18 @@
</div>
<div style="position: relative;top:0;height:700px;overflow:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;">
    <input type="hidden" value="{!ir.Id}" id="IrId"/>
    <apex:inputHidden value="{!ir.Responsible_Person_Encrypted__c}" id="Responsible_Person_Encrypted__c"/>
    <apex:inputHidden value="{!ir.phone_Encrypted__c}" id="phone_Encrypted__c"/>
    <apex:inputHidden value="{!ir.AWS_Data_Id__c}" id="AWS_Data_Id__c"/>
    <apex:repeat value="{!sectionList}" var="section" id="SectionList">
    <apex:pageBlockSection title="{!section.title}" columns="{!section.column}" showHeader="{!section.showHeader}" rendered="{!!section.isTop}">
    <apex:repeat value="{!section.sectionItemList}" var="sectionItem" id="SectionItemList">
    <apex:outputField value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/>
    <apex:inputField style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&sectionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
    <apex:inputField html-field-api="{!sectionItem.api}" style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&sectionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
    <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}">
    <apex:outputLabel value="{!sectionItem.customizeLable}"/>
    <apex:outputPanel layout="none">
@@ -222,7 +379,7 @@
</apex:outputPanel>
<apex:outputPanel layout="none" rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}">
<apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
<apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
<apex:inputField html-field-api="{!api}" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
<apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
<apex:outputField value="{!ir[api]}"/>
</apex:outputPanel>
@@ -234,7 +391,7 @@
<apex:outputPanel layout="none">
<apex:repeat value="{!sectionItem.apiList}" var="api">
<apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
<apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
<apex:inputField html-field-api="api" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
<apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
<apex:outputField value="{!ir[api]}"/>
</apex:outputPanel>