o2oa api: x-游戏厅捕鱼达人

source

mwf.xdesktop.requireapp("process.xform", "$module", null, false);
/** @class label 文本组件。
 * @o2cn 文本组件
 * @example
 * //可以在脚本中获取该组件
 * //方法1:
 * var label = this.form.get("name"); //获取组件
 * //方法2
 * var label = this.target; //在组件事件脚本中获取
 * @extends mwf.xapplication.process.xform.$module
 * @o2category formcomponents
 * @o2range {process|cms|portal}
 * @hideconstructor
 */
mwf.xapplication.process.xform.label = mwf.applabel =  new class(
    /** @lends mwf.xapplication.process.xform.label# */
    {
	implements: [events],
	extends: mwf.app$module,
	
	_loaduserinterface: function(){
		if (this.json.valuetype == "text"){
			this.node.set("text", this.json.text || "");
		}
		if (this.json.valuetype == "script"){
			var code = (this.json.script) ? this.json.script.code : "";
			if (code){
			    var value = this.form.macro.exec(code, this);
			    this._setnodetext(value);
				//this.node.set("text", this.form.macro.exec(code, this) || "");
			} 
		}
		if (this.json.prefixicon || this.json.suffixicon){
            var text = this.node.get("text");
            this.node.empty();
            var tnode = new element("div", {"styles": {
            	"margin-left": (this.json.prefixicon) ? "20px" : "0px",
                "margin-right": (this.json.suffixicon) ? "20px" : "0px",
                "height": "100%"
			}, "text": text}).inject(this.node);
            var height = (this.node.offsetparent === null) ? "20" : this.node.getsize().y;
            if (this.json.prefixicon){
                var node = new element("div", {"styles": {
                    "float": "left",
                    "width": "20px",
                    "height": "" height "px",
                    "background": " center center no-repeat"
                }}).inject(tnode, "before");
            }
            if (this.json.suffixicon){
                var node = new element("div", {"styles": {
                    "float": "right",
                    "width": "20px",
                    "height": "" height "px",
                    "background": " center center no-repeat"
                }}).inject(tnode, "before");
            }
		}
	},
    _setnodetext: function(value){
        if (value && value.isag){
            value.addresolve(function(v){
                this._setnodetext(v);
            }.bind(this));
        }else{
            o2.promiseall(value).then(function(v){
                this.node.set("text", v || "");
            }.bind(this), function(){});
            //this.node.set("text", value || "");
        }
    },
    /**当参数为promise的时候,请参考文档: {@link  https://www.yuque.com/o2oa/ixsnyt/ws07m0|使用promise处理表单异步}
* @summary 为组件设置文本,该文本不会被保存到后台。 * @param text{string|promise} . * @example * this.form.get("fieldid").settext("test"); //赋文本值 * @example * //使用promise * var field = this.form.get("fieldid"); * var dict = new this.dict("test"); //test为数据字典名称 * var promise = dict.get("tools", true); //异步使用数据字典的get方法时返回promise,参数true表示异步 * field.settext( promise ); */ settext: function(text){ if (!!text){ o2.promiseall(text).then(function(v){ this.node.set("text", v || ""); }.bind(this), function(){}); }else{ this.node.set("text", v || ""); } //this.node.set("text", text); } });
网站地图