ParamsetPortal.js 4.3 KB

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