ExcelPanel.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Ext.define('erp.view.excel.ExcelPanel',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpExcelFormPanel',
  4. id: 'excelform',
  5. region: 'north',
  6. frame : true,
  7. layout : 'column',
  8. autoScroll : true,
  9. defaultType : 'textfield',
  10. labelSeparator : ':',
  11. buttonAlign : 'center',
  12. fieldDefaults : {
  13. margin : '2 2 2 2',
  14. fieldStyle : "background:#FFFAFA;color:#515151;",
  15. focusCls: 'x-form-field-cir',//fieldCls
  16. labelAlign : "right",
  17. msgTarget: 'side',
  18. blankText : $I18N.common.form.blankText
  19. },
  20. FormUtil: Ext.create('erp.util.FormUtil'),
  21. params: null,
  22. initComponent : function(){
  23. var id= getUrlParam('id');
  24. id=3008;
  25. this.params={id:id};
  26. this.getItemsAndButtons(this, 'excel/getTemplateCondition.action', this.params );//从后台拿到formpanel的items
  27. this.callParent(arguments);
  28. },
  29. getItemsAndButtons:function(form,url,param){
  30. var me = this;
  31. Ext.Ajax.request({//拿到form的items
  32. url : basePath + url,
  33. params: param,
  34. method : 'post',
  35. callback : function(options,success,response){
  36. var res = new Ext.decode(response.responseText);
  37. if(res.exceptionInfo != null){
  38. showError(res.exceptionInfo);return;
  39. }
  40. var items=res.items;
  41. form.add(items);
  42. /* var buttons = new Array();
  43. buttons.push('->');
  44. var o = {};
  45. o.xtype = 'erpSaveButton';
  46. buttons.push(o);
  47. o.xtype='erpCloseButton';
  48. buttons.push(o);
  49. buttons.push('->');
  50. form.addDocked({
  51. xtype: 'toolbar',
  52. dock: 'bottom',
  53. defaults: {
  54. style: {
  55. marginLeft: '14px'
  56. }
  57. },
  58. items: buttons//12个加进去
  59. });*/
  60. if(res.title && res.title != ''){
  61. form.setTitle(res.title);
  62. }
  63. me.focusFirst(form);
  64. }
  65. });
  66. },
  67. focusFirst: function(form){
  68. var bool = true;
  69. Ext.each(form.items.items, function(){
  70. if(bool && this.hidden == false && this.readOnly == false && this.editable == true){
  71. this.focus(false, 200);
  72. bool = false;
  73. }
  74. });
  75. },
  76. });