From 486d94ff25dfb5fe2b6735499b3455261373d747 Mon Sep 17 00:00:00 2001 From: huqi Date: Tue, 27 Oct 2020 19:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BD=91=E6=A0=BC=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x_component_process_Xform/Attachment.js | 12 ++- .../DatagridMobile.js | 91 ++++++++++++++++++- .../x_component_process_Xform/DatagridPC.js | 45 +-------- 3 files changed, 104 insertions(+), 44 deletions(-) diff --git a/o2web/source/x_component_process_Xform/Attachment.js b/o2web/source/x_component_process_Xform/Attachment.js index 09d8f2f49a..220f87a4d7 100644 --- a/o2web/source/x_component_process_Xform/Attachment.js +++ b/o2web/source/x_component_process_Xform/Attachment.js @@ -1589,7 +1589,17 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({ getTextData: function(){ var data = []; this.attachmentController.attachments.each(function(att){ - data.push(att.data); + var o = { + "person": att.data.person, + "creatorUid": att.data.creatorUid, + "name": att.data.name, + "orderNumber": att.data.orderNumber, + "length": att.data.length, + "extension": att.data.extension, + "lastUpdateTime": att.data.lastUpdateTime, + "activityName": att.data.activityName + } + data.push(o); }); return data; }, diff --git a/o2web/source/x_component_process_Xform/DatagridMobile.js b/o2web/source/x_component_process_Xform/DatagridMobile.js index 397a2e024c..5d10cfb8dc 100644 --- a/o2web/source/x_component_process_Xform/DatagridMobile.js +++ b/o2web/source/x_component_process_Xform/DatagridMobile.js @@ -219,6 +219,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ var module = this.editModules[index]; if( module && module.json.type == "ImageClipper" ){ this._createImage( cell, module, v ); + }else if( module && (module.json.type == "Attachment" || module.json.type == "AttachmentDg") ){ + this._createAttachment( cell, module, v ); }else{ text = this._getValueText(index, v); if( module && module.json.type == "Textarea" ){ @@ -306,6 +308,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ var module = this.editModules[index]; if( module && module.json.type == "ImageClipper" ){ this._createImage( cell, module, v ) + }else if( module && (module.json.type == "Attachment" || module.json.type == "AttachmentDg") ){ + this._createAttachment( cell, module, v ); }else{ text = this._getValueText(index, v); if( module && module.json.type == "Textarea" ){ @@ -415,6 +419,50 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ "max-width": "90%" }) }, + _createAttachment: function ( cell, module, data ){ + cell.empty(); + var options = { + "style": module.json.style || "default", + "title": "附件区域", + "listStyle": module.json.dg_listStyle || "icon", + "size": module.json.dg_size || "min", + "resize": (module.json.dg_resize === "y" || this.json.dg_resize === "true"), + "attachmentCount": 0, + "isUpload": false, + "isDelete": false, + "isReplace": false, + "isDownload": true, + "isSizeChange": (module.json.dg_isSizeChange === "y" || module.json.dg_isSizeChange === "true"), + "readonly": true, + "availableListStyles": module.json.dg_availableListStyles ? module.json.dg_availableListStyles : ["list", "seq", "icon", "preview"], + "isDeleteOption": "n", + "isReplaceOption": "n", + "toolbarGroupHidden": module.json.dg_toolbarGroupHidden || [] + }; + if (this.readonly) options.readonly = true; + + var atts = []; + data.each(function(d){ + var att = module.attachmentController.attachments.find(function(a){ + return d.id == a.data.id; + }); + if (att) module.attachmentController.removeAttachment(att); + }); + module.setAttachmentBusinessData(); + + + var attachmentController = new MWF.xApplication.process.Xform.AttachmentController(cell, this, options); + attachmentController.load(); + + data.each(function (att) { + var attachment = this.form.businessData.attachmentList.find(function(a){ + return a.id==att.id; + }); + var attData = attachment || att; + //if (att.site===this.json.id || (this.json.isOpenInOffice && this.json.officeControlName===att.site)) this.attachmentController.addAttachment(att); + attachmentController.addAttachment(attData); + }.bind(this)); + }, _createItemTitleNode: function(node, idx){ var n = idx+1; var titleDiv = new Element("div", {"styles": this.json.itemTitleStyles}).inject(node); @@ -588,6 +636,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ if(datagridDataDiv)datagridDataDiv.destroy(); } + datagrid.editModules.each(function(module){ + if (module && (module.json.type=="Attachment" || module.json.type=="AttachmentDg")){ + module.attachmentController.attachments.each(function(att){ + datagrid.form.workAction.deleteAttachment(att.data.id, datagrid.form.businessData.work.id); + }); + module.attachmentController.clear(); + } + }); + datagrid.currentEditLine = null; if (!_self.gridData.data.length){ @@ -679,6 +736,11 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ i = this.currentEditLine.getElement("table").getElements("tr")[idx].getElement("td").get("text"); } data = {"value": [i], "text": [i]}; + }else if (module.json.type=="Attachment" || module.json.type == "AttachmentDg"){ + var data = module.getTextData(); + //data.site = module.json.site; + if (!griddata[id]) griddata[id] = {}; + griddata[id][module.json.id] = data; }else{ data = module.getTextData(); //if (data.value[0]) flag = false; @@ -697,6 +759,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ if( module.json.type == "ImageClipper" ){ this._createImage( cell, module, data.text ); + }else if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){ + this._createAttachment( cell, module, data ); }else{ var text = this._getValueText(idx, data.text.join(", ")); if( module.json.type == "Textarea"){ @@ -719,6 +783,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ var cellData = data[th.get("id")]; if( module.json.type == "ImageClipper" ){ this._createImage( cell, module, data.text ); + }else if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){ + this._createAttachment( cell, module, data ); }else{ var text = this._getValueText(idx, data.text.join(", ")); if( module.json.type == "Textarea"){ @@ -763,7 +829,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ this._addLine(); }.bind(this)); - + this.form.saveFormData(); return true; }, _editorTrGoBack: function(){ @@ -881,6 +947,20 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.deleteDatagridLineTitle, MWF.xApplication.process.Xform.LP.deleteDatagridLine, 300, 120, function(){ _self.fireEvent("deleteLine", [currentTable]); + var data = currentTable.retrieve("data"); + + //var attKeys = []; + var titleThs = currentTable.getElements("th"); + titleThs.each(function(th, i){ + var key = th.get("id"); + var module = _self.editModules[i]; + if (key && module && (module.json.type=="Attachment" || module.json.type=="AttachmentDg")){ + data[key][module.json.id].each(function(d){ + _self.form.workAction.deleteAttachment(d.id, _self.form.businessData.work.id); + }); + } + }); + node.destroy(); //datagrid._loadZebraStyle(); datagrid._loadSequence(); @@ -897,6 +977,8 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({ this.close(); _self.fireEvent("afterDeleteLine"); + _self.form.saveFormData(); + }, function(){ //var color = currentTr.retrieve("bgcolor"); //currentTr.tween("background-color", color); @@ -1483,6 +1565,13 @@ MWF.xApplication.process.Xform.DatagridMobile$Data = new Class({ moduleNodes.each(function(node){ var json = this.form._getDomjson(node); var isField = false; + + if (json.type=="Attachment" || json.type=="AttachmentDg" ){ + json.type = "AttachmentDg"; + //json.site = this.dataGrid.getAttachmentRandomSite(); + //json.id = json.site; + } + var module = this.form._loadModule(json, node, function(){ isField = this.field; this.field = false; diff --git a/o2web/source/x_component_process_Xform/DatagridPC.js b/o2web/source/x_component_process_Xform/DatagridPC.js index cfded7f94d..e9a33b2303 100644 --- a/o2web/source/x_component_process_Xform/DatagridPC.js +++ b/o2web/source/x_component_process_Xform/DatagridPC.js @@ -79,10 +79,6 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ this.editorTr = trs[trs.length-1]; this.editorTr.addClass("datagridEditorTr"); - this.editorTr.addEvent("blur", function(){ - alert('blur') - }); - return this.editorTr; }, _addTitleActionColumn: function(){ @@ -440,7 +436,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({ if (!this.editValidation()){ return false; } -debugger; + this.isEdit = false; var flag = true; @@ -489,7 +485,7 @@ debugger; if (cell){ if( module.json.type == "ImageClipper" ){ this._createImage( cell, module, data.text ); - }if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){ + }else if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){ this._createAttachment( cell, module, data ); }else{ var text = this._getValueText(idx-1, data.text.join(", ")); @@ -626,29 +622,6 @@ debugger; var currentTr = node.getParent("tr"); if (currentTr){ this.editorTr.inject(currentTr, "after"); - this.editorTr.focus(); - this.editModules.each(function(module, idx){ - if (module.json.type=="Attachment" || module.json.type == "AttachmentDg"){ - //module.json.site = this.getAttachmentRandomSite(); - //module.json.id = module.json.site; - //module.reload(); - // var d = this.getData(); - // - // var titleThs = this.titleTr.getElements("th"); - // var th = titleThs[idx+1]; - // var title = th.get("id"); - // - // var atts = []; - // d.data.each(function(line){ - // atts = line[title][module.json.id]; - // }); - //d.data - - // if (json.type=="Attachment" || json.type=="AttachmentDg" ){ - // module. - // } - } - }.bind(this)); } this.isEdit =true; this.validationMode(); @@ -665,9 +638,6 @@ debugger; currentTr.tween("background-color", "#ffd4d4"); var datagrid = this; var _self = this; - - - this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.deleteDatagridLineTitle, MWF.xApplication.process.Xform.LP.deleteDatagridLine, 300, 120, function(){ _self.fireEvent("deleteLine", [currentTr]); @@ -684,14 +654,6 @@ debugger; }); } }); - // attKeys.each(function(k){ - // if (data[k]){ - // data[k].each(function(d){ - // _self.form.workAction.deleteAttachment(d.id, _self.form.businessData.work.id); - // }); - // } - // }); - currentTr.destroy(); datagrid._loadZebraStyle(); @@ -1396,6 +1358,5 @@ MWF.xApplication.process.Xform.DatagridPC$Data = new Class({ this.dataGrid.editModules.push(module); }.bind(this)); } - }, - + } }); -- GitLab