123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- /**
- * 商机分配
- */
- Ext.define('erp.view.core.button.BusDistribute',{
- extend: 'Ext.Button',
- alias: 'widget.erpBusDistributeButton',
- iconCls: 'x-button-icon-check',
- cls: 'x-btn-gray',
- id: 'busdistributebtn',
- text: $I18N.common.button.erpBusDistributeButton,
- style: {
- marginLeft: '10px'
- },
- width: 100,
- initComponent : function(){
- this.callParent(arguments);
- },
- handler: function(btn) {
- var me=this;
- var grid = Ext.getCmp('batchDealGridPanel');
- var items = grid.selModel.getSelection();
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- var bool = true;
- Ext.each(grid.multiselected, function(){
- if(this.data[grid.keyField] == item.data[grid.keyField]){
- bool = false;
- }
- });
- if(bool){
- grid.multiselected.push(item);
- }
- }
- });
- var records = grid.multiselected;
- if(records.length > 0){
- var ids = new Array();
- Ext.each(records, function(record, index){
- ids.push(record.data['bc_id']);
- });
- this.ids=ids;
- this.showWin(grid,btn);
- } else {
- showError("请勾选需要的明细!");
- }
- },
- getData:function(grid){
- var f="nvl(em_class,' ')<>'离职'";
- Ext.Ajax.request({
- url : basePath + 'ma/update/getEmpdbfindData.action',
- method : 'post',
- params : {
- fields:'em_id,em_code,em_name,em_depart,em_defaultorname,em_position',
- condition: f,
- page: -1,
- pagesize: 0
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success && r.data){
- var data = Ext.decode(r.data.replace(/,}/g, '}').replace(/,]/g, ']'));
- grid.getStore().loadData(data);
- }
- }
- });
- },
- showWin:function(grid,btn){
- var me=this;
- var win = btn.win;
- if (!win) {
- win = Ext.create('Ext.Window', {
- id : 'emp-win',
- width : 600,
- height : 400,
- title : '员工',
- modal : true,
- closeAction:'hide',
- layout: 'anchor',
- items : [ {
- xtype : 'gridpanel',
- anchor: '100% 100%',
- autoScroller:true,
- columnLines : true,
- plugins : [Ext.create(
- 'erp.view.core.grid.HeaderFilter'
- ), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
- singleSelect:true,
- columns : [ {
- text : 'ID',
- dataIndex : 'em_id',
- hidden : true
- }, {
- text : '编号',
- dataIndex : 'em_code',
- flex : 1,
- filter: {xtype: 'textfield', filterName: 'em_code'}
- }, {
- text : '姓名',
- dataIndex : 'em_name',
- flex : 1,
- filter: {xtype: 'textfield', filterName: 'em_name'}
- }, {
- text : '部门',
- dataIndex : 'em_depart',
- flex : 1,
- filter: {xtype: 'textfield', filterName: 'em_depart'}
- },{
- text : '组织',
- dataIndex : 'em_defaultorname',
- flex : 1,
- filter: {xtype: 'textfield', filterName: 'em_defaultorname'}
- }, {
- text : '职位',
- dataIndex : 'em_position',
- flex : 1,
- filter: {xtype: 'textfield', filterName: 'em_position'}
- } ],
- store:Ext.create('Ext.data.Store',{
- fields : [ {
- name : 'em_id',
- type : 'number'
- }, 'em_code', 'em_name','em_depart','em_defaultorname', 'em_position' ],
- data:[],
- autoLoad: false
- }),
- listeners: {
- afterrender: function() {
- me.getData(this);
- }
- }
- }],
- buttonAlign: 'center',
- buttons: [{
- text: $I18N.common.button.erpConfirmButton,
- iconCls: 'x-btn-confirm',
- handler: function(btn) {
- me.confirm(grid,btn.ownerCt.ownerCt.down('gridpanel'));
- btn.ownerCt.ownerCt.hide();
- }
- },{
- text: $I18N.common.button.erpCloseButton,
- iconCls: 'x-btn-close',
- handler: function(btn) {
- btn.ownerCt.ownerCt.hide();
- }
- }]
- });
- }
- btn.win = win;
- win.show();
- },
-
- confirm: function(grid,gl) {
- var ids=this.ids.join(",");
- var em_code=gl.selModel.lastSelected.get('em_code');
- var em_name=gl.selModel.lastSelected.get('em_name');
- grid.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'crm/chance/busDistribute.action',
- params: {
- ids: ids,
- em_code:em_code,
- em_name:em_name,
- caller:caller
- },
- method : 'post',
- callback : function(options,success,response){
- grid.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- } else {
- if(localJson.success){
- grid.multiselected = new Array();
- Ext.getCmp('dealform').onQuery(true);
- }
- }
- }
- });
- }
- });
|