Copy.js 959 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * 明细行复制按钮
  3. */
  4. Ext.define('erp.view.core.button.Copy',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.copydetail',
  7. iconCls: 'x-button-icon-copy',
  8. cls: 'x-btn-tb',
  9. tooltip: $I18N.common.button.erpCopyDetailButton,
  10. disabled: true,
  11. //width: 65,
  12. initComponent : function(){
  13. this.callParent(arguments);
  14. },
  15. handler: function(btn){
  16. /**
  17. * 该按钮只支持单行复制,
  18. * 有需求可添加多行复制功能
  19. */
  20. var grid = btn.ownerCt.ownerCt;
  21. var record = grid.selModel.lastSelected;
  22. if(record){
  23. var keys = Ext.Object.getKeys(record.data);
  24. var values = Ext.Object.getValues(record.data);
  25. var o = new Object();
  26. Ext.each(keys, function(key, index){
  27. if(key != grid.detno && key != grid.keyField){//排序字段和主键字段的值均不复制
  28. o[key] = values[index];
  29. }
  30. });
  31. grid.copyData = o;//需要粘贴时,直接取grid.copyData即可
  32. }
  33. }
  34. });