ModuleSetPortal.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. console.log(item);
  106. }
  107. }
  108. }
  109. });
  110. break;
  111. case 'COLOR':
  112. items.push({
  113. xtype: 'colorfield',
  114. fieldLabel: c.title,
  115. id:"configs-"+c.id,
  116. name: c.code,
  117. value: c.data,
  118. readOnly: c.editable == 0,
  119. editable: c.editable == 1,
  120. labelWidth: 150,
  121. columnWidth:0.5
  122. });
  123. break;
  124. case 'NUMBER':
  125. items.push({
  126. xtype: 'numberfield',
  127. fieldLabel: c.title,
  128. id:"configs-"+c.id,
  129. name: c.code,
  130. value: c.data,
  131. readOnly: c.editable == 0,
  132. labelWidth: 150,
  133. //maxWidth:400,
  134. columnWidth:panel.itemColumnWidth || .5,
  135. help:c.help,
  136. clearable: true,
  137. afterLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  138. listeners:{
  139. render : function(field) {
  140. var p = document.createElement("td");
  141. //padding:2cm 4cm 3cm 4cm;
  142. p.setAttribute('style'," color:gray; width:100px;line-height:22px;");
  143. var redStar = document.createTextNode('光标离开完成修改');
  144. p.appendChild(redStar);
  145. field.el.dom.firstChild.firstChild.appendChild(p);
  146. },
  147. click: {
  148. element: 'labelEl',
  149. fn: function(e,el) {
  150. var target = e.getTarget('.help-terms'),
  151. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  152. e.preventDefault();
  153. item.up('modulesetportal').setHelp(item.help,e);
  154. console.log(item);
  155. }
  156. }
  157. }
  158. });
  159. break;
  160. default :
  161. if(c.multi == 1) {
  162. var data = c.data ? c.data.split('\n') : [null], s = [];
  163. Ext.Array.each(data, function(d){
  164. s.push({
  165. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  166. name: c.dbfind || c.code,
  167. value: d,
  168. readOnly: !c.dbfind && c.editable == 0,
  169. editable: c.editable == 1,
  170. clearable: true
  171. });
  172. });
  173. s.push({
  174. xtype: 'button',
  175. text: '添加',
  176. width: 22,
  177. maxWidth:22,
  178. cls: 'x-dd-drop-ok-add',
  179. iconCls: 'x-dd-drop-icon',
  180. iconAlign: 'right',
  181. config: c
  182. });
  183. items.push({
  184. xtype: 'fieldset',
  185. title: c.title,
  186. id:"configs-"+c.id,
  187. name: c.code,
  188. columnWidth:1,
  189. layout: 'column',
  190. defaults: {
  191. columnWidth: .25,
  192. margin: '4 8 4 8'
  193. },
  194. items: s
  195. });
  196. } else {
  197. items.push({
  198. xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
  199. fieldLabel: c.title,
  200. afterLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=configs-'+c.id+'>?</a>':'',
  201. id:"configs-"+c.id,
  202. name: c.dbfind || c.code,
  203. value: c.data,
  204. help:c.help,
  205. readOnly: !c.dbfind && c.editable == 0,
  206. editable: c.editable == 1,
  207. clearable: true,
  208. columnWidth: .4,
  209. labelWidth: 150,
  210. dbCaller:c.caller,
  211. //minWidth:300,
  212. listeners: {
  213. click: {
  214. element: 'labelEl',
  215. fn: function(e,el) {
  216. var target = e.getTarget('.help-terms'),
  217. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  218. e.preventDefault();
  219. item.up('modulesetportal').setHelp(item.help,e);
  220. }
  221. }
  222. }
  223. });
  224. }
  225. break;
  226. }
  227. if(c.help) {
  228. /*items.push({
  229. xtype: 'fieldset',
  230. html: c.help,
  231. columnWidth:1,
  232. title:'详细描述',
  233. collapsible: true,
  234. collapsed: true,
  235. //cls: 'help-block',
  236. margin: '4 8 8 8'
  237. });*/
  238. } else {
  239. if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
  240. items.push({
  241. xtype: 'displayfield'
  242. });
  243. }
  244. }
  245. });
  246. if(items.length == 0)
  247. items.push({
  248. html: '没有参数配置',
  249. cls: 'x-form-empty'
  250. });
  251. panel.add(items);
  252. },
  253. setInterceptors: function(Interceptors,panel) {
  254. var me = this,items = [];
  255. Ext.Array.each(Interceptors, function(c, i){
  256. items.push({
  257. xtype: 'checkbox',
  258. boxLabel: c.title,
  259. checked: c.data == 1,
  260. columnWidth:.5,
  261. margin: '0 5 0 0',
  262. allowBlank: false,
  263. id:"interceptors-"+c.id,
  264. help:c.help,
  265. afterBoxLabelTextTpl:c.help?'<a href="#" class="help-terms" itemId=interceptors-'+c.id+'>?</a>':'',
  266. listeners: {
  267. click: {
  268. element: 'boxLabelEl',
  269. fn: function(e,el) {
  270. var target = e.getTarget('.help-terms'),
  271. win,itemId=el.getAttribute("itemId"),item=Ext.getCmp(itemId);
  272. e.preventDefault();
  273. item.up('modulesetportal').setHelp(item.help,e);
  274. }
  275. }
  276. }
  277. });
  278. if(c.help) {
  279. /*items.push({
  280. xtype: 'fieldset',
  281. html: c.help,
  282. columnWidth:1,
  283. title:'详细描述',
  284. collapsible: true,
  285. collapsed: true,
  286. //cls: 'help-block',
  287. margin: '4 8 8 8'
  288. });*/
  289. } else {
  290. if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
  291. items.push({
  292. xtype: 'displayfield'
  293. });
  294. }
  295. }
  296. });
  297. if(items.length>0)
  298. panel.add(items);
  299. },
  300. loadInterceptors: function(condition, callback,panel) {
  301. Ext.Ajax.request({
  302. url: basePath + 'ma/setting/getInterceptorsByCondition.action?condition=' + condition,
  303. method: 'GET',
  304. callback: function(opt, s, r) {
  305. if(r && r.status == 200) {
  306. var res = Ext.JSON.decode(r.responseText);
  307. callback.call( null,res,panel);
  308. }
  309. }
  310. });
  311. },
  312. getTip: function(position) {
  313. var tip = this.tip
  314. if (!tip) {
  315. tip = this.tip = Ext.widget('tooltip', {
  316. title: '详细描述:',
  317. minWidth: 200,
  318. autoHide: true,
  319. anchor: 'top',
  320. closable: true,
  321. cls: 'errors-tip'
  322. });
  323. }
  324. tip.showAt([position[0]-19,position[1]+9]);
  325. return tip;
  326. },
  327. setHelp: function(help,e) {
  328. var me = this,
  329. tip = me.getTip(e.getXY());
  330. if (help) {
  331. tip.setDisabled(false);
  332. tip.update(me.tipTpl.apply({help:help}));
  333. } else {
  334. tip.hide();
  335. }
  336. },
  337. showResult : function(title,format,btn){
  338. if(!msgCt){
  339. msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
  340. }
  341. var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1));
  342. var m = Ext.DomHelper.append(msgCt, createBox(title, s), true);
  343. m.hide();
  344. m.slideIn('t').ghost("t", { delay: 1000, remove: true});
  345. }
  346. });