LimitDetail.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. xtype:'checkcolumn',
  74. editor:{
  75. xtype:'checkbox',
  76. value:0,
  77. cls: 'x-grid-checkheader-editor'
  78. }
  79. },{
  80. text:'删除权',
  81. dataIndex:'delete_',
  82. xtype:'checkcolumn',
  83. sortable:false,
  84. flex:0.33,
  85. xtype:'checkcolumn',
  86. editor:{
  87. xtype:'checkbox',
  88. cls: 'x-grid-checkheader-editor',
  89. value:0
  90. }
  91. }],
  92. GridUtil: Ext.create('erp.util.GridUtil'),
  93. initComponent : function(){
  94. this.callParent(arguments);
  95. },
  96. insertRecords:function(records){
  97. var insertRecords=new Array(),store=this.getStore(),maxIndex=store.getTotalCount();
  98. Ext.Array.each(records,function(item){
  99. if(store.find("code_",item.get('CODE_'))==-1){
  100. insertRecords.push({
  101. code_:item.data.CODE_,
  102. desc_:item.data.DESC_,
  103. see_:1,
  104. update_:0,
  105. delete_:0
  106. });
  107. }
  108. });
  109. store.insert(maxIndex,insertRecords);
  110. },
  111. getChange: function(){
  112. var grid = this,items = grid.store.data.items,key = grid.keyField,
  113. added = new Array(),updated = new Array(),d = null;
  114. Ext.each(items, function(item){
  115. d = item.data;
  116. if(d[key] !=0 && d[key]!=null && d[key]!=" "){
  117. if(item.dirty)updated.push(Ext.JSON.encode(d));
  118. }else{
  119. added.push(Ext.JSON.encode(d));
  120. }
  121. });
  122. return {
  123. added: added,
  124. updated: updated
  125. };
  126. }
  127. });