From 282d4883924c5e8bc7eacf164ae9e9385fbd0cb6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Mar 2022 14:01:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E7=9A=84=E9=99=84=E4=BB=B6=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E4=B8=8A=E4=BC=A0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x_component_cms_Xform/Attachment.js | 28 +++++++++++ o2web/source/x_component_cms_Xform/Form.js | 50 +++++++++++++++++++ .../x_component_process_Xform/Attachment.js | 28 +++++++++++ .../source/x_component_process_Xform/Form.js | 49 ++++++++++++++++++ 4 files changed, 155 insertions(+) diff --git a/o2web/source/x_component_cms_Xform/Attachment.js b/o2web/source/x_component_cms_Xform/Attachment.js index a3b2286495..30820c5af8 100644 --- a/o2web/source/x_component_cms_Xform/Attachment.js +++ b/o2web/source/x_component_cms_Xform/Attachment.js @@ -689,5 +689,33 @@ MWF.xApplication.cms.Xform.AttachmentDg = MWF.CMSAttachmentDg = new Class({ this._setBusinessData([]); } } + }, + uploadAttachment: function (e, node, files) { + debugger; + if (window.o2android && window.o2android.uploadAttachmentForDatagrid) { + window.o2android.uploadAttachmentForDatagrid((this.json.site || this.json.id), this.json.id); + } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.uploadAttachmentForDatagrid) { + window.webkit.messageHandlers.uploadAttachmentForDatagrid.postMessage({ "site": (this.json.site || this.json.id) , "param":this.json.id}); + } else { + // if (!this.uploadFileAreaNode){ + this.createUploadFileNode(files); + // } + // this.fileUploadNode.click(); + } + }, + replaceAttachment: function (e, node, attachment) { + if (window.o2android && window.o2android.replaceAttachmentForDatagrid) { + window.o2android.replaceAttachmentForDatagrid(attachment.data.id, (this.json.site || this.json.id), this.json.id); + } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.replaceAttachmentForDatagrid) { + window.webkit.messageHandlers.replaceAttachmentForDatagrid.postMessage({ "id": attachment.data.id, "site": (this.json.site || this.json.id) , "param":this.json.id}); + } else { + var _self = this; + this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.replaceAttachmentTitle, MWF.xApplication.process.Xform.LP.replaceAttachment + "( " + attachment.data.name + " )", 350, 120, function () { + _self.replaceAttachmentFile(attachment); + this.close(); + }, function () { + this.close(); + }, null, null, this.form.json.confirmStyle); + } } }); diff --git a/o2web/source/x_component_cms_Xform/Form.js b/o2web/source/x_component_cms_Xform/Form.js index a1034c0372..3588430c2c 100644 --- a/o2web/source/x_component_cms_Xform/Form.js +++ b/o2web/source/x_component_cms_Xform/Form.js @@ -1284,6 +1284,14 @@ MWF.xApplication.cms.Xform.Form = MWF.CMSForm = new Class( */ uploadedAttachment: function (site, id) { this.documentAction.getAttachment(id, this.businessData.document.id, function (json) { + + var flag = this.businessData.attachmentList.some(function (attData) { + return json.data.id === attData.id; + }.bind(this)); + if( !flag ){ + this.businessData.attachmentList.push(json.data); + } + var att = this.all[site]; if (att) { if (json.data) att.attachmentController.addAttachment(json.data); @@ -1312,6 +1320,48 @@ MWF.xApplication.cms.Xform.Form = MWF.CMSForm = new Class( }.bind(this)) }, + uploadedAttachmentDatagrid: function (site, id, moduleId) { + this.documentAction.getAttachment(id, this.businessData.document.id, function (json) { + + var flag = this.businessData.attachmentList.some(function (attData) { + return json.data.id === attData.id; + }.bind(this)); + if( !flag ){ + this.businessData.attachmentList.push(json.data); + } + + var att = this.all[moduleId]; + if (att) { + if (json.data) att.attachmentController.addAttachment(json.data); + att.setAttachmentBusinessData(); + att.attachmentController.checkActions(); + att.fireEvent("upload", [json.data]); + att.fireEvent("change", [json.data]); + } + }.bind(this)); + }, + replacedAttachmentDatagrid: function (site, id, moduleId) { + this.documentAction.getAttachment(id, this.businessData.document.id, function (json) { + + var att = this.all[moduleId]; + if (att) { + var attachmentController = att.attachmentController; + var attachment = null; + for (var i = 0; i < attachmentController.attachments.length; i++) { + if (attachmentController.attachments[i].data.id === id) { + attachment = attachmentController.attachments[i]; + break; + } + } + attachment.data = json.data; + att.setAttachmentBusinessData(); + attachment.reload(); + attachmentController.checkActions(); + att.fireEvent("change", [json.data]); + } + }.bind(this)) + }, + /** * @summary 弹出文档置顶对话框,操作后使当前文档在列式服务中排在前面. * @method setTop diff --git a/o2web/source/x_component_process_Xform/Attachment.js b/o2web/source/x_component_process_Xform/Attachment.js index f0da84f175..7d724c5e6c 100644 --- a/o2web/source/x_component_process_Xform/Attachment.js +++ b/o2web/source/x_component_process_Xform/Attachment.js @@ -2361,5 +2361,33 @@ MWF.xApplication.process.Xform.AttachmentDg = MWF.APPAttachmentDg = new Class({ this._setBusinessData([]); } } + }, + uploadAttachment: function (e, node, files) { + debugger; + if (window.o2android && window.o2android.uploadAttachmentForDatagrid) { + window.o2android.uploadAttachmentForDatagrid((this.json.site || this.json.id), this.json.id); + } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.uploadAttachmentForDatagrid) { + window.webkit.messageHandlers.uploadAttachmentForDatagrid.postMessage({ "site": (this.json.site || this.json.id) , "param":this.json.id}); + } else { + // if (!this.uploadFileAreaNode){ + this.createUploadFileNode(files); + // } + // this.fileUploadNode.click(); + } + }, + replaceAttachment: function (e, node, attachment) { + if (window.o2android && window.o2android.replaceAttachmentForDatagrid) { + window.o2android.replaceAttachmentForDatagrid(attachment.data.id, (this.json.site || this.json.id), this.json.id); + } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.replaceAttachmentForDatagrid) { + window.webkit.messageHandlers.replaceAttachmentForDatagrid.postMessage({ "id": attachment.data.id, "site": (this.json.site || this.json.id) , "param":this.json.id}); + } else { + var _self = this; + this.form.confirm("warn", e, MWF.xApplication.process.Xform.LP.replaceAttachmentTitle, MWF.xApplication.process.Xform.LP.replaceAttachment + "( " + attachment.data.name + " )", 350, 120, function () { + _self.replaceAttachmentFile(attachment); + this.close(); + }, function () { + this.close(); + }, null, null, this.form.json.confirmStyle); + } } }); diff --git a/o2web/source/x_component_process_Xform/Form.js b/o2web/source/x_component_process_Xform/Form.js index 03aa3bc65e..2d65832402 100644 --- a/o2web/source/x_component_process_Xform/Form.js +++ b/o2web/source/x_component_process_Xform/Form.js @@ -4609,6 +4609,14 @@ debugger; */ uploadedAttachment: function (site, id) { this.workAction.getAttachment(id, this.businessData.work.id, function (json) { + + var flag = this.businessData.attachmentList.some(function (attData) { + return json.data.id === attData.id; + }.bind(this)); + if( !flag ){ + this.businessData.attachmentList.push(json.data); + } + var att = this.all[site]; if (att) { if (json.data) att.attachmentController.addAttachment(json.data); @@ -4636,6 +4644,47 @@ debugger; } }.bind(this)) }, + uploadedAttachmentDatagrid: function (site, id, moduleId) { + this.workAction.getAttachment(id, this.businessData.work.id, function (json) { + + var flag = this.businessData.attachmentList.some(function (attData) { + return json.data.id === attData.id; + }.bind(this)); + if( !flag ){ + this.businessData.attachmentList.push(json.data); + } + + var att = this.all[moduleId]; + if (att) { + if (json.data) att.attachmentController.addAttachment(json.data); + att.setAttachmentBusinessData(); + att.attachmentController.checkActions(); + att.fireEvent("upload", [json.data]); + att.fireEvent("change", [json.data]); + } + }.bind(this)); + }, + replacedAttachmentDatagrid: function (site, id, moduleId) { + this.workAction.getAttachment(id, this.businessData.work.id, function (json) { + + var att = this.all[moduleId]; + if (att) { + var attachmentController = att.attachmentController; + var attachment = null; + for (var i = 0; i < attachmentController.attachments.length; i++) { + if (attachmentController.attachments[i].data.id === id) { + attachment = attachmentController.attachments[i]; + break; + } + } + attachment.data = json.data; + att.setAttachmentBusinessData(); + attachment.reload(); + attachmentController.checkActions(); + att.fireEvent("change", [json.data]); + } + }.bind(this)) + }, // 打开工作关联聊天 openIMChatStarter: function(jobId) { -- GitLab