Picture_wev8.js 1.01 KB
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);
});