HrOrgStr.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.emplmana.HrOrgStr', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'hr.emplmana.HrOrgStr','hr.emplmana.HrOrgStrTree',
  8. 'core.form.YnField',
  9. 'core.form.Panel',
  10. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger',
  11. 'core.grid.Panel2','core.button.Save','core.button.Update','core.button.Close',
  12. 'hr.emplmana.EducationGrid','hr.emplmana.PositionGrid','hr.emplmana.WorkGrid',
  13. 'hr.emplmana.ReandpunishGrid','core.grid.YnColumn','core.toolbar.Toolbar'
  14. ],
  15. init:function(){
  16. var me = this;
  17. me.datamanager = [];
  18. this.control({
  19. 'hrOrgStrTree': {
  20. itemmousedown:function(selModel,record){
  21. var emid,emcode='';
  22. if(record.data.leaf){
  23. emid = record.data.id;
  24. if(record.data.id.indexOf('-')>0)emid=emid.split('-')[0];
  25. me.getFormData(emid, emcode);
  26. } else {
  27. var parentId=record.data.id;
  28. if (record.isExpanded() && record.childNodes.length > 0) { //是根节点,且已展开
  29. record.collapse(true, true); //收拢
  30. } else { //未展开
  31. //看是否加载了其children
  32. if (record.childNodes.length == 0) {
  33. //从后台加载
  34. var tree = Ext.getCmp('tree-panel');
  35. tree.setLoading(true, tree.body);
  36. Ext.Ajax.request({ //拿到tree数据
  37. url: basePath + 'hr/employee/getAllHrOrgsTree.action',
  38. params: {
  39. parentId: parentId
  40. },
  41. callback: function(options, success, response) {
  42. tree.setLoading(false);
  43. var res = new Ext.decode(response.responseText);
  44. if (res.tree) {
  45. record.appendChild(res.tree);
  46. record.expand(false, true); //展开
  47. } else if (res.exceptionInfo) {
  48. showError(res.exceptionInfo);
  49. }
  50. }
  51. });
  52. } else {
  53. record.expand(false, true); //展开
  54. }
  55. }
  56. }
  57. }
  58. },
  59. 'erpFormPanel': {
  60. afterrender: function(f){
  61. f.readOnly = true;
  62. var items = f.items.items;
  63. Ext.each(items, function(item){
  64. item.setFieldStyle('background:#f1f1f1;');
  65. item.setReadOnly(true);
  66. });
  67. }
  68. }
  69. });
  70. },
  71. getForm: function(btn){
  72. return btn.ownerCt.ownerCt;
  73. },
  74. getFormData: function(id, code){
  75. var condition = '';
  76. if(id==null){
  77. condition = "em_code='" + code + "'";
  78. } else {
  79. condition = 'em_id=' + id;
  80. }
  81. Ext.Ajax.request({//拿到tree数据
  82. url : basePath + 'hr/employee/getEmployee.action',
  83. params: {
  84. condition: condition
  85. },
  86. async: false,
  87. callback : function(options,success,response){
  88. var res = new Ext.decode(response.responseText);
  89. if(res.success){
  90. var employee = res.employee;
  91. Ext.getCmp('em_name').setValue(employee.em_name);
  92. Ext.getCmp('em_sex').setValue(employee.em_sex == '男' || employee.em_sex == 'M' ? '男':'女');
  93. Ext.getCmp('em_birthday').setValue(Ext.util.Format.date(new Date(employee.em_birthday),'Y-m-d H:i:s'));
  94. Ext.getCmp('em_indate').setValue(Ext.util.Format.date(new Date(employee.em_indate),'Y-m-d H:i:s'));
  95. Ext.getCmp('em_nation').setValue(employee.em_nation);
  96. Ext.getCmp('em_polity').setValue(employee.em_polity);
  97. Ext.getCmp('em_native').setValue(employee.em_native);
  98. Ext.getCmp('em_blood').setValue(employee.em_blood);
  99. Ext.getCmp('em_weight').setValue(employee.em_weight);
  100. Ext.getCmp('em_height').setValue(employee.em_height);
  101. Ext.getCmp('em_marry').setValue(employee.em_marry == -1 ? '未婚':'已婚');
  102. Ext.getCmp('em_iccode').setValue(employee.em_iccode);
  103. Ext.getCmp('em_worktime').setValue(employee.em_worktime == 0 ? '没有工作经验':(employee.em_worktime + ' 年'));
  104. Ext.getCmp('em_email').setValue(employee.em_email);
  105. Ext.getCmp('em_address').setValue(employee.em_address);
  106. Ext.getCmp('em_heathlevel').setValue(employee.em_heathlevel);
  107. Ext.getCmp('em_speciality').setValue(employee.em_speciality);
  108. Ext.getCmp('em_finishschool').setValue(employee.em_finishschool);
  109. Ext.getCmp('em_culture').setValue(employee.em_culture);
  110. Ext.getCmp('em_mobile').setValue(employee.em_mobile);
  111. Ext.getCmp('em_position').setValue(employee.em_position);
  112. Ext.getCmp('em_defaultorname').setValue(employee.em_defaultorname);
  113. Ext.getCmp('em_depart').setValue(employee.em_depart);
  114. Ext.getCmp('em_code').setValue(employee.em_code);
  115. Ext.getCmp('em_professname').setValue(employee.em_professname);
  116. Ext.getCmp('em_class').setValue(employee.em_class);
  117. Ext.getCmp('em_ctel').setValue(employee.em_ctel);
  118. Ext.getCmp('em_contact').setValue(employee.em_contact);
  119. Ext.getCmp('em_tel').setValue(employee.em_tel);
  120. } else if(res.exceptionInfo){
  121. showError(res.exceptionInfo);
  122. }
  123. }
  124. });
  125. }
  126. });