Просмотр исходного кода

数据网格中支持附件组件

huqi 5 лет назад
Родитель
Сommit
3621ac9211

+ 12 - 0
o2web/source/o2_core/o2.js

@@ -1701,6 +1701,18 @@ o2.core = true;
             return this.some(function(item){ return (arr.indexOf(item)!==-1); })
         }
     });
+    if (!Array.prototype.find){
+        if (Array.implement) Array.implement({
+            "find": this.find || function(callback, thisArg){
+                for (var i=0; i<this.length; i++){
+                    if (callback.apply((thisArg || this), this[i], i, this)){
+                        return this[i];
+                    }
+                }
+                return undefined;
+            }
+        });
+    }
     if (window.Element && Element.implement) Element.implement({
         "isIntoView": function() {
             // var pNode = this.getParent();

+ 4 - 2
o2web/source/o2_core/o2/widget/AttachmentController.js

@@ -1499,7 +1499,8 @@ o2.widget.AttachmentController.Attachment = new Class({
         this.node.addEvents({
             "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["attachmentNode_"+this.controller.options.listStyle+"_over"])}.bind(this),
             "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["attachmentNode_"+this.controller.options.listStyle])}.bind(this),
-            "mousedown": function(e){this.selected(e);}.bind(this),
+            "mousedown": function(e){this.selected(e); e.stopPropagation();}.bind(this),
+            "click": function(e){e.stopPropagation();}.bind(this),
             "dblclick": function(e){this.openAttachment(e);}.bind(this)
         });
     },
@@ -1869,7 +1870,8 @@ o2.widget.AttachmentController.AttachmentMin = new Class({
                     }
                 }
             }.bind(this),
-            "mousedown": function(e){this.selected(e);}.bind(this),
+            "mousedown": function(e){this.selected(e);e.stopPropagation();}.bind(this),
+            "click": function(e){e.stopPropagation();}.bind(this),
             "dblclick": function(e){this.openAttachment(e);}.bind(this)
         });
     },

+ 3 - 2
o2web/source/o2_core/o2/widget/chart/Bar.js

@@ -78,8 +78,9 @@ o2.widget.chart.Bar = new Class({
             );
         }.bind(this));
         var max = d3.max(this.barsData, function(d){ return d3.max(d, function(d){return d.data}); });
+        var min = d3.min(this.barsData, function(d){ return d3.min(d, function(d){return d.data}); });
 
-        this.yScale = d3.scaleLinear().domain([0, max])
+        this.yScale = d3.scaleLinear().domain([min*0.9, max*1.1])
             .range(this.getYScaleRange());
     },
 
@@ -263,4 +264,4 @@ o2.widget.chart.Bar = new Class({
         this.svgNode.destroy();
         o2.release(this);
     }
-});
+});

+ 5 - 0
o2web/source/x_component_process_FormDesigner/Module/Attachment.js

