zhuth 7 years ago
parent
commit
cfb8586d7a

+ 1 - 1
frontend/saas-web/app/Application.scss

@@ -153,7 +153,7 @@ body.launching {
   }
   }
 }
 }
 
 
-
+.x-btn-default-small,
 .x-btn-default-toolbar-small{
 .x-btn-default-toolbar-small{
   border-radius: 2px !important;
   border-radius: 2px !important;
 }
 }

+ 49 - 2
frontend/saas-web/app/view/core/form/field/DetailGridField.js

@@ -12,6 +12,7 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
     columnWidth : 1.0, 
     columnWidth : 1.0, 
 
 
     requires: [
     requires: [
+        'Ext.Action',
         'Ext.grid.plugin.CellEditing',
         'Ext.grid.plugin.CellEditing',
         'Ext.selection.CellModel'
         'Ext.selection.CellModel'
     ],
     ],
@@ -26,6 +27,10 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
     allowEmpty: false, // 表格为空时校验合法
     allowEmpty: false, // 表格为空时校验合法
     showCount: true, // 显示合计栏
     showCount: true, // 显示合计栏
 
 
+    // Clearing selection disables the Actions.
+    allowDeselect: true,
+    defaultActionType: 'button',
+
     initComponent: function() {
     initComponent: function() {
         var me = this;
         var me = this;
         me.initColumns();
         me.initColumns();
@@ -39,6 +44,15 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
         };
         };
 
 
         Ext.apply(me, {
         Ext.apply(me, {
+            actions: {
+                copy: {
+                    iconCls: 'x-fa fa-copy',
+                    text: '复制单元格',
+                    handler: function() {
+                        me.onCopy(me.selectedData);
+                    }
+                }
+            },
             plugins: {
             plugins: {
                 cellediting: {
                 cellediting: {
                     clicksToEdit: 1,
                     clicksToEdit: 1,
@@ -51,7 +65,15 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
             },
             },
             normalViewConfig: {
             normalViewConfig: {
                 deferEmptyText: false,
                 deferEmptyText: false,
-                emptyText: '无数据'
+                emptyText: '无数据',
+                listeners: {
+                    itemcontextmenu: function(view, rec, node, index, e) {
+                        e.stopEvent();
+                        me.getContextMenu().show().setLocalXY(e.getXY());
+                        me.selectedData = e.target.innerText;
+                        return false;
+                    }
+                }
             },
             },
             lockedGridConfig: {
             lockedGridConfig: {
                 // scrollable: {
                 // scrollable: {
@@ -464,6 +486,31 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
             }
             }
         });
         });
         return trueData;
         return trueData;
-    }
+    },
+
+    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);
+	},
 
 
 });
 });