o2.xdesktop.requireapp("process.xform", "$elinput", null, false);
/** @class elinput 基于element ui的开关组件。
* @o2cn 开关组件
* @example
* //可以在脚本中获取该组件
* //方法1:
* var input = this.form.get("name"); //获取组件
* //方法2
* var input = this.target; //在组件事件脚本中获取
* @extends mwf.xapplication.process.xform.$module
* @o2category formcomponents
* @o2range {process|cms|portal}
* @hideconstructor
* @see {@link https://element.eleme.cn/#/zh-cn/component/switch|element ui switch 开关}
*/
mwf.xapplication.process.xform.elswitch = mwf.appelswitch = new class(
/** @lends o2.xapplication.process.xform.elswitch# */
{
implements: [events],
extends: mwf.app$elinput,
options: {
"moduleevents": ["load", "queryload", "postload"],
/**
* switch 状态发生变化时的回调函数。this.event[0]为新状态的值
* @event mwf.xapplication.process.xform.elswitch#change
* @see {@link https://element.eleme.cn/#/zh-cn/component/switch|开关组件的的 events章节}
*/
"elevents": ["change"]
},
_loadmergereadcontentnode: function( contentnode, data ){
this._loadactivejson();
if (data.data==="" || data.data){
contentnode.set("text", (this.json.activetext || "true"));
}else{
contentnode.set("text", (this.json.inactivetext || "false"));
}
},
/**
* @summary 组件的配置信息,同时也是vue组件的data。
* @member mwf.xapplication.process.xform.elinput#json {jsonobject}
* @example
* //可以在脚本中获取此对象,下面两行代码是等价的,它们获取的是同一个对象
* var json = this.form.get("elinput").json; //获取组件的json对象
* var json = this.form.get("elinput").vm.$data; //获取vue组件的data数据,
*
* //通过json对象操作element组件
* json.disabled = true; //设置输入框为禁用
*/
// _loadnode: function(){
// debugger;
// if (this.isreadonly()) this.json.disabled = true;
// this._loadnodeedit();
// },
_appendvuedata: function(){
this.form.macro.environment.data.check(this.json.id);
this.json[this.json.id] = this._getbusinessdata();
if (!this.json.width || !this.json.width.tofloat()) this.json.width = 40;
if (!this.json.activetext) this.json.activetext = "";
if (!this.json.inactivetext) this.json.inactivetext = "";
if (!this.json.activecolor) this.json.activecolor = "#409eff";
if (!this.json.inactivecolor) this.json.inactivecolor = "#c0ccda";
if (!this.json.activeiconclass) this.json.activeiconclass = "";
if (!this.json.inactiveiconclass) this.json.inactiveiconclass = "";
if (!this.json.readonly) this.json.readonly = false;
if (!this.json.description) this.json.description = "";
if (!this.json.disabled) this.json.disabled = false;
this._loadactivejson();
},
_loadactivejson: function(){
if (!this.json.valuetype) this.json.activevaluetype = "boolean";
switch(this.json.valuetype){
case "boolean":
this.json.activevalue = true;
this.json.inactivevalue = false;
break;
case "string":
if (!this.json.activevalue) this.json.activevalue = "1";
if (!this.json.inactivevalue) this.json.inactivevalue = "0";
break;
case "number":
if (!this.json.activevalue) this.json.activevalue = 1;
if (!this.json.inactivevalue) this.json.inactivevalue = 0;
this.json.activevalue = this.json.activevalue.tofloat();
this.json.inactivevalue = this.json.inactivevalue.tofloat();
break;
default:
this.json.activevalue = true;
this.json.inactivevalue = false;
}
},
// appendvueextend: function(app){
// if (!app.methods) app.methods = {};
// app.methods.$loadelevent = function(ev){
// this.validationmode();
// if (ev==="change") this._setbusinessdata(this.getinputdata());
// if (this.json.events && this.json.events[ev] && this.json.events[ev].code){
// this.form.macro.fire(this.json.events[ev].code, this, event);
// }
// }.bind(this);
// },
_createelementhtml: function(){
var html = "