InterceptorPortal.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. Ext.define('erp.view.sys.base.InterceptorPortal',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.interceptorportal',
  4. layout:'fit',
  5. caller:null,
  6. columns: [{
  7. xtype: 'rownumberer'
  8. }, {
  9. text : 'Company<br>Name',
  10. locked : true,
  11. width : 200,
  12. sortable : false,
  13. dataIndex: 'company'
  14. },{
  15. text : 'Price',
  16. lockable: false,
  17. width : 125,
  18. sortable : true,
  19. renderer : 'usMoney',
  20. dataIndex: 'price'
  21. },{
  22. text : 'Change',
  23. width : 125,
  24. sortable : true,
  25. renderer : change,
  26. dataIndex: 'change'
  27. },{
  28. text : '% Change',
  29. width : 125,
  30. sortable : true,
  31. renderer : pctChange,
  32. dataIndex: 'pctChange'
  33. },{
  34. text : 'Last Updated',
  35. width : 135,
  36. sortable : true,
  37. renderer : Ext.util.Format.dateRenderer('m/d/Y'),
  38. dataIndex: 'lastChange'
  39. }],
  40. buttons: [{
  41. text: '清空',
  42. handler: function() {
  43. this.up('form').getForm().reset();
  44. }
  45. },{
  46. text: '保存',
  47. formBind: true, //only enabled once the form is valid
  48. disabled: true,
  49. handler: function() {
  50. var form = this.up('form').getForm();
  51. if (form.isValid()) {
  52. form.submit({
  53. success: function(form, action) {
  54. Ext.Msg.alert('Success', action.result.msg);
  55. },
  56. failure: function(form, action) {
  57. Ext.Msg.alert('Failed', action.result.msg);
  58. }
  59. });
  60. }
  61. }
  62. }],
  63. initComponent : function(){
  64. this.loadConfigs(this.caller, this.setConfigs,this);
  65. this.callParent(arguments);
  66. },
  67. loadConfigs: function(caller, callback,panel) {
  68. Ext.Ajax.request({
  69. url: basePath + 'ma/setting/configs.action?caller=' + caller,
  70. method: 'GET',
  71. callback: function(opt, s, r) {
  72. if(r && r.status == 200) {
  73. var res = Ext.JSON.decode(r.responseText);
  74. callback.call(null, res,panel);
  75. }
  76. }
  77. });
  78. },
  79. setConfigs: function(configs,panel) {
  80. var me = this,items = [];
  81. Ext.Array.each(configs, function(c, i){
  82. switch(c.data_type) {
  83. case 'YN':
  84. items.push({
  85. xtype: 'checkbox',
  86. boxLabel: c.title,
  87. name: c.code,
  88. id: c.id,
  89. checked: c.data == 1,
  90. columnWidth: 1,
  91. margin: c.help ? '4 8 0 8' : '4 8 4 8'
  92. });
  93. break;
  94. case 'RADIO':
  95. var s = [];
  96. Ext.Array.each(c.properties, function(p){
  97. s.push({
  98. name: c.code,
  99. boxLabel: p.display,
  100. inputValue: p.value,
  101. checked: p.value == c.data
  102. });
  103. });
  104. items.push({
  105. xtype: 'radiogroup',
  106. id: c.id,
  107. fieldLabel: c.title,
  108. columnWidth: 1,
  109. columns: 2,
  110. vertical: true,
  111. items: s
  112. });
  113. break;
  114. case 'COLOR':
  115. items.push({
  116. xtype: 'colorfield',
  117. fieldLabel: c.title,
  118. id: c.id,
  119. name: c.code,
  120. value: c.data,
  121. readOnly: c.editable == 0,
  122. editable: c.editable == 1,
  123. labelWidth: 150
  124. });
  125. break;
  126. case 'NUMBER':
  127. items.push({
  128. xtype: 'numberfield',
  129. fieldLabel: c.title,
  130. id: c.id,
  131. name: c.code,
  132. value: c.data,
  133. readOnly: c.editable == 0,
  134. labelWidth: 150
  135. });
  136. break;
  137. default :
  138. if(c.multi == 1) {
  139. var data = c.data ? c.data.split('\n') : [null], s = [];
  140. Ext.Array.each(data, function(d){
  141. s.push({
  142. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  143. name: c.dbfind || c.code,
  144. value: d,
  145. readOnly: !c.dbfind && c.editable == 0,
  146. editable: c.editable == 1,
  147. clearable: true
  148. });
  149. });
  150. s.push({
  151. xtype: 'button',
  152. text: '添加',
  153. width: 22,
  154. cls: 'x-dd-drop-ok-add',
  155. iconCls: 'x-dd-drop-icon',
  156. iconAlign: 'right',
  157. config: c
  158. });
  159. items.push({
  160. xtype: 'fieldset',
  161. title: c.title,
  162. id: c.id,
  163. name: c.code,
  164. columnWidth: 1,
  165. layout: 'column',
  166. defaults: {
  167. columnWidth: .25,
  168. margin: '4 8 4 8'
  169. },
  170. items: s
  171. });
  172. } else {
  173. items.push({
  174. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  175. fieldLabel: c.title,
  176. id: c.id,
  177. name: c.dbfind || c.code,
  178. value: c.data,
  179. readOnly: !c.dbfind && c.editable == 0,
  180. editable: c.editable == 1,
  181. clearable: true,
  182. columnWidth: .5,
  183. labelWidth: 150
  184. });
  185. }
  186. break;
  187. }
  188. if(c.help) {
  189. items.push({
  190. xtype: 'displayfield',
  191. value: c.help,
  192. columnWidth: ['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1 ? .5 : 1,
  193. cls: 'help-block',
  194. margin: '4 8 8 8'
  195. });
  196. } else {
  197. if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
  198. items.push({
  199. xtype: 'displayfield'
  200. });
  201. }
  202. }
  203. });
  204. if(items.length == 0)
  205. items.push({
  206. html: '没有参数配置',
  207. cls: 'x-form-empty'
  208. });
  209. panel.add(items);
  210. }
  211. });