({ // 设置table 各栏属性 getColumnAndAction : function(cmp) { var actions = [ {label: 'Edit', name: 'edit'}, {label: 'Delete', name: 'delete'}, {label: 'View', name: 'view'} ]; cmp.set('v.columns', [ // {label: 'CODE', fieldName: 'OTCode__c', type: 'text', wrapText:false // , hideDefaultActions: true ,fixedWidth: 110 }, {label: '产品型号', fieldName: 'Asset_Model_No__c', type: 'text' , wrapText:false , hideDefaultActions: true ,fixedWidth: 110 }, {label: 'CODE', fieldName: 'OTCode__c', type: 'text', wrapText:false , hideDefaultActions: true ,fixedWidth: 137 }, {label: '产品名称', fieldName: 'productName__c', type: 'text', wrapText:false , hideDefaultActions: true ,fixedWidth: 330 }, {label: '数量', fieldName: 'Count_Text__c', type: 'text' , wrapText:false , hideDefaultActions: true ,fixedWidth: 50 }, {label: '箱号', fieldName: 'CaseNumber__c', type: 'text' , wrapText:false , hideDefaultActions: true ,fixedWidth: 100 }, {label: '货物情况', fieldName: 'agencyGoodStatus__c', type: 'text', wrapText:false , hideDefaultActions: true ,fixedWidth: 110 }, {label: '处理意见', fieldName: 'handleOpinion__c', type: 'text', wrapText:false , hideDefaultActions: true ,fixedWidth: 170 }, {label: '经销商确认结果', fieldName: 'agencyConfirmResult__c', type: 'text', wrapText:false , hideDefaultActions: true , editable:true,fixedWidth: 140 }, ]); }, // 获取数据 geteSign : function(cmp) { this.showSpinner(cmp); var action = cmp.get("c.geteSigns"); var DNName = cmp.get("v.DNName").toString(); action.setParams({ 'DNName' : DNName }); action.setCallback(this,function(response) { var state = response.getState(); if (state === "SUCCESS") { var resultData = response.getReturnValue(); if(!!resultData && !!resultData.eSignFormLineItems && !!resultData.eSignForm){ var data = resultData.eSignFormLineItems; var goodsData = []; if(data!=null){ for(var i=0;i 0){ var currentData = cmp.get('v.currentData'); for(var i = 0; i0){ // spanList[2].innerText = '上传附件'; // } //返回首页带值start cmp.set('v.agencyDNSignUpStatus',resultData.agencyDNSignUpStatus); cmp.set('v.HPDNSignUpStatus',resultData.HPDNSignUpStatus); cmp.set('v.agencySubmit',resultData.agencySubmit); cmp.set('v.DNNameSpare',resultData.DNNameSpare); //返回首页带值 end alert('确认完成。'); cmp.set('v.handlingOpinionsPage',false); cmp.set('v.uploadFilePage',true); } else{ cmp.set("v.errorMessage", resultData.result); this.showErrorToast(cmp); } }else{ cmp.set("v.errorMessage", '保存失败,请重新加载!'); this.showErrorToast(cmp); } }); $A.enqueueAction(action); }, // 首页跳转至明细页逻辑,先判断是否勾选内容 handleHomePageNextClick : function(cmp) { //存一下检索框里的值 不然会被清掉 cmp.set('v.searchCase',cmp.get('v.searchCaseKey')); console.log('searchCaseKey:'+cmp.get('v.searchCaseKey')); var contentCheck = cmp.get('v.check'); if(contentCheck){ if(confirm('请再次确认DN号/收货单位与随货同行单一致。')){ cmp.set('v.HomePage',false); cmp.set('v.DetailsPage',true); //设置页面宽度 const width = document.documentElement.clientWidth; const contentDOM1 = document.getElementById('floatDiv'); contentDOM1.style.width = width + 'px'; //隐藏列 cmp.set('v.hideCheckboxColumn',true); } }else{ // if(confirm('请勾选上述内容已阅读。')){ // } alert('请勾选上述内容已阅读。'); return; } }, // 明细也跳转至文件上传页逻辑,先提示是否填写完毕 handleDetailsPageNextClick : function(cmp , event) { //存一下检索框里的值 不然会被清掉 var key = document.getElementById('searchInput').value; cmp.set('v.searchCaseKey',key); var AgencyClick = cmp.get('v.AgencyClick'); // if(confirm('请确认是否保存确认结果?')){ // this.saveeSign(cmp); cmp.set('v.DetailsPage',false); // cmp.set('v.uploadFilePage',true); cmp.set('v.handlingOpinionsPage',true); // } }, //给提交按钮一个默认的值 submitClick : function(cmp,event){ //设置一个flag用于避免提交两次 // cmp.set('v.AgencyClick', true); // alert('请点击提交按钮提交'); this.saveeSign(cmp); // cmp.set('v.handlingOpinionsPage',true); }, //弹出 成功提示toast 方法 showSuccessToast : function(cmp) { $A.util.removeClass(cmp.find('successDiv'), 'slds-hide'); window.setTimeout($A.getCallback(function() { $A.util.addClass(cmp.find('successDiv'), 'slds-hide'); }), 5000 ); }, //弹出 错误提示toast 方法 showErrorToast : function(cmp) { const width = document.documentElement.clientWidth; const contentDOM1 = document.getElementById('errorSonDiv1'); contentDOM1.style.width = width*0.6 + 'px'; const contentDOM2 = document.getElementById('errorSonDiv2'); contentDOM2.style.width = width*0.38 + 'px'; contentDOM2.style.height = '4rem'; const contentDOM3 =document.getElementById('errorSonDiv3'); contentDOM3.style.width = width-150 + 'px'; $A.util.removeClass(cmp.find('errorDiv'), 'slds-hide'); window.setTimeout($A.getCallback(function() { $A.util.addClass(cmp.find('errorDiv'), 'slds-hide'); }), 5000 ); }, // 展示 等待框 showSpinner: function(cmp) { // remove slds-hide class from mySpinner var spinner = cmp.find("mySpinner"); $A.util.removeClass(spinner, "slds-hide"); }, // 隐藏 等待框 hideSpinner : function(cmp){ // add slds-hide class from mySpinner var spinner = cmp.find("mySpinner"); $A.util.addClass(spinner, "slds-hide"); }, //返回明细页 handleShowFielePageNextClick : function(cmp) { cmp.set('v.handlingOpinionsPage',true); cmp.set('v.uploadFilePage',false); //隐藏列 // cmp.set('v.hideCheckboxColumn',true); }, //返回首页 handleShowPageNextClick : function(cmp) { //存一下检索框里的值 不然会被清掉 var key = document.getElementById('searchInput').value; cmp.set('v.searchCaseKey',key); cmp.set('v.HomePage',true); cmp.set('v.DetailsPage',false); }, //返回明细页 OpinionsTODetailsPage : function(cmp, event, helper){ //存一下检索框里的值 不然会被清掉 cmp.set('v.searchCase',cmp.get('v.searchCaseKey')); console.log('searchCaseKey:'+cmp.get('v.searchCaseKey')); cmp.set('v.handlingOpinionsPage',false); cmp.set('v.DetailsPage',true); }, //跳转附件页 nextToFile : function(cmp, event, helper){ cmp.set('v.handlingOpinionsPage',false); cmp.set('v.uploadFilePage',true); }, GoodsChanged:function(cmp){ var currentData = cmp.get('v.currentData'); for(var i = 0; i0 && file.size <307200){ imgWidth = this.width; imgHeight = this.height; }else{ if(Math.sqrt(this.width*this.height)/Math.sqrt(2) >1200){ maxSize = 1200; } else { maxSize =Math.sqrt(this.width*this.height)/Math.sqrt(2); } var imgScale = self.imgScaleW(maxSize,this.width,this.height); imgWidth = imgScale.width, imgHeight = imgScale.height; } var canvas = document.createElement("canvas"); var ctx = canvas.getContext("2d"); canvas.width = imgWidth; canvas.height = imgHeight; ctx.drawImage(this, 0, 0, imgWidth, imgHeight); //增加可以上传的图片类型 精琢技术 thh 2021-09-13 start if(pdf =='image/jpeg' ){ fileContents = canvas.toDataURL("image/jpeg", 0.9); }else if(pdf =='image/png'){ fileContents = canvas.toDataURL("image/png", 0.9); } //增加可以上传的图片类型 精琢技术 thh 2021-09-13 end var base64 = "base64,"; var dataStart = fileContents.indexOf(base64) + base64.length; fileContents = fileContents.substring(dataStart); // call the uploadProcess method self.uploadProcess(component, file, fileContents); }; }); }else{ //event var objFileReader = new FileReader(); // set onload function of FileReader object objFileReader.onload = $A.getCallback(function() { var fileContents = objFileReader.result; var base64 = "base64,"; var dataStart = fileContents.indexOf(base64) + base64.length; if (fileContents.length > 4608000) { component.set("v.showLoadingSpinner", false); alert("提醒,文件压缩大小不能超过4.5M,请重新上传。"); return; } else{ fileContents = fileContents.substring(dataStart); // call the uploadProcess method self.uploadProcess(component, file, fileContents); } }); } objFileReader.readAsDataURL(file); }, uploadProcess: function(component, file, fileContents) { // set a default size or startpostiton as 0 var startPosition = 0; // calculate the end size or endPostion using Math.min() function which is return the min. value var endPosition = Math.min( fileContents.length, startPosition + this.CHUNK_SIZE ); // start with the initial chunk, and set the attachId(last parameter)is null in begin this.uploadInChunk( component, file, fileContents, startPosition, endPosition, "" ); }, uploadInChunk: function( component, file, fileContents, startPosition, endPosition, attachId ) { // call the apex method 'saveChunk' var getchunk = fileContents.substring(startPosition, endPosition); //增加文件列表删除功能  精琢技术 thh 2021-08-31 start //把压缩完的src和文件名存入map var filesrc = component.get("v.FileSrc"); var emptyflag = true; for(var key in filesrc) { var emptyflag = false; } if(emptyflag){ filesrc[file.name] = getchunk; } else { for(var key in filesrc){ if(key == file.name){ filesrc[file.name] = filesrc[file.name] + getchunk; }else { filesrc[file.name] = getchunk; console.log('filesrc:'+filesrc); } } } component.set('v.FileSrc', filesrc); //增加文件列表删除功能  精琢技术 thh 2021-09-01 end var baseFile = component.get("v.baseFile"); var base64List = component.get("v.base64List"); //用于判断上传同一个文件提示 var messageFlag = component.get("v.messageFlag"); //判断是否出现过网络不好,上传失败的情况 var errorFlag = component.get("v.errorFlag"); if(!base64List){ if(baseFile != getchunk){ //用于判断上传同一个文件提示 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(); //增加文件列表删除功能  精琢技术 thh 2021-09-02 start //关联附件ID和附件名 var attachmentID = component.get("v.attachmentID"); attachmentID[file.name] = attachId; component.set("v.attachmentID", attachmentID); //增加文件列表删除功能  精琢技术 thh 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 = '当前文件:' + fileName + ''; document.getElementById("uploadicon").style.display = 'inline-block'; } else{ var str = '当前文件:' + fileName + ''; 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--; } } } //存放到变量中 用于上一页下一页连点 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 = '
'; } else{ var str = '
'; } //标识文件是否已经上传 精琢技术 thh 2021-09-26 end //拼接p标签 列出文件名id不同 strList += str; } var obj = document.getElementById('file00'); obj.innerHTML = strList; } } //上传成功后文件列表的文件名变色 精琢技术 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"); } } }); // 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(); //增加文件列表删除功能  精琢技术 thh 2021-09-02 start //关联附件ID和附件名 var attachmentID = component.get("v.attachmentID"); attachmentID[file.name] = attachId; component.set("v.attachmentID", attachmentID); //增加文件列表删除功能  精琢技术 thh 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 = '当前文件:' + fileName + ''; document.getElementById("uploadicon").style.display = 'inline-block'; } else{ var str = '当前文件:' + fileName + ''; 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--; } } } //存放到变量中 用于上一页下一页连点 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 = '
'; } else{ var str = '
'; } //标识文件是否已经上传 精琢技术 thh 2021-09-26 end //拼接p标签 列出文件名id不同 strList += str; } var obj = document.getElementById('file00'); obj.innerHTML = strList; } } //上传成功后文件列表的文件名变色 精琢技术 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"); } } }); // enqueue the action $A.enqueueAction(action); }else{ if(messageFlag){ alert("您已经上传过该文件了!") component.set("v.showLoadingSpinner", false); } } //存放上传过的文件base64 数组 var baseFile = component.get("v.baseFile"); var base64List = component.get("v.base64List"); if(baseFile){ component.set('v.baseFile',baseFile+','+getchunk); // nameList.pust(name); }else{ component.set('v.baseFile',getchunk); } baseFile = component.get("v.baseFile"); var base64List =baseFile.split(','); component.set("v.base64List",base64List); // component.set("v.showLoadingSpinner", false); // baseFile = getchunk; }, /** * 图片压缩 * @param maxWidth 最大宽度或最大高度 * @param width 宽度 * @param height 高度 * @returns {___anonymous1968_1969} */ imgScaleW:function(maxWidth,width,height){ var imgScale = {}; var w = 0; var h = 0; if(width <= maxWidth && height <= maxWidth){ // 如果图片宽高都小于限制的最大值,不用缩放 imgScale = { width:width, height:height }; }else{ if(width >= height){ // 如果图片宽大于高 w = maxWidth; h = Math.ceil(maxWidth * height / width); }else{ // 如果图片高大于宽 h = maxWidth; w = Math.ceil(maxWidth * width / height); } imgScale = { width:w, height:h }; } return imgScale; }, DrawImage1:function(maxWidth,width,height){ var imgScale = {}; var w = 0; var h = 0; if (width > 0 && height > 0) { if (width / height >= 1) { if (width > maxWidth) { imgScale = { width:maxWidth, height:(height * maxWidth) / width }; } else { imgScale = { width:width, height:height }; } } else { if (height > maxWidth) { imgScale = { width:maxWidth, height:(width * maxWidth) / height }; } else { imgScale = { width:width, height:height }; } } } return imgScale; }, })