123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- Ext.define('erp.view.ma.update.EmpgridLeft',{
- extend: 'Ext.grid.Panel',
- alias: 'widget.empgridleft',
- layout:'column',
- id: 'dbfindGridPanel',
- emptyText : $I18N.common.grid.emptyText,
- columnLines : true,
- autoScroll : true,
- multiselected: [],
- store:[],
- columns:[],
- defaultcolumns: [{align: "left",cls: "x-grid-header-1",dataIndex: "em_code",flex: 1,header: "员工编号",text: "员工编号",filter:{autoDim: true,dataIndex: 'em_code',
- displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
- },{align: "left",cls: "x-grid-header-1",dataIndex: "em_name",flex: 1,header: "员工姓名",text: "员工姓名",filter:{autoDim: true,dataIndex: 'em_name',
- displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
- },{align: "left",cls: "x-grid-header-1",dataIndex: "em_defaulthsname",flex: 1,header: "岗位",text: "岗位",filter:{autoDim: true,dataIndex: 'em_defalthsname',
- displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
- },{align: "left",cls: "x-grid-header-1",dataIndex: "em_defaultorname",flex: 1,header: "组织",text: "组织",filter:{autoDim: true,dataIndex: 'em_defaultorname',
- displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}}],
- multiselected: new Array(),
- selModel: Ext.create('Ext.selection.CheckboxModel',{
- ignoreRightMouseSelection : false,
- checkOnly: true
- }),
- plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- }), Ext.create('Ext.ux.grid.GridHeaderFilters')],
- initComponent : function(){
- this.callParent(arguments);
- this.getCount();
- },
- RenderUtil: Ext.create('erp.util.RenderUtil'),
- getColumnsAndStore: function(c, d, g, s, callback){
- var me = this;
- c = c || caller;
- d = d || condition;
- g = g || page;
- s = s || pageSize;
- var f = d;
- if(me.filterCondition){
- if(d == null || d == ''){
- f = me.filterCondition;
- } else {
- f += ' AND ' + me.filterCondition;
- }
- }
- me.setLoading(true);
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'ma/update/getEmpdbfindData.action',
- method : 'post',
- params : {
- fields:'em_code,em_name,em_defaulthsname,em_defaultorname',
- condition: f,
- page: g,
- pagesize: s
- },
- callback : function(options, success, response){
- me.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- var data = Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']'));
- if(callback)
- callback.call(me, data);
- else {
- if(me.columns && me.columns.length > 2){
- me.store.loadData(data);
- if(me.store.data.items.length != data.length){
- me.store.removeAll();
- me.store.add(data);
- }
- }else{
- var grid = this;
- me.reconfigure(Ext.create('Ext.data.Store', {
- fields:[{name: 'em_code',type: 'string'},{name: 'em_name',type: 'string'},
- {name: 'em_defaulthsname',type: 'string'},{name: 'em_defaultorname',type: 'string'}],
- data: data
- }),me.defaultcolumns);
- if(me.store.data.items.length != data.length){
- me.store.removeAll();
- me.store.add(data);
- }
- }
- Ext.getCmp('pagingtoolbar').afterOnLoad();
- }
- }
- });
- },
- getCount: function(c, d, callback){
- var me = this;
- c = 'UpdateScheme';
- d = d|| condition;
- var f = d;
- if(me.filterCondition){
- if(d == null || d == ''){
- f = me.filterCondition;
- } else {
- f += ' AND ' + me.filterCondition;
- }
- }
- Ext.Ajax.request({//拿到grid的数据总数count
- url : basePath + 'common/getCountByTable.action',
- params : {
- tablename: 'employee',
- condition: f
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- dataCount = res.count;
- if(callback)
- callback.call(me, dataCount, c, d);
- else
- me.getColumnsAndStore(c, d);
- }
- });
- },
- selectDefault: function(){
- var grid = this;
- },
- addToRight:function(){
- var gridL=Ext.getCmp('dbfindGridPanel'),gridR=Ext.getCmp('selectgrid');
- var o1=new Object(),o2=new Object(),a1=new Array(),a2=new Array();
- Ext.each(gridL.selModel.getSelection(),function(ss){
- o1[ss.data.em_code]=ss.data;
- });
- Ext.each(gridR.store.data.items,function(ss){
- if(ss.data.em_code!=''){
- o1[ss.data.em_code]=ss.data;
- }
- });
- var keys=Ext.Object.getKeys(o1);
- Ext.each(keys, function(k){
- a1.push(o1[k]);
- });
- gridR.getStore().loadData(a1);
- gridL.getSelectionModel().select([]);
- },
- listeners: {
- 'headerfiltersapply': function(grid, filters) {
- if(this.allowFilter){
- var condition = null;
- for(var fn in filters){
- var value = filters[fn],f = grid.getHeaderFilterField(fn);
- if(!Ext.isEmpty(value)){
- if(f.filtertype) {
- if (f.filtertype == 'numberfield') {
- value = fn + "=" + value + " ";
- }
- } else {
- if(Ext.isDate(value)){
- value = Ext.Date.toString(value);
- value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
- } else {
- var exp_t = /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,
- exp_d = /^(\d{4})\-(\d{2})\-(\d{2})$/;
- if(exp_d.test(value)){
- value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value + "' ";
- } else if(exp_t.test(value)){
- value = "to_char(" + fn + ",'yyyy-MM-dd')='" + value.substr(0, 10) + "' ";
- } else{
- if(!f.autoDim) {
- value = fn + " LIKE '" + value + "%' ";
- } else {
- value = fn + " LIKE '%" + value + "%' ";
- }
- }
- }
- }
- if(condition == null){
- condition = value;
- } else {
- condition = condition + " AND " + value;
- }
- }
- }
- this.filterCondition = condition;
- page = 1;
- this.getCount();
- } else {
- this.allowFilter = true;
- }
- return false;
- }
- }
- });
|