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/input-number|element ui inputnumber 计数器}
*/
mwf.xapplication.process.xform.elnumber = mwf.appelnumber = new class(
/** @lends o2.xapplication.process.xform.elnumber# */
{
implements: [events],
extends: mwf.app$elinput,
options: {
"moduleevents": ["load", "queryload", "postload"],
/**
* 当 input 获得焦点时触发。this.event[0]指向event
* @event mwf.xapplication.process.xform.elnumber#focus
* @see {@link https://element.eleme.cn/#/zh-cn/component/input-number|计数器的events章节}
*/
/**
* 当 input 失去焦点时触发。this.event[0]指向event
* @event mwf.xapplication.process.xform.elnumber#blur
* @see {@link https://element.eleme.cn/#/zh-cn/component/input-number|计数器的events章节}
*/
/**
* 绑定值被改变时触发。this.event[0]为组件的currentvalue,this.event[1]为组件的oldvalue
* @event mwf.xapplication.process.xform.elnumber#change
* @see {@link https://element.eleme.cn/#/zh-cn/component/input-number|计数器的events章节}
*/
"elevents": ["focus", "blur", "change"]
},
/**
* @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.size = "mini"; //改变输入框大小
* json.disabled = true; //设置输入框为禁用
*/
_loaduserinterface: function(){
if ( this.issectionmergeread() ) { //区段合并显示
this.node.empty();
this.node.set({
"nodeid": this.json.id,
"mwftype": this.json.type
});
switch (this.json.mergetyperead) {
case "amount":
this._loadmergeamountreadnode();
break;
case "average":
this._loadmergeaveragereadnode();
break;
default:
this._loadmergereadnode();
break;
}
}else{
if( this.issectionmergeedit() ){
switch (this.json.mergetypeedit) {
case "amount":
this._loadmergeamounteidtnode();
break;
case "average":
this._loadmergeaverageeditnode();
break;
}
}else{
this._loadnode();
}
if (this.json.compute === "show"){
this._setvalue(this._computevalue());
}else{
this._loadvalue();
}
}
},
_loadmergeamountreadnode: function(){
var data = this.getbusinessdatabyid();
var total = new decimal(0);
for( var key in data ){
total = total.plus(new decimal(data[key] || 0));
}
this.node.set("text", total.tostring());
},
_loadmergeaveragereadnode: function(){
var data = this.getbusinessdatabyid();
var total = new decimal(0);
for( var key in data ){
total = total.plus(new decimal(data[key] || 0));
}
var average = total.div( new decimal(object.keys(data).length) );
this.node.set("text", average.tostring());
},
_loadmergeamounteidtnode: function(){
var data = this.getbusinessdatabyid();
var total = new decimal(0);
for( var key in data ){
total = total.plus(new decimal(data[key] || 0));
}
this._setbusinessdata( total.tonumber() );
this._loadnode();
},
_loadmergeaverageeditnode: function(){
var data = this.getbusinessdatabyid();
var total = new decimal(0);
for( var key in data ){
total = total.plus(new decimal(data[key] || 0));
}
var average = total.div( new decimal(object.keys(data).length) );
this._setbusinessdata( average.tonumber() );
this._loadnode();
},
_appendvuedata: function(){
this.form.macro.environment.data.check(this.json.id);
this.json[this.json.id] = this._getbusinessdata();
// if (!this.json.max || o2.typeof(this.json.max)!=="number") this.json.max = "infinity";
// if (!this.json.min || o2.typeof(this.json.max)!=="number") this.json.min = "-infinity";
if (!this.json.step || o2.typeof(this.json.step)!=="number") this.json.step = 1;
if (!this.json.stepstrictly) this.json.stepstrictly = false;
if (!this.json.disabled) this.json.disabled = false;
if (!this.json.precision) this.json.precision = 0;
if (!this.json.size) this.json.size = "";
if (!this.json.controlsposition) this.json.controlsposition = "";
if (!this.json.readonly) this.json.readonly = false;
if (!this.json.description) this.json.description = "";
},
// appendvueextend: function(app){
// if (!app.methods) app.methods = {};
// app.methods.$loadelevent = function(ev){
// debugger;
// 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 = "