InquiryReply.js 2.9 KB

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