ModuleSetPortal.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. Ext.define('erp.view.sys.base.ModuleSetPortal',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.modulesetportal',
  4. autoScroll : true,
  5. labelSeparator : ':',
  6. buttonAlign : 'center',
  7. bodyStyle : 'background:#f9f9f9;',
  8. fieldDefaults : {
  9. msgTarget: 'none',
  10. blankText : $I18N.common.form.blankText
  11. },
  12. bodyBorder: false,
  13. border: false,
  14. FormUtil: Ext.create('erp.util.FormUtil'),
  15. BaseUtil: Ext.create('erp.util.BaseUtil'),
  16. layout:'column',
  17. //glyph:'66@My Font Family',
  18. items:[{
  19. xtype:'label',
  20. html:'<span style="font-weight:bold;" >基础设置 <span style="color:gray;font-size:10px!important; ">(点击 ? 可查看设置项详细描述)</span></span>',
  21. columnWidth:1,
  22. margin:'0 0 0 0'
  23. }],
  24. defaults:{
  25. xtype:'textfield',
  26. columnWidth:0.33,
  27. margin:'5 5 5 5'
  28. },
  29. tipTpl: Ext.create('Ext.XTemplate', '<ul class="' + Ext.plainListCls + '"><tpl for="."><li><span class="field-name">{help}</span>!</li></tpl></ul>'),
  30. initComponent : function(){
  31. this.loadConfigs(this.condition,this.setConfigs,this);
  32. this.loadInterceptors(this.condition, this.setInterceptors,this);
  33. this.callParent(arguments);
  34. },
  35. loadConfigs: function(condition, callback,panel) {
  36. condition=condition==null?"caller="+this.caller:condition;
  37. Ext.Ajax.request({
  38. url: basePath + 'ma/setting/getConfigsByCondition.action?condition='+condition,
  39. method: 'GET',
  40. callback: function(opt, s, r) {
  41. if(r && r.status == 200) {
  42. var res = Ext.JSON.decode(r.responseText);
  43. callback.call(null, res,panel);
  44. }
  45. }
  46. });
  47. },
  48. setConfigs: function(configs,panel) {
  49. var me = this,items = [];
  50. Ext.Array.each(configs, function(c, i){
  51. switch(c.data_type) {
  52. case 'YN':
  53. items.push({
  54. xtype: 'checkbox',
  55. boxLabel: c.title,
  56. name: c.code,
  57. checked: c.data == 1,
  58. columnWidth:panel.itemColumnWidth||.5,
  59. margin: '0 5 0 0',
  60. allowBlank: false,
  61. id:"configs-"+c.id,
  62. help:c.help,
  63. afterBoxLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  64. listeners: {
  65. click: {
  66. element: 'boxLabelEl',
  67. fn: function(e,el) {
  68. var target = e.getTarget('.help-terms'),
  69. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  70. e.preventDefault();
  71. item.up('modulesetportal').setHelp(item.help,e);
  72. }
  73. }
  74. }
  75. });
  76. break;
  77. case 'RADIO':
  78. var s = [];
  79. Ext.Array.each(c.properties, function(p){
  80. s.push({
  81. name: c.code,
  82. boxLabel: p.display,
  83. inputValue: p.value,
  84. checked: p.value == c.data
  85. });
  86. });
  87. items.push({
  88. xtype: 'radiogroup',
  89. id:"configs-"+c.id,
  90. fieldLabel: c.title,
  91. columnWidth: panel.itemColumnWidth || .5,
  92. columns: 1,
  93. vertical: true,
  94. items: s,
  95. help:c.help,
  96. afterLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  97. listeners: {
  98. click: {
  99. element: 'labelEl',
  100. fn: function(e,el) {
  101. var target = e.getTarget('.help-terms'),
  102. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  103. e.preventDefault();
  104. item.up('modulesetportal').setHelp(item.help,e);
  105. }
  106. }
  107. }
  108. });
  109. break;
  110. case 'COLOR':
  111. items.push({
  112. xtype: 'colorfield',
  113. fieldLabel: c.title,
  114. id:"configs-"+c.id,
  115. name: c.code,
  116. value: c.data,
  117. readOnly: c.editable == 0,
  118. editable: c.editable == 1,
  119. labelWidth: 150,
  120. columnWidth:0.5
  121. });
  122. break;
  123. case 'NUMBER':
  124. items.push({
  125. xtype: 'numberfield',
  126. fieldLabel: c.title,
  127. id:"configs-"+c.id,
  128. name: c.code,
  129. value: c.data,
  130. readOnly: c.editable == 0,
  131. labelWidth: 150,
  132. //maxWidth:400,
  133. columnWidth:panel.itemColumnWidth || .5,
  134. help:c.help,
  135. clearable: true,
  136. afterLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  137. listeners:{
  138. render : function(field) {
  139. var p = document.createElement("td");
  140. //padding:2cm 4cm 3cm 4cm;
  141. p.setAttribute('style'," color:gray; width:100px;line-height:22px;");
  142. var redStar = document.createTextNode('光标离开完成修改');
  143. p.appendChild(redStar);
  144. field.el.dom.firstChild.firstChild.appendChild(p);
  145. },
  146. click: {
  147. element: 'labelEl',
  148. fn: function(e,el) {
  149. var target = e.getTarget('.help-terms'),
  150. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  151. e.preventDefault();
  152. item.up('modulesetportal').setHelp(item.help,e);
  153. }
  154. }
  155. }
  156. });
  157. break;
  158. default :
  159. if(c.multi == 1) {
  160. var data = c.data ? c.data.split('\n') : [null], s = [];
  161. Ext.Array.each(data, function(d){
  162. s.push({
  163. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  164. name: c.dbfind || c.code,
  165. value: d,
  166. readOnly: !c.dbfind && c.editable == 0,
  167. editable: c.editable == 1,
  168. clearable: true
  169. });
  170. });
  171. s.push({
  172. xtype: 'button',
  173. text: '添加',
  174. width: 22,
  175. maxWidth:22,
  176. cls: 'x-dd-drop-ok-add',
  177. iconCls: 'x-dd-drop-icon',
  178. iconAlign: 'right',
  179. config: c
  180. });
  181. items.push({
  182. xtype: 'fieldset',
  183. title: c.title,
  184. id:"configs-"+c.id,
  185. name: c.code,
  186. columnWidth:1,
  187. layout: 'column',
  188. defaults: {
  189. columnWidth: .25,
  190. margin: '4 8 4 8'
  191. },
  192. items: s
  193. });
  194. } else {
  195. items.push({
  196. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  197. fieldLabel: c.title,
  198. afterLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  199. id:"configs-"+c.id,
  200. name: c.dbfind || c.code,
  201. value: c.data,
  202. help:c.help,
  203. readOnly: !c.dbfind && c.editable == 0,
  204. editable: c.editable == 1,
  205. clearable: true,
  206. columnWidth: .4,
  207. labelWidth: 150,
  208. dbCaller:c.caller,
  209. //minWidth:300,
  210. listeners: {
  211. click: {
  212. element: 'labelEl',
  213. fn: function(e,el) {
  214. var target = e.getTarget('.help-terms'),
  215. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  216. e.preventDefault();
  217. item.up('modulesetportal').setHelp(item.help,e);
  218. }
  219. }
  220. }
  221. });
  222. }
  223. break;
  224. }
  225. if(c.help) {
  226. /*items.push({
  227. xtype: 'fieldset',
  228. html: c.help,
  229. columnWidth:1,
  230. title:'详细描述',
  231. collapsible: true,
  232. collapsed: true,
  233. //cls: 'help-block',
  234. margin: '4 8 8 8'
  235. });*/
  236. } else {
  237. if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
  238. items.push({
  239. xtype: 'displayfield'
  240. });
  241. }
  242. }
  243. });
  244. if(items.length == 0)
  245. items.push({
  246. html: '没有参数配置',
  247. cls: 'x-form-empty'
  248. });
  249. panel.add(items);
  250. },
  251. setInterceptors: function(Interceptors,panel) {
  252. var me = this,items = [];
  253. Ext.Array.each(Interceptors, function(c, i){
  254. items.push({
  255. xtype: 'checkbox',
  256. boxLabel: c.title,
  257. checked: c.data == 1,
  258. columnWidth:.5,
  259. margin: '0 5 0 0',
  260. allowBlank: false,
  261. id:"interceptors-"+c.id,
  262. help:c.help,
  263. afterBoxLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=interceptors-'+c.id+'>?</a>':'',
  264. listeners: {
  265. click: {
  266. element: 'boxLabelEl',
  267. fn: function(e,el) {
  268. var target = e.getTarget('.help-terms'),
  269. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  270. e.preventDefault();
  271. item.up('modulesetportal').setHelp(item.help,e);
  272. }
  273. }
  274. }
  275. });
  276. if(c.help) {
  277. /*items.push({
  278. xtype: 'fieldset',
  279. html: c.help,
  280. columnWidth:1,
  281. title:'详细描述',
  282. collapsible: true,
  283. collapsed: true,
  284. //cls: 'help-block',
  285. margin: '4 8 8 8'
  286. });*/
  287. } else {
  288. if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
  289. items.push({
  290. xtype: 'displayfield'
  291. });
  292. }
  293. }
  294. });
  295. if(items.length>0)
  296. panel.add(items);
  297. },
  298. loadInterceptors: function(condition, callback,panel) {
  299. Ext.Ajax.request({
  300. url: basePath + 'ma/setting/getInterceptorsByCondition.action?condition=' + condition,
  301. method: 'GET',
  302. callback: function(opt, s, r) {
  303. if(r && r.status == 200) {
  304. var res = Ext.JSON.decode(r.responseText);
  305. callback.call( null,res,panel);
  306. }
  307. }
  308. });
  309. },
  310. getTip: function(position) {
  311. var tip = this.tip
  312. if (!tip) {
  313. tip = this.tip = Ext.widget('tooltip', {
  314. title: '详细描述:',
  315. minWidth: 200,
  316. autoHide: true,
  317. anchor: 'top',
  318. closable: true,
  319. cls: 'errors-tip'
  320. });
  321. }
  322. tip.showAt([position[0]-19,position[1]+9]);
  323. return tip;
  324. },
  325. setHelp: function(help,e) {
  326. var me = this,
  327. tip = me.getTip(e.getXY());
  328. if (help) {
  329. tip.setDisabled(false);
  330. tip.update(me.tipTpl.apply({help:help}));
  331. } else {
  332. tip.hide();
  333. }
  334. },
  335. showResult : function(title,format,btn){
  336. if(!msgCt){
  337. msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
  338. }
  339. var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1));
  340. var m = Ext.DomHelper.append(msgCt, createBox(title, s), true);
  341. m.hide();
  342. m.slideIn('t').ghost("t", { delay: 1000, remove: true});
  343. }
  344. });