attachment(非attachmentSimple)附件手机端平台默认没有提供下载,可以自己放一个按钮做下载,参考如下:
本例是在list的行中放按钮下载的,因此获取row用的是list上的方式,如果不在list中可以自己修改
1.js中添加引用
var fileApi = require("$UI/system/components/justep/docCommon/fileApi");
var DocUtils = require("$UI/system/components/justep/docCommon/docUtil");
2.list中的下载按钮的onClick事件的实现
Model.prototype.button4Click = function(event){
var row = event.bindingContext.$object;//获取当前操作的行
var fFJ = row.val("fFJ");
var jsonList = eval("(" + fFJ + ")");// 获取附件组件的json值
var url = "";
var name = "";
if (jsonList.length > 0) {
// 获取第一个附件的相关的信息
var docPath = jsonList[0]["docPath"];
var fileID = jsonList[0]["fileID"];
name = jsonList[0]["docName"];
url = DocUtils.InnerUtils.getdocServerAction({
"docPath" : docPath,
urlPattern : "/repository/file/download/" + fileID + "/last/content",
isFormAction : false,
context : this.getContext(),
useCookie : false
});// 调用API获取url
url = url.indexOf(window.location.protocol) < 1 ? url : window.location.protocol + "//" + window.location.host + url;// 拼接最终需要的
}
fileApi.download(url, name).done(function() {
}).fail(function() {
alert("下载出错");
});//调用filleApi中的方法下载
};
fileApi提供的方法下载成功后默认没有提示,如果需要提示可以到/UI2/system/components/justep/docCommon/fileApi.js中的方法的具体实现中添加,如下:
评一波