From cd730d0b1a775abacfba06003bb58327d5d1fb3c Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期四, 02 二月 2023 12:23:31 +0800
Subject: [PATCH] 同步数据

---
 force-app/main/default/aura/eSignAgencyPage/eSignAgencyPageHelper.js |  600 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 354 insertions(+), 246 deletions(-)

diff --git a/force-app/main/default/aura/eSignAgencyPage/eSignAgencyPageHelper.js b/force-app/main/default/aura/eSignAgencyPage/eSignAgencyPageHelper.js
index 1d431fb..3327a7b 100644
--- a/force-app/main/default/aura/eSignAgencyPage/eSignAgencyPageHelper.js
+++ b/force-app/main/default/aura/eSignAgencyPage/eSignAgencyPageHelper.js
@@ -945,270 +945,328 @@
                 //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
                 component.set("v.messageFlag", false);
                 messageFlag = component.get("v.messageFlag");
-                var action = component.get("c.saveChunk");
-                action.setParams({
-                    parentId: component.get("v.parentId"),
-                    fileName: file.name,
-                    base64Data: encodeURIComponent(getchunk),
-                    contentType: file.type,
-                    fileId: attachId
-                });
-                // set call back
-                action.setCallback(this, function(response) {
-                    // store the response / Attachment Id
-                    attachId = response.getReturnValue();
-                    //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽start
-                    //鍏宠仈闄勪欢ID鍜岄檮浠跺悕
-                    var attachmentID = component.get("v.attachmentID");
-                    attachmentID[file.name] = attachId;
-                    component.set("v.attachmentID", attachmentID);
-                    //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽end
-                    var state = response.getState();
-                    if (state === "SUCCESS") {
-                        // update the start position with end postion
-                        startPosition = endPosition;
-                        endPosition = Math.min(
-                            fileContents.length,
-                            startPosition + this.CHUNK_SIZE
-                        );
-                        // check if the start postion is still less then end postion
-                        // then call again 'uploadInChunk' method ,
-                        // else, diaply alert msg and hide the loading spinner
-                        if (startPosition < endPosition) {
-                            this.uploadInChunk(
-                                component,
-                                file,
-                                fileContents,
-                                startPosition,
-                                endPosition,
-                                attachId
-                            );
-                        } else {
-                            //鍒ゆ柇涓婁紶鏂囦欢鍐呭 鎻愮ず涓�娆′俊鎭�
-                            var base = component.get("v.getchunk");
-                            if (!base || (base && base != getchunk)) {
-                                // alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲��");
-                                component.set("v.getchunk", getchunk);
-                            }
-
-                            alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲�俓n璇风偣鍑绘彁浜ゅ悗閫�鍑恒��");
-                            //鐢ㄤ簬鎻愪氦鎸夐挳鍒ゆ柇鏄惁鏈夊凡涓婁紶鐨勬枃浠�
-                            component.set('v.IsUpLoad', true);
-                            //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
-                            component.set("v.messageFlag", true);
-                            messageFlag = component.get("v.messageFlag");
-                            component.set("v.showLoadingSpinner", false);
-                            //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 start
-                            var isUploadName = component.get("v.isUploadName");
-                            var fileName = component.find("fileId").get("v.files")[0]['name'];
-                            if (isUploadName[fileName]) {
-                                var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Green;" title="' + fileName + '">' + fileName + '</span>';
-                                document.getElementById("uploadicon").style.display = 'inline-block';
-                            } else {
-                                var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Gray;" title="' + fileName + '">' + fileName + '</span>';
-                                document.getElementById("uploadicon").style.display = 'none';
-                            }
-                            var obj = document.getElementById('filenow');
-                            obj.innerHTML = str;
-                            //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 end
-                            //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 start
-                            var count = component.get("v.fileUpLoadSize");
-                            var fileName = component.get("v.flUpLoadName");
-                            if (count > 0) {
-                                //鍒楀嚭鏂囦欢鍚�01 鎵�鏈夋枃浠跺悕閮界敤閫楀彿闅斿紑 鏍规嵁閫楀彿鎷嗗垎锛屽瓨鏀炬暟缁�
-                                var nameList = fileName.split(',');
-                                for (var i = 0; i < nameList.length; i++) {
-                                    for (var j = i + 1; j < nameList.length; j++) {
-                                        if (nameList[i] == nameList[j]) { //绗竴涓瓑鍚屼簬绗簩涓紝splice鏂规硶鍒犻櫎绗簩涓�
-                                            nameList.splice(j, 1);
-                                            j--;
+                //zhj 涓嶄娇鐢ㄥ垎鎵逛笂浼犵殑鍔熻兘锛岀瓑璇ユ枃浠剁疮璁″畬鎴愪箣鍚庡啀涓婁紶鍒癆WS鐒跺悗瀛樺湪sf鐨凢ileAddress__c start
+                debugger
+                startPosition = endPosition;
+                endPosition = Math.min(
+                    fileContents.length,
+                    startPosition + this.CHUNK_SIZE
+                );
+                if (startPosition < endPosition) {
+                    this.uploadInChunk(
+                        component,
+                        file,
+                        fileContents,
+                        startPosition,
+                        endPosition,
+                        ''
+                    );
+                }
+                let staticResource = component.get('v.staticResource');
+                var reader = new FileReader();
+                reader.readAsDataURL(file.slice(0, endPosition));
+                var that = this;
+                reader.onloadend = function(evt){
+                    if(evt.target.readyState == FileReader.DONE){
+                        var base64value = evt.target.result;
+                        var Base64 = {};
+                        Base64.file = base64value;
+                        Base64.fileName = file.name;
+                        Base64.size = fileContents.length;
+                        //璋冪敤AWS 淇濆瓨鏂囦欢v.staticResource
+                        //awsPushData : function(destUrl, payloadForNewPI, callback, token,type)
+                        that.awsPushData(staticResource.newUrl,JSON.stringify(Base64), function(result){
+                            console.log('result = ' + result);
+                            if(result.status == '0'){
+                                //sf鍘讳繚瀛�
+                                // var action = component.get("c.saveFile");
+                                // action.setParams({
+                                //     fileName: file.name,
+                                //     key : result.object,
+                                //     transId : result.txId,
+                                //     parentId: component.get("v.parentId")
+                                // });
+                                that.CallBackAction(component,'saveFile',{
+                                    fileName: file.name,
+                                    key : result.object,
+                                    transId : result.txId,
+                                    parentId: component.get("v.parentId")
+                                },function(response){
+                                    //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽end
+                                    var state = response.getState();
+                                    if (state === "SUCCESS") {
+                                        //鎵цtrans鏂规硶锛岃繘琛岀‘璁ゆ垚鍔�
+                                        that.awsPushData(staticResource.updateUrl,JSON.stringify({ 'txId': result.txId, "isSuccess": 1 }), function(result){
+                                            console('纭浜嬪姟 =' + json.stringify(result));
+                                        },staticResource.token,'POST');
+                                        // store the response / Attachment Id
+                                        attachId = response.getReturnValue();       //attachId鏀归�犱箣鍚庡彉鎴愪簡鏄疐ile_Address__c鐨処d deloitte-zhj 2023-01-11
+                                        //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽start
+                                        //鍏宠仈闄勪欢ID鍜岄檮浠跺悕
+                                        var attachmentID = component.get("v.attachmentID");
+                                        attachmentID[file.name] = attachId;
+                                        component.set("v.attachmentID", attachmentID);
+                                        //鍒ゆ柇涓婁紶鏂囦欢鍐呭 鎻愮ず涓�娆′俊鎭�
+                                        var base = component.get("v.getchunk");
+                                        if (!base || (base && base != getchunk)) {
+                                            // alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲��");
+                                            component.set("v.getchunk", getchunk);
                                         }
-                                    }
-                                }
-                                //瀛樻斁鍒板彉閲忎腑 鐢ㄤ簬涓婁竴椤典笅涓�椤佃繛鐐�
-                                component.set('v.nameUpLoadList', nameList);
-                                //閲嶆柊瀹氫箟閫変腑鏂囦欢鐨勬暟閲�
-                                component.set('v.fileSize', nameList.length);
-                                console.log("nameList:" + component.get('v.nameUpLoadList'));
-                                var isUploadName = component.get("v.isUploadName");
-                                if (nameList.length > 0) {
-                                    var strList = '';
-                                    for (var i = 0; i < nameList.length; i++) {
-                                        var num = Number(i) + 1;
-                                        var id = 'file0' + num;
-                                        //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 start
-                                        if (isUploadName[nameList[i]]) {
-                                            var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Green;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+
+                                        alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲�俓n璇风偣鍑绘彁浜ゅ悗閫�鍑恒��");
+                                        //鐢ㄤ簬鎻愪氦鎸夐挳鍒ゆ柇鏄惁鏈夊凡涓婁紶鐨勬枃浠�
+                                        component.set('v.IsUpLoad', true);
+                                        //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
+                                        component.set("v.messageFlag", true);
+                                        messageFlag = component.get("v.messageFlag");
+                                        component.set("v.showLoadingSpinner", false);
+                                        //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 start
+                                        var isUploadName = component.get("v.isUploadName");
+                                        var fileName = component.find("fileId").get("v.files")[0]['name'];
+                                        if (isUploadName[fileName]) {
+                                            var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Green;" title="' + fileName + '">' + fileName + '</span>';
+                                            document.getElementById("uploadicon").style.display = 'inline-block';
                                         } else {
-                                            var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Gray;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                            var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Gray;" title="' + fileName + '">' + fileName + '</span>';
+                                            document.getElementById("uploadicon").style.display = 'none';
                                         }
-                                        //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 end
-                                        //鎷兼帴p鏍囩 鍒楀嚭鏂囦欢鍚峣d涓嶅悓
-                                        strList += str;
+                                        var obj = document.getElementById('filenow');
+                                        obj.innerHTML = str;
+                                        //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 end
+                                        //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 start
+                                        var count = component.get("v.fileUpLoadSize");
+                                        var fileName = component.get("v.flUpLoadName");
+                                        if (count > 0) {
+                                            //鍒楀嚭鏂囦欢鍚�01 鎵�鏈夋枃浠跺悕閮界敤閫楀彿闅斿紑 鏍规嵁閫楀彿鎷嗗垎锛屽瓨鏀炬暟缁�
+                                            var nameList = fileName.split(',');
+                                            for (var i = 0; i < nameList.length; i++) {
+                                                for (var j = i + 1; j < nameList.length; j++) {
+                                                    if (nameList[i] == nameList[j]) { //绗竴涓瓑鍚屼簬绗簩涓紝splice鏂规硶鍒犻櫎绗簩涓�
+                                                        nameList.splice(j, 1);
+                                                        j--;
+                                                    }
+                                                }
+                                            }
+                                            //瀛樻斁鍒板彉閲忎腑 鐢ㄤ簬涓婁竴椤典笅涓�椤佃繛鐐�
+                                            component.set('v.nameUpLoadList', nameList);
+                                            //閲嶆柊瀹氫箟閫変腑鏂囦欢鐨勬暟閲�
+                                            component.set('v.fileSize', nameList.length);
+                                            console.log("nameList:" + component.get('v.nameUpLoadList'));
+                                            var isUploadName = component.get("v.isUploadName");
+                                            if (nameList.length > 0) {
+                                                var strList = '';
+                                                for (var i = 0; i < nameList.length; i++) {
+                                                    var num = Number(i) + 1;
+                                                    var id = 'file0' + num;
+                                                    //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 start
+                                                    if (isUploadName[nameList[i]]) {
+                                                        var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Green;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                                    } else {
+                                                        var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Gray;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                                    }
+                                                    //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 end
+                                                    //鎷兼帴p鏍囩 鍒楀嚭鏂囦欢鍚峣d涓嶅悓
+                                                    strList += str;
+                                                }
+                                                var obj = document.getElementById('file00');
+                                                obj.innerHTML = strList;
+                                            }
+                                        }
+                                        //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 end
+                                    //}
+                                    //zhj 涓嶄娇鐢ㄥ垎鎵逛笂浼犵殑鍔熻兘锛岀瓑璇ユ枃浠剁疮璁″畬鎴愪箣鍚庡啀涓婁紶鍒癆WS鐒跺悗瀛樺湪sf鐨凢ileAddress__c end
+                                    // handel the response errors
+                                    } else if (state === "INCOMPLETE") {
+                                        alert("From server: " + response.getReturnValue());
+                                        component.set("v.showLoadingSpinner", false);
+                                        component.set("v.errorFlag", true);
+
+                                    } else if (state === "ERROR") {
+                                        var errors = response.getError();
+                                        component.set("v.showLoadingSpinner", false);
+                                        component.set("v.errorFlag", true);
+                                        if (errors) {
+                                            if (errors[0] && errors[0].message) {
+                                                console.log("Error message: " + errors[0].message);
+                                            }
+                                        } else {
+                                            console.log("Unknown error");
+                                        }
                                     }
-                                    var obj = document.getElementById('file00');
-                                    obj.innerHTML = strList;
-                                }
+                                });
+                                // enqueue the action
+                                //$A.enqueueAction(action);
                             }
-                            //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 end
-                        }
-                        // handel the response errors
-                    } else if (state === "INCOMPLETE") {
-                        alert("From server: " + response.getReturnValue());
-                        component.set("v.showLoadingSpinner", false);
-                        component.set("v.errorFlag", true);
-
-                    } else if (state === "ERROR") {
-                        var errors = response.getError();
-                        component.set("v.showLoadingSpinner", false);
-                        component.set("v.errorFlag", true);
-                        if (errors) {
-                            if (errors[0] && errors[0].message) {
-                                console.log("Error message: " + errors[0].message);
-                            }
-                        } else {
-                            console.log("Unknown error");
-                        }
+                        },staticResource.token,'POST');
+                    }else{
+                        alert('Could not read file');
                     }
-                });
-                // enqueue the action
-                $A.enqueueAction(action);
-
-            }
-
+                }
+            } 
         } else if (!base64List.includes(getchunk) || (base64List.includes(getchunk) && errorFlag)) {
             //缃戠粶娉㈠姩杩涙潵浠ュ悗 缃垚false
             component.set("v.errorFlag", false);
             //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
             component.set("v.messageFlag", false);
             messageFlag = component.get("v.messageFlag");
-            var action = component.get("c.saveChunk");
-            action.setParams({
-                parentId: component.get("v.parentId"),
-                fileName: file.name,
-                base64Data: encodeURIComponent(getchunk),
-                contentType: file.type,
-                fileId: attachId
-            });
 
-            // set call back
-            action.setCallback(this, function(response) {
-                // store the response / Attachment Id
-                attachId = response.getReturnValue();
-                //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽start
-                //鍏宠仈闄勪欢ID鍜岄檮浠跺悕
-                var attachmentID = component.get("v.attachmentID");
-                attachmentID[file.name] = attachId;
-                component.set("v.attachmentID", attachmentID);
-                //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽end
-                var state = response.getState();
-                if (state === "SUCCESS") {
-                    // update the start position with end postion
-                    startPosition = endPosition;
-                    endPosition = Math.min(
-                        fileContents.length,
-                        startPosition + this.CHUNK_SIZE
-                    );
-                    // check if the start postion is still less then end postion
-                    // then call again 'uploadInChunk' method ,
-                    // else, diaply alert msg and hide the loading spinner
-                    if (startPosition < endPosition) {
-                        this.uploadInChunk(
-                            component,
-                            file,
-                            fileContents,
-                            startPosition,
-                            endPosition,
-                            attachId
-                        );
-                    } else {
-                        //鍒ゆ柇涓婁紶鏂囦欢鍐呭 鎻愮ず涓�娆′俊鎭�
-                        var base = component.get("v.getchunk");
-                        if (!base || (base && base != getchunk)) {
-                            // alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲��");
-                            component.set("v.getchunk", getchunk);
-                        }
-                        alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲�俓n璇风偣鍑绘彁浜ゅ悗閫�鍑恒��");
-                        //鐢ㄤ簬鎻愪氦鎸夐挳鍒ゆ柇鏄惁鏈夊凡涓婁紶鐨勬枃浠�
-                        component.set('v.IsUpLoad', true);
-                        //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
-                        component.set("v.messageFlag", true);
-                        messageFlag = component.get("v.messageFlag");
-                        component.set("v.showLoadingSpinner", false);
-                        //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 start
-                        var isUploadName = component.get("v.isUploadName");
-                        var fileName = component.find("fileId").get("v.files")[0]['name'];
-                        if (isUploadName[fileName]) {
-                            var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Green;" title="' + fileName + '">' + fileName + '</span>';
-                            document.getElementById("uploadicon").style.display = 'inline-block';
-                        } else {
-                            var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Gray;" title="' + fileName + '">' + fileName + '</span>';
-                            document.getElementById("uploadicon").style.display = 'none';
-                        }
-                        var obj = document.getElementById('filenow');
-                        obj.innerHTML = str;
-                        //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 end
-                        //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 start
-                        var count = component.get("v.fileUpLoadSize");
-                        var fileName = component.get("v.flUpLoadName");
-                        if (count > 0) {
-                            //鍒楀嚭鏂囦欢鍚�01 鎵�鏈夋枃浠跺悕閮界敤閫楀彿闅斿紑 鏍规嵁閫楀彿鎷嗗垎锛屽瓨鏀炬暟缁�
-                            var nameList = fileName.split(',');
-                            for (var i = 0; i < nameList.length; i++) {
-                                for (var j = i + 1; j < nameList.length; j++) {
-                                    if (nameList[i] == nameList[j]) { //绗竴涓瓑鍚屼簬绗簩涓紝splice鏂规硶鍒犻櫎绗簩涓�
-                                        nameList.splice(j, 1);
-                                        j--;
+            //zhj 涓嶄娇鐢ㄥ垎鎵逛笂浼犵殑鍔熻兘锛岀瓑璇ユ枃浠剁疮璁″畬鎴愪箣鍚庡啀涓婁紶鍒癆WS鐒跺悗瀛樺湪sf鐨凢ileAddress__c start
+            debugger
+            startPosition = endPosition;
+            endPosition = Math.min(
+                fileContents.length,
+                startPosition + this.CHUNK_SIZE
+            );
+            if (startPosition < endPosition) {
+                this.uploadInChunk(
+                    component,
+                    file,
+                    fileContents,
+                    startPosition,
+                    endPosition,
+                    ''
+                );
+            }
+            let staticResource = component.get('v.staticResource');
+            var reader = new FileReader();
+            reader.readAsDataURL(file.slice(0, endPosition));
+            var that = this;
+            reader.onloadend = function(evt){
+                if(evt.target.readyState == FileReader.DONE){
+                    var base64value = evt.target.result;
+                    var Base64 = {};
+                    Base64.file = base64value;
+                    Base64.fileName = file.name;
+                    Base64.size = fileContents.length;
+                    //璋冪敤AWS 淇濆瓨鏂囦欢v.staticResource
+                    that.awsPushData(staticResource.newUrl,JSON.stringify(Base64), function(result){
+                        console.log('result = ' + result);
+                        if(result.status == '0'){
+                            //sf鍘讳繚瀛�
+                            // var action = component.get("c.saveFile");
+                            // action.setParams({
+                            //     fileName: file.name,
+                            //     key : result.object,
+                            //     transId : result.txId,
+                            //     parentId: component.get("v.parentId")
+                            // });
+                            that.CallBackAction(component,'saveFile',{
+                                fileName: file.name,
+                                key : result.object,
+                                transId : result.txId,
+                                parentId: component.get("v.parentId")
+                            },function(response){
+                            // });
+                            // action.setCallback(that, function(response) {
+                                //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽end
+                                var state = response.getState();
+                                if (state === "SUCCESS") {
+                                    //鎵цtrans鏂规硶锛岃繘琛岀‘璁ゆ垚鍔�
+                                    that.awsPushData(staticResource.updateUrl,JSON.stringify({ 'txId': result.txId, "isSuccess": 1 }), function(result){
+                                        console('纭浜嬪姟 =' + JSON.stringify(result));
+                                    },staticResource.token,'POST');
+                                    // store the response / Attachment Id
+                                    attachId = response.getReturnValue();       //attachId鏀归�犱箣鍚庡彉鎴愪簡鏄疐ile_Address__c鐨処d deloitte-zhj 2023-01-11
+                                    //澧炲姞鏂囦欢鍒楄〃鍒犻櫎鍔熻兘聽聽绮剧悽鎶�鏈爐hh聽2021-09-02聽start
+                                    //鍏宠仈闄勪欢ID鍜岄檮浠跺悕
+                                    var attachmentID = component.get("v.attachmentID");
+                                    attachmentID[file.name] = attachId;
+                                    component.set("v.attachmentID", attachmentID);
+                                    //鍒ゆ柇涓婁紶鏂囦欢鍐呭 鎻愮ず涓�娆′俊鎭�
+                                    var base = component.get("v.getchunk");
+                                    if (!base || (base && base != getchunk)) {
+                                        // alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲��");
+                                        component.set("v.getchunk", getchunk);
                                     }
-                                }
-                            }
-                            //瀛樻斁鍒板彉閲忎腑 鐢ㄤ簬涓婁竴椤典笅涓�椤佃繛鐐�
-                            component.set('v.nameUpLoadList', nameList);
-                            //閲嶆柊瀹氫箟閫変腑鏂囦欢鐨勬暟閲�
-                            component.set('v.fileSize', nameList.length);
-                            console.log("nameList:" + component.get('v.nameUpLoadList'));
-                            var isUploadName = component.get("v.isUploadName");
-                            if (nameList.length > 0) {
-                                var strList = '';
-                                for (var i = 0; i < nameList.length; i++) {
-                                    var num = Number(i) + 1;
-                                    var id = 'file0' + num;
-                                    //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 start
-                                    if (isUploadName[nameList[i]]) {
-                                        var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Green;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+
+                                    alert("鎮ㄥ凡缁忔垚鍔熶笂浼犳枃浠躲�俓n璇风偣鍑绘彁浜ゅ悗閫�鍑恒��");
+                                    //鐢ㄤ簬鎻愪氦鎸夐挳鍒ゆ柇鏄惁鏈夊凡涓婁紶鐨勬枃浠�
+                                    component.set('v.IsUpLoad', true);
+                                    //鐢ㄤ簬鍒ゆ柇涓婁紶鍚屼竴涓枃浠舵彁绀�
+                                    component.set("v.messageFlag", true);
+                                    messageFlag = component.get("v.messageFlag");
+                                    component.set("v.showLoadingSpinner", false);
+                                    //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 start
+                                    var isUploadName = component.get("v.isUploadName");
+                                    var fileName = component.find("fileId").get("v.files")[0]['name'];
+                                    if (isUploadName[fileName]) {
+                                        var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Green;" title="' + fileName + '">' + fileName + '</span>';
+                                        document.getElementById("uploadicon").style.display = 'inline-block';
                                     } else {
-                                        var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Gray;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                        var str = '<span>褰撳墠鏂囦欢锛�</span><span id="nowfile" class="field-title" style="color:Gray;" title="' + fileName + '">' + fileName + '</span>';
+                                        document.getElementById("uploadicon").style.display = 'none';
                                     }
-                                    //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 end
-                                    //鎷兼帴p鏍囩 鍒楀嚭鏂囦欢鍚峣d涓嶅悓
-                                    strList += str;
+                                    var obj = document.getElementById('filenow');
+                                    obj.innerHTML = str;
+                                    //鏍囪瘑棰勮鍥剧墖鍚嶅瓧  绮剧悽鎶�鏈� thh 2021-09-15 end
+                                    //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 start
+                                    var count = component.get("v.fileUpLoadSize");
+                                    var fileName = component.get("v.flUpLoadName");
+                                    if (count > 0) {
+                                        //鍒楀嚭鏂囦欢鍚�01 鎵�鏈夋枃浠跺悕閮界敤閫楀彿闅斿紑 鏍规嵁閫楀彿鎷嗗垎锛屽瓨鏀炬暟缁�
+                                        var nameList = fileName.split(',');
+                                        for (var i = 0; i < nameList.length; i++) {
+                                            for (var j = i + 1; j < nameList.length; j++) {
+                                                if (nameList[i] == nameList[j]) { //绗竴涓瓑鍚屼簬绗簩涓紝splice鏂规硶鍒犻櫎绗簩涓�
+                                                    nameList.splice(j, 1);
+                                                    j--;
+                                                }
+                                            }
+                                        }
+                                        //瀛樻斁鍒板彉閲忎腑 鐢ㄤ簬涓婁竴椤典笅涓�椤佃繛鐐�
+                                        component.set('v.nameUpLoadList', nameList);
+                                        //閲嶆柊瀹氫箟閫変腑鏂囦欢鐨勬暟閲�
+                                        component.set('v.fileSize', nameList.length);
+                                        console.log("nameList:" + component.get('v.nameUpLoadList'));
+                                        var isUploadName = component.get("v.isUploadName");
+                                        if (nameList.length > 0) {
+                                            var strList = '';
+                                            for (var i = 0; i < nameList.length; i++) {
+                                                var num = Number(i) + 1;
+                                                var id = 'file0' + num;
+                                                //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 start
+                                                if (isUploadName[nameList[i]]) {
+                                                    var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Green;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                                } else {
+                                                    var str = '<button id="' + id + '" class="slds-button" title="Field 3" style="text-align:left;width:250px;font-weight:bold;font-size: 15px;color:Gray;" name="' + nameList[i] + '">' + nameList[i] + '</button><br>';
+                                                }
+                                                //鏍囪瘑鏂囦欢鏄惁宸茬粡涓婁紶  绮剧悽鎶�鏈� thh 2021-09-26 end
+                                                //鎷兼帴p鏍囩 鍒楀嚭鏂囦欢鍚峣d涓嶅悓
+                                                strList += str;
+                                            }
+                                            var obj = document.getElementById('file00');
+                                            obj.innerHTML = strList;
+                                        }
+                                    }
+                                    //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 end
+                                    //zhj 涓嶄娇鐢ㄥ垎鎵逛笂浼犵殑鍔熻兘锛岀瓑璇ユ枃浠剁疮璁″畬鎴愪箣鍚庡啀涓婁紶鍒癆WS鐒跺悗瀛樺湪sf鐨凢ileAddress__c end
+                                    // handel the response errors
+                                } else if (state === "INCOMPLETE") {
+                                    alert("From server: " + response.getReturnValue());
+                                    component.set("v.showLoadingSpinner", false);
+                                    component.set("v.errorFlag", true);
+
+                                } else if (state === "ERROR") {
+                                    var errors = response.getError();
+                                    component.set("v.showLoadingSpinner", false);
+                                    component.set("v.errorFlag", true);
+                                    if (errors) {
+                                        if (errors[0] && errors[0].message) {
+                                            console.log("Error message: " + errors[0].message);
+                                        }
+                                    } else {
+                                        console.log("Unknown error");
+                                    }
                                 }
-                                var obj = document.getElementById('file00');
-                                obj.innerHTML = strList;
-                            }
+                            });
+                            // enqueue the action
+                            //$A.enqueueAction(action);
                         }
-                        //涓婁紶鎴愬姛鍚庢枃浠跺垪琛ㄧ殑鏂囦欢鍚嶅彉鑹�  绮剧悽鎶�鏈� thh 2021-09-26 end
-                    }
-                    // handel the response errors
-                } else if (state === "INCOMPLETE") {
-                    alert("From server: " + response.getReturnValue());
-                    component.set("v.showLoadingSpinner", false);
-                    component.set("v.errorFlag", true);
-                } else if (state === "ERROR") {
-                    var errors = response.getError();
-                    component.set("v.showLoadingSpinner", false);
-                    component.set("v.errorFlag", true);
-                    if (errors) {
-                        if (errors[0] && errors[0].message) {
-                            console.log("Error message: " + errors[0].message);
-                        }
-                    } else {
-                        console.log("Unknown error");
-                    }
+                    },staticResource.token,'POST');
+                }else{
+                    alert('Could not read file');
                 }
-            });
-            // enqueue the action
-            $A.enqueueAction(action);
+            }
         } else {
             if (messageFlag) {
                 alert("鎮ㄥ凡缁忎笂浼犺繃璇ユ枃浠朵簡锛�")
@@ -1230,6 +1288,7 @@
         component.set("v.base64List", base64List);
         // component.set("v.showLoadingSpinner", false);
         // baseFile = getchunk;
+        
 
     },
 
@@ -1298,7 +1357,56 @@
         }
 
         return imgScale;
-    },
+    },CallBackAction  : function(component,action_name,para,callback) {  //璋冪敤鍚庡彴鏂规硶 zhj 2022-01-03
+		var action = component.get("c." + action_name.trimStart().replace("c.",""));
+        if(para){
+            action.setParams(para);
+        }
+        if(callback){
+            action.setCallback(this,function(data){
+                callback(data);
+            });
+        }
+        
+        $A.enqueueAction(action);
+	},trans : function (fileName,txId,isSuccess){       //纭浜嬪姟 AWS zhj 2022-01-03
+		let transParameters = {
+			txId: txId,
+			isSuccess: isSuccess
+		};
+		console.log('txId = ' + txId);
+		AWSService.confirmTrans(staticResource.updateUrl,JSON.stringify(transParameters),function(result){
+			console.log(fileName);
+			console.log(JSON.stringify(result))
+		},staticResource.token)
+	},awsPushData : function(destUrl, payloadForNewPI, callback, token,type) {  //纭浜嬪姟 AWS zhj 2022-01-03
+       console.log('enter '+type);
+       let payloadstr= null;
+       if (payloadForNewPI) {
+           if (typeof payloadForNewPI == 'string') {
+               payloadstr = payloadForNewPI;
+           }else{
+               payloadstr = JSON.stringify(payloadForNewPI);
+           }
+       }
+       console.log(payloadstr);
+       fetch(destUrl, {
+            method: type,
+            body: payloadstr,
+            headers: {
+                'Content-Type': 'application/json',
+                'pi-token': token
+            }
+        }).then((data) => {
+            return data.json();
+        }).then((result) => {
+            console.log(result);
+            callback(result);      
+        }).catch(error => {
+            console.log(error);
+            callback(0);     
+        });
+   }
 
 
 })
\ No newline at end of file

--
Gitblit v1.9.1