Job.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.employee.Job', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'hr.employee.Job','core.form.Panel','core.button.Sync',
  8. 'core.button.Add','core.button.Save','core.button.Close','core.button.CopyPower',
  9. 'core.button.Update','core.button.Delete','core.form.YnField','core.button.Banned','core.button.ResBanned',
  10. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpSyncButton': {
  16. afterrender: function(btn){
  17. btn.autoClearCache = true;
  18. }
  19. },
  20. 'erpSaveButton': {
  21. click: function(btn){
  22. var form = me.getForm(btn);
  23. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  24. me.BaseUtil.getRandomNumber();//自动添加编号
  25. }
  26. this.FormUtil.beforeSave(this);
  27. }
  28. },
  29. 'erpCloseButton': {
  30. click: function(btn){
  31. this.FormUtil.beforeClose(this);
  32. }
  33. },
  34. 'erpUpdateButton': {
  35. afterrender: function(btn){
  36. var status = Ext.getCmp('jo_statuscode');
  37. if(status && status.value == 'DISABLE'){
  38. btn.hide();
  39. }
  40. },
  41. click: function(btn){
  42. this.FormUtil.onUpdate(this);
  43. }
  44. },
  45. 'erpDeleteButton': {
  46. afterrender: function(btn){
  47. var status = Ext.getCmp('jo_statuscode');
  48. if(status && status.value == 'DISABLE'){
  49. btn.hide();
  50. }
  51. },
  52. click: function(btn){
  53. me.FormUtil.onDelete(Ext.getCmp('jo_id').value);
  54. }
  55. },
  56. 'erpAddButton': {
  57. click: function(){
  58. me.FormUtil.onAdd('addJob', '新增岗位资料', 'jsps/hr/employee/job.jsp');
  59. }
  60. },
  61. 'erpBannedButton': {
  62. afterrender: function(btn){
  63. var status = Ext.getCmp('jo_statuscode');
  64. if(status && status.value == 'DISABLE'){
  65. btn.hide();
  66. }
  67. },
  68. click: function(btn){
  69. this.FormUtil.onBanned(Ext.getCmp('jo_id').value);
  70. }
  71. },
  72. 'erpResBannedButton': {
  73. afterrender: function(btn){
  74. var status = Ext.getCmp('jo_statuscode');
  75. if(status && status.value != 'DISABLE'){
  76. btn.hide();
  77. }
  78. },
  79. click: function(btn){
  80. this.FormUtil.onResBanned(Ext.getCmp('jo_id').value);
  81. }
  82. },
  83. 'erpCopyPowerButton': {//复制权限
  84. click: function() {
  85. var id = Ext.getCmp('jo_id').value;
  86. if(id == null || id == 0) {
  87. return;
  88. }
  89. var win = Ext.getCmp('power-copy-win');
  90. if(!win ) {
  91. win = Ext.create('Ext.Window', {
  92. id: 'power-copy-win',
  93. width: 800,
  94. height: 400,
  95. title: '选择目标岗位',
  96. layout: {
  97. type: 'vbox'
  98. },
  99. defaults: {
  100. margin: '3 3 3 10'
  101. },
  102. items: [{
  103. xtype: 'dbfindtrigger',
  104. fieldLabel: '岗位编号',
  105. id: 'jo_code_source',
  106. name: 'jo_code_source'
  107. }, {
  108. xtype: 'displayfield',
  109. fieldLabel: '岗位名称',
  110. id: 'jo_name_source',
  111. name: 'jo_name_source'
  112. }, {
  113. xtype: 'displayfield',
  114. fieldLabel: '岗位描述',
  115. id: 'jo_description_source',
  116. name: 'jo_description_source'
  117. }, {
  118. xtype: 'hidden',
  119. fieldLabel: 'ID',
  120. id: 'jo_id_source',
  121. name: 'jo_id_source'
  122. }],
  123. buttonAlign: 'center',
  124. buttons: [{
  125. text: $I18N.common.button.erpConfirmButton,
  126. cls: 'x-btn-blue',
  127. handler: function(btn) {
  128. var w = btn.ownerCt.ownerCt;
  129. if(w.down('#jo_id_source').value > 0) {
  130. warnMsg('确定复制 ' + w.down('#jo_name_source').value + ' 的权限吗?', function(btn){
  131. if(btn == 'yes'){
  132. me.copyPower(Ext.getCmp('jo_id').value, w.down('#jo_id_source').value);
  133. }
  134. });
  135. }
  136. }
  137. }, {
  138. text: $I18N.common.button.erpCloseButton,
  139. cls: 'x-btn-blue',
  140. handler: function(btn) {
  141. btn.ownerCt.ownerCt.close();
  142. }
  143. }]
  144. });
  145. }
  146. win.show();
  147. }
  148. }
  149. });
  150. },
  151. getForm: function(btn){
  152. return btn.ownerCt.ownerCt;
  153. },
  154. copyPower: function(id, sourceid) {
  155. Ext.Ajax.request({
  156. });
  157. }
  158. });