You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
6.4 KiB
178 lines
6.4 KiB
|
|
var initHyJs = function () { |
|
var util = { |
|
isMobile: function () { |
|
try { |
|
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { |
|
return true; |
|
} else { |
|
return false; |
|
} |
|
} catch (e) { |
|
return false; |
|
} |
|
}, |
|
isAndroidMobile: function () { |
|
try { |
|
if (/Android/i.test(navigator.userAgent)) { |
|
return true; |
|
} else { |
|
return false; |
|
} |
|
} catch (e) { |
|
return false; |
|
} |
|
}, |
|
postJSON: function (url, data, callback, error) { |
|
url = FR.servletURL + url; |
|
FR.ajax({ |
|
type: "POST", |
|
url: url, |
|
contentType: "application/json; charset=utf-8", |
|
data: JSON.stringify(data), |
|
success: function (resp) { |
|
callback != undefined && callback(JSON.parse(resp)); |
|
}, |
|
error: function (err) { |
|
error != undefined && error(err); |
|
} |
|
}) |
|
}, |
|
get: function (url, data, callback, error) { |
|
url = FR.servletURL + url; |
|
FR.ajax({ |
|
type: "GET", |
|
url: url, |
|
data: data, |
|
success: function (resp) { |
|
callback != undefined && callback(JSON.parse(resp)); |
|
}, |
|
error: function (err) { |
|
error != undefined && error(err); |
|
} |
|
}) |
|
} |
|
}; |
|
|
|
window["EDO"] = { |
|
"downloadFile":function (fileId, verId, userName) {//下载 |
|
if (util.isAndroidMobile()) { |
|
console.log("android platform") |
|
var url = "/edo/getDownloadUrlFr?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
|
util.get(url, {}, function (res) { |
|
console.log("下载返回结果:" + JSON.stringify(res)) |
|
if (!res.errorCode) { |
|
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
|
// alert("下载地址为:"+newUrl) |
|
window.open(newUrl) |
|
// window.location.href = newUrl; |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
}); |
|
} |
|
else { |
|
console.log("not android platform") |
|
var url = "/edo/download?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
|
util.get(url, {}, function (res) { |
|
// FR.Msg.toast(res.data) |
|
console.log("下载返回结果:" + JSON.stringify(res)) |
|
if (!res.errorCode) { |
|
//window.open(res.data) |
|
window.location.href = res.data; |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
}); |
|
} |
|
}, |
|
"priviewFile": function (fileId, userName) { //预览 |
|
var url = "/edo/priview?fileId=" + fileId + "&edocName=" + userName; |
|
|
|
util.get(url, {}, function (res) { |
|
|
|
if (!res.errorCode) { |
|
|
|
window.location=res.data; |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
},function(err){ |
|
|
|
FR.Msg.toast("err:"+err); |
|
}); |
|
}, |
|
"deleteFiles":function (fileIds, callback, userName) { //删除 |
|
var url = "/edo/remove" + "?edocName=" + userName; |
|
|
|
util.postJSON(url, fileIds, function () { |
|
callback && callback(); |
|
}) |
|
|
|
}, |
|
"batchDownload": function (fileIds, folders, userName) { //批量下载 |
|
if (util.isAndroidMobile()) { |
|
console.log("android platform") |
|
var url = "/edo/batch/downloadFr" + "?edocName=" + userName; |
|
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
|
console.log("批量下载返回结果:" + JSON.stringify(res)) |
|
if (!res.errorCode) { |
|
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
|
console.log("下载地址为:"+newUrl) |
|
// window.open(newUrl) |
|
window.location=newUrl; |
|
// window.open(res.data) |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
}) |
|
} |
|
else{ |
|
console.log("not android platform") |
|
var url = "/edo/batch/download" + "?edocName=" + userName; |
|
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
|
console.log("批量下载返回结果:" + JSON.stringify(res)) |
|
if (!res.errorCode) { |
|
//window.open(res.data) |
|
window.location=res.data; |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
}) |
|
} |
|
|
|
}, |
|
|
|
"fileManager":function (folderId, userName, callback) { |
|
var url = "/edo/file/manager?" + "folderId=" + folderId + "&edocName=" + userName; |
|
|
|
util.get(url, {}, function (res) { |
|
if (!res.errorCode) { |
|
if ($.isFunction(callback)) { |
|
callback(res); |
|
} else { |
|
window.open(res.data) |
|
} |
|
} else { |
|
FR.Msg.toast(res.errorMsg); |
|
} |
|
|
|
}); |
|
} |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("FR.EDO init complted") |
|
|
|
} |
|
|
|
initHyJs(); |
|
|
|
var test = function () { |
|
alert("aaaaa") |
|
}
|
|
|