LogoSet.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Ext.define('erp.view.ma.LogoSet',{
  2. extend: 'Ext.Viewport',
  3. layout: 'fit',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. xtype: "window",
  10. title:'上传Logo',
  11. autoShow: true,
  12. closable: false,
  13. maximizable : true,
  14. width: 605,
  15. height: 300,
  16. layout: 'fit',
  17. items: [{
  18. xtype:'form',
  19. frame:true,
  20. layout:'vbox',
  21. fieldDefaults : {
  22. margin : '2 2 2 2',
  23. fieldStyle : "background:#FFFAFA;color:#515151;",
  24. labelAlign : "right",
  25. blankText : $I18N.common.form.blankText
  26. },
  27. items:[{
  28. xtype: 'filefield',
  29. columnWidth:1,
  30. name: 'file',
  31. labelWidth:300,
  32. labelSeparator:'',
  33. fieldLabel:'<div style="color:blue;padding-left:10px;">Logo目前只支持小于8K图片(像素:85*30)</div>',
  34. allowBlank: false,
  35. buttonOnly:true,
  36. buttonConfig:{
  37. text:'选择图片',
  38. iconCls:'x-button-icon-pic'
  39. },
  40. listeners: {
  41. change: function(field){
  42. field.ownerCt.upload(field);
  43. }
  44. }
  45. },{
  46. xtype: 'image',
  47. width: 85,
  48. height: 30,
  49. id:'logo',
  50. margins:'30 255 50 255'
  51. }],
  52. upload: function(field){
  53. if(field.ownerCt.down('image').hidden){
  54. field.ownerCt.getForm().submit({
  55. url: basePath + 'ma/logo/save.action',
  56. waitMsg:'正在上传',
  57. success: function(fp, o){
  58. if(o.result.success){
  59. Ext.Msg.alert('提示','更新成功');
  60. var logo=Ext.getCmp('logo');
  61. logo.show();
  62. logo.setSrc(basePath+'ma/logo/get.action');
  63. }else Ext.Msg.alert('提示','上传失败,请检查文件大小及格式!');
  64. },
  65. failure:function(fp,o){
  66. Ext.Msg.alert('提示','上传失败,请检查文件大小及格式!');
  67. }
  68. });
  69. }else Ext.Msg.alert('提示','已存在Logo,请先删除!');
  70. },
  71. }],
  72. buttonAlign:'center',
  73. buttons:[{
  74. text: $I18N.common.button.erpDeleteButton,
  75. iconCls: 'x-button-icon-delete',
  76. cls: 'x-btn-gray',
  77. width: 60,
  78. handler: function(btn){
  79. var logo=Ext.getCmp('logo');
  80. if(!logo.src) alert('未上传任何logo,无法删除!');
  81. else {
  82. Ext.Ajax.request({
  83. url: basePath + 'ma/logo/del.action',
  84. success: function(fp, o){
  85. Ext.Msg.alert('提示','删除成功!');
  86. logo.hide();
  87. }
  88. })
  89. }
  90. }
  91. },{
  92. text: $I18N.common.button.erpCloseButton,
  93. iconCls: 'x-button-icon-close',
  94. cls: 'x-btn-gray',
  95. width: 60,
  96. handler: function(btn){
  97. var main = parent.Ext.getCmp("content-panel");
  98. if(main){
  99. main.getActiveTab().close();
  100. }
  101. }
  102. }]
  103. }]
  104. });
  105. me.callParent(arguments);
  106. }
  107. });