Msg.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * 右下角消息提示类型2
  3. */
  4. Ext.define('erp.view.core.window.Msg', {
  5. extend: 'Ext.window.Window',
  6. alias: 'widget.msg',
  7. frame: true,
  8. closable: false,
  9. bodyStyle: 'background: #E0EEEE;',
  10. width: 400,
  11. height: 320,
  12. clientY: 465,
  13. renderTo: Ext.getBody(),
  14. x: screen.width - 400 -10,
  15. y: screen.height - 465 - 10,
  16. tools: [{
  17. type: 'close',
  18. handler: function(btn){
  19. var me = arguments[2].ownerCt;
  20. me.fireEvent('close', me);
  21. me.destroy();
  22. }
  23. }],
  24. autoClose: true,//自动关闭
  25. closeAction: 'destroy',
  26. autoCloseTime: 8000,
  27. isError: true,//是否为出错提示
  28. initComponent: function() {
  29. this.autoCloseTime = this.autoCloseTime || (this.isDebug() ? 60000 : 8000);
  30. this.addEvents({
  31. 'close': true
  32. });
  33. if(!this.isError){
  34. this.buttons = null;
  35. this.clientY = 430;
  36. }
  37. if (this.autoCloseTime <= 3000) {// fast slide in and out
  38. this.width = 300;
  39. this.height = 150;
  40. this.x = screen.width - 300 -10;
  41. this.y = screen.height - 150 - 10;
  42. this.clientY = 300;
  43. this.context = '<font size=4 color=blue>' + this.context + '</font>';
  44. }
  45. this.title = '<div style="height:25;padding-top:5px;color:#FF6A6A;background: #E0EEEE url(' + basePath +
  46. 'resource/ext/resources/themes/images/default/grid/grid-blue-hd.gif) repeat center center">&nbsp;' + this.title + '</div>';
  47. this.callParent(arguments);
  48. this.updatePosition();
  49. this.insertMsg(this.context);
  50. var me = this;
  51. if(me.autoClose){//自动关闭
  52. setTimeout(function(){
  53. me.destroy();
  54. }, me.autoCloseTime);
  55. }
  56. },
  57. bbar: ['->',{
  58. width: 100,
  59. text: '导出错误信息',
  60. cls: 'x-btn-errormsg',
  61. handler: function(btn){
  62. var me = btn.ownerCt.ownerCt;
  63. me.sendError(me);
  64. me.close();
  65. },
  66. listeners:{
  67. afterrender:function(btn){
  68. var me = btn.ownerCt.ownerCt;
  69. if(!me.isDebug()){
  70. btn.hide();
  71. }
  72. }
  73. }
  74. }/*,{
  75. width: 60,
  76. style: {
  77. marginLeft: '3px'
  78. },
  79. text: '帮助',
  80. cls: 'x-btn-blue',
  81. handler: function(btn){
  82. var me = btn.ownerCt.ownerCt;
  83. me.help();
  84. me.close();
  85. }
  86. },{
  87. width: 60,
  88. style: {
  89. marginLeft: '3px'
  90. },
  91. text: '关&nbsp;闭',
  92. cls: 'x-btn-blue',
  93. handler: function(btn){
  94. var me = btn.ownerCt.ownerCt;
  95. me.fireEvent('close', me);
  96. me.destroy();
  97. }
  98. }*/],
  99. updatePosition: function(){
  100. var count = Ext.ComponentQuery.query('msg').length;
  101. this.setPosition(screen.width - this.width - count*30 - 10, screen.height - this.clientY - 10);
  102. this.show();
  103. this.el.slideIn('r', { duration: 500 });
  104. },
  105. insertMsg: function(msg){
  106. this.insert(0, {
  107. xtype: 'panel',
  108. height: '100%',
  109. autoScroll: true,
  110. html: '<div style="font-size:14px;padding: 5px 10px">' + msg + '</div>'
  111. });
  112. },
  113. sendError: function(msg){
  114. var all = msg.context;
  115. var start = all.indexOf('"display:none;">')+16;
  116. var end = all.indexOf('</div></div>');
  117. var error = all.substring(start,end);
  118. //ajax 响应下载必须要创建一个form实例
  119. if (!Ext.fly('formFly')) {
  120. var frm = document.createElement('form');
  121. frm.id = 'formFly';
  122. frm.className = 'x-hidden';
  123. document.body.appendChild(frm);
  124. }
  125. Ext.Ajax.request({
  126. disableCaching: true ,
  127. url : basePath+ 'excel/saveAsTxt.action',
  128. timeout: 100000000,
  129. method : 'post',
  130. isUpload: true,
  131. form: Ext.fly('formFly'),
  132. params : {
  133. error:error
  134. }
  135. });
  136. },
  137. help: function(){
  138. },
  139. isDebug: function() {
  140. return this.context.indexOf('_error_stack') > 0;
  141. }
  142. });