weboffice.jsp
4.96 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.hrm.*,weaver.conn.RecordSet" %>
<%@ page import="com.api.doc.detail.util.ImageConvertUtil,java.util.Map,weaver.general.Util" %>
<%
User user = HrmUserVarify.getUser (request , response);
if(user == null){
return;
}
int fileid = Util.getIntValue(request.getParameter("fileid"));
String isEdit = request.getParameter("isEdit");
String mFileType = request.getParameter("mFileType");
int userid = user.getUID();
String usernaem = user.getLastname();
RecordSet rs = new RecordSet();
// http://edit.fanwei.com:9090/uploadFile.do
ImageConvertUtil icu = new ImageConvertUtil();
String filecode = "";
String filepath = "";
String dataStr = "";
String errMsg = "";
String filename = "";
String status = "";
//if(fileid > 0){
// rs.executeQuery("select filecode,filepath,filename from Yozo_ImgaFile where imagefileid=?",fileid);
//}
//if(fileid > 0 && rs.next()){
// filecode = rs.getString("filecode");
// filepath = rs.getString("filepath");
// filename = rs.getString("filename");
// status = "1";
//}else{
Map<String,String> dataMap = icu.uploadToYozo(fileid,mFileType);
status = dataMap.get("result");
filename = dataMap.get("filename");
if("0".equals(status)){
dataStr = dataMap.get("data");
}else{
errMsg = dataMap.get("message");
}
//}
String clientPath = icu.getYozoClient();
String hostname = rs.getPropValue("doc_yozo_for_weaver","yozo_hostname");
%>
<HTML>
<HEAD>
<script src="/cloudstore/resource/pc/jquery/jquery-1.8.3.min.js"></script>
<script src="/docs/e9/weboffice_yozo.js?version=2018122402"></script>
<script>
let openurl = '';
window.__clientpath = "<%=clientPath%>";
window.__filecode = "";
function openfile(filecode,filepath)
{
window.filepath = filepath;
let data = weboffice_yozo_Util.openFile('<%=userid%>','<%=usernaem%>',filecode,filepath,'<%=filename%>',false,true);
let hostName='<%=hostname%>';//全局根域名,在线编辑根域名
let token = data.result.token; //接口返回的token
let cookieStr = filecode + "="+token+";path=/;domain="+hostName;
document.cookie=cookieStr;
window.__filecode = filecode;
openurl = data.result.urls;
$('#webofficeIframe').attr('src', data.result.urls);
}
function savefile()
{
let data = "";
if("0" == "<%=status%>"){
var dataStr = eval('(<%=dataStr%>)');
if(dataStr.errorCode == "0"){
data = weboffice_yozo_Util.saveFile(dataStr.result.fileId);
}else{
alert(dataStr.errorCode + "," + dataStr.errorMessage);
}
}else if("1" == "<%=status%>"){
data = weboffice_yozo_Util.saveFile('<%=filecode%>');
}else{
alert("<%=status%>,<%=errMsg%>");
}
return data;
}
function closefile() {
let data = weboffice_yozo_Util.closeFile('1546110921508',true);
console.log(data);
}
function isOpen() {
let data = weboffice_yozo_Util.isOpen('1546110921508');
console.log(data);
}
function toSaveDocument(obj){
var data = savefile();
if(data.errorCode == "0"){
var result;
jQuery.ajax({
url : "/api/doc/acc/loadFromYoZo",
data : {
filepath : window.filepath,filename : obj ? (obj.fileName + "<%=mFileType%>") : "<%=filename%>",
},
dataType : "json",
type : "post",
async: false,
success: function(data) {
result = data;
}
});
if(result.fileid > 0){
return {
off_status : 1,
off_imagefileid : result.fileid
}
}else{
return {
off_status : 0
}
}
}else{
if(window.console){
console.log(data);
}
return {
off_status : 0
}
}
}
jQuery(function(){
if("0" == "<%=status%>"){
var dataStr = eval('(<%=dataStr%>)');
if(dataStr.errorCode == "0"){
openfile(dataStr.result.fileId,dataStr.result.filePath);
}else{
alert(dataStr.errorCode + "," + dataStr.errorMessage);
}
}else if("1" == "<%=status%>"){
openfile('<%=filecode%>','<%=filepath%>');
}else{
alert("<%=status%>,<%=errMsg%>");
}
})
function getCookie(name){
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
function delCookie(name){
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null)
document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
window.onbeforeunload = function(){
delCookie(window.__filecode);
}
</script>
</head>
<body style="margin:0">
<iframe id="webofficeIframe" width="100%" height="100%" frameBorder="0" src="" scrolling="no"></iframe>
</body>
</html>