From 85038e3ea8ac0ad5093fcff35c6e64ae6b330f2b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Sep 2021 13:53:04 +0800 Subject: [PATCH] =?UTF-8?q?datatemplate=E6=8B=86=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x_component_process_Xform/Datatemplate.js | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/o2web/source/x_component_process_Xform/Datatemplate.js b/o2web/source/x_component_process_Xform/Datatemplate.js index a10404a2aa..5a302ecca2 100644 --- a/o2web/source/x_component_process_Xform/Datatemplate.js +++ b/o2web/source/x_component_process_Xform/Datatemplate.js @@ -840,6 +840,30 @@ MWF.xApplication.process.Xform.Datatemplate = MWF.APPDatatemplate = new Class( return this._getBusinessData(); } }, + _getSectionKey: function(){ + if (this.json.section!=="yes"){ + return ""; + }else { + switch (this.json.sectionBy){ + case "person": + return layout.desktop.session.user.id; + case "unit": + return (this.form.businessData.task) ? this.form.businessData.task.unit : ""; + case "activity": + return (this.form.businessData.work) ? this.form.businessData.work.activity : ""; + case "splitValue": + return (this.form.businessData.work) ? this.form.businessData.work.splitValue : ""; + case "script": + if( this.json.sectionByScript && this.json.sectionByScript.code){ + return this.form.Macro.exec(this.json.sectionByScript.code, this) || ""; + }else{ + return ""; + } + default: + return ""; + } + } + }, createErrorNode: function(text){ var node = new Element("div"); var iconNode = new Element("div", { @@ -1049,6 +1073,10 @@ MWF.xApplication.process.Xform.Datatemplate.Line = new Class({ load: function(){ this.node.set("html", this.template.templateHtml); var moduleNodes = this.form._getModuleNodes(this.node); + + //拆分状态 + var sectionKey = this.template._getSectionKey(); + moduleNodes.each(function (node) { if (node.get("MWFtype") !== "form") { var _self = this; @@ -1063,8 +1091,12 @@ MWF.xApplication.process.Xform.Datatemplate.Line = new Class({ var index = this.options.index; - - var id = this.template.json.id + ".." + index + ".." + json.id; + var id; + if( sectionKey ){ + id = this.template.json.id + ".." + sectionKey + ".."+ index + ".." + json.id; + }else{ + id = this.template.json.id + ".." + index + ".." + json.id; + } json.id = id; node.set("id", id); @@ -1072,7 +1104,7 @@ MWF.xApplication.process.Xform.Datatemplate.Line = new Class({ if( json.type==="Attachment" || json.type==="AttachmentDg" ){ json.type = "AttachmentDg"; json.ignoreSite = true; - json.site = this.getAttachmentSite(json, templateJsonId); + json.site = this.getAttachmentSite(json, templateJsonId, sectionKey); } if (this.form.all[id]) this.form.all[id] = null; @@ -1136,7 +1168,7 @@ MWF.xApplication.process.Xform.Datatemplate.Line = new Class({ get: function(templateJsonId){ return this.all_templateId[templateJsonId]; }, - getAttachmentSite: function(json, templateJsonId){ + getAttachmentSite: function(json, templateJsonId, sectionKey){ //确保site最长为64,否则后台会报错 var index = this.options.index; @@ -1144,12 +1176,21 @@ MWF.xApplication.process.Xform.Datatemplate.Line = new Class({ var baseSite; baseSite = "." + index + "." + (json.site || templateJsonId); - var maxLength = 64 - baseSite.length; + var maxLength; + var sectionId = ""; + if( sectionKey ){ + maxLength = Math.floor((63 - baseSite.length)/2 ); + + sectionId = (sectionKey.length > maxLength) ? sectionKey.substr(sectionKey.length-maxLength, maxLength) : sectionKey; + sectionId = "." + sectionId; + }else{ + maxLength = 64 - baseSite.length; + } var templateId = this.template.json.id; templateId = (templateId.length > maxLength) ? templateId.substr(templateId.length-maxLength, maxLength) : templateId; - return templateId + baseSite; + return templateId + sectionId + baseSite; }, setEvents: function (module, id) { if( this.template.addActionIdList.contains( id )){ -- GitLab