Reply.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * grid,tip显示多次回复信息
  3. */
  4. Ext.define('erp.view.scm.purchase.plugin.Reply', {
  5. ptype : 'purchasereply',
  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 && ['pd_qtyreply', 'pd_deliveryreply', 'pd_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 : 'pr_type',
  71. width : 90
  72. }, {
  73. text : '时间',
  74. cls : 'x-grid-header-1',
  75. xtype : 'datecolumn',
  76. dataIndex : 'pr_date',
  77. format:'Y-m-d',
  78. width : 90
  79. }, {
  80. text : '回复人',
  81. cls : 'x-grid-header-1',
  82. dataIndex : 'pr_recorder',
  83. width : 70
  84. },{
  85. text: '数量',
  86. cls : 'x-grid-header-1',
  87. xtype : 'numbercolumn',
  88. align: 'right',
  89. dataIndex : 'pr_qty',
  90. width : 70
  91. }, {
  92. text : '回复交期',
  93. cls : 'x-grid-header-1',
  94. xtype : 'datecolumn',
  95. dataIndex : 'pr_delivery',
  96. width : 90
  97. },{
  98. text: '备注',
  99. cls : 'x-grid-header-1',
  100. dataIndex: 'pr_remark',
  101. width: 140
  102. } ],
  103. columnLines : true,
  104. store : new Ext.data.Store({
  105. fields : ['pr_type', { name: 'pr_date', type: 'date', dateFormat: 'Y-m-d'}, 'pr_recorder', 'pr_qty', 'pr_delivery', 'pr_reamrk', 'pr_pucode', 'pr_pddetno' ],
  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 && me.grid.readOnly) {
  114. var c = record.get('pd_detno'), data = new Array();
  115. Ext.each(me.tipStore, function(d) {
  116. if (d.pr_pddetno == c) {
  117. data.push(d);
  118. }
  119. });
  120. tip.down('grid').store.loadData(data);
  121. tip.down('grid').setTitle('行:' + record.get('pd_detno'));
  122. }
  123. },
  124. getReply : function(grid) {
  125. var me = this;
  126. me.tipStore = [];
  127. Ext.defer(function(){
  128. var idField = Ext.getCmp('pu_id'), statusField = Ext.getCmp('pu_statuscode');
  129. if(statusField && statusField.getValue() == 'AUDITED') {
  130. Ext.Ajax.request({
  131. url : basePath + 'scm/purchase/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.pr_date = Ext.Date.format(new Date(d.pr_date), 'Y-m-d');
  140. d.pr_delivery = Ext.Date.format(new Date(d.pr_delivery), 'Y-m-d');
  141. });
  142. me.tipStore = datas;
  143. }
  144. }
  145. });
  146. }
  147. }, 200);
  148. }
  149. });