Reply.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * grid,tip显示多次回复信息
  3. */
  4. Ext.define('erp.view.b2b.sale.plugin.Reply', {
  5. ptype : 'salereply',
  6. constructor : function(cfg) {
  7. if (cfg) {
  8. Ext.apply(this, cfg);
  9. }
  10. },
  11. init : function(grid) {
  12. this.grid = grid;
  13. var me = this, view = grid.view.normalView || grid.view;
  14. if (view) {
  15. view.on({
  16. scope: me,
  17. render: me.renderTip,
  18. uievent: me.currentUI
  19. });
  20. grid.on({
  21. scope: me,
  22. reconfigure: me.getReply
  23. });
  24. }
  25. },
  26. renderTip: function(view) {
  27. if (!view.tip) {
  28. var me = this;
  29. view.tip = me.createTip(view);
  30. view.tip.on({
  31. beforeshow : function() {
  32. return view.tip._visible;
  33. }
  34. });
  35. }
  36. },
  37. currentUI : function(type, view, cell, recordIndex, cellIndex, e) {
  38. this.activeIndex = {x: cellIndex, y: recordIndex};
  39. if(view.tip) {
  40. if(this.tipStore && this.tipStore.length > 0) {
  41. var column = view.headerCt.getGridColumns()[this.activeIndex.x];
  42. if(column && ['sd_replyqty', 'sd_replydate', 'sd_replydetail'].indexOf(column.dataIndex) > -1) {
  43. view.tip._visible = true;
  44. this.updateTipBody(view, view.tip);
  45. view.tip.show();
  46. } else {
  47. view.tip._visible = false;
  48. view.tip.hide();
  49. }
  50. } else {
  51. view.tip._visible = false;
  52. view.tip.hide();
  53. }
  54. }
  55. },
  56. createTip : function(view) {
  57. return Ext.create('Ext.tip.ToolTip', {
  58. target : view.el,
  59. delegate : view.itemSelector,
  60. trackMouse : true,
  61. renderTo : Ext.getBody(),
  62. maxWidth : 580,
  63. showDelay : 100,
  64. items : [ {
  65. xtype : 'grid',
  66. width : 580,
  67. columns : [ {
  68. text : '类型',
  69. cls : 'x-grid-header-1',
  70. dataIndex : 'sr_type',
  71. width : 90
  72. }, {
  73. text : '时间',
  74. cls : 'x-grid-header-1',
  75. xtype : 'datecolumn',
  76. dataIndex : 'sr_date',
  77. format:'Y-m-d',
  78. width : 90
  79. }, {
  80. text : '回复人',
  81. cls : 'x-grid-header-1',
  82. dataIndex : 'sr_recorder',
  83. width : 70
  84. },{
  85. text: '数量',
  86. cls : 'x-grid-header-1',
  87. xtype : 'numbercolumn',
  88. align: 'right',
  89. dataIndex : 'sr_qty',
  90. width : 70
  91. }, {
  92. text : '回复交期',
  93. cls : 'x-grid-header-1',
  94. xtype : 'datecolumn',
  95. dataIndex : 'sr_delivery',
  96. width : 90
  97. },{
  98. text: '备注',
  99. cls : 'x-grid-header-1',
  100. dataIndex: 'sr_remark',
  101. width: 140
  102. } ],
  103. columnLines : true,
  104. store : new Ext.data.Store({
  105. fields : ['sr_type', { name: 'sr_date', type: 'date', dateFormat: 'Y-m-d'}, 'sr_recorder', 'sr_qty', 'sr_delivery', 'sr_remark', 'sr_sacode', 'sr_sddetno' ],
  106. data : [ {} ]
  107. })
  108. } ]
  109. });
  110. },
  111. updateTipBody : function(view, tip) {
  112. var me = this, record = me.grid.store.getAt(me.activeIndex.y);
  113. if (record && me.tipStore) {
  114. var c = record.get('sd_detno'), data = new Array();
  115. Ext.each(me.tipStore, function(d) {
  116. if (d.sr_sddetno == c) {
  117. data.push(d);
  118. }
  119. });
  120. tip.down('grid').store.loadData(data);
  121. tip.down('grid').setTitle('行:' + record.get('sd_detno'));
  122. }
  123. },
  124. getReply : function(grid) {
  125. var me = this;
  126. me.tipStore = [];
  127. Ext.defer(function(){
  128. var idField = Ext.getCmp('sa_id');
  129. if(idField && idField.getValue() > 0) {
  130. Ext.Ajax.request({
  131. url : basePath + 'b2b/sale/getReply.action',
  132. params : {
  133. id: idField.getValue()
  134. },
  135. callback : function(opt, s, r) {
  136. if (s) {
  137. var datas = Ext.decode(r.responseText);
  138. Ext.Array.each(datas, function(d){
  139. d.sr_date = Ext.Date.format(new Date(d.sr_date), 'Y-m-d');
  140. d.sr_delivery = Ext.Date.format(new Date(d.sr_delivery), 'Y-m-d');
  141. });
  142. me.tipStore = datas;
  143. }
  144. }
  145. });
  146. }
  147. }, 200);
  148. }
  149. });