CashFlowGrid.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /**
  2. * ERP项目gridpane
  3. */
  4. Ext.define('erp.view.fa.gla.cashFlowSum.CashFlowGrid', {
  5. extend: 'Ext.tree.Panel',
  6. alias: 'widget.erpCashFlowGrid',
  7. layout: 'fit',
  8. id: 'cashflowgrid',
  9. cls: 'u-treegrid',
  10. emptyText: $I18N.common.grid.emptyText,
  11. rootVisible: false,
  12. singleExpand: true,
  13. store: Ext.create('Ext.data.TreeStore', {
  14. storeId: 'cashflowstore',
  15. fields: [{
  16. "name": "cfs_catecode",
  17. "type": "string"
  18. }, {
  19. "name": "cfs_name",
  20. "type": "string"
  21. }, {
  22. "name": "cfs_credit",
  23. "type": "string"
  24. }, {
  25. "name": "cfs_debit",
  26. "type": "string"
  27. }, {
  28. "name": "leaf",
  29. "type": "bool"
  30. }, {
  31. "name": "cfs_typename",
  32. "type": "string"
  33. }, {
  34. "name": "ca_defaultcashcode",
  35. "type": "string"
  36. }, {
  37. "name": "ca_defaultcashflow",
  38. "type": "string"
  39. }],
  40. root: {
  41. text: 'root',
  42. id: 'root',
  43. expanded: true
  44. }
  45. }),
  46. columnLines: true,
  47. columns: [{
  48. "cls": "x-grid-header-1",
  49. "dataIndex": "cfs_catecode",
  50. "align": "left",
  51. "xtype": "treecolumn",
  52. "width": 200.0,
  53. "text": "对方科目"
  54. }, {
  55. "cls": "x-grid-header-1",
  56. "dataIndex": "cfs_name",
  57. "align": "left",
  58. "width": 200.0,
  59. "text": "科目名称"
  60. }, {
  61. "cls": "x-grid-header-1",
  62. "dataIndex": "cfs_credit",
  63. "align": "right",
  64. "width": 200.0,
  65. "text": "借方金额",
  66. "xtype": "numbercolumn"
  67. }, {
  68. "cls": "x-grid-header-1",
  69. "dataIndex": "cfs_debit",
  70. "align": "right",
  71. "width": 200.0,
  72. "text": "贷方金额",
  73. "xtype": "numbercolumn"
  74. }, {
  75. "cls": "x-grid-header-1",
  76. "dataIndex": "cfs_typename",
  77. "align": "left",
  78. "width": 150.0,
  79. "text": "类型"
  80. }],
  81. plugins: Ext.create('Ext.grid.plugin.CellEditing', {
  82. clicksToEdit: 1
  83. }),
  84. tbar: [{
  85. xtype: 'monthdatefield',
  86. fieldLabel: '期间',
  87. labelWidth: 40,
  88. id: 'yearmonth',
  89. name: 'yearmonth',
  90. margin: '3 2 3 0'
  91. }, '-', {
  92. name: 'catchdata',
  93. id: 'catchdata',
  94. width: 100,
  95. text: $I18N.common.button.erpCatchDataButton,
  96. cls: 'u-button'
  97. }, '->', {
  98. iconCls: null,
  99. cls: 'u-button',
  100. width: 60,
  101. xtype: 'erpPrintButton'
  102. }, '-', {
  103. name: 'export',
  104. text: $I18N.common.button.erpExportButton,
  105. cls: 'u-button',
  106. width: 60
  107. }, '-', {
  108. xtype: 'erpCloseButton',
  109. iconCls: null,
  110. cls: 'u-button',
  111. width: 60,
  112. style: {
  113. marginLeft: 0
  114. }
  115. }],
  116. bodyStyle: 'background-color:#f1f1f1;',
  117. initComponent: function () {
  118. Ext.override(Ext.data.AbstractStore, {
  119. indexOf: Ext.emptyFn
  120. });
  121. this.callParent(arguments);
  122. this.view.onItemClick = function () {
  123. return true;
  124. };
  125. },
  126. getExpandItem: function(root){
  127. var me = this;
  128. if(!root){
  129. root = this.store.tree.root;
  130. }
  131. var node = null;
  132. if(root.childNodes.length > 0){
  133. Ext.each(root.childNodes, function(){
  134. if(this.isExpanded()){
  135. node = this;
  136. if(this.childNodes.length > 0){
  137. var n = me.getExpandItem(this);
  138. node = n == null ? node : n;
  139. }
  140. }
  141. });
  142. }
  143. return node;
  144. },
  145. listeners: { // 滚动条有时候没反应,添加此监听器
  146. scrollershow: function (scroller) {
  147. if (scroller && scroller.scrollEl) {
  148. scroller.clearManagedListeners();
  149. scroller.mon(scroller.scrollEl, 'scroll',scroller.onElScroll, scroller);
  150. }
  151. }
  152. },
  153. viewConfig: {
  154. listeners: {
  155. cellcontextmenu: function(view, td, colIdx, record, tr, rowIdx, e) {
  156. if(record.get('leaf')) {
  157. e.preventDefault();
  158. var contextMenu = view.contextMenu;
  159. if(!contextMenu) {
  160. contextMenu = view.contextMenu = new Ext.menu.Menu({
  161. items: [{
  162. id: 'cashflowset',
  163. text: '设置现金流量项目',
  164. iconCls: 'x-button-icon-query'
  165. }, '-', {
  166. id: 'setVoucher',
  167. text: '已设置现金流量凭证',
  168. iconCls: 'x-button-icon-query'
  169. }, '-', {
  170. id: 'noSetVoucher',
  171. text: '未设置现金流量凭证',
  172. iconCls: 'x-button-icon-query'
  173. }]
  174. });
  175. }
  176. contextMenu.record = record;
  177. contextMenu.showAt(e.getXY());
  178. }
  179. }
  180. }
  181. }
  182. });