Turnposition.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.emplmana.Turnposition', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'hr.emplmana.Turnposition','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.DeleteDetail',
  10. 'core.button.Update','core.button.Delete','core.form.YnField','core.form.FileField',
  11. 'core.button.ResAudit','core.button.Audit','core.button.Submit','core.button.ResSubmit',
  12. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.button.TurnPosition'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'dbfindtrigger[name=tp_emcode]':{
  18. 'aftertrigger':function(){
  19. console.log('aa');
  20. Ext.getCmp('tp_oldposition').setValue(Ext.getCmp('tp_position').value);
  21. }
  22. },
  23. 'erpGridPanel2': {
  24. itemclick: this.onGridItemClick
  25. },
  26. 'erpSaveButton': {
  27. click: function(btn){
  28. var form = me.getForm(btn);
  29. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  30. me.BaseUtil.getRandomNumber();//自动添加编号
  31. }
  32. var type=Ext.getCmp("tp_type").value;
  33. if(type=='turnposition'){
  34. var old_po=Ext.getCmp('tp_oldpositionid').value;
  35. var new_po=Ext.getCmp('tp_newpositionid').value;
  36. if(new_po==""||new_po==null){
  37. showError('新岗位未选择');
  38. }else if(old_po==new_po){
  39. showError('原岗位与新岗位相同,请重新选择');
  40. } else{
  41. this.FormUtil.beforeSave(this);
  42. }
  43. }else{
  44. this.FormUtil.beforeSave(this);
  45. }
  46. }
  47. },
  48. 'erpCloseButton': {
  49. click: function(btn){
  50. this.FormUtil.beforeClose(this);
  51. }
  52. },
  53. 'erpUpdateButton': {
  54. click: function(btn){
  55. var type=Ext.getCmp("tp_type").value;
  56. if(type=='turnposition'){
  57. var old_po=Ext.getCmp('tp_oldpositionid').value;
  58. var new_po=Ext.getCmp('tp_newpositionid').value;
  59. if(new_po==""||new_po==null){
  60. showError('新岗位未选择');
  61. }else if(old_po==new_po){
  62. showError('原岗位与新岗位相同,请重新选择');
  63. } else{
  64. this.FormUtil.onUpdate(this);
  65. }
  66. }else{
  67. this.FormUtil.onUpdate(this);
  68. }
  69. }
  70. },
  71. 'erpDeleteButton': {
  72. click: function(btn){
  73. me.FormUtil.onDelete(Ext.getCmp('tp_id').value);
  74. }
  75. },
  76. 'erpAddButton': {
  77. click: function(){
  78. me.FormUtil.onAdd('addTurnposition', '新增职位调用单', 'jsps/hr/emplmana/employee/turnposition.jsp');
  79. }
  80. },'erpSubmitButton': {
  81. afterrender: function(btn){
  82. var status = Ext.getCmp('tp_statuscode');
  83. if(status && status.value != 'ENTERING'){
  84. btn.hide();
  85. }
  86. },
  87. click: function(btn){
  88. me.FormUtil.onSubmit(Ext.getCmp('tp_id').value);
  89. }
  90. },
  91. 'erpResSubmitButton': {
  92. afterrender: function(btn){
  93. var status = Ext.getCmp('tp_statuscode');
  94. if(status && status.value != 'COMMITED'){
  95. btn.hide();
  96. }
  97. },
  98. click: function(btn){
  99. me.FormUtil.onResSubmit(Ext.getCmp('tp_id').value);
  100. }
  101. },
  102. 'erpAuditButton': {
  103. afterrender: function(btn){
  104. var status = Ext.getCmp('tp_statuscode');
  105. if(status && status.value != 'COMMITED'){
  106. btn.hide();
  107. }
  108. },
  109. click: function(btn){
  110. me.FormUtil.onAudit(Ext.getCmp('tp_id').value);
  111. }
  112. },
  113. 'erpResAuditButton': {
  114. afterrender: function(btn){
  115. var status = Ext.getCmp('tp_statuscode');
  116. if(status && status.value != 'AUDITED'){
  117. btn.hide();
  118. }
  119. },
  120. click: function(btn){
  121. me.FormUtil.onResAudit(Ext.getCmp('tp_id').value);
  122. }
  123. },
  124. 'erpTurnPositionButton': {
  125. afterrender: function(btn){
  126. var status = Ext.getCmp('tp_statuscode');
  127. if(status && status.value != 'AUDITED'){
  128. btn.hide();
  129. }
  130. },
  131. click: function(btn){
  132. var param = this.GridUtil.getAllGridStore();
  133. param = "[" + param.toString() + "]";
  134. warnMsg('确定要更新用户资料吗?', function(btn){
  135. if (btn == 'yes') {
  136. Ext.Ajax.request({
  137. url:basePath + "hr/emplmana/updatePosition.action",
  138. params:{
  139. param:param
  140. },
  141. method:'post',
  142. callback:function(options,success,response){
  143. var res = new Ext.decode(response.responseText);
  144. if(res.success){
  145. Ext.Msg.alert("提示", "更新员工资料成功!");
  146. }else{
  147. Ext.Msg.alert("提示", "更新员工资料失败!");
  148. }
  149. }
  150. });
  151. } else {
  152. return;
  153. }
  154. });
  155. }
  156. }
  157. });
  158. },
  159. onGridItemClick: function(selModel, record){//grid行选择
  160. this.GridUtil.onGridItemClick(selModel, record);
  161. },
  162. getForm: function(btn){
  163. return btn.ownerCt.ownerCt;
  164. }
  165. });