Picture_wev8.js
1.01 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
define(['mUtil', "Component","docHelper"],function(mUtil, Component,docHelper) {
var Picture = function(options) {
Component.super(this, options);
this.type = "Picture";
this.tpl = this.type + "_html";
var vm = this.viewModel = {
width : "100%",
height : 200,
queryString : "",
dataAjax : true
};
this.beforeMount = function() {
//如果路径传的是docid,则转化为文件请求地址
if(!isNaN(vm.path)){
vm.docid = vm.path;
vm.path = "";
}
};
this.mounted = function () {
if (vm.callback && mUtil.isFunction(vm.callback.click)) {
$(".wev-comp-Picture > a", this.$el).on("click", function () {
vm.callback.click.call(this);
});
}
var $img = $("img", this.$el);
vm.docid && docHelper.convertDocidsToImageIds(vm.docid ,function (fileids){
if(fileids.length) $img.attr('src', '/weaver/weaver.file.FileDownload?fileid=' + fileids[fileids.length -1]);
$img.css('visibility','visible');
});
};
};
return Component.init(Picture);
});