|
|
@@ -1050,6 +1050,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
this.json = json;
|
|
|
this.form = form;
|
|
|
this.field = true;
|
|
|
+ debugger;
|
|
|
},
|
|
|
|
|
|
_loadUserInterface: function () {
|
|
|
@@ -1059,6 +1060,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
this.fireEvent("load");
|
|
|
}
|
|
|
},
|
|
|
+ reload: function(){
|
|
|
+ this.node.empty();
|
|
|
+ if (this.form.businessData.work.startTime){
|
|
|
+ this.loadAttachmentController();
|
|
|
+ }
|
|
|
+ },
|
|
|
loadAttachmentController: function () {
|
|
|
//MWF.require("MWF.widget.AttachmentController", function() {
|
|
|
var options = {
|
|
|
@@ -1093,7 +1100,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
|
|
|
this.form.businessData.attachmentList.each(function (att) {
|
|
|
//if (att.site===this.json.id || (this.json.isOpenInOffice && this.json.officeControlName===att.site)) this.attachmentController.addAttachment(att);
|
|
|
- if (att.site === this.json.id) this.attachmentController.addAttachment(att);
|
|
|
+ if (att.site === (this.json.site || this.json.id)) this.attachmentController.addAttachment(att);
|
|
|
}.bind(this));
|
|
|
this.setAttachmentBusinessData();
|
|
|
//}.bind(this));
|
|
|
@@ -1183,7 +1190,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
}
|
|
|
var size = 0;
|
|
|
if (this.json.attachmentSize) size = this.json.attachmentSize.toFloat();
|
|
|
- this.attachmentController.doUploadAttachment({ "site": this.json.id }, this.form.workAction.action, "uploadAttachment", { "id": this.form.businessData.work.id }, null, function (o) {
|
|
|
+ this.attachmentController.doUploadAttachment({ "site": (this.json.site || this.json.id) }, this.form.workAction.action, "uploadAttachment", { "id": this.form.businessData.work.id }, null, function (o) {
|
|
|
if (o.id) {
|
|
|
this.form.workAction.getAttachment(o.id, this.form.businessData.work.id, function (json) {
|
|
|
if (json.data) {
|
|
|
@@ -1252,9 +1259,9 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
},
|
|
|
uploadAttachment: function (e, node) {
|
|
|
if (window.o2android && window.o2android.uploadAttachment) {
|
|
|
- window.o2android.uploadAttachment(this.json.id);
|
|
|
+ window.o2android.uploadAttachment((this.json.site || this.json.id));
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.uploadAttachment) {
|
|
|
- window.webkit.messageHandlers.uploadAttachment.postMessage({ "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.uploadAttachment.postMessage({ "site": (this.json.site || this.json.id) });
|
|
|
} else {
|
|
|
// if (!this.uploadFileAreaNode){
|
|
|
this.createUploadFileNode();
|
|
|
@@ -1332,9 +1339,9 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
|
|
|
replaceAttachment: function (e, node, attachment) {
|
|
|
if (window.o2android && window.o2android.replaceAttachment) {
|
|
|
- window.o2android.replaceAttachment(attachment.data.id, this.json.id);
|
|
|
+ window.o2android.replaceAttachment(attachment.data.id, (this.json.site || this.json.id));
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.replaceAttachment) {
|
|
|
- window.webkit.messageHandlers.replaceAttachment.postMessage({ "id": attachment.data.id, "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.replaceAttachment.postMessage({ "id": attachment.data.id, "site": (this.json.site || 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 () {
|
|
|
@@ -1390,7 +1397,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
}
|
|
|
var size = 0;
|
|
|
if (this.json.attachmentSize) size = this.json.attachmentSize.toFloat();
|
|
|
- this.attachmentController.doUploadAttachment({ "site": this.json.id }, this.form.workAction.action, "replaceAttachment",
|
|
|
+ this.attachmentController.doUploadAttachment({ "site": (this.json.site || this.json.id) }, this.form.workAction.action, "replaceAttachment",
|
|
|
{ "id": attachment.data.id, "workid": this.form.businessData.work.id }, null, function (o) {
|
|
|
this.form.workAction.getAttachment(attachment.data.id, this.form.businessData.work.id, function (json) {
|
|
|
attachment.data = json.data;
|
|
|
@@ -1474,7 +1481,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
if (window.o2android && window.o2android.downloadAttachment) {
|
|
|
window.o2android.downloadAttachment(att.data.id);
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.downloadAttachment) {
|
|
|
- window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": (this.json.site || this.json.id) });
|
|
|
} else if (window.wx && window.__wxjs_environment === 'miniprogram' && this.checkMiniProgramFile(att.data.extension)) { //微信小程序
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: '../file/download?attId=' + att.data.id + '&type=work&work=' + this.form.businessData.work.id
|
|
|
@@ -1498,7 +1505,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
if (window.o2android && window.o2android.downloadAttachment) {
|
|
|
window.o2android.downloadAttachment(att.data.id);
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.downloadAttachment) {
|
|
|
- window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": (this.json.site || this.json.id) });
|
|
|
} else if (window.wx && window.__wxjs_environment === 'miniprogram' && this.checkMiniProgramFile(att.data.extension)) { //微信小程序
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: '../file/download?attId=' + att.data.id + '&type=work&workCompleted=' + this.form.businessData.workCompleted.id
|
|
|
@@ -1525,7 +1532,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
if (window.o2android && window.o2android.downloadAttachment) {
|
|
|
window.o2android.downloadAttachment(att.data.id);
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.downloadAttachment) {
|
|
|
- window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": (this.json.site || this.json.id) });
|
|
|
} else if (window.wx && window.__wxjs_environment === 'miniprogram' && this.checkMiniProgramFile(att.data.extension)) { //微信小程序
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: '../file/download?attId=' + att.data.id + '&type=work&work=' + this.form.businessData.work.id
|
|
|
@@ -1550,7 +1557,7 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
if (window.o2android && window.o2android.downloadAttachment) {
|
|
|
window.o2android.downloadAttachment(att.data.id);
|
|
|
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.downloadAttachment) {
|
|
|
- window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": this.json.id });
|
|
|
+ window.webkit.messageHandlers.downloadAttachment.postMessage({ "id": att.data.id, "site": (this.json.site || this.json.id) });
|
|
|
} else if (window.wx && window.__wxjs_environment === 'miniprogram' && this.checkMiniProgramFile(att.data.extension)) { //微信小程序
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: '../file/download?attId=' + att.data.id + '&type=work&workCompleted=' + this.form.businessData.workCompleted.id
|
|
|
@@ -1579,6 +1586,25 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
this.form.workAction.getAttachmentWorkcompletedUrl(attachment.data.id, this.form.businessData.workCompleted.id, callback);
|
|
|
}
|
|
|
},
|
|
|
+ getTextData: function(){
|
|
|
+ var data = [];
|
|
|
+ this.attachmentController.attachments.each(function(att){
|
|
|
+ data.push(att.data);
|
|
|
+ });
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ setData: function(data){
|
|
|
+ this.attachmentController.clear();
|
|
|
+ data.each(function (att) {
|
|
|
+ var attachment = this.form.businessData.attachmentList.find(function(a){
|
|
|
+ return a.id==att.id;
|
|
|
+ });
|
|
|
+ var attData = attachment || att;
|
|
|
+
|
|
|
+ this.attachmentController.addAttachment(attData);
|
|
|
+ }.bind(this));
|
|
|
+ this.setAttachmentBusinessData();
|
|
|
+ },
|
|
|
createErrorNode: function (text) {
|
|
|
var node = new Element("div");
|
|
|
var iconNode = new Element("div", {
|
|
|
@@ -1724,4 +1750,70 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-});
|
|
|
+});
|
|
|
+
|
|
|
+MWF.xApplication.process.Xform.AttachmentDg = MWF.APPAttachmentDg = new Class({
|
|
|
+ Extends: MWF.APPAttachment,
|
|
|
+ loadAttachmentController: function () {
|
|
|
+ //MWF.require("MWF.widget.AttachmentController", function() {
|
|
|
+ var options = {
|
|
|
+ "style": this.json.style || "default",
|
|
|
+ "title": "附件区域DG",
|
|
|
+ "listStyle": this.json.listStyle || "icon",
|
|
|
+ "size": this.json.size || "max",
|
|
|
+ "resize": (this.json.resize === "y" || this.json.resize === "true"),
|
|
|
+ "attachmentCount": this.json.attachmentCount || 0,
|
|
|
+ "isUpload": (this.json.isUpload === "y" || this.json.isUpload === "true"),
|
|
|
+ "isDelete": (this.json.isDelete === "y" || this.json.isDelete === "true"),
|
|
|
+ "isReplace": (this.json.isReplace === "y" || this.json.isReplace === "true"),
|
|
|
+ "isDownload": (this.json.isDownload === "y" || this.json.isDownload === "true"),
|
|
|
+ "isSizeChange": (this.json.isSizeChange === "y" || this.json.isSizeChange === "true"),
|
|
|
+ "readonly": (this.json.readonly === "y" || this.json.readonly === "true"),
|
|
|
+ "availableListStyles": this.json.availableListStyles ? this.json.availableListStyles : ["list", "seq", "icon", "preview"],
|
|
|
+ "isDeleteOption": this.json.isDelete,
|
|
|
+ "isReplaceOption": this.json.isReplace,
|
|
|
+ "toolbarGroupHidden": this.json.toolbarGroupHidden || [],
|
|
|
+ "onOrder": function () {
|
|
|
+ this.fireEvent("change");
|
|
|
+ }.bind(this)
|
|
|
+ };
|
|
|
+ if (this.readonly) options.readonly = true;
|
|
|
+ if (this.form.json.attachmentStyle) {
|
|
|
+ options = Object.merge(options, this.form.json.attachmentStyle);
|
|
|
+ }
|
|
|
+ this.attachmentController = new MWF.xApplication.process.Xform.AttachmentController(this.node, this, options);
|
|
|
+ this.attachmentController.load();
|
|
|
+
|
|
|
+ // var d = this._getBusinessData();
|
|
|
+ // if (d) d.each(function (att) {
|
|
|
+ // this.attachmentController.addAttachment(att);
|
|
|
+ // }.bind(this));
|
|
|
+ this.form.businessData.attachmentList.each(function (att) {
|
|
|
+ if (att.site === (this.json.site || this.json.id)) this.attachmentController.addAttachment(att);
|
|
|
+ }.bind(this));
|
|
|
+ this.setAttachmentBusinessData();
|
|
|
+ },
|
|
|
+ setAttachmentBusinessData: function(){
|
|
|
+ if (this.attachmentController) {
|
|
|
+ if (this.attachmentController.attachments.length) {
|
|
|
+ var values = this.attachmentController.attachments.map(function (d) {
|
|
|
+ return {
|
|
|
+ "control": d.data.control,
|
|
|
+ "name": d.data.name,
|
|
|
+ "id": d.data.id,
|
|
|
+ "person": d.data.person,
|
|
|
+ "creatorUid": d.data.creatorUid,
|
|
|
+ "orderNumber": d.data.orderNumber,
|
|
|
+ "length": d.data.length,
|
|
|
+ "extension": d.data.extension,
|
|
|
+ "lastUpdateTime": d.data.lastUpdateTime,
|
|
|
+ "activityName": d.data.activityName
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this._setBusinessData(values);
|
|
|
+ } else {
|
|
|
+ this._setBusinessData([]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|