diff --git a/o2web/source/x_component_process_Xform/$Input.js b/o2web/source/x_component_process_Xform/$Input.js index 8d274efcd234d479957c98bb64301f13fa0b2661..c3b7782f646c3a7ee68ab0e6327c8ce25d8d9772 100644 --- a/o2web/source/x_component_process_Xform/$Input.js +++ b/o2web/source/x_component_process_Xform/$Input.js @@ -10,9 +10,6 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input = new Class( Implements: [Events], Extends: MWF.APP$Module, iconStyle: "personfieldIcon", - /** - * @hideconstructor - */ initialize: function(node, json, form, options){ this.node = $(node); this.node.store("module", this); @@ -287,10 +284,12 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input = new Class( return !data || !data.trim(); }, /** - * 获取组件值. + * 获取组件值。该方法和 this.data.{fieldName} 在绝大部分的时候效果一样。区别如下: + * 当使用异步函数生成器(Promise)为组件赋值的时候,getData立即获取数据,可能返回修改前的值,当Promise执行完成以后,会返回修改后的值。 + * this.data.{fieldName} 立即获取数据,可能获取到异步函数生成器,当Promise执行完成以后,会返回修改后的值。{@link https://www.yuque.com/o2oa/ixsnyt/ws07m0#EggIl|具体差异请查看链接} * @example * var data = this.form.get('subject').getData(); - * @return {Array|Object|String|Number|Boolean} 组件的数据. + * @return 组件的数据. */ getData: function(when){ if (this.json.compute == "save") this._setValue(this._computeValue()); diff --git a/o2web/source/x_component_process_Xform/Checkbox.js b/o2web/source/x_component_process_Xform/Checkbox.js index c9bc727528fafd2d46ffd4bd859b3f6a4e1c432c..32e72a91f4fa6c334461b9f12052049ef280251b 100644 --- a/o2web/source/x_component_process_Xform/Checkbox.js +++ b/o2web/source/x_component_process_Xform/Checkbox.js @@ -1,6 +1,18 @@ MWF.xDesktop.requireApp("process.Xform", "$Input", null, false); MWF.require("MWF.widget.UUID", null, false); -MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox = new Class({ +/** @class process.Calendar 多选按钮组件。 + * @example + * //可以在脚本中获取该组件 + * //方法1: + * var field = this.form.get("fieldName"); //获取组件对象 + * //方法2 + * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等 + * @extends MWF.xApplication.process.Xform.$Input + * @hideconstructor + */ +MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox = new Class( + /** @lends MWF.xApplication.process.Xform.Checkbox# */ + { Implements: [Events], Extends: MWF.APP$Input, @@ -85,10 +97,21 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox = new Class({ }.bind(this)); } }, + /** + * 重新计算下拉选项,该功能通常用在下拉选项为动态计算的情况. + * @example + * this.form.get('fieldName').resetOption(); + */ resetOption: function(){ this.node.empty(); this.setOptions(); }, + /** + * 获取选择项数组. + * @example + * var array = this.form.get('fieldName').getOptions(); + * @return {Array} 选择项数组,如果是脚本返回计算结果. + */ getOptions: function(){ if (this.json.itemType == "values"){ return this.json.itemValues; @@ -215,6 +238,12 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox = new Class({ radio.checked = value.indexOf(radio.value) != -1; } }, + /** + * 获取选中的值和文本. + * @example + * var array = this.form.get('fieldName').getTextData(); + * @return {Object} 返回选中项值和文本,格式为 { 'value' : value, 'text' : text }. + */ getTextData: function(){ var inputs = this.node.getElements("input"); var value = []; @@ -272,7 +301,10 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox = new Class({ resetData: function(){ this.setData(this.getValue()); }, - + /** + * 为字段赋值,并且使值对应的选项选中。 + * @param data{String} . + */ setData: function(data){ return this._setValue(data, "__setData"); // if (data && data.isAG){