LabelForm.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Ext.define('erp.view.scm.reserve.setLabelTemplate.LabelForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpLabelFormPanel',
  4. id: 'labelForm',
  5. region: 'north',
  6. frame : true,
  7. layout : 'column',
  8. autoScroll : true,
  9. defaultType : 'textfield',
  10. labelSeparator : ':',
  11. buttonAlign : 'center',
  12. cls: 'u-form-default',
  13. fieldDefaults : {
  14. fieldStyle : "background:#FFFAFA;color:#515151;",
  15. focusCls: 'x-form-field-cir-focus',
  16. labelAlign : "right",
  17. msgTarget: 'side',
  18. blankText : $I18N.common.form.blankText
  19. },
  20. FormUtil: Ext.create('erp.util.FormUtil'),
  21. BaseUtil: Ext.create('erp.util.BaseUtil'),
  22. keyField: '',
  23. codeField: '',
  24. statusField: '',
  25. params: null,
  26. caller: null,
  27. formCondition:null,
  28. Contextvalue:null,
  29. LastValue:null,
  30. enableTools: true,
  31. enableKeyEvents: true,
  32. _noc: 0,
  33. initComponent : function(){
  34. formCondition = getUrlParam('formCondition');//从url解析参数
  35. formCondition = (formCondition == null) ? "" : formCondition.replace(/IS/g,"=");
  36. var param = {caller: 'LabelTemplateBarcode',condition:'', _noc: (getUrlParam('_noc') || this._noc)};
  37. this.FormUtil.getItemsAndButtons(this, 'common/singleFormItems.action', param);//从后台拿到formpanel的items
  38. this.callParent(arguments);
  39. //给页面加上ctrl+alt+s键盘事件,自动跳转form配置界面
  40. if(this.enableKeyEvents) {
  41. this.addKeyBoardEvents();
  42. }
  43. },
  44. /**
  45. * 监听一些事件
  46. * <br>
  47. * Ctrl+Alt+S 单据配置维护
  48. * Ctrl+Alt+P 参数、逻辑配置维护
  49. */
  50. addKeyBoardEvents: function(){
  51. var me = this;
  52. Ext.EventManager.addListener(document.body, 'keydown', function(e){
  53. if(e.altKey && e.ctrlKey) {
  54. if(e.keyCode == Ext.EventObject.S) {
  55. var url = "jsps/ma/form.jsp?formCondition=fo_idIS" + me.fo_id + "&gridCondition=fd_foidIS" + me.fo_id,
  56. forms = Ext.ComponentQuery.query('form'),
  57. grids = Ext.ComponentQuery.query('gridpanel'),
  58. formSet = [], gridSet = [];
  59. if(forms.length > 0) {
  60. Ext.Array.each(forms, function(f){
  61. f.fo_id && (formSet.push(f.fo_id));
  62. });
  63. }
  64. if(grids.length > 0) {
  65. Ext.Array.each(grids, function(g){
  66. if(g.xtype.indexOf('erpGridPanel') > -1)
  67. gridSet.push(window.caller);
  68. else if(g.caller)
  69. gridSet.push(g.caller);
  70. });
  71. }
  72. if(formSet.length > 0 || gridSet.length > 0) {
  73. url = "jsps/ma/multiform.jsp?formParam=" + formSet.join(',') + '&gridParam=' + gridSet.join(',');
  74. }
  75. me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', url);
  76. } else if(e.keyCode == Ext.EventObject.P) {
  77. me.FormUtil.onAdd('configs-' + caller, '逻辑配置维护(' + caller + ')', "jsps/ma/logic/config.jsp?whoami=" + caller);
  78. }
  79. }
  80. });
  81. },
  82. getDataByField : function(field) {
  83. var form = this, f = form.child('#' + field);
  84. return f ? "'" + f.getValue() + "'" : '';
  85. },
  86. getYearmonthByField : function(field) {
  87. var form = this;
  88. var f = form.child('#' + field),
  89. v = f ? (Ext.isDate(f.value) ? f.value : Ext.Date.parse(f.value, 'Y-m-d')) : new Date();
  90. return Ext.Date.format(v, 'Ym');
  91. }
  92. });