EmpgridRight.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. Ext.define('erp.view.ma.update.EmpgridRight',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.empgridright',
  4. layout : 'fit',
  5. emptyText : $I18N.common.grid.emptyText,
  6. columnLines : true,
  7. autoScroll : true,
  8. multiselected: [],
  9. defaultdata:new Array(),
  10. filterEvevt:false,
  11. requires: ['erp.view.core.grid.HeaderFilter', 'erp.view.core.plugin.CopyPasteMenu'],
  12. columns:[{align: "left",cls: "x-grid-header-1",dataIndex: "em_code",flex: 1,header: "员工编号",text: "员工编号",filter:{autoDim: true,dataIndex: 'em_code',
  13. displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
  14. },{align: "left",cls: "x-grid-header-1",dataIndex: "em_name",flex: 1,header: "员工姓名",text: "员工姓名",filter:{autoDim: true,dataIndex: 'em_name',
  15. displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
  16. },{align: "left",cls: "x-grid-header-1",dataIndex: "em_defaulthsname",flex: 1,header: "岗位",text: "岗位",filter:{autoDim: true,dataIndex: 'em_defalthsname',
  17. displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}
  18. },{align: "left",cls: "x-grid-header-1",dataIndex: "em_defaultorname",flex: 1,header: "组织",text: "组织",filter:{autoDim: true,dataIndex: 'em_defaultorname',
  19. displayField: "display",exactSearch: false,ignoreCase: false,queryMode: 'local',store: null,valueField: 'value',xtype:'textfield'}}],
  20. store: Ext.create('Ext.data.Store', {
  21. fields:[{name: 'em_code',type: 'string'},{name: 'em_name',type: 'string'},
  22. {name: 'em_defalthsname',type: 'string'},{name: 'em_defaultorname',type: 'string'}],
  23. data:[],
  24. listeners:{
  25. 'datachanged':function(){
  26. var grid=Ext.getCmp('selectgrid');
  27. var s1=new Array();
  28. if(grid){
  29. Ext.each(this.data.items,function(d){
  30. s1.push(d.data);
  31. });
  32. grid.defaultdata=s1;
  33. parent.Ext.getCmp('empnames_').selecteddata=grid.defaultdata;
  34. }
  35. }
  36. }
  37. }),
  38. multiselected: new Array(),
  39. selModel: Ext.create('Ext.selection.CheckboxModel',{
  40. ignoreRightMouseSelection : false,
  41. checkOnly: true,
  42. listeners:{}
  43. }),
  44. constructor: function(cfg) {
  45. if(cfg) {
  46. cfg.headerCt = cfg.headerCt || Ext.create("Ext.grid.header.Container", {
  47. id: (cfg.id || this.id) + '-ct',
  48. forceFit: false,
  49. sortable: true,
  50. enableColumnMove:true,
  51. enableColumnResize:true,
  52. enableColumnHide: true
  53. });
  54. cfg.plugins = cfg.plugins || [Ext.create('erp.view.core.grid.HeaderFilter'), Ext.create('erp.view.core.plugin.CopyPasteMenu')];
  55. Ext.apply(this, cfg);
  56. }
  57. this.callParent(arguments);
  58. },
  59. initComponent : function(){
  60. this.getColumnsAndStore();
  61. this.callParent(arguments);
  62. var codes=parent.Ext.getCmp('emps_').value;
  63. if(codes!=''){
  64. var cond="'"+codes.replace(/#/g,"','")+"'";
  65. this.getData(cond);
  66. }else{
  67. data=new Array();
  68. for(var i=0;i<pageSize;i++){
  69. var o = new Object();
  70. data.push(o);
  71. }
  72. this.getStore().loadData(data);
  73. }
  74. },
  75. removeFromRight:function(){
  76. var gridR=Ext.getCmp('selectgrid');
  77. var remove=new Array(),s1=new Array();
  78. Ext.each(gridR.selModel.getSelection(),function(ss){
  79. remove.push(ss.data);
  80. });
  81. Ext.each(gridR.store.data.items,function(ss){
  82. s1.push(ss.data);
  83. });
  84. Ext.each(remove,function(r){
  85. if(Ext.Array.contains(s1,r)){
  86. Ext.Array.remove(s1,r);
  87. }
  88. });
  89. gridR.getStore().loadData(s1);
  90. },
  91. getData:function(cond){
  92. var me=this;
  93. var f=condition+"and em_code in("+cond+")";
  94. me.setLoading(true);
  95. Ext.Ajax.request({
  96. url : basePath + 'ma/update/getEmpdbfindData.action',
  97. method : 'post',
  98. params : {
  99. fields:'em_code,em_name,em_defaulthsname,em_defaultorname',
  100. condition: f,
  101. page: -1,
  102. pagesize: 0
  103. },
  104. method : 'post',
  105. callback : function(opt, s, res){
  106. me.setLoading(false);
  107. var r = new Ext.decode(res.responseText);
  108. if(r.exceptionInfo){
  109. showError(r.exceptionInfo);return;
  110. } else if(r.success && r.data){
  111. var data = Ext.decode(r.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  112. me.getStore().loadData(data);
  113. }
  114. }
  115. });
  116. },
  117. RenderUtil: Ext.create('erp.util.RenderUtil'),
  118. getColumnsAndStore: function(c, d, g, s, callback){
  119. var me = this;
  120. me.reconfigure(me.store, me.columns);
  121. }
  122. });