QuotationReply.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * grid,tip显示多次回复信息
  3. */
  4. Ext.define('erp.view.b2b.sale.plugin.QuotationReply', {
  5. ptype : 'quotationreply',
  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 && ['qd_lapqty', 'qd_price'].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 : 250,
  63. showDelay : 100,
  64. items : [ {
  65. xtype : 'grid',
  66. width : 250,
  67. columns : [{
  68. text: '分段数量',
  69. cls : 'x-grid-header-1',
  70. align: 'right',
  71. dataIndex : 'qdd_lapqty',
  72. width : 110
  73. } ,{
  74. text: '单价',
  75. cls : 'x-grid-header-1',
  76. xtype : 'numbercolumn',
  77. align: 'right',
  78. dataIndex : 'qdd_price',
  79. width : 110
  80. }],
  81. columnLines : true,
  82. store : new Ext.data.Store({
  83. fields : ['qdd_lapqty', 'qdd_price' ],
  84. data : [ {} ]
  85. })
  86. } ]
  87. });
  88. },
  89. updateTipBody : function(view, tip) {
  90. var me = this, record = me.grid.store.getAt(me.activeIndex.y);
  91. if (record && me.tipStore) {
  92. var c = record.get('qd_id'), data = new Array();
  93. Ext.each(me.tipStore, function(d) {
  94. if (d.qdd_qdid == c) {
  95. data.push(d);
  96. }
  97. });
  98. tip.down('grid').store.loadData(data);
  99. tip.down('grid').setTitle('行:' + record.get('qd_detno'));
  100. }
  101. },
  102. getReply : function(grid) {
  103. var me = this;
  104. me.tipStore = [];
  105. Ext.defer(function(){
  106. var idField = Ext.getCmp('qu_id');
  107. if(idField && idField.getValue() > 0) {
  108. Ext.Ajax.request({
  109. url : basePath + 'b2b/sale/zdquotation/getReply.action',
  110. params : {
  111. id: idField.getValue()
  112. },
  113. callback : function(opt, s, r) {
  114. if (s) {
  115. var datas = Ext.decode(r.responseText);
  116. me.tipStore = datas;
  117. }
  118. }
  119. });
  120. }
  121. }, 200);
  122. }
  123. });