<apex:page Controller="ContentPreviewController" sidebar="false" action="{!init}" id="Page">
|
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.downloadJs)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
|
<script type="text/javascript" src="{!URLFOR($Resource.pdfjs113, 'build/pdf.js')}"></script>
|
<script type="text/javascript" src="{!URLFOR($Resource.pdfjs113, 'build/pdf.worker.js')}"></script>
|
<apex:form id="Form">
|
<apex:outputPanel id="message"><apex:pageMessages /></apex:outputPanel>
|
<apex:outputPanel layout="none" rendered="{!isError}">
|
{!msg}
|
</apex:outputPanel>
|
<apex:outputPanel layout="none" rendered="{!noDoc}">
|
{!msg}
|
<br/>
|
<input class="btn" style="width:120px;" type="button" value="现状分析文档更新" onclick="sendRefRequest();" />
|
</apex:outputPanel>
|
<apex:outputPanel layout="none" rendered="{!NOT(isError || noDoc)}">
|
<script type="text/javascript">
|
// pdf.worker.js へのパスを指定する
|
PDFJS.workerSrc = "{!URLFOR($Resource.pdfjs113, 'build/pdf.worker.js')}";
|
|
sforce.connection.sessionId = '{!$Api.Session_ID}';
|
|
var idx = 1;
|
var base64pdfData;
|
var pdfData;
|
var docid;
|
var docInfoMap;
|
|
// PDFとPPTファイルのマッピング
|
var pdfpptObj = new Object();
|
<apex:repeat value="{!pdfpptList}" var="pp">
|
var tmpid = '{!pp}';
|
pdfpptObj[tmpid.split('_')[0]] = tmpid.split('_')[1];
|
</apex:repeat>
|
|
function drawPdfCanvas(cnt) {
|
PDFJS.getDocument(pdfData).then(function (pdf) {
|
// nページ目を取得する
|
return pdf.getPage(cnt);
|
}).then(function (page) {
|
// Canvas にnページ目の内容を描画
|
var scale = 1;
|
var viewport = page.getViewport(scale);
|
var canvas = jQuery(escapeVfId('myCanvas'))[0];
|
var context = canvas.getContext('2d');
|
canvas.height = viewport.height;
|
canvas.width = viewport.width;
|
var renderContext = {
|
canvasContext: context,
|
viewport: viewport
|
};
|
page.render(renderContext);
|
}, function(reason){
|
if (idx > 1) {
|
alert("已到最后一页");
|
idx = idx - 1;
|
}
|
});
|
}
|
|
function showPage(id) {
|
docid = id;
|
docInfoMap = null;
|
ContentPreviewController.getDocumentBody(docid, function(res, event) {
|
if(event.status) {
|
docInfoMap = res;
|
base64pdfData = docInfoMap['body'];
|
pdfData = loadPDFData();
|
|
// title描画
|
jQuery("#pdfTitle").html('<font size="4"><b>'
|
+ docInfoMap['name'] + '(作成日期:' + docInfoMap['time'] + ')'
|
+ '</b></font>');
|
jQuery(escapeVfId('previewPDF')).val("");
|
jQuery(escapeVfId('downloadPPT')).val("");
|
idx = 1;
|
drawPdfCanvas(idx);
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 120000});
|
}
|
|
function loadPDFData() {
|
function base64ToUint8Array(base64) {
|
var raw = atob(base64);
|
var uint8Array = new Uint8Array(new ArrayBuffer(raw.length));
|
for (var i = 0, len = raw.length; i < len; ++i) {
|
uint8Array[i] = raw.charCodeAt(i);
|
}
|
return uint8Array;
|
}
|
return base64ToUint8Array(base64pdfData);
|
}
|
|
function nextPage() {
|
idx = idx + 1;
|
drawPdfCanvas(idx);
|
// プレビューカウント
|
var previewPDF = jQuery(escapeVfId('previewPDF')).value();
|
if (previewPDF == "") {
|
sforce.apex.execute("ControllerUtil", "addBatchIfLogForCnt", {typeStr:"现状分析阅览统计", operationType:"阅览PDF", fileType:docInfoMap['type'], hpId:'{!hpId}'});
|
jQuery(escapeVfId('previewPDF')).val(docid);
|
}
|
}
|
|
function prevPage() {
|
if (idx == 1) {
|
alert("已到第一页");
|
} else {
|
idx = idx - 1;
|
drawPdfCanvas(idx);
|
}
|
}
|
|
function downloadppt() {
|
var pptid = pdfpptObj[docid];
|
docInfoMap = null;
|
ContentPreviewController.getDocumentBody(pptid, function(res, event) {
|
if(event.status) {
|
docInfoMap = res;
|
base64pdfData = docInfoMap['body'];
|
download("data:text/plain;base64," + base64pdfData, docInfoMap['name'] + ".ppt", "text/plain");
|
// ダウンロードカウント
|
var downloadPPT = jQuery(escapeVfId('downloadPPT')).value();
|
if (downloadPPT == "") {
|
sforce.apex.execute("ControllerUtil", "addBatchIfLogForCnt", {typeStr:"现状分析阅览统计", operationType:"下载PPT", fileType:docInfoMap['type'], hpId:'{!hpId}'});
|
jQuery(escapeVfId('downloadPPT')).val(pptid);
|
}
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 120000});
|
}
|
|
function downloadexcel() {
|
docInfoMap = null;
|
ContentPreviewController.getDocumentBody('{!xlsId}', function(res, event) {
|
if(event.status) {
|
docInfoMap = res;
|
base64pdfData = docInfoMap['body'];
|
download("data:text/plain;base64," + base64pdfData, docInfoMap['name'] + ".xlsx", "text/plain");
|
// ダウンロードカウント
|
var downloadExcel = jQuery(escapeVfId('downloadExcel')).value();
|
if (downloadExcel == "") {
|
sforce.apex.execute("ControllerUtil", "addBatchIfLogForCnt", {typeStr:"现状分析阅览统计", operationType:"下载Excel", fileType:docInfoMap['type'], hpId:'{!hpId}'});
|
jQuery(escapeVfId('downloadExcel')).val('{!xlsId}');
|
}
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 120000});
|
}
|
|
function downloadRequest() {
|
if (jQuery(escapeVfId("Page:Form:targetUser_lkid")).val() == '000000000000000') {
|
alert("请先选择请求对象");
|
return;
|
}
|
sendDlRequest(docid, jQuery(escapeVfId("Page:Form:targetUser_lkid")).val());
|
}
|
|
function sendComment() {
|
var subject = '{!hpName}的提案书有问题';
|
var comment = jQuery(escapeVfId("Page:Form:comment")).val();
|
if (comment != "") {
|
ContentPreviewController.saveComment(subject, comment, docid, '{!hpId}', function(res, event) {
|
if(event.status) {
|
alert("留言完毕");
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 120000});
|
}
|
}
|
|
</script>
|
<input type="hidden" value="" id="previewPDF" />
|
<input type="hidden" value="" id="downloadPPT" />
|
<input type="hidden" value="" id="downloadExcel" />
|
<div>
|
<table>
|
<tr height="50px">
|
<td width="720px"><div id="pdfTitle" style="width:720px; height:50px; text-align: center;"></div></td>
|
<td width="200px" style="padding-left: 10px;"><input id="refBtn" class="btn" type="button" value="文档更新" onclick="document.getElementById('requestBtn').style.top = '180px';sendRefRequest();"/></td>
|
</tr>
|
<tr>
|
<td>
|
<table width="100%">
|
<tr>
|
<td style="width:50%; text-align: left;"><input class="btn" style="width:100px" type="button" value="←" onclick="prevPage();"/></td>
|
<td style="text-align: right;"><input class="btn" style="width:100px" type="button" value="→" onclick="nextPage();"/></td>
|
</tr>
|
</table>
|
</td>
|
<td style="padding-left: 10px;">切换提案书:<apex:selectList id="pdfType" value="{!docId}" size="1" style="width:120px;" onchange="showPage(this.value);return false;"><apex:selectOptions value="{!pdfTypeOpts}"/></apex:selectList></td>
|
</tr>
|
<tr>
|
<td><canvas id="myCanvas" width="720px" height="540px"></canvas></td>
|
<td style="vertical-align: top;padding-left: 10px;">
|
<apex:outputPanel layout="none" rendered="{!NOT(disableDL)}">
|
<input class="btn" type="button" value="下载PPT" onclick="downloadppt();"/>
|
<input class="btn" type="button" value="下载Excel" onclick="downloadexcel();"/>
|
</apex:outputPanel>
|
<apex:outputPanel layout="none" rendered="{!disableDL}">
|
您没有下载提案书的权限,<br/>请选择别的用户发送下载请求<br/><br/>
|
<apex:inputField id="targetUser" value="{!dummyReport.OwnerId}" style="width:90px;"/>
|
<input id="requestBtn" class="btn" style="width:90px; position: absolute; left: 870px; top: 135px;" type="button" value="下载请求" onclick="downloadRequest();" />
|
</apex:outputPanel>
|
</td>
|
</tr>
|
</table>
|
</div>
|
<b>对te2am的反馈意见:</b><br/>
|
<apex:inputTextarea id="comment" value="{!comment}" cols="90" rows="10" style="resize: none;"/>
|
<input class="btn" style="width:90px; position: absolute; left: 600px; bottom: 20px;" type="button" value="留言" onclick="sendComment();" />
|
</apex:outputPanel>
|
<script type="text/javascript">
|
setFocusOnLoad();
|
showPage('{!docId}');
|
if ('{!refBtnNG}' == "true") {
|
//jQuery(escapeVfId('refBtn')).prop("disabled", true);
|
jQuery(escapeVfId('refBtn')).css("display", "none");
|
}
|
</script>
|
</apex:form>
|
<!-- TODO なぜプルダウンのValidationエラーが発生しますか?一旦別フォームにする -->
|
<apex:form id="Form2">
|
<apex:actionFunction name="sendDlRequest" action="{!sendDlRequest}" rerender="dummy" oncomplete="alert('您的下载请求已发送');">
|
<apex:param name="p1" value="" assignTo="{!docId}" />
|
<apex:param name="p2" value="" assignTo="{!dummyReport.OwnerId}" />
|
</apex:actionFunction>
|
<apex:actionFunction name="sendRefRequest" action="{!sendRefRequest}" rerender="message" />
|
</apex:form>
|
</apex:page>
|