From b6c34a51c1e937bfb1530dcd79751be8ac5489de Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2022 10:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E6=95=B0=E6=8D=AE=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E3=80=81=E6=95=B0=E6=8D=AE=E6=A8=A1=E6=9D=BF=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?afterImport=E4=BA=8B=E4=BB=B6=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A1=A8=E6=A0=BC=E3=80=81=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=9A=84resetData=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Module/Datatable/template.json | 4 ++ .../Module/Datatemplate/template.json | 4 ++ .../x_component_process_Xform/DatatablePC.js | 32 +++++++++++---- .../x_component_process_Xform/Datatemplate.js | 41 +++++++++++++++---- 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/o2web/source/x_component_process_FormDesigner/Module/Datatable/template.json b/o2web/source/x_component_process_FormDesigner/Module/Datatable/template.json index 4901f7fadc..a44e362000 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Datatable/template.json +++ b/o2web/source/x_component_process_FormDesigner/Module/Datatable/template.json @@ -77,6 +77,10 @@ "code": "", "html": "" }, + "afterImport": { + "code": "", + "html": "" + }, "click": { "code": "", "html": "" diff --git a/o2web/source/x_component_process_FormDesigner/Module/Datatemplate/template.json b/o2web/source/x_component_process_FormDesigner/Module/Datatemplate/template.json index ded06edc88..5cd355b71d 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Datatemplate/template.json +++ b/o2web/source/x_component_process_FormDesigner/Module/Datatemplate/template.json @@ -62,6 +62,10 @@ "code": "", "html": "" }, + "afterImport": { + "code": "", + "html": "" + }, "click": { "code": "", "html": "" diff --git a/o2web/source/x_component_process_Xform/DatatablePC.js b/o2web/source/x_component_process_Xform/DatatablePC.js index 86007dda4f..201b4e11c0 100644 --- a/o2web/source/x_component_process_Xform/DatatablePC.js +++ b/o2web/source/x_component_process_Xform/DatatablePC.js @@ -165,8 +165,13 @@ MWF.xApplication.process.Xform.DatatablePC = new Class( * @event MWF.xApplication.process.Xform.DatatablePC#import * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明} */ + /** + * 在导入excel,数据设置回数据表格以后触发,this.event指向整理过的导入数据,格式见{@link DatatableData}。 + * @event MWF.xApplication.process.Xform.DatatablePC#afterImport + * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明} + */ "moduleEvents": ["queryLoad","postLoad","load", "afterLoad", - "beforeLoadLine", "afterLoadLine", "addLine", "deleteLine", "afterDeleteLine", "editLine", "completeLineEdit", "cancelLineEdit", "export", "import", "validImport"] + "beforeLoadLine", "afterLoadLine", "addLine", "deleteLine", "afterDeleteLine", "editLine", "completeLineEdit", "cancelLineEdit", "export", "import", "validImport", "afterImport"] }, initialize: function(node, json, form, options){ @@ -476,13 +481,10 @@ MWF.xApplication.process.Xform.DatatablePC = new Class( this.table.setStyles(this.json.tableStyles); this.table.set(this.json.properties); }, - _getValue: function(){ - if (this.moduleValueAG) return this.moduleValueAG; - var value = this._getBusinessData(); - if (!value){ - if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); - if (value && !value.then) if (o2.typeOf(value)==="array") value = {"data": value || [], "total":{}}; - } + getDefaultValue: function(){ + var value; + if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); + if (value && !value.then) if (o2.typeOf(value)==="array") value = {"data": value || [], "total":{}}; if(!value && this.multiEditMode){ value = {"data": [], "total":{}}; var count = this.json.defaultCount ? this.json.defaultCount.toInt() : 0; @@ -490,6 +492,14 @@ MWF.xApplication.process.Xform.DatatablePC = new Class( value.data.push({}) } } + return value; + }, + _getValue: function(){ + if (this.moduleValueAG) return this.moduleValueAG; + var value = this._getBusinessData(); + if (!value){ + value = this.getDefaultValue(); + } return value || {"data": [], "total":{}}; }, getValue: function(){ @@ -828,7 +838,8 @@ MWF.xApplication.process.Xform.DatatablePC = new Class( * this.form.get('fieldId').resetData(); */ resetData: function(){ - this.setData(this._getValue()); + var value = this.getDefaultValue() || {"data": [], "total":{}}; + this.setData( value ); }, /**当参数为Promise的时候,请查看文档: {@link https://www.yuque.com/o2oa/ixsnyt/ws07m0|使用Promise处理表单异步}
* 当表单上没有对应组件的时候,可以使用this.data[fieldId] = data赋值。 @@ -2400,6 +2411,9 @@ MWF.xApplication.process.Xform.DatatablePC.Importer = new Class({ this.datatable.fireEvent("import", [data] ); this.datatable.setData( { "data" : data } ); + + this.datatable.fireEvent("afterImport", [data] ); + this.form.notice( MWF.xApplication.process.Xform.LP.importSuccess ); }, diff --git a/o2web/source/x_component_process_Xform/Datatemplate.js b/o2web/source/x_component_process_Xform/Datatemplate.js index f6a6dec300..29cccd470c 100644 --- a/o2web/source/x_component_process_Xform/Datatemplate.js +++ b/o2web/source/x_component_process_Xform/Datatemplate.js @@ -144,8 +144,13 @@ MWF.xApplication.process.Xform.Datatemplate = MWF.APPDatatemplate = new Class( * @event MWF.xApplication.process.Xform.Datatemplate#import * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明} */ + /** + * 在导入excel,数据设置回数据模板以后触发,this.event指向整理过的导入数据,格式见{@link DatatemplateData}。 + * @event MWF.xApplication.process.Xform.Datatemplate#afterImport + * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明} + */ "moduleEvents": ["queryLoad","postLoad","load", "afterLoad", - "beforeLoadLine", "afterLoadLine","addLine", "deleteLine", "afterDeleteLine","export", "import", "validImport"] + "beforeLoadLine", "afterLoadLine","addLine", "deleteLine", "afterDeleteLine","export", "import", "validImport", "afterImport"] }, initialize: function(node, json, form, options){ @@ -326,13 +331,10 @@ MWF.xApplication.process.Xform.Datatemplate = MWF.APPDatatemplate = new Class( //去要表单的所有组件加载完成以后再去获取外部组件 this.form.addEvent("afterModulesLoad", this.bindEvent ); }, - _getValue: function(){ - if (this.moduleValueAG) return this.moduleValueAG; - var value = this._getBusinessData(); - if (!value){ - if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); - if (value && !value.then) if (o2.typeOf(value)==="object") value = [value]; - } + getDefaultValue: function(){ + var value; + if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); + if (value && !value.then) if (o2.typeOf(value)==="object") value = [value]; if(!value){ value = []; var count = this.json.defaultCount ? this.json.defaultCount.toInt() : 0; @@ -340,6 +342,23 @@ MWF.xApplication.process.Xform.Datatemplate = MWF.APPDatatemplate = new Class( } return value; }, + _getValue: function(){ + if (this.moduleValueAG) return this.moduleValueAG; + var value = this._getBusinessData(); + if( !value ){ + value = this.getDefaultValue(); + } + // if (!value){ + // if (this.json.defaultData && this.json.defaultData.code) value = this.form.Macro.exec(this.json.defaultData.code, this); + // if (value && !value.then) if (o2.typeOf(value)==="object") value = [value]; + // } + // if(!value){ + // value = []; + // var count = this.json.defaultCount ? this.json.defaultCount.toInt() : 0; + // for( var i=0; i * 当表单上没有对应组件的时候,可以使用this.data[fieldId] = data赋值。 @@ -1802,6 +1822,9 @@ MWF.xApplication.process.Xform.Datatemplate.Importer = new Class({ this.template.fireEvent("import", [data] ); this.template.setData( data ); + + this.template.fireEvent("afterImport", [data] ); + this.form.notice( MWF.xApplication.process.Xform.LP.importSuccess ); }, -- GitLab