TaskForm.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. Ext.define('erp.view.plm.task.TaskForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.TaskForm',
  4. id: 'uploadform',
  5. layout: 'column',
  6. bodyStyle: {background: '#f1f1f1'},
  7. fieldDefaults: {
  8. labelAlign : "right",
  9. columnWidth: .6
  10. },
  11. FormUtil: Ext.create('erp.util.FormUtil'),
  12. listeners: {
  13. afterrender: function(){
  14. var form = Ext.getCmp('form');
  15. form.add({
  16. xtype: 'hidden',
  17. name: 'files',
  18. fieldLabel: '附件',
  19. value: '',
  20. id: 'files'
  21. });
  22. }
  23. },
  24. /**items: [{
  25. xtype: 'filefield',
  26. fieldLabel: '附件',
  27. id: 'attach',
  28. name: 'file',
  29. msgTarget: 'side',
  30. allowBlank: false,
  31. buttonText: '浏览...',
  32. listeners: {
  33. afterrender: function(field){
  34. field.attachcount = 0;
  35. upload.files = new Array();
  36. },
  37. change: function(field){
  38. if(field.value != null){
  39. field.button.disable(true);
  40. var container = Ext.create('Ext.form.FieldContainer', {
  41. layout: 'hbox',
  42. fieldLabel: "附件" + (field.attachcount + 1),
  43. items: [{
  44. xtype: 'textfield',
  45. id: 'attach' + field.attachcount,
  46. flex: 1
  47. }, {
  48. xtype: 'button',
  49. text: '上传',
  50. id: 'upload' + field.attachcount,
  51. handler: function(btn){
  52. var form = btn.ownerCt.ownerCt;
  53. var f = Ext.getCmp(btn.id.replace('upload', 'attach'));
  54. if(f.value != null && f.value != ''){
  55. //field.value = f.value;
  56. form.getForm().submit({
  57. url: basePath + 'common/upload.action?em_code=' + em_code,
  58. waitMsg: "正在上传:" + f.value,
  59. success: function(fp, o){
  60. if(o.result.error){
  61. showError(o.result.error);
  62. } else {
  63. Ext.Msg.alert("恭喜", f.value + " 上传成功!");
  64. btn.setText("上传成功(" + Ext.util.Format.fileSize(o.result.size) + ")");
  65. btn.disable(true);
  66. field.button.setDisabled(false);
  67. Ext.getCmp('files').setValue(Ext.getCmp('files').value + ',' + o.result.filepath);
  68. upload.files[Number(btn.id.replace('upload', ''))] = o.result.filepath;
  69. }
  70. }
  71. });
  72. }
  73. },
  74. flex: 1
  75. }, {
  76. xtype: 'button',
  77. text: '删除',
  78. id: 'delete' + field.attachcount,
  79. handler: function(btn){
  80. var f = Ext.getCmp(btn.id.replace('delete', 'attach'));
  81. if(f.value != null && f.value != ''){
  82. Ext.getCmp('files').setValue(Ext.getCmp('files').value.replace(upload.files[Number(btn.id.replace('delete', ''))], ''));
  83. upload.files[Number(btn.id.replace('delete', ''))] = '';
  84. }
  85. btn.ownerCt.destroy(true);
  86. field.attachcount--;
  87. },
  88. flex: 1
  89. }]
  90. });
  91. if(contains(field.value, "\\", true)){
  92. Ext.getCmp('attach' + field.attachcount).setValue(field.value.substring(field.value.lastIndexOf('\\') + 1));
  93. } else {
  94. Ext.getCmp('attach' + field.attachcount).setValue(field.value.substring(field.value.lastIndexOf('/') + 1));
  95. }
  96. Ext.getCmp('uploadform').insert(1, container);
  97. field.attachcount++;
  98. field.button.setText("继续...");
  99. }
  100. }
  101. }
  102. },{
  103. xtype: 'displayfield',
  104. id: 'attachs',
  105. cls: 'mail-attach',
  106. height: 'auto'
  107. }],**/
  108. initComponent : function(){
  109. this.callParent(arguments);
  110. },
  111. listeners: {
  112. collapse: function(){
  113. },
  114. expand: function(){
  115. }
  116. }
  117. });