GridPanel.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Ext.define('erp.view.ma.copy.GridPanel', {
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpCopyGridPanel',
  4. requires: ['erp.view.core.toolbar.Toolbar', 'erp.view.core.plugin.CopyPasteMenu'],
  5. region: 'south',
  6. layout : 'fit',
  7. id: 'grid',
  8. deleteBeforeImport : false,
  9. emptyText : $I18N.common.grid.emptyText,
  10. columnLines : true,
  11. autoScroll : true,
  12. store: [],
  13. columns: [],
  14. binds:null,
  15. limitArr:[],
  16. bodyStyle: 'background-color:#f1f1f1;',
  17. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  18. clicksToEdit: 1,
  19. listeners:{
  20. beforeedit:function(e){
  21. var g=e.grid,r=e.record,f=e.field;
  22. if(g.binds){
  23. var bool=true;
  24. Ext.Array.each(g.binds,function(item){
  25. if(Ext.Array.contains(item.fields,f)){
  26. Ext.each(item.refFields,function(field){
  27. if(r.get(field)!=null && r.get(field)!=0 && r.get(field)!='' && r.get(field)!='0'){
  28. bool=false;
  29. }
  30. });
  31. }
  32. });
  33. return bool;
  34. }
  35. }
  36. }
  37. }), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  38. features : [Ext.create('Ext.grid.feature.GroupingSummary',{
  39. startCollapsed: true,
  40. groupHeaderTpl: '{name} (共:{rows.length}条)'
  41. }),{
  42. ftype : 'summary',
  43. showSummaryRow : false,//不显示默认合计行
  44. generateSummaryData: function(){
  45. // 避开在grid reconfigure后的计算,节约加载时间50~600ms
  46. return {};
  47. }
  48. }],
  49. bbar: {xtype: 'erpToolbar',id:'toolbar'},
  50. GridUtil: Ext.create('erp.util.GridUtil'),
  51. BaseUtil: Ext.create('erp.util.BaseUtil'),
  52. necessaryField: '',//必填字段
  53. detno: '',//编号字段
  54. keyField: '',//主键字段
  55. mainField: '',//对应主表主键的字段
  56. dbfinds: [],
  57. caller: null,
  58. condition: null,
  59. gridCondition:null,
  60. initComponent : function(){
  61. if(!this.boxready) {
  62. if(this._buttons)
  63. this.bbar._buttons = this._buttons;// 在toolbar加入grid固定按钮
  64. var condition = this.condition;
  65. if(!condition){
  66. var urlCondition = this.BaseUtil.getUrlParam('gridCondition');
  67. urlCondition = urlCondition == null || urlCondition == "null" ? "" : urlCondition;
  68. urlCondition = urlCondition.replace(/cc_callerIS/g, "");
  69. condition = "cc_caller="+"'"+urlCondition+"'";
  70. }
  71. var gridParam = {caller: this.caller || caller, condition: condition, _m: 0};
  72. var master = getUrlParam('newMaster'),_config=getUrlParam('_config');
  73. if(master){
  74. gridParam.master = master;
  75. }
  76. if(_config)gridParam._config=_config;
  77. var _copyConf=getUrlParam('_copyConf');
  78. if(_copyConf!=null){//复制来源单据的条件
  79. gridParam._copyConf=_copyConf;
  80. }
  81. this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "" , true);//从后台拿到gridpanel的配置及数据
  82. }
  83. this.callParent(arguments);
  84. }
  85. });