@@ -66,6 +66,8 @@ MWF.xApplication.process.FormDesigner.Module.Attachment = MWF.FCAttachment = new
 
 	_initModule: function(){
 		this.node.empty();
+		if (this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.size) this.json.size = "min";
+		if (this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.listStyle) this.json.listStyle = "sequence";
 		this.loadAttachmentController(this.json.editorProperties);
 
 		this.setPropertiesOrStyles("styles");
@@ -73,6 +75,9 @@ MWF.xApplication.process.FormDesigner.Module.Attachment = MWF.FCAttachment = new
 		this._setNodeProperty();
         if (!this.form.isSubform) this._createIconAction();
 		this._setNodeEvent();
+
+		debugger;
+
 	},
     loadAttachmentController: function(){
         MWF.require("MWF.widget.AttachmentController", function(){

+ 57 - 1
o2web/source/x_component_process_FormDesigner/Module/Attachment/attachment.html

@@ -13,6 +13,10 @@
                 <td class="editTableTitle">描述:</td>
                 <td class="editTableValue"><input type="text" name="description" value="text{$.description}" class="editTableInput"/></td>
             </tr>
+            <tr>
+                <td class="editTableTitle">site:</td>
+                <td class="editTableValue"><input type="text" name="site" value="text{$.site}" class="editTableInput"/><br>(默认与标识相同)</td>
+            </tr>
             <tr>
                 <td class="editTableTitle">在控件中编辑:</td>
                 <td class="editTableValue">
@@ -181,6 +185,58 @@
                 </td>
             </tr>
         </table>
+        <div style="height: 28px; font-weight: bold; line-height:28px; background-color: #EEE; padding: 0px 6px; border-top: 1px solid #999">数据网格中的展现</div>
+        <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+            <tr>
+                <td class="editTableTitle">显示方式:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="dg_size" text{($.dg_size=='max')?'checked':''} type="radio" value="max"/>完整
+                    <input class="editTableRadio" name="dg_size" text{($.dg_size!=='max')?'checked':''} type="radio" value="min"/>简单
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">切换样式:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="dg_isSizeChange" text{($.dg_isSizeChange=='y')?'checked':''} type="radio" value="y"/>允许
+                    <input class="editTableRadio" name="dg_isSizeChange" text{($.dg_isSizeChange!=='y')?'checked':''} type="radio" value="n"/>不允许
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">改变大小:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="dg_resize" text{($.resize=='y')?'checked':''} type="radio" value="y"/>允许
+                    <input class="editTableRadio" name="dg_resize" text{($.resize!=='y')?'checked':''} type="radio" value="n"/>不允许
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">允许使用的附件样式:</td>
+                <td class="editTableValue">
+                    <input type="checkbox" name="dg_availableListStyles" text{(!$.dg_availableListStyles || $.dg_availableListStyles.indexOf('list')!=-1)?'checked':''} value="list">列表
+                    <input type="checkbox" name="dg_availableListStyles" text{(!$.dg_availableListStyles || $.dg_availableListStyles.indexOf('seq')!=-1)?'checked':''} value="seq">序列
+                    <input type="checkbox" name="dg_availableListStyles" text{(!$.dg_availableListStyles || $.dg_availableListStyles.indexOf('icon')!=-1)?'checked':''} value="icon">图标
+                    <input type="checkbox" name="dg_availableListStyles" text{(!$.dg_availableListStyles || $.dg_availableListStyles.indexOf('preview')!=-1)?'checked':''} value="preview">预览
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">默认附件样式:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="dg_listStyle" text{($.dg_listStyle=='list')?'checked':''} type="radio" value="list"/>列表 </br>
+                    <input class="editTableRadio" name="dg_listStyle" text{($.dg_listStyle=='icon')?'checked':''} type="radio" value="icon"/>图标 </br>
+                    <input class="editTableRadio" name="dg_listStyle" text{($.dg_listStyle=='preview')?'checked':''} type="radio" value="preview"/>预览</br>
+                    <input class="editTableRadio" name="dg_listStyle" text{($.dg_listStyle!=='list' && $.dg_listStyle!=='icon' && $.dg_listStyle!=='preview')?'checked':''} type="radio" value="sequence"/>序列
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">操作条:</td>
+                <td class="editTableValue">
+                    <input class="editTableRadio" name="dg_toolbarGroupHidden" text{(($.dg_toolbarGroupHidden || []).indexOf('edit')!=-1)?'checked':''} type="checkbox" value="edit"/>隐藏编辑操作组<br/>
+                    <input class="editTableRadio" name="dg_toolbarGroupHidden" text{(($.dg_toolbarGroupHidden || []).indexOf('read')!=-1)?'checked':''} type="checkbox" value="read"/>隐藏阅读操作组<br/>
+                    <input class="editTableRadio" name="dg_toolbarGroupHidden" text{(($.dg_toolbarGroupHidden || []).indexOf('list')!=-1)?'checked':''} type="checkbox" value="list"/>隐藏布局操作组<br/>
+                    <input class="editTableRadio" name="dg_toolbarGroupHidden" text{(($.dg_toolbarGroupHidden || []).indexOf('config')!=-1)?'checked':''} type="checkbox" value="config"/>隐藏设置操作组<br/>
+                    <input class="editTableRadio" name="dg_toolbarGroupHidden" text{(($.dg_toolbarGroupHidden || []).indexOf('view')!=-1)?'checked':''} type="checkbox" value="view"/>隐藏模式操作<br/>
+                </td>
+            </tr>
+        </table>
     </div>
 
     <div title="事件"  class="MWFTab" style="overflow: hidden">
@@ -192,4 +248,4 @@
     <div title="JSON"  class="MWFTab">
         <div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
     </div>
-</div>
+</div>

+ 3 - 3
o2web/source/x_component_process_FormDesigner/Module/Attachment/template.json

@@ -65,11 +65,11 @@
       "html": ""
     }
   },
-  "size": "max", //max, min
+  "size": "", //max, min
   "isSizeChange": "y",
   "attachmentCount": "0",
   "resize": "n",
-  "listStyle": "icon", //list, icon, preview
+  "listStyle": "", //list, icon, preview
   "readonly": "n",
   "isUpload": "y",
   "isDelete": "y",
@@ -82,4 +82,4 @@
   "class": "",
   "styles": {},
   "container": ""
-}
+}

