<!-- 该页面用于Lead对象上传PDF,未来如果要添加其他对象的上传PDF功能,复制该页面,将**standardController**修改为其他对象API名称即可 -->
|
<apex:page standardController="eSignForm__c" extensions="eSignFormFileUploadController" id="page" lightningStyleSheets="true">
|
<!-- <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> -->
|
<script>
|
var parentId = '{!parentId}';
|
// var uploadUrl = staticResources.newUrl;
|
var key;
|
|
function alertErrorMessage(errorMsg) {
|
let errorMsgNode = document.getElementById("page:theForm:block:msgContent");
|
errorMsgNode.innerText = errorMsg;
|
errorMsgNode.className = 'message errorM3';
|
}
|
|
function hiddenErrorMsgNode() {
|
let errorMsgNode = document.getElementById("page:theForm:block:msgContent");
|
errorMsgNode.innerText = '';
|
errorMsgNode.className = '';
|
}
|
function getFileContent(event) {
|
var fileObject = document.getElementById("page:theForm:block:uploadSection:file");
|
var reader = new FileReader();
|
var data = reader.readAsDataURL(fileObject.files[0]);
|
debugger
|
console.log(event);
|
}
|
// function getBase64(file) {
|
// return new Promise((resolve, reject) => {
|
// const reader = new FileReader();
|
// reader.readAsDataURL(file);
|
// reader.onload = () => resolve(reader.result);
|
// reader.onerror = error => reject(error);
|
// });
|
// }
|
function disableButtonStatus() {
|
let btnNode = document.getElementById('uploadFileId');
|
btnNode.classList.add("btnDisabled");
|
}
|
|
function enableButtonStatus() {
|
let btnNode = document.getElementById('uploadFileId');
|
btnNode.classList.remove("btnDisabled");
|
}
|
|
// function uploadFile() {
|
// disableButtonStatus();
|
// var fileObject = document.getElementById("file").files[0];
|
// getBase64(fileObject).then(
|
// data => {
|
// console.log(data);
|
// uploadFileToAWS(data, (fileObject.size).toString(), fileObject.name);
|
|
// }
|
// );
|
// }
|
// function confirmTrans(transId, isSuccess) {
|
|
// fetch(staticResources.updateUrl, {
|
// method: 'POST',
|
// body: JSON.stringify({ 'txId': transId, "isSuccess": isSuccess }),
|
// headers: {
|
// 'Content-Type': 'application/json',
|
// 'pi-token': staticResources.token
|
// }
|
// }).then((data) => {
|
// return data.json();
|
// }).then(data => {
|
// console.log("confirmTrans-" + JSON.stringify(data));
|
// document.getElementById("file").files[0].name = '';
|
// enableButtonStatus();
|
// refreshFiles();
|
// return data.status;
|
// })
|
|
// }
|
// function calculateFileSize(fileObject) {
|
// if (fileObject.size > 20971520) {
|
// alertErrorMessage('文件过大,请选择小于20mb的文件');
|
// }
|
// }
|
function downPdf(fileUrl) {
|
window.open(fileUrl,'_blank');
|
}
|
|
function previewPdf(viewUrl,FileName) {
|
let fileUrl = '/apex/ImgPreviewVF?type=preview&viewUrl='+viewUrl+'&name='+FileName+'';
|
console.log('fileUrl = ' + fileUrl);
|
window.open(fileUrl,'_blank');
|
}
|
|
</script>
|
<style>
|
.pdf .num {
|
width: 30%;
|
}
|
|
.pdf.name {
|
width: 30%
|
}
|
|
.pdf.downLink {
|
width: 40%
|
}
|
</style>
|
<apex:form id="theForm">
|
<apex:actionFunction name="refreshFiles" action="{!refreshFiles}" reRender="pdf,uploadSection"/>
|
<!-- <br/>
|
<br/>
|
<apex:pageBlock id="block">
|
<div style="text-align: center;">
|
<apex:outputPanel id="errorMsg">
|
<apex:pageMessages id="msgContent" escape="false" />
|
</apex:outputPanel>
|
</div>
|
<apex:pageBlockSection id="uploadSection">
|
<input type="file" id="file" name="filename"/>
|
<input class="btn" id='uploadFileId' type="Button" value="确认上传" onclick="uploadFile()" />
|
</apex:pageBlockSection>
|
</apex:pageBlock> -->
|
<apex:pageBlock title="PDF列表" id="pdf">
|
<!-- <apex:pageBlockSection > -->
|
<!-- show uploated file list -->
|
<apex:pageBlockTable value="{!fileList}" var="file" align="center" columns="4" columnsWidth="25%,25%,25%,25%">
|
<apex:column id="name" headerValue="文件名称">
|
<apex:outputLink value="/{!file.ESignFileAddressId}" target="_blank">{!file.FileName}</apex:outputLink>
|
</apex:column>
|
<!-- <apex:column id="num" headerValue="父记录链接">
|
<apex:outputLink value="/{!file.ParentRecordId__c}" target="_blank">{!file.ParentRecordId__c}</apex:outputLink>
|
</apex:column> -->
|
<apex:column id="previewLink" headerValue="预览链接" rendered="{!IF(file.IsImg,false,true)}">
|
<apex:outputLink value="{!file.ViewLink}" target="{!file.ViewLink}">预览链接
|
</apex:outputLink>
|
</apex:column>
|
<apex:column id="previewLinkIMG" headerValue="预览链接" rendered="{!IF(file.IsImg,true,false)}">
|
<!-- <apex:outputLink value="/apex/ImgPreviewVF?type=preview&key={!file.AWS_File_Key}&name={!file.FileName}" target="{!file.ViewLink}">预览链接
|
</apex:outputLink> -->
|
<apex:outputLink onclick="previewPdf('{!file.ViewLink}','{!file.FileName}')">预览链接
|
</apex:outputLink>
|
</apex:column>
|
<apex:column id="downLink" headerValue="下载链接">
|
<!-- <apex:outputLink value= "{!file.DownloadLink__c}" target="{!file.DownloadLink__c}">下载链接
|
</apex:outputLink> -->
|
<input class="btn" id='downloadFileButton' type="Button" value="下载" onclick="downPdf('{!file.DownloadLink}')" />
|
</apex:column>
|
|
<apex:column id="contentType" headerValue="附件类型">
|
<!-- <span id="theText" style="font-style:italic">{!file.ContentType}</span> -->
|
<apex:outputText value="{!file.ContentType}"></apex:outputText>
|
</apex:column>
|
</apex:pageBlockTable>
|
<!-- </apex:pageBlockSection> -->
|
</apex:pageBlock>
|
</apex:form>
|
|
</apex:page>
|