BusDistribute.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * 商机分配
  3. */
  4. Ext.define('erp.view.core.button.BusDistribute',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpBusDistributeButton',
  7. iconCls: 'x-button-icon-check',
  8. cls: 'x-btn-gray',
  9. id: 'busdistributebtn',
  10. text: $I18N.common.button.erpBusDistributeButton,
  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. var f="nvl(em_class,' ')<>'离职'";
  50. Ext.Ajax.request({
  51. url : basePath + 'ma/update/getEmpdbfindData.action',
  52. method : 'post',
  53. params : {
  54. fields:'em_id,em_code,em_name,em_depart,em_defaultorname,em_position',
  55. condition: f,
  56. page: -1,
  57. pagesize: 0
  58. },
  59. method : 'post',
  60. callback : function(opt, s, res){
  61. var r = new Ext.decode(res.responseText);
  62. if(r.exceptionInfo){
  63. showError(r.exceptionInfo);return;
  64. } else if(r.success && r.data){
  65. var data = Ext.decode(r.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  66. grid.getStore().loadData(data);
  67. }
  68. }
  69. });
  70. },
  71. showWin:function(grid,btn){
  72. var me=this;
  73. var win = btn.win;
  74. if (!win) {
  75. win = Ext.create('Ext.Window', {
  76. id : 'emp-win',
  77. width : 600,
  78. height : 400,
  79. title : '员工',
  80. modal : true,
  81. closeAction:'hide',
  82. layout: 'anchor',
  83. items : [ {
  84. xtype : 'gridpanel',
  85. anchor: '100% 100%',
  86. autoScroller:true,
  87. columnLines : true,
  88. plugins : [Ext.create(
  89. 'erp.view.core.grid.HeaderFilter'
  90. ), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  91. singleSelect:true,
  92. columns : [ {
  93. text : 'ID',
  94. dataIndex : 'em_id',
  95. hidden : true
  96. }, {
  97. text : '编号',
  98. dataIndex : 'em_code',
  99. flex : 1,
  100. filter: {xtype: 'textfield', filterName: 'em_code'}
  101. }, {
  102. text : '姓名',
  103. dataIndex : 'em_name',
  104. flex : 1,
  105. filter: {xtype: 'textfield', filterName: 'em_name'}
  106. }, {
  107. text : '部门',
  108. dataIndex : 'em_depart',
  109. flex : 1,
  110. filter: {xtype: 'textfield', filterName: 'em_depart'}
  111. },{
  112. text : '组织',
  113. dataIndex : 'em_defaultorname',
  114. flex : 1,
  115. filter: {xtype: 'textfield', filterName: 'em_defaultorname'}
  116. }, {
  117. text : '职位',
  118. dataIndex : 'em_position',
  119. flex : 1,
  120. filter: {xtype: 'textfield', filterName: 'em_position'}
  121. } ],
  122. store:Ext.create('Ext.data.Store',{
  123. fields : [ {
  124. name : 'em_id',
  125. type : 'number'
  126. }, 'em_code', 'em_name','em_depart','em_defaultorname', 'em_position' ],
  127. data:[],
  128. autoLoad: false
  129. }),
  130. listeners: {
  131. afterrender: function() {
  132. me.getData(this);
  133. }
  134. }
  135. }],
  136. buttonAlign: 'center',
  137. buttons: [{
  138. text: $I18N.common.button.erpConfirmButton,
  139. iconCls: 'x-btn-confirm',
  140. handler: function(btn) {
  141. me.confirm(grid,btn.ownerCt.ownerCt.down('gridpanel'));
  142. btn.ownerCt.ownerCt.hide();
  143. }
  144. },{
  145. text: $I18N.common.button.erpCloseButton,
  146. iconCls: 'x-btn-close',
  147. handler: function(btn) {
  148. btn.ownerCt.ownerCt.hide();
  149. }
  150. }]
  151. });
  152. }
  153. btn.win = win;
  154. win.show();
  155. },
  156. confirm: function(grid,gl) {
  157. var ids=this.ids.join(",");
  158. var em_code=gl.selModel.lastSelected.get('em_code');
  159. var em_name=gl.selModel.lastSelected.get('em_name');
  160. grid.setLoading(true);
  161. Ext.Ajax.request({
  162. url : basePath + 'crm/chance/busDistribute.action',
  163. params: {
  164. ids: ids,
  165. em_code:em_code,
  166. em_name:em_name,
  167. caller:caller
  168. },
  169. method : 'post',
  170. callback : function(options,success,response){
  171. grid.setLoading(false);
  172. var localJson = new Ext.decode(response.responseText);
  173. if(localJson.exceptionInfo){
  174. showError(localJson.exceptionInfo);
  175. } else {
  176. if(localJson.success){
  177. grid.multiselected = new Array();
  178. Ext.getCmp('dealform').onQuery(true);
  179. }
  180. }
  181. }
  182. });
  183. }
  184. });