InitDataCheck.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. Ext.define('erp.view.sys.init.InitDataCheck', {
  2. extend : 'Ext.grid.Panel',
  3. alias : 'widget.initdatacheck',
  4. columnLines : true,
  5. forceFit : true,
  6. /*
  7. * viewConfig : { stripeRows : true, enableTextSelection : true },
  8. */
  9. autoScroll : true,
  10. columns : [ {
  11. text : '检测项',
  12. dataIndex : 'desc',
  13. flex : 10,
  14. renderer : function(val, meta, record) {
  15. if (record.get('check') == 'error') {
  16. meta.style = 'color: gray';
  17. }
  18. return val;
  19. }
  20. }, {
  21. text : '',
  22. dataIndex : 'check',
  23. style : 'text-align:center',
  24. width : 150,
  25. renderer : function(val, meta, record) {
  26. meta.tdCls = val;
  27. return '';
  28. }
  29. }, {
  30. text : '',
  31. dataIndex : 'link',
  32. width : 0,
  33. renderer : function(val, meta, record) {
  34. if (record.get('check') == 'error') {
  35. meta.tdCls = 'detail';
  36. return '详细情况';
  37. }
  38. return '';
  39. }
  40. }, {
  41. menuDisabled : true,
  42. sortable : false,
  43. xtype : 'actioncolumn',
  44. width : 50,
  45. items : [ {
  46. iconCls : 'refresh',
  47. tooltip : '开账',
  48. handler : function(grid, rowIndex, colIndex) {
  49. grid.ownerCt.refreshItem(this, grid.ownerCt, rowIndex);
  50. }
  51. } ]
  52. } ],
  53. store : Ext.create('Ext.data.Store', {
  54. fields : [ {
  55. name : 'link',
  56. type : 'string'
  57. }, {
  58. name : 'desc',
  59. type : 'string'
  60. }, {
  61. name : 'groupName',
  62. type : 'string'
  63. }, {
  64. name : 'detail'
  65. } ],
  66. groupField : 'groupName',
  67. data : [ {
  68. link : 'common/GL/refreshLedger.action',
  69. desc : '总账开帐',
  70. groupName : '科目余额初始化'
  71. }, {
  72. link : 'common/GL/refreshAR.action',
  73. desc : '应收确认开帐',
  74. groupName : '应收应付初始化'
  75. }, {
  76. link : 'common/GL/refreshAP.action',
  77. desc : '应付确认开帐',
  78. groupName : '应收应付初始化'
  79. } ]
  80. }),
  81. features : [ {
  82. id : 'group',
  83. ftype : 'grouping',
  84. groupHeaderTpl : Ext.create('Ext.XTemplate', '{rows:this.formatName}', {
  85. formatName : function(f) {
  86. return f[0].data.groupName;
  87. }
  88. }),
  89. enableGroupingMenu : false
  90. } ],
  91. plugins : [ {
  92. ptype : 'rowexpander',
  93. rowBodyTpl : [ '<div style="padding: 1em;color: #f30">{detail}</div>' ]
  94. } ],
  95. initComponent : function() {
  96. var me = this;
  97. this.callParent();
  98. },
  99. refreshItem : function(btn, grid, idx) {
  100. var me = this, r;
  101. if (Ext.isNumber(idx)) {
  102. r = grid.store.getAt(idx);
  103. }
  104. r.set('check', 'loading');
  105. var action = r.get('link');
  106. Ext.Ajax.request({
  107. url : basePath + action,
  108. //async : false,
  109. method : 'GET',
  110. //timeout : 600000,
  111. callback : function(opt, s, re) {
  112. r.set('check', 'checked');
  113. var rs = Ext.decode(re.responseText);
  114. if(rs.error) {
  115. r.set('check', 'error');
  116. }
  117. if(rs.result) {
  118. r.set('detail', rs.result);
  119. }
  120. me.toggleRowbody(idx, rs.error);
  121. if (!Ext.isNumber(idx)) {
  122. btn.setDisabled(false);
  123. }
  124. }
  125. });
  126. },
  127. /**
  128. * 展开收拢RowBody
  129. * @param rowIdx 行号
  130. * @param expand {Boolean} 展开/收拢
  131. */
  132. toggleRowbody : function(rowIdx, expand) {
  133. var p = this.plugins[0], rowNode = this.view.getNode(rowIdx), row = Ext.get(rowNode), nextBd = Ext.get(row)
  134. .down(p.rowBodyTrSelector), record = this.view.getRecord(rowNode), isCollapsed = row
  135. .hasCls(p.rowCollapsedCls);
  136. if (expand && isCollapsed) {
  137. row.removeCls(p.rowCollapsedCls);
  138. nextBd.removeCls(p.rowBodyHiddenCls);
  139. p.recordsExpanded[record.internalId] = true;
  140. this.view.fireEvent('expandbody', rowNode, record, nextBd.dom);
  141. } else if (!expand && !isCollapsed) {
  142. row.addCls(p.rowCollapsedCls);
  143. nextBd.addCls(p.rowBodyHiddenCls);
  144. p.recordsExpanded[record.internalId] = false;
  145. this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
  146. }
  147. this.view.up('gridpanel').invalidateScroller();
  148. }
  149. });