+ 1 - 1
o2web/source/x_component_process_FormDesigner/Module/Datagrid$Data.js

@@ -21,7 +21,7 @@ MWF.xApplication.process.FormDesigner.Module.Datagrid$Data = MWF.FCDatagrid$Data
 		    	"title": MWF.LP.process.formAction.deleteCol
 		    }
 		],
-		"allowModules": ["textfield", "number", "personfield", "orgfield", "org", "calendar", "textarea", "select", "radio", "checkbox", "html", "combox", "image", "label", "htmleditor", "button","imageclipper", "address"]
+		"allowModules": ["textfield", "number", "personfield", "orgfield", "org", "calendar", "textarea", "select", "radio", "checkbox", "combox", "image", "label", "htmleditor", "button","imageclipper", "address", "attachment"]
 	},
 	
 	initialize: function(form, options){

+ 1 - 1
o2web/source/x_component_process_ProcessManager/Explorer.js

@@ -171,7 +171,7 @@ MWF.xApplication.process.ProcessManager.Explorer = new Class({
         this.app.addEvent("resize", this.setContentSize.bind(this));
     },
     setContentSize: function(){
-        var toolbarSize = this.toolbarNode.getSize();
+        var toolbarSize = (this.toolbarNode) ? this.toolbarNode.getSize() : {"x": 0, "y": 0};
         var nodeSize = this.node.getSize();
         var pt = this.elementContentNode.getStyle("padding-top").toFloat();
         var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();

+ 104 - 12
o2web/source/x_component_process_Xform/Attachment.js

@@ -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([]);
+            }
+        }
+    }
+});

+ 138 - 13
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -79,6 +79,10 @@ 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(){
@@ -226,6 +230,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			var module = this.editModules[idx-1];
 			if( module && module.json.type == "ImageClipper" ){
 				this._createImage( cell, module, text )
+			}else if( module && (module.json.type == "Attachment" || module.json.type == "AttachmentDg") ){
+				this._createAttachment( cell, module, text );
 			}else{
 				if( module && module.json.type == "Textarea" ){
 					cell.set("html", text);
@@ -316,9 +322,6 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				if (module){
 					if (module.json.type=="sequence"){
 						module.node.set("text", module.node.getParent("tr").rowIndex);
-
-						//var i = newTr.rowIndex;
-						//var data = {"value": [i], "text": [i]};
 					}else {
 						debugger;
 						if (data[id]) {
@@ -399,6 +402,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				datagrid.currentEditLine.setStyle("display", "table-row");
 			}
 
+			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.isEdit = false;
 			datagrid.currentEditLine = null;
 
@@ -428,7 +440,7 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		if (!this.editValidation()){
 			return false;
 		}
-
+debugger;
 		this.isEdit = false;
 
 		var flag = true;
@@ -453,8 +465,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			var module = this.editModules[idx-1];
 			if (module){
 				if (module.json.type=="sequence"){
+					flag = false;
 					var i = newTr.rowIndex;
 					var data = {"value": [i], "text": [i]};
+				}else if (module.json.type=="Attachment" || module.json.type == "AttachmentDg"){
+					flag = false;
+					var data = module.getTextData();
+					//data.site = module.json.site;
+					if (!griddata[id]) griddata[id] = {};
+					griddata[id][module.json.id] = data;
 				}else{
 					var data = module.getTextData();
 					if (data.value[0]) flag = false;
@@ -470,6 +489,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				if (cell){
 					if( module.json.type == "ImageClipper" ){
 						this._createImage( cell, module, data.text );
+					}if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){
+						this._createAttachment( cell, module, data );
 					}else{
 						var text = this._getValueText(idx-1, data.text.join(", "));
 						if( module.json.type == "Textarea"){
@@ -479,8 +500,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 						}
 					}
 				}else{
-					var text = this._getValueText(idx-1, data.text.join(", "));
-					this._createNewEditTd(newTr, idx, editorTds[idx].get("id"), text, titleThs.length-1);
+					if( module.json.type == "Attachment" || module.json.type == "AttachmentDg" ){
+						this._createNewEditTd(newTr, idx, editorTds[idx].get("id"), data, titleThs.length-1);
+					}else{
+						var text = this._getValueText(idx-1, data.text.join(", "));
+						this._createNewEditTd(newTr, idx, editorTds[idx].get("id"), text, titleThs.length-1);
+					}
 				}
 			}else{
 				if (!cell) this._createNewEditTd(newTr, idx, id, "", titleThs.length-1);
@@ -506,18 +531,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			newTr.getFirst().setStyles(this.json.actionStyles);
 		}
 
-
-		//this._loadTotal();
-
 		this._loadBorderStyle();
 		this._loadZebraStyle();
 		this._loadSequence();
-
-
 		this.getData();
 		this.validationMode();
 		this.fireEvent("completeLineEdit", [newTr]);
 
+		this.form.saveFormData();
+
 		return true;
 	},
 	_createImage : function( cell, module, data ){
@@ -537,6 +559,50 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			}
 		}
 	},
+	_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));
+	},
 	_editorTrGoBack: function(){
 		this.editorTr.setStyle("display", "none");
 //		this.editTr.removeEvents("blur");
@@ -560,6 +626,29 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		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();
@@ -576,9 +665,34 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			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]);
 
+				var data = currentTr.retrieve("data");
+
+				//var attKeys = [];
+				var titleThs = _self.titleTr.getElements("th");
+				titleThs.each(function(th, i){
+					var key = th.get("id");
+					var module = (i>0) ? _self.editModules[i-1] : null;
+					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);
+						});
+					}
+				});
+				// 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();
 				datagrid._loadSequence();
@@ -587,6 +701,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 				this.close();
 
 				_self.fireEvent("afterDeleteLine");
+
+				_self.form.saveFormData();
 			}, function(){
 				var color = currentTr.retrieve("bgcolor");
 				currentTr.tween("background", color);
@@ -1214,6 +1330,10 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			return false;
 		}
 		return true;
+	},
+	getAttachmentRandomSite: function(){
+		var i = (new Date()).getTime();
+		return this.json.id+i;
 	}
 
 });
@@ -1260,8 +1380,12 @@ MWF.xApplication.process.Xform.DatagridPC$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(){
-					debugger;
 					isField = this.field;
 					this.field = false;
 				});
@@ -1272,5 +1396,6 @@ MWF.xApplication.process.Xform.DatagridPC$Data =  new Class({
 				this.dataGrid.editModules.push(module);
 			}.bind(this));
 		}
-	}
+	},
+
 });