detailAttach.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * 明细行附件上传
  3. */
  4. Ext.define('erp.view.core.grid.detailAttach', {
  5. extend : 'Ext.form.Panel',
  6. alias : 'widget.erpdetailAttach',
  7. id : 'fileform',
  8. layout : 'column',
  9. bodyStyle : 'background: transparent no-repeat 0 0;border: none;',
  10. initComponent : function(){
  11. this.callParent(arguments);
  12. },
  13. items : [{
  14. xtype : 'filefield',
  15. name : 'file',
  16. buttonOnly : true,
  17. hideLabel : true,
  18. disabled : false,
  19. width : 90,
  20. height : 17,
  21. id : 'file',
  22. buttonConfig : {
  23. iconCls : 'x-button-icon-pic',
  24. text : '上传附件'
  25. },
  26. listeners : {
  27. change : function(field) {
  28. var filename = '';
  29. if (contains(field.value, "\\", true)) {
  30. filename = field.value.substring(field.value
  31. .lastIndexOf('\\')
  32. + 1);
  33. } else {
  34. filename = field.value.substring(field.value
  35. .lastIndexOf('/')
  36. + 1);
  37. }
  38. field.ownerCt.getForm().submit({
  39. url : basePath + 'common/upload.action?em_code=' + em_code,
  40. waitMsg : "正在解析文件信息",
  41. success : function(fp, o) {
  42. if (o.result.error) {
  43. showError(o.result.error);
  44. } else {
  45. Ext.Msg.alert("恭喜", filename + " 上传成功!");
  46. field.setDisabled(true);
  47. var record = Ext.getCmp('grid').selModel.lastSelected;
  48. if (record) {
  49. record.set('1detailAttach',filename+";"+o.result.filepath);
  50. }
  51. }
  52. }
  53. });
  54. }
  55. }
  56. }]
  57. });