Grid.js.svn-base 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. Ext.define('erp.view.ma.Grid', {
  2. extend : 'Ext.Viewport',
  3. layout : 'border',
  4. initComponent : function() {
  5. var me = this;
  6. Ext.apply(me, {
  7. items : [ {
  8. region: 'east',
  9. xtype: 'container',
  10. width: '25%',
  11. height: '100%',
  12. layout: 'border',
  13. items: [{
  14. region: 'north',
  15. title: '基本信息',
  16. height: 280,
  17. maxHeight: 320,
  18. split: true,
  19. xtype: 'form',
  20. collapsible: true,
  21. cls: 'custom',
  22. layout: 'column',
  23. defaults: {
  24. xtype: 'textfield',
  25. labelAlign: 'top',
  26. columnWidth: 1,
  27. margin: '3 3 3 3'
  28. },
  29. items: [{
  30. fieldLabel: 'Caller',
  31. readOnly: true,
  32. value: whoami
  33. },{
  34. fieldLabel: '表名',
  35. name: 'fo_detailtable'
  36. },{
  37. fieldLabel: '默认条件',
  38. name: 'fo_detailcondition',
  39. xtype: 'textarea',
  40. height: 80
  41. },{
  42. fieldLabel: '默认排序',
  43. name: 'fo_detailgridorderby'
  44. }]
  45. },{
  46. xtype: 'form',
  47. id: 'detailset',
  48. title: '列信息',
  49. cls: 'custom',
  50. region: 'center',
  51. width: '100%',
  52. layout: 'column',
  53. defaults: {
  54. xtype: 'textfield',
  55. labelAlign: 'top',
  56. columnWidth: 1,
  57. margin: '3 3 3 3'
  58. },
  59. items: [{
  60. fieldLabel: '描述',
  61. name: 'dg_caption'
  62. },{
  63. fieldLabel: '序号',
  64. name: 'dg_sequence',
  65. columnWidth: .3
  66. },{
  67. fieldLabel: '字段',
  68. name: 'dg_field',
  69. columnWidth: .7
  70. },{
  71. fieldLabel: '宽度',
  72. name: 'dg_width',
  73. columnWidth: .3
  74. },{
  75. fieldLabel: '类型',
  76. name: 'dg_type',
  77. columnWidth: .7
  78. },{
  79. fieldLabel: '逻辑',
  80. name: 'dg_logictype'
  81. },{
  82. fieldLabel: 'Render',
  83. name: 'dg_renderer'
  84. },{
  85. fieldLabel: '合计类型',
  86. name: 'dg_summarytype',
  87. xtype: 'combo',
  88. displayField: 'display',
  89. valueField: 'value',
  90. queryMode: 'local',
  91. store: {
  92. fields: ['display', 'value'],
  93. data: [{
  94. display: '求和', value: 'sum'
  95. },{
  96. display: '平均值', value: 'average'
  97. },{
  98. display: 'Count', value: 'count'
  99. }]
  100. }
  101. }],
  102. buttonAlign: 'center',
  103. buttons: [{
  104. text: '提交到Grid',
  105. height: 30
  106. }]
  107. }]
  108. }, {
  109. region: 'center',
  110. xtype: 'container',
  111. id: 'grid',
  112. layout: 'fit'
  113. }]
  114. });
  115. me.callParent(arguments);
  116. me.getFormSet(function(formParam){
  117. });
  118. me.getGridSet(function(gridParam){
  119. me.down('#grid').add(me.createGrid(gridParam));
  120. });
  121. },
  122. getFormSet: function(fn) {
  123. var me = this;
  124. Ext.Ajax.request({
  125. url : basePath + 'common/singleFormItems.action',
  126. params: {
  127. caller: 'Form',
  128. condition: 'fo_caller=\'' + whoami + '\''
  129. },
  130. method : 'post',
  131. callback : function(opt, s, r){
  132. var res = new Ext.decode(r.responseText);
  133. if(res.exceptionInfo){
  134. showError(res.exceptionInfo);return;
  135. }
  136. if(res.columns){
  137. fn.call(me, res);
  138. }
  139. }
  140. });
  141. },
  142. getGridSet: function(fn) {
  143. var me = this;
  144. Ext.Ajax.request({
  145. url : basePath + 'common/singleGridPanel.action',
  146. params: {
  147. caller: 'DetailGrid',
  148. condition: 'dg_caller=\'' + whoami + '\''
  149. },
  150. method : 'post',
  151. callback : function(opt, s, r){
  152. var res = new Ext.decode(r.responseText);
  153. if(res.exceptionInfo){
  154. showError(res.exceptionInfo);return;
  155. }
  156. if(res.columns){
  157. fn.call(me, res);
  158. }
  159. }
  160. });
  161. },
  162. createGrid: function(param) {
  163. var data = (param.data && Ext.decode(param.data.replace(/,}/g, '}').replace(/,]/g, ']')))
  164. || [], store = Ext.create('Ext.data.Store', {
  165. fields: param.fields,
  166. data: data
  167. });
  168. return Ext.create('Ext.grid.Panel', {
  169. width: '100%',
  170. height: '100%',
  171. BaseUtil: Ext.create('erp.util.BaseUtil'),
  172. RenderUtil: Ext.create('erp.util.RenderUtil'),
  173. columns: param.columns,
  174. store: store,
  175. columnLines: true,
  176. buttonAlign: 'center',
  177. buttons: [{
  178. text: $I18N.common.button.erpSaveButton,
  179. height: 30
  180. }, {
  181. text: $I18N.common.button.erpCloseButton,
  182. height: 30
  183. }],
  184. listeners: {
  185. selectionchange: function(model, records) {
  186. if (records[0]) {
  187. this.ownerCt.ownerCt.down('#detailset').getForm().loadRecord(records[0]);
  188. }
  189. }
  190. }
  191. });
  192. }
  193. });