ReportFilesFG.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fp.ReportFilesFG', {
  3. extend : 'Ext.app.Controller',
  4. FormUtil : Ext.create('erp.util.FormUtil'),
  5. GridUtil : Ext.create('erp.util.GridUtil'),
  6. BaseUtil : Ext.create('erp.util.BaseUtil'),
  7. views : [ 'fa.fp.ReportFilesFG', 'core.form.Panel','core.grid.Panel2', 'core.toolbar.Toolbar', 'core.grid.YnColumn',
  8. 'core.button.Add','core.button.Sync','core.button.Save', 'core.button.Close','core.button.Upload', 'core.button.Update',
  9. 'core.button.Delete' ,'core.grid.detailAttach','core.trigger.DbfindTrigger','core.form.YnField', 'core.button.DeleteDetail',
  10. 'core.button.Upload', 'core.form.FileField','core.trigger.MultiDbfindTrigger' ],
  11. init : function() {
  12. var me = this;
  13. this.control({
  14. 'erpGridPanel2' : {
  15. itemclick : this.onGridItemClick
  16. },
  17. 'erpSaveButton' : {
  18. click : function(btn) {
  19. me.GridUtil.onSave(Ext.getCmp('grid'));
  20. }
  21. },
  22. 'field[name=fo_id]' : {
  23. change : function(f) {
  24. if (f.value != null && f.value != '') {
  25. window.location.href = window.location.href
  26. .toString().split('?')[0]
  27. + '?formCondition=fo_id='
  28. + f.value
  29. + '&gridCondition=foid=' + f.value;
  30. } else {
  31. Ext.getCmp('deletebutton').hide();
  32. Ext.getCmp('updatebutton').hide();
  33. }
  34. }
  35. },
  36. 'field[name=fo_caller]' : {
  37. beforerender:function(f){
  38. f.readOnly=true;
  39. f.editable=false;
  40. }
  41. },
  42. 'field[name=caller]' : {
  43. beforerender:function(f){
  44. f.autoDbfind=false;
  45. }
  46. },
  47. 'erpAddButton' : {
  48. click : function(btn) {
  49. me.FormUtil.onAdd('addReportFilesFG', '新增报表文件设置',
  50. 'jsps/fa/fp/ReportFilesFG.jsp');
  51. }
  52. },
  53. 'erpCloseButton' : {
  54. click : function(btn) {
  55. me.FormUtil.beforeClose(me);
  56. }
  57. },
  58. 'erpUpdateButton' : {
  59. click : function(btn) {
  60. this.FormUtil.onUpdate(this);
  61. }
  62. },
  63. 'erpDeleteButton' : {
  64. click : function(btn) {
  65. me.FormUtil.onDelete(Ext.getCmp('fo_id').value);
  66. }
  67. },
  68. 'erpDeleteDetailButton': {
  69. afterrender: function(btn){
  70. if(en_admin=='pdf'){
  71. btn.ownerCt.add({
  72. id:'fileform',
  73. xtype:'form',
  74. layout:'column',
  75. bodyStyle: 'background: transparent no-repeat 0 0;border: none;',
  76. items: [{
  77. xtype : 'filefield',
  78. name : 'file',
  79. buttonOnly : true,
  80. hideLabel : true,
  81. disabled : false,
  82. width : 90,
  83. height : 17,
  84. id : 'file',
  85. buttonConfig : {
  86. iconCls : 'x-button-icon-pic',
  87. text : '上传报表'
  88. },
  89. listeners : {
  90. change : function(field) {
  91. var filename = '';
  92. if (contains(field.value, "\\", true)) {
  93. filename = field.value.substring(field.value
  94. .lastIndexOf('\\')
  95. + 1);
  96. } else {
  97. filename = field.value.substring(field.value
  98. .lastIndexOf('/')
  99. + 1);
  100. }
  101. field.ownerCt.getForm().submit({
  102. url : basePath + 'common/uploadRP.action?em_code=' + em_code,
  103. waitMsg : "正在解析文件信息",
  104. success : function(fp, o) {
  105. if (o.result.error) {
  106. showError(o.result.error);
  107. } else {
  108. Ext.Msg.alert("恭喜", filename + " 上传成功!");
  109. field.setDisabled(true);
  110. var record = Ext.getCmp('grid').selModel.lastSelected;
  111. if (record) {
  112. record.set('1detailAttach',filename+";"+o.result.filepath);
  113. }
  114. }
  115. }
  116. });
  117. }
  118. }
  119. }]
  120. });
  121. }
  122. }
  123. }
  124. });
  125. },
  126. onGridItemClick : function(selModel, record) {//grid行选择
  127. this.GridUtil.onGridItemClick(selModel, record);
  128. },
  129. getForm : function(btn) {
  130. return btn.ownerCt.ownerCt;
  131. }
  132. });