|
|
@@ -15,39 +15,48 @@ Ext.define('school.view.core.form.field.FileField', {
|
|
|
this.cls = '';
|
|
|
this.title = this.title || '附件';
|
|
|
this._title = this.title;
|
|
|
+ this.fileRegex = this.fileRegex || /\.*$/;
|
|
|
+ this.items = [{
|
|
|
+ xtype: 'form',
|
|
|
+ columnWidth: 1,
|
|
|
+ frame: false,
|
|
|
+ border: false,
|
|
|
+ minHeight: 22,
|
|
|
+ bodyStyle: 'padding:2px;background:#f7f7f7',
|
|
|
+ layout: 'hbox',
|
|
|
+ items: [{
|
|
|
+ xtype: 'hidden',
|
|
|
+ name: 'value'
|
|
|
+ }, {
|
|
|
+ xtype: 'filefield',
|
|
|
+ name: 'file',
|
|
|
+ cls:'x-form-filefield',
|
|
|
+ buttonText: '浏览文件(≤20MB)',
|
|
|
+ buttonOnly: true,
|
|
|
+ hideLabel: true,
|
|
|
+ buttonConfig:{
|
|
|
+ cls:'x-filefield-button'
|
|
|
+ },
|
|
|
+ regex: this.fileRegex,
|
|
|
+ regexText: "不支持的文件类型",
|
|
|
+ listeners: {
|
|
|
+ change: function(field, value){
|
|
|
+ if(!value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(field.validate()) {
|
|
|
+ field.ownerCt.ownerCt.upload(field.ownerCt, field);
|
|
|
+ }else {
|
|
|
+ field.reset();
|
|
|
+ school.util.BaseUtil.showErrorToast('不支持的文件类型');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }];
|
|
|
this.callParent(arguments);
|
|
|
},
|
|
|
layout:'column',
|
|
|
- items: [{
|
|
|
- xtype: 'form',
|
|
|
- columnWidth: 1,
|
|
|
- frame: false,
|
|
|
- border: false,
|
|
|
- minHeight: 22,
|
|
|
- bodyStyle: 'padding:2px;background:#f7f7f7',
|
|
|
- layout: 'hbox',
|
|
|
- items: [{
|
|
|
- xtype: 'hidden',
|
|
|
- name: 'value'
|
|
|
- }, {
|
|
|
- xtype: 'filefield',
|
|
|
- name: 'file',
|
|
|
- cls:'x-form-filefield',
|
|
|
- buttonText: '浏览文件(≤20MB)',
|
|
|
- buttonOnly: true,
|
|
|
- hideLabel: true,
|
|
|
- buttonConfig:{
|
|
|
- cls:'x-filefield-button'
|
|
|
- },
|
|
|
- listeners: {
|
|
|
- change: function(field){
|
|
|
- if(!!field.value){
|
|
|
- field.ownerCt.ownerCt.upload(field.ownerCt, field);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }]
|
|
|
- }],
|
|
|
setValue: function(value){
|
|
|
this.value = value;
|
|
|
this.getValueField().setValue(value);
|