Li Jun
2022-04-19 2f183a6b0a83ec3f7d35375d5d25d200efc2a3e1
force-app/main/default/pages/ConsumTrial.page
@@ -6,6 +6,12 @@
    <apex:includeScript value="{!URLFOR($Resource.ReceivingNotePageJS)}"/>
    <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/>
    <script type="text/javascript">
       var txIds = [];
        var trialuserMap={};
    </script>
    <apex:form id="allForm">
        <style>
            table.headTable td   {
@@ -312,6 +318,42 @@
            var TrialUser = {};
            var ids = [];
        function HasError(){
            // let e = document.getElementById("allPage:allForm:message");
            // 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 cls in divs[i].classList){
            //             console.log('cls = ' + cls);
            //             if (cls.indexOf('error')>-1) {
            //                 return true;
            //             }
            //         }
            //     }
            // }
            // return false;
            if(document.getElementById("allPage:allForm:message").children[0] && document.getElementById("allPage:allForm:message").children[0].children[0].className == 'message errorM3'){
                return true;
            }
            return false;
        }
        function isError(){
            if(HasError()){
                alert('xxxx');
            }
        }
            queryUser();
            function q1(){
@@ -420,38 +462,42 @@
                document.getElementById(awsDataId+'_PI').remove();
            }
            function q3(){
                var p = new Promise(function(resolve, reject){
                    console.log('saveRecordJS')
                txIds = [];
                trialuserMap = {};
                    var a = 0;
                    var b = 0;
                debugger
                    let newCallBack = function newCallBack(result,indexNumber){
                        console.log('result = '+JSON.stringify(result))
                        //赋值dataId和trialUser
                        document.getElementById('allPage:allForm:dataBlock:dataline_R_aws:'+indexNumber+':EditAWSDataId').value = result.object[0].dataId;
                    document.getElementById('allPage:allForm:dataBlock:dataline_R_aws:'+indexNumber+':TrialUserEncrypt').value = result.object[0].trialUserEncrypt;
                        document.getElementById('allPage:allForm:dataBlock:dataline_R:'+indexNumber+':inputField:6:inputField').value = result.object[0].trialUser;
                        let transParameters = {
                            txId: result.txId,
                            isSuccess: 1
                        };
                        let confirmCallBack = function confirmCallBack(result){
                            console.log('confirmCallBack = '+JSON.stringify(result))
                        }
                    // let transParameters = {
                    //     txId: result.txId,
                    //     isSuccess: 1
                    // };
                    // let confirmCallBack = function confirmCallBack(result){
                    //     console.log('confirmCallBack = '+JSON.stringify(result))
                    // }
                        b++;
                        AWSService.confirmTrans(staticResource.transactionUrl,JSON.stringify(transParameters),confirmCallBack,staticResource.token)
                    txIds.push(result.txId)
                    //AWSService.confirmTrans(staticResource.transactionUrl,JSON.stringify(transParameters),confirmCallBack,staticResource.token)
                    };
                    for(var i=0;i<rowBList.length;i++){
                        if(document.getElementById('allPage:allForm:dataBlock:dataline_L:'+i+':rowCheck').checked == true){
                            a++;
                        }
                    }
                    debugger
                    for(var i=0;i<rowBList.length;i++){
                        if(document.getElementById('allPage:allForm:dataBlock:dataline_L:'+i+':rowCheck').checked == true){
                            //加密试用者
                            var trialUser = document.getElementById('allPage:allForm:dataBlock:dataline_R:'+i+':inputField:6:j_id86').children[0].children[0].value
                        let e = document.getElementById('allPage:allForm:dataBlock:dataline_R:'+i+':inputField:6:j_id86').children[0].children[0];
                        var trialUser = e.value;
                        trialuserMap['allPage:allForm:dataBlock:dataline_R:'+i+':inputField:6:j_id86'] = trialUser;
                            let consumApplyPayloadList = [];
                            let consumApplyPIData = new Object();
                            consumApplyPIData.trialUser = trialUser;
@@ -475,6 +521,34 @@
                debugger
                saveRecord();
            }
        function Trans(){
            if(HasError()){
                unblockUI();
                for(var e in trialuserMap){
                    document.getElementById(e).children[0].children[0].value = trialuserMap[e];
                }
                return;
            }
            var x = 0;
            let confirmCallBack = function confirmCallBack(result){
                console.log('confirmCallBack = '+JSON.stringify(result))
                x++;
                if(x == txIds.length){
                    refopener();
                    unblockUI();
                    window.location.href='/apex/ConsumTrial?id=' + '{!parId}' + '&canedit=true&saveType=1';
                }
            }
            for(var i=0;i<txIds.length;i++){
                let transParameters = {
                        txId: txIds[i],
                        isSuccess: 1
                };
                AWSService.confirmTrans(staticResource.transactionUrl,JSON.stringify(transParameters),confirmCallBack,staticResource.token)
            }
        }
            function saveRecordJS(){
                if('{!pageB.fixMode}' != 'true'){
                        return
@@ -486,7 +560,7 @@
            }
            //2022 02 24 张华建 display PI Data end
        </script>
        <apex:pageMessages />
        <apex:pageMessages id="message"/>
        <!-- oncomplete="clearApplyValue(); return false;" -->
        <apex:actionFunction name="passApplyMsgToController" action="{!showApplyMsg}"  rerender="allForm">
            <apex:param name="applyMsg" value="" />
@@ -495,7 +569,7 @@
        <apex:actionFunction name="sendEmail" action="{!sendEmail}"  rerender="allForm" oncomplete="unblockUI();">
            <apex:param name="emailBody" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="saveRecord" action="{!saveRecord}" oncomplete="refopener();unblockUI();" rerender="allForm"/>
        <apex:actionFunction name="saveRecord" action="{!saveRecord}" oncomplete="Trans();" rerender="allForm"/>
        <apex:inputHidden id="clearApplyFlagId" />
        <apex:outputPanel id="pageallPanel">
            <apex:pageBlock id="searchBlock">
@@ -631,6 +705,7 @@
                </div>
                <apex:repeat id="dataline_R_aws" value="{!pageB.rowBList}" var="var">
                    <apex:inputHidden value="{!var.rnd.AWS_Data_Id__c}" id="EditAWSDataId"/> 
                    <apex:inputHidden value="{!var.rnd.Trial_User_Encrypt__c}" id="TrialUserEncrypt"/>
                </apex:repeat>
                <div id="in_Div" style="overflow:auto;">
                    <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableData">