Browse Source

grid复制功能时间类型处理,添加copyRender

zhuth 7 years ago
parent
commit
1295ed3597

+ 15 - 46
frontend/saas-web/app/view/core/query/QueryGridPanel.js

@@ -9,9 +9,12 @@ Ext.define('saas.view.core.query.QueryGridPanel', {
     requires: [
     requires: [
         'Ext.grid.plugin.Exporter'
         'Ext.grid.plugin.Exporter'
     ],
     ],
-    plugins: {
-        gridexporter: true
-    },
+
+    plugins: [{
+        ptype: 'gridexporter',
+    }, {
+        ptype: 'menuclipboard'
+    }],
 
 
     idField:'',
     idField:'',
     codeField:'',
     codeField:'',
@@ -58,26 +61,9 @@ Ext.define('saas.view.core.query.QueryGridPanel', {
         }
         }
 
 
         Ext.apply(me, {
         Ext.apply(me, {
-            actions: {
-                copy: {
-                    iconCls: 'x-fa fa-copy',
-                    text: '复制单元格',
-                    handler: function() {
-                        me.onCopy(me.selectedData);
-                    }
-                }
-            },
             viewConfig: {
             viewConfig: {
                 deferEmptyText: false,
                 deferEmptyText: false,
-                emptyText: '无数据',
-                listeners: {
-                    itemcontextmenu: function(view, rec, node, index, e) {
-                        e.stopEvent();
-                        me.getContextMenu().show().setLocalXY(e.getXY());
-                        me.selectedData = e.target.innerText;
-                        return false;
-                    }
-                }
+                emptyText: '无数据'
             },
             },
             columns: me.initColumns(),
             columns: me.initColumns(),
             store: Ext.create('Ext.data.Store', {
             store: Ext.create('Ext.data.Store', {
@@ -287,11 +273,19 @@ Ext.define('saas.view.core.query.QueryGridPanel', {
                     // exportStyle: {
                     // exportStyle: {
                     //     format: 'Medium Date'
                     //     format: 'Medium Date'
                     // },
                     // },
+                    copyRender: function(value) {
+                        return Ext.Date.format(new Date(value), 'Y-m-d');
+                    },
                     exportRenderer: function (value) {
                     exportRenderer: function (value) {
                         return Ext.Date.format(new Date(value), 'Y-m-d');
                         return Ext.Date.format(new Date(value), 'Y-m-d');
                     }
                     }
                 })
                 })
             }
             }
+            if(c.xtype == 'numbercolumn') {
+                Ext.applyIf(c, {
+                    align: 'end'
+                });
+            }
         });
         });
 
 
         return columns;
         return columns;
@@ -422,29 +416,4 @@ Ext.define('saas.view.core.query.QueryGridPanel', {
             });
             });
 		return data;
 		return data;
     },
     },
-
-    getContextMenu: function() {
-        var me = this;
-
-        return me.contextMenu || (me.contextMenu = me.add({
-            xtype: 'menu',
-            items: [
-                // Actions can be converted into MenuItems
-                '@copy',
-            ]
-        }));
-    },
-
-    onCopy: function(text) {
-		var target = Ext.DomHelper.append(document.body, {
-			tag: 'textarea',
-			style: 'opacity: 0;position: absolute;top: -10000px;right: 0;',
-			html: text
-		});
-		target.focus();
-		target.select();
-	    document.execCommand('Copy');
-	    target.blur();
-	    document.body.removeChild(target);
-	},
 });
 });

+ 0 - 8
frontend/saas-web/app/view/core/query/QueryPanel.js

@@ -102,14 +102,6 @@ Ext.define('saas.view.core.query.QueryPanel', {
         
         
         var columns = queryGridConfig.baseColumn || [];
         var columns = queryGridConfig.baseColumn || [];
 
 
-        Ext.Array.each(columns, function(c) {
-            if(c.xtype == 'numbercolumn') {
-                Ext.applyIf(c, {
-                    align: 'end'
-                });
-            }
-        });
-
         if(columns[columns.length - 1].flex != 1) {
         if(columns[columns.length - 1].flex != 1) {
             columns.push({
             columns.push({
                 flex: 1,
                 flex: 1,

+ 5 - 0
frontend/saas-web/ext/packages/ux/src/plugin/MenuClipboard.js

@@ -133,6 +133,11 @@ Ext.define('Ext.ux.plugin.MenuClipboard', {
     getCellText : function(grid, td, record, column, dataIndex, cell) {
     getCellText : function(grid, td, record, column, dataIndex, cell) {
 		var v = record.get(dataIndex), cv;
 		var v = record.get(dataIndex), cv;
 		v = v || cell.textContent;
 		v = v || cell.textContent;
+
+		if(typeof column.copyRender == 'function') {
+			return column.copyRender(v);
+		}
+
         if(Ext.isDate(v)) {
         if(Ext.isDate(v)) {
             cv = Ext.Date.format(v, column.format || Ext.Date.defaultFormat);
             cv = Ext.Date.format(v, column.format || Ext.Date.defaultFormat);
         }else if(Ext.isNumber(v)) {
         }else if(Ext.isNumber(v)) {