AddDossier.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.officialDocument.fileManagement.AddDossier', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.officialDocument.fileManagement.dossier.AddDossier','core.form.Panel','core.form.YearDateField',
  8. 'core.button.Save','core.button.Close','core.button.Update','core.button.Delete',
  9. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger'
  10. ],
  11. init:function(){
  12. var me = this;
  13. this.control({
  14. 'erpSaveButton': {
  15. click: function(btn){
  16. this.FormUtil.beforeSave(this);
  17. // parent.window.location.href = parent.window.location.href;
  18. }
  19. },
  20. 'erpUpdateButton': {
  21. click: function(btn){
  22. this.FormUtil.onUpdate(this);
  23. // parent.window.location.href = parent.window.location.href;
  24. }
  25. },
  26. 'erpDeleteButton': {
  27. click: function(btn){
  28. me.onDelete((Ext.getCmp('do_id').value));
  29. // me.FormUtil.onDelete((Ext.getCmp('dr_id').value));
  30. // parent.window.location.href = parent.window.location.href;
  31. }
  32. },
  33. 'erpCloseButton': {
  34. click: function(btn){
  35. parent.Ext.getCmp('grid').getCount('Dossier',"do_documentroom_id=" + Ext.getCmp('do_documentroom_id').value);
  36. this.FormUtil.onClose(this);
  37. // window.close();
  38. }
  39. },
  40. 'textfield[id=do_documentroom]':{
  41. afterrender: function(field){
  42. if(getUrlParam('name') != null && getUrlParam('name') != ''){
  43. field.setValue(getUrlParam('name'));
  44. Ext.getCmp('do_documentroom_id').setValue(getUrlParam('id'));
  45. }
  46. }
  47. },
  48. 'textfield[id=do_charger]':{
  49. change: function(field){
  50. if(field.value == null || field.value == ''){
  51. Ext.getCmp('do_charger_id').setValue(null);
  52. }
  53. }
  54. },
  55. 'datefield[id=do_enddate]': {
  56. change: function(field){
  57. var time = Ext.getCmp('do_startdate').value;
  58. if(time == null || time == ''){
  59. showError('请先选择文件开始日期');
  60. field.setValue('');
  61. } else {
  62. var start = Date.parse(time);
  63. var end = Date.parse(field.value);
  64. if(start > end){
  65. showError('结束日期不能早于开始日期 ');
  66. field.setValue('');
  67. }
  68. }
  69. }
  70. },
  71. });
  72. },
  73. getForm: function(btn){
  74. return btn.ownerCt.ownerCt;
  75. },
  76. openTab : function (panel,id){
  77. var o = (typeof panel == "string" ? panel : id || panel.id);
  78. var main = parent.Ext.getCmp("content-panel");
  79. var tab = main.getComponent(o);
  80. if (tab) {
  81. main.setActiveTab(tab);
  82. } else if(typeof panel!="string"){
  83. panel.id = o;
  84. var p = main.add(panel);
  85. main.setActiveTab(p);
  86. }
  87. },
  88. onDelete: function(id){
  89. var me = this;
  90. warnMsg($I18N.common.msg.ask_del_main, function(btn){
  91. if(btn == 'yes'){
  92. var form = Ext.getCmp('form');
  93. if(!contains(form.deleteUrl, '?caller=', true)){
  94. form.deleteUrl = form.deleteUrl + "?caller=" + caller;
  95. }
  96. // me.getActiveTab().setLoading(true);//loading...
  97. Ext.Ajax.request({
  98. url : basePath + form.deleteUrl,
  99. params: {
  100. id: id
  101. },
  102. method : 'post',
  103. callback : function(options,success,response){
  104. // me.getActiveTab().setLoading(false);
  105. var localJson = new Ext.decode(response.responseText);
  106. if(localJson.exceptionInfo){
  107. showError(localJson.exceptionInfo);return;
  108. }
  109. if(localJson.success){
  110. delSuccess(function(){
  111. parent.window.location.href = parent.window.location.href;
  112. me.FormUtil.onClose();
  113. });//@i18n/i18n.js
  114. } else {
  115. delFailure();
  116. }
  117. }
  118. });
  119. }
  120. });
  121. }
  122. });