Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
pageContext.setAttribute("basePath", basePath);
%>
<head>
<title>文件查看</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript">
var _ctx = '${ctx}';
</script>
<script src="${ctx}/static/jquery-cui/js/jquery-1.9.1.min.js"></script>
<script src="${ctx}/static/suwell/suwell_ofdReader.js"></script>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
.readOnly {
pointer-events: none;
filter: alpha(opacity=50); /*IE滤镜,透明度50%*/
-moz-opacity: 0.5; /*Firefox私有,透明度50%*/
opacity: 0.5; /*其他,透明度50%*/
text-decoration: line-through;
color: darkgrey;
}
a {
color: #000000;
border: 1px solid #818181;
background-image: url(${ctx}/static/cm/image/btn-bg.png);
padding: 4px 15px;
border-radius: 2px;
margin: 0px 4px;
text-decoration: none;
}
</style>
</head>
<body>
<div style="text-align: left;width: 100%;height: 100%;">
<div id="tools" style="height: 40px;padding-top: 5px;">
<div class="buttens-foot-tools" style="margin: auto">
<a href="${ctx}/stamp/downloadFiles?attachmentId=${attachmentId}" target="_blank">下载</a>
<%--<a href="javascript:;" onclick="fileSaveTest()" id="refreshRed">保存</a>--%>
</div>
</div>
<div id="ofdReader" style="">
</div>
<script type="text/javascript">
//var exampleOfdUrl ='D:\\upload\\201909\\c4889422-254a-4f40-9666-3c7486316d6a.ofd';
var ocx = null;
var attachmentId = '${attachmentId}';
var businessId = '${businessId}';
var exampleOfdUrl = '${basePath}/attachment/viewOfd/${attachmentId}';
var uploadOFDUrl = '${basePath}/attachment/uploadOnlyOneDZYZ/${attachmentId}';
$(function () {
init();
if (ocx) {
ocx.setCompsiteVisible('f_open', false);//隐藏【打开】菜单
ocx.setCompsiteVisible('f_save', false);//隐藏【保存】菜单
ocx.setCompsiteVisible('f_print', false);//隐藏【打印】菜单
//ocx.setCompsiteVisible('f_saveas', false);//显示【另保存】菜单
//ocx.setCompsiteVisible('t_sealsign', false);//隐藏【签章工具栏】 //需要打开电子签章这行要注释
ocx.setConfigInfo('print_fast_checked', false);//“快速打印”不勾选
openFile(exampleOfdUrl, true);
// ocx.setPrintCompsiteEnable('copies', false);
// registListener('f_print', 'beforePrint', false);
registListener('f_print', 'afterPrint', true);
}
});
/**
* 初始化插件
*/
function init() {
var width = $('body').width();
var height = $('body').height() - $('#tools').height();
console.log('width:' + width + ',height:' + height);
ocx = suwell.ofdReaderInit('ofdReader', width, height);
}
function openExample() {
openFile(exampleOfdUrl, true);
}
/**
* 打开文件
* @param path string型,欲打开的本地文件路径、http链接或ftp文件路径。
* @param readOnly boolean,是否只读模式打开。
* @returns boolean 成功返回true,否则返回false。
*/
function openFile(path, readOnly) {
//var b = ocx.openFile(path, readOnly);
var b = ocx.openFile(path, readOnly); //需要打开电子签章这行readOnly要改成false
return b;
}
function registListener(commandId, functionName, after) {
ocx.registListener(commandId, functionName, after);
}
function beforePrint(param) {
console.log('打印前', param);
}
function afterPrint() {
$.ajax({
type: 'GET',
url: '${ctx}/print-num/updatePrintNum?attachmentId=' + attachmentId + '&businessId=' + businessId,
dataType: 'json',
success: function (data) {
if (data) {
initPrintTimes();
}
}
});
}
function printFile() {
ocx.printFile('', false);
debugger;
}
function printFileCopies() {
ocx.printFileCopies(1);
}
function fileSaveTest() {
console.log("上传文件1111");
ocx.saveFile(uploadOFDUrl)
//location.href=path;
}
</script>
</body>
</html>