MailDetailForm.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Ext.define('erp.view.oa.mail.MailDetailForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpMailDetailFormPanel',
  4. id: 'form',
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. region: 'center',
  7. frame : true,
  8. fieldDefaults: {
  9. labelWidth: 55,
  10. cls: 'form-field-allowBlank'
  11. },
  12. layout: {
  13. type: 'vbox',//hbox水平盒布局
  14. align: 'stretch' // Child items are stretched to full width子面板高度充满父容器
  15. },
  16. items: [{
  17. xtype: 'displayfield',
  18. fieldLabel: '发件人',
  19. id:'ma_from',
  20. name: 'ma_from'
  21. }, {
  22. xtype: 'displayfield',
  23. fieldLabel: '时间',
  24. id:'ma_senddate',
  25. name: 'ma_senddate'
  26. }, {
  27. xtype: 'displayfield',
  28. fieldLabel: '收件人',
  29. id:'ma_to',
  30. name: 'ma_to'
  31. }, {
  32. xtype: 'displayfield',
  33. fieldLabel: '主题',
  34. name: 'ma_subject',
  35. id: 'ma_subject'
  36. }, {
  37. xtype: 'displayfield',
  38. fieldLabel: '附件',
  39. name: 'ma_attach',
  40. id: 'ma_attach'
  41. },{
  42. xtype: 'htmleditor',
  43. hideLabel: true,
  44. autoScroll: true,
  45. height: height*0.8,
  46. name: 'ma_context',
  47. id: 'ma_context',
  48. anchor: '100%'//编辑框******
  49. }],
  50. buttonAlign: 'center',
  51. buttons: [{
  52. id: 'post',
  53. text: '回复',
  54. iconCls: 'group-read',
  55. cls: 'x-btn-gray'
  56. },{
  57. id: 'save',
  58. text: '删除',
  59. iconCls: 'group-delete',
  60. cls: 'x-btn-gray'
  61. },{
  62. id: 'close',
  63. text: '转发',
  64. iconCls: 'group-post',
  65. cls: 'x-btn-gray'
  66. }, {
  67. id: 'close',
  68. text: '关闭',
  69. iconCls: 'group-close',
  70. cls: 'x-btn-gray'
  71. }],
  72. initComponent : function(){
  73. this.callParent(arguments);
  74. this.getMailDetail(getUrlParam('id'));
  75. },
  76. getMailDetail: function(id){
  77. var me = this;
  78. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(true);//loading...
  79. Ext.Ajax.request({//拿到grid的columns
  80. url : basePath + "oa/mail/getMailDetail.action",
  81. params: {
  82. id: id
  83. },
  84. method : 'post',
  85. callback : function(options, success, response){
  86. parent.Ext.getCmp("content-panel").getActiveTab().setLoading(false);
  87. var res = new Ext.decode(response.responseText);
  88. if(res.exceptionInfo){
  89. showError(res.exceptionInfo);return;
  90. }
  91. if(!res.mail){
  92. return;
  93. } else {
  94. Ext.getCmp('ma_from').setValue(res.mail.ma_from + "&nbsp;&nbsp;<a class='mail-attach'>添加好友</a>"
  95. + "&nbsp;&nbsp;<a class='mail-attach'>查看往来邮件</a>");
  96. var day = new Date(Date.parse(res.mail.ma_senddate.replace(/-/g, '/'))); //将日期值格式化
  97. var today = new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
  98. Ext.getCmp('ma_senddate').setValue(res.mail.ma_senddate + "(" + today[day.getDay()] + ")");
  99. Ext.getCmp('ma_to').setValue(res.mail.ma_receaddr);
  100. Ext.getCmp('ma_subject').setValue(res.mail.ma_subject);
  101. Ext.getCmp('ma_context').setValue(res.mail.ma_context);
  102. if(res.mail.ma_attach != null){
  103. var attach = res.mail.ma_attach.split(';');
  104. var text = "";
  105. Ext.each(attach, function(a, index){
  106. var path = a.toString();
  107. if(me.BaseUtil.contains(a, '\\', true)){
  108. text += "&nbsp;&nbsp;<a class='mail-attach' href='" + basePath + "common/download.action?path=" + path + "'>" + a.substring(a.lastIndexOf('\\') + 1) + "</a>";
  109. } else {
  110. text += "&nbsp;&nbsp;<a class='mail-attach' href='" + basePath + "common/download.action?path=" + path + "'>" + a.substring(a.lastIndexOf('/') + 1) + "</a>";
  111. }
  112. });
  113. Ext.getCmp('ma_attach').setValue(text);
  114. } else {
  115. Ext.getCmp('ma_attach').hide();
  116. }
  117. }
  118. }
  119. });
  120. }
  121. });