MyJProcess.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.MyJProcess', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'common.JProcess.MyJProcess','core.button.Add',
  8. 'core.button.Close',
  9. ],
  10. init:function(){
  11. var me = this;
  12. /*formCondition = this.BaseUtil.getUrlParam('formCondition');
  13. */
  14. this.control({
  15. 'erpSaveButton': {
  16. click: function(btn){
  17. this.saveEmployee(btn);
  18. }
  19. },
  20. 'erpUpdateButton': {
  21. click: function(btn){
  22. me.FormUtil.onUpdate(me.getForm(btn), 'hr/employee/update.action', []); // 后台未写……
  23. }
  24. },
  25. 'erpDeleteButton': {
  26. click: function(btn){
  27. var params = {
  28. //pr_id: Number(Ext.getCmp('pr_id').value)
  29. };
  30. me.FormUtil.onUpdate('hr/employee/delete.action', params); // 后台未写……
  31. }
  32. },
  33. 'erpAddButton': {
  34. click: function(btn){
  35. me.FormUtil.onAdd('addEmployee', '新增员工', 'jsps/hr/employee/employee.jsp');
  36. }
  37. },
  38. 'erpCloseButton': {
  39. click: function(btn){
  40. var s = me.FormUtil.checkFormDirty(me.getForm(btn));
  41. if(s == ''){
  42. me.FormUtil.onClose();
  43. } else {
  44. if(!formCondition){//单据新增界面哦
  45. //关闭前保存新增的数据
  46. Ext.MessageBox.show({//关闭前保存修改的数据
  47. title:'保存新添加的数据?',
  48. msg: '详细:<br/>' + s + '<br/>离开前要保存吗?',
  49. buttons: Ext.Msg.YESNOCANCEL,
  50. icon: Ext.Msg.WARNING,
  51. fn: function(btn){
  52. if(btn == 'yes'){
  53. me.saveProduct(btn);
  54. } else if(btn == 'no'){
  55. me.FormUtil.onClose();
  56. } else {
  57. return;
  58. }
  59. }
  60. });
  61. } else {//单据查看界面哦
  62. Ext.MessageBox.show({
  63. title:'保存修改?',
  64. msg: '该单据已被修改:<br/>' + s + '<br/>离开前要保存吗?',
  65. buttons: Ext.Msg.YESNOCANCEL,
  66. icon: Ext.Msg.WARNING,
  67. fn: function(btn){
  68. if(btn == 'yes'){
  69. me.FormUtil.onUpdate(me.getForm(btn), 'scm/product/update.action', []);
  70. } else if(btn == 'no'){
  71. me.FormUtil.onClose();
  72. } else {
  73. return;
  74. }
  75. }
  76. });
  77. }
  78. }
  79. }
  80. }
  81. });
  82. },
  83. getForm: function(btn){
  84. return btn.ownerCt.ownerCt;
  85. },
  86. saveEmployee: function(btn){
  87. var me = this;
  88. if(Ext.getCmp('em_code').value == null || Ext.getCmp('em_code').value == ''){
  89. Ext.getCmp('em_code').setValue(me.BaseUtil.getRandomNumber(em_uu));
  90. }
  91. me.FormUtil.onSave(me.getForm(btn), 'hr/employee/save.action', []);
  92. }
  93. });