Transfer.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * 商机转移
  3. */
  4. Ext.define('erp.view.core.button.Transfer',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpTransferButton',
  7. iconCls: 'x-button-icon-check',
  8. cls: 'x-btn-gray',
  9. id: 'transferbtn',
  10. text: $I18N.common.button.erpTransferButton,
  11. style: {
  12. marginLeft: '10px'
  13. },
  14. width: 100,
  15. initComponent : function(){
  16. this.callParent(arguments);
  17. },
  18. handler: function(btn) {
  19. var me=this;
  20. var grid = Ext.getCmp('batchDealGridPanel');
  21. var items = grid.selModel.getSelection();
  22. Ext.each(items, function(item, index){
  23. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  24. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  25. var bool = true;
  26. Ext.each(grid.multiselected, function(){
  27. if(this.data[grid.keyField] == item.data[grid.keyField]){
  28. bool = false;
  29. }
  30. });
  31. if(bool){
  32. grid.multiselected.push(item);
  33. }
  34. }
  35. });
  36. var records = grid.multiselected;
  37. if(records.length > 0){
  38. var ids = new Array();
  39. Ext.each(records, function(record, index){
  40. ids.push(record.data['bc_id']);
  41. });
  42. this.ids=ids;
  43. this.showWin(grid,btn);
  44. } else {
  45. showError("请勾选需要的明细!");
  46. }
  47. },
  48. getData:function(grid){
  49. Ext.Ajax.request({
  50. url : basePath + 'common/getFieldsDatas.action',
  51. method : 'post',
  52. params : {
  53. fields:'bd_id,bd_name,bd_prop,bd_admincode,bd_admin,bd_overtime,bd_remark',
  54. condition: "1=1",
  55. caller:'BUSINESSDATABASE'
  56. },
  57. method : 'post',
  58. callback : function(opt, s, res){
  59. var r = new Ext.decode(res.responseText);
  60. if(r.exceptionInfo){
  61. showError(r.exceptionInfo);return;
  62. } else if(r.success && r.data){
  63. var data = Ext.decode(r.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  64. grid.getStore().loadData(data);
  65. }
  66. }
  67. });
  68. },
  69. showWin:function(grid,btn){
  70. var me=this;
  71. var win = btn.win;
  72. if (!win) {
  73. win = Ext.create('Ext.Window', {
  74. id : 'bus-win',
  75. width : 600,
  76. height : 400,
  77. title : '商机库',
  78. modal : true,
  79. closeAction:'hide',
  80. layout: 'anchor',
  81. items : [ {
  82. xtype : 'gridpanel',
  83. anchor: '100% 100%',
  84. autoScroller:true,
  85. columnLines : true,
  86. plugins : [Ext.create(
  87. 'erp.view.core.grid.HeaderFilter'
  88. ), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  89. singleSelect:true,
  90. columns : [ {
  91. text : 'ID',
  92. dataIndex : 'BD_ID',
  93. hidden : true
  94. }, {
  95. text : '名称',
  96. dataIndex : 'BD_NAME',
  97. flex : 1,
  98. filter: {xtype: 'textfield', filterName: 'BD_NAME'}
  99. }, {
  100. text : '属性',
  101. dataIndex : 'BD_PROP',
  102. flex : 1,
  103. filter: {xtype: 'textfield', filterName: 'BD_PROP'}
  104. },{
  105. text : '管理员编号',
  106. dataIndex : 'BD_ADMINCODE',
  107. flex : 1,
  108. filter: {xtype: 'textfield', filterName: 'BD_ADMINCODE'}
  109. }, {
  110. text : '管理员名称',
  111. dataIndex : 'BD_ADMIN',
  112. flex : 1,
  113. filter: {xtype: 'textfield', filterName: 'BD_ADMIN'}
  114. } ],
  115. store:Ext.create('Ext.data.Store',{
  116. fields : [ {
  117. name : 'BD_ID',
  118. type : 'number'
  119. }, 'BD_NAME', 'BD_PROP','BD_ADMINCODE','BD_ADMIN' ],
  120. data:[],
  121. autoLoad: false
  122. }),
  123. listeners: {
  124. afterrender: function() {
  125. me.getData(this);
  126. }
  127. }
  128. }],
  129. buttonAlign: 'center',
  130. buttons: [{
  131. text: $I18N.common.button.erpConfirmButton,
  132. iconCls: 'x-btn-confirm',
  133. handler: function(btn) {
  134. me.confirm(grid,btn.ownerCt.ownerCt.down('gridpanel'));
  135. btn.ownerCt.ownerCt.hide();
  136. }
  137. },{
  138. text: $I18N.common.button.erpCloseButton,
  139. iconCls: 'x-btn-close',
  140. handler: function(btn) {
  141. btn.ownerCt.ownerCt.hide();
  142. }
  143. }]
  144. });
  145. }
  146. btn.win = win;
  147. win.show();
  148. },
  149. confirm: function(grid,gl) {
  150. var ids=this.ids.join(",");
  151. var bd_name=gl.selModel.lastSelected.get('BD_NAME');
  152. grid.setLoading(true);
  153. Ext.Ajax.request({
  154. url : basePath + 'crm/chance/transfer.action',
  155. params: {
  156. ids: ids,
  157. bd_name:bd_name,
  158. caller:caller
  159. },
  160. method : 'post',
  161. callback : function(options,success,response){
  162. grid.setLoading(false);
  163. var localJson = new Ext.decode(response.responseText);
  164. if(localJson.exceptionInfo){
  165. showError(localJson.exceptionInfo);
  166. } else {
  167. if(localJson.success){
  168. grid.multiselected = new Array();
  169. Ext.getCmp('dealform').onQuery(true);
  170. }
  171. }
  172. }
  173. });
  174. }
  175. });