InfoPanel.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. Ext.define('erp.view.opensys.home.InfoPanel', {
  2. extend: 'Ext.panel.Panel',
  3. alias: 'widget.infopanel',
  4. id:'infopanel',
  5. title:'消息中心',
  6. region: 'center',
  7. border: false,
  8. /* split: true,*/
  9. flex: 2,
  10. autoScroll: true,
  11. layout:'fit',
  12. initComponent: function(){
  13. this.addEvents(
  14. 'rowdblclick',
  15. 'select'
  16. );
  17. Ext.apply(this, {
  18. items:[
  19. Ext.widget('panel',{
  20. layout: 'anchor',
  21. border:true,
  22. items:[
  23. Ext.widget('gridpanel',{
  24. columnLines : false,
  25. id:'curnotifygridpanel',
  26. autoScroll : true,
  27. anchor:'100% 100%',
  28. layout:'fit',
  29. store: Ext.create('Ext.data.Store', {
  30. fields:['CN_ID','CN_DESC','CN_MAN','CN_DATE','CN_KEYFIELD','CN_KEYVALUE','CN_URL'],
  31. data: []
  32. }),
  33. columns: [{
  34. text: '标题',
  35. dataIndex: 'CN_DESC',
  36. cls:'x-grid-header-simple',
  37. flex: 1,
  38. sortable:false,
  39. renderer:function(val,meta,record){
  40. var url=record.get('CN_URL');
  41. if(contains(url, '?', true)){
  42. url= url + '&formCondition=' + record.get('CN_KEYFIELD')+'IS'+record.get('CN_KEYVALUE');
  43. } else {
  44. url= url + '?&formCondition=' + record.get('CN_KEYFIELD')+'IS'+record.get('CN_KEYVALUE');
  45. }
  46. return Ext.String.format('<span style="color:#436EEE;padding-left:2px;"><a href="javascript:openTable(\''+val+'\',\''+url+'\',null);" target="_blank" style="padding-left:2px">{0}&nbsp;</a></span>',
  47. val
  48. );
  49. }
  50. },{
  51. text:'发送人',
  52. cls:'x-grid-header-simple',
  53. width:100,
  54. dataIndex:'CN_MAN',
  55. renderer:function(value){
  56. return value;
  57. }
  58. },{
  59. text: '发送时间',
  60. cls:'x-grid-header-simple',
  61. xtype:'datecolumn',
  62. dataIndex: 'CN_DATE',
  63. width: 200,
  64. renderer:function(value){
  65. return Ext.Date.format(new Date(value),'Y-m-d H:i:s');
  66. }
  67. }]
  68. })]
  69. })]
  70. });
  71. this.getData();
  72. this.callParent(arguments);
  73. },
  74. getData:function(){
  75. var con='cn_enuu='+enUU+' and cn_emuu='+emUU;
  76. var me=this;
  77. Ext.Ajax.request({
  78. url : basePath + 'opensys/getCurNotify.action',
  79. async: false,
  80. params: {
  81. condition:con
  82. },
  83. method : 'get',
  84. callback : function(opt, s, res){
  85. var r = new Ext.decode(res.responseText);
  86. if(r.exceptionInfo){
  87. showError(r.exceptionInfo);return;
  88. } else if(r.success && r.data){
  89. Ext.getCmp('curnotifygridpanel').store.loadData(r.data);
  90. }
  91. }
  92. });
  93. },
  94. onRowDblClick: function(view, record, item, index, e) {
  95. this.fireEvent('rowdblclick', this, this.store.getAt(index));
  96. },
  97. onSelect: function(model, selections){
  98. var selected = selections[0];
  99. if (selected) {
  100. this.fireEvent('select', this, selected);
  101. }
  102. },
  103. onLoad: function(store, records, success) {
  104. if (this.getStore().getCount()) {
  105. this.getSelectionModel().select(0);
  106. }
  107. },
  108. onProxyException: function(proxy, response, operation) {
  109. Ext.Msg.alert("Error with data from server", operation.error);
  110. this.view.el.update('');
  111. // Update the detail view with a dummy empty record
  112. this.fireEvent('select', this, {data:{}});
  113. },
  114. loadFeed: function(url){
  115. var store = this.store;
  116. store.getProxy().extraParams.feed = url;
  117. store.load();
  118. },
  119. formatTitle: function(value, p, record){
  120. return Ext.String.format('<div class="topic"><b>{0}</b><span class="author">{1}</span></div>', value, record.get('author') || "Unknown");
  121. },
  122. formatDate: function(date){
  123. if (!date) {
  124. return '';
  125. }
  126. var now = new Date(), d = Ext.Date.clearTime(now, true), notime = Ext.Date.clearTime(date, true).getTime();
  127. if (notime === d.getTime()) {
  128. return 'Today ' + Ext.Date.format(date, 'g:i a');
  129. }
  130. d = Ext.Date.add(d, 'd', -6);
  131. if (d.getTime() <= notime) {
  132. return Ext.Date.format(date, 'D g:i a');
  133. }
  134. return Ext.Date.format(date, 'Y/m/d g:i a');
  135. }
  136. });