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

source

mwf.xdesktop.requireapp("process.xform", "$selector", null, false);
/** @class combox 组合框组件。
 * @o2cn 组合框
 * @example
 * //可以在脚本中获取该组件
 * //方法1:
 * var field = this.form.get("fieldid"); //获取组件对象
 * //方法2
 * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
 * @extends mwf.xapplication.process.xform.$selector
 * @o2category formcomponents
 * @o2range {process|cms}
 * @hideconstructor
 */
mwf.xapplication.process.xform.combox = mwf.appcombox =  new class(
    /** @lends mwf.xapplication.process.xform.combox# */
{
	implements: [events],
	extends: mwf.app$selector,
	iconstyle: "selecticon",
    options: {
        /**
         * 手工输入完成后触发。
         * @event mwf.xapplication.process.xform.combox#commitinput
         * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
         */
        /**
         * 值改变时触发。
         * @event mwf.xapplication.process.xform.combox#change
         * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zts|组件事件说明}
         */
        "moduleevents": ["load", "queryload", "postload", "commitinput", "change"]
    },
    initialize: function(node, json, form, options){
        this.node = $(node);
        this.node.store("module", this);
        this.json = json;
        this.form = form;
        this.field = true;
        this.fieldmoduleloaded = false;
    },
    _loaduserinterface: function(){
        if ( this.issectionmergeread() ) { //区段合并显示
            this._loadmergereadnode();
        }else{
            if( this.issectionmergeedit() ){
                this._loadmergeeditnode();
            }else{
                this._loadnode();
            }
            // if (this.json.compute === "show"){
            //     this._setvalue(this._computevalue());
            // }else{
            //     this._loadvalue();
            // }
        }
    },
    loadval: function(){
        if (this.json.compute === "show"){
            this._setvalue(this._computevalue());
        }else{
            this._loadvalue();
        }
    },
	/**
	 * @summary 重新加载组件。会执行postload事件。
	 * @example
	 * this.form.get("fieldid").reload(); //重新加载事件
	 */
	reload: function(){
		if (this.areanode){
			this.node = this.areanode;
			this.areanode.empty();
			this.areanode = null;
		}
		this._beforereloaded();
		this._loaduserinterface();
        this._loadstyles();
		this._afterloaded();
		this._afterreloaded();
		this.fireevent("postload");
	},
    _loadnode: function(){
        if (this.isreadonly()){
            this._loadnoderead();
        }else{
            this._loadnodeedit();
        }
    },
    _loadnoderead: function(){
        this.node.empty();
        this.node.set({
            "nodeid": this.json.id,
            "mwftype": this.json.type
        });
        this.loadval();
        //new element("select").inject(this.node);
    },
    _loadmergereadcontentnode: function( contentnode, data ){
	    this.mergeread = true;
        contentnode.setstyles({ "overflow": "hidden"});
		var textlist = this.gettextlistbyvalue( data.data );
        if( typeof(textlist.then) === "function" ){
            promise.resolve(textlist).then(function (tlist) {
                this.__setvalueread( data.data, tlist, contentnode );
            }.bind(this))
        }else{
            this.__setvalueread( data.data, textlist, contentnode );
        }
        // textlist.each(function(text, i){
        //     if (iy2) || y2=="auto") ? y1 : y2;
            //    size.y = (y=="auto") ? "auto" : y.toint();
            //    //alert(size.y)
            //}
            this.iconnode.setstyle("height", "" size.y "px");
            //alert(this.iconnode.getstyle("height"))
        }
    },
    _searchoptions: function(){
        if (this.json.itemtype === "dynamic"){
			return function(value, callback){
				var event = {
					"value": value,
					"callback": callback
				};
                this.form.macro.fire(((this.json.itemdynamic) ? this.json.itemdynamic.code : ""), this, event);
			}.bind(this);
		}else{
        	return null;
		}
	},
    /**
     * @summary 获取选择项。
     * @return {array | promise} 返回选择项数组或promise,如:
[
     *  "女|female",
     *  "男|male"
     * ]
* @example * this.form.get('fieldid').getoptions(); * @example * //异步 * var opt = this.form.get('fieldid').getoptions(); * promise.resolve(opt).then(function(options){ * //options为选择项数组 * }) */ getoptions: function(async, refresh){ if( this.optionscache && !refresh )return this.optionscache; this.optionscache = null; var opt = this._getoptions(async, refresh); if( (opt && typeof(opt.then) === "function") ){ var p = promise.resolve( opt ).then(function(option){ this.moduleselectag = null; this.optionscache = this.parseoptions(option || []); return this.optionscache; }.bind(this)); this.moduleselectag = p; return p; }else{ this.optionscache = this.parseoptions(opt || []); return this.optionscache; } }, parseoptions: function(list){ // var list = []; // if (this.json.itemtype === "values"){ // list = this.json.itemvalues; // }else if (this.json.itemtype === "script"){ // list = this.form.macro.exec(((this.json.itemscript) ? this.json.itemscript.code : ""), this); // } if (list.length){ var options = []; list.each(function(v){ if (typeof(v)==="object"){ options.push(v); }else{ v = v.tostring(); var arr = v.split("|"); var o = { "text": "", "keyword": "", "value": "" }; switch (arr.length){ case 0: break; case 1: o.text = arr[0]; o.keyword = arr[0]; o.value = arr[0]; break; case 2: o.text = arr[0]; o.keyword = arr[0]; o.value = arr[1]; break; case 3: o.text = arr[0]; o.keyword = arr[1]; o.value = arr[2]; break; default: o.text = arr[0]; o.keyword = arr[1]; o.value = arr[2]; } options.push(o); } }.bind(this)); return options; } return []; }, /** * 当表单上没有对应组件的时候,可以使用this.data[fieldid] = data赋值。 * @summary 为组件赋值。 * @param value{string} . * @example * this.form.get("fieldid").setdata("test"); //赋文本值 * @example * //如果无法确定表单上是否有组件,需要判断 * if( this.form.get('fieldid') ){ //判断表单是否有无对应组件 * this.form.get('fieldid').setdata( data ); * }else{ * this.data['fieldid'] = data; * } */ setdata: function(value){ this._setbusinessdata(value); this._setvalue(value); }, _setvalue: function(value){ if (!value) value = []; if (value.length==1 && (!value[0])) value = []; if (typeof(value) !=="array") value = [value]; if (this.combox){ var textdata = this.gettextdata( value ); if( typeof(textdata.then) === "function" ){ promise.resolve(textdata).then(function (tdata) { this.combox.clear(); this.__setvalueedit( tdata ); }.bind(this)) }else{ this.combox.clear(); this.__setvalueedit( textdata ) } }else{ var textlist = this.gettextlistbyvalue( value ); if( typeof(textlist.then) === "function" ){ promise.resolve(textlist).then(function (tlist) { this.__setvalueread( value, tlist ); }.bind(this)) }else{ this.__setvalueread( value, textlist ); } } }, __setvalueedit: function(textdata){ var comboxvalues = []; textdata.value.each(function(v, i){ comboxvalues.push({ "text": textdata.text[i] || v, "value": v }); }.bind(this)); this.combox.addnewvalues(comboxvalues); this.fieldmoduleloaded = true; }, __setvalueread: function(value, textlist, contentnode){ if(!contentnode)contentnode = new element("div", { "styles": { "overflow": "hidden"} }).inject(this.node); textlist.each(function(text, i){ if (i
网站地图