LimitDetail.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Ext.define('erp.view.ma.datalimit.LimitDetail',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.limitdetailgrid',
  4. id:'limitdetail',
  5. layout : 'fit',
  6. emptyText : $I18N.common.grid.emptyText,
  7. columnLines : true,
  8. autoScroll : true,
  9. store:Ext.create('Ext.data.Store',{
  10. fields:['id_','code_','desc_','see_','update_','delete_'],
  11. proxy: {
  12. type: 'ajax',
  13. url : basePath+'/ma/datalimit/getLimitDetails.action',
  14. reader: {
  15. type: 'json'
  16. }
  17. }
  18. }),
  19. // forceFit:true,
  20. keyField:'id_',
  21. initcount_:0,
  22. selModel: Ext.create('Ext.selection.CheckboxModel',{
  23. checkOnly : true,
  24. ignoreRightMouseSelection : false,
  25. getEditor: function(){
  26. return null;
  27. },
  28. onHeaderClick: function(headerCt, header, e) {
  29. if (header.isCheckerHd) {
  30. e.stopEvent();
  31. var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
  32. if (isChecked && this.getSelection().length > 0) {
  33. this.deselectAll(true);
  34. } else {
  35. this.selectAll(true);
  36. this.view.ownerCt.selectall = true;
  37. }
  38. }
  39. }
  40. }),
  41. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  42. clicksToEdit: 1})],
  43. columns: [{
  44. text:'ID',
  45. dataIndex:'id_',
  46. width:0
  47. },{
  48. text:'代码',
  49. dataIndex:'code_',
  50. sortable:false,
  51. flex:1
  52. },{
  53. text:'名称',
  54. dataIndex:'desc_',
  55. sortable:false,
  56. flex:1
  57. },{
  58. text:'查询权',
  59. dataIndex:'see_',
  60. sortable:false,
  61. flex:0.33,
  62. xtype:'checkcolumn',
  63. editor:{
  64. xtype:'checkbox',
  65. cls: 'x-grid-checkheader-editor'
  66. }
  67. },{
  68. text:'修改权',
  69. dataIndex:'update_',
  70. xtype:'checkcolumn',
  71. sortable:false,
  72. flex:0.33,
  73. editor:{
  74. xtype:'checkbox',
  75. value:0,
  76. cls: 'x-grid-checkheader-editor'
  77. }
  78. },{
  79. text:'删除权',
  80. dataIndex:'delete_',
  81. xtype:'checkcolumn',
  82. sortable:false,
  83. flex:0.33,
  84. editor:{
  85. xtype:'checkbox',
  86. cls: 'x-grid-checkheader-editor',
  87. value:0
  88. }
  89. }],
  90. GridUtil: Ext.create('erp.util.GridUtil'),
  91. initComponent : function(){
  92. this.callParent(arguments);
  93. },
  94. insertRecords:function(records){
  95. var insertRecords=new Array(),store=this.getStore(),maxIndex=store.getTotalCount();
  96. Ext.Array.each(records,function(item){
  97. if(store.find("code_",item.get('CODE_'))==-1){
  98. insertRecords.push({
  99. code_:item.data.CODE_,
  100. desc_:item.data.DESC_,
  101. see_:1,
  102. update_:0,
  103. delete_:0
  104. });
  105. }
  106. });
  107. store.insert(maxIndex,insertRecords);
  108. },
  109. getChange: function(){
  110. var grid = this,items = grid.store.data.items,key = grid.keyField,
  111. added = new Array(),updated = new Array(),d = null;
  112. Ext.each(items, function(item){
  113. d = item.data;
  114. d['see_']=d['see_'] ? 1 : 0;
  115. d['update_']=d['update_'] ? 1 : 0;
  116. d['delete_']=d['delete_'] ? 1 : 0;
  117. if(d[key] !=0 && d[key]!=null && d[key]!=" "){
  118. if(item.dirty)
  119. updated.push(Ext.JSON.encode(d));
  120. }else{
  121. added.push(Ext.JSON.encode(d));
  122. }
  123. });
  124. return {
  125. added: added,
  126. updated: updated
  127. };
  128. }
  129. });