/*
描述:文件上传
编写:CoolHu
日期:2012-12-14
修改:
*/
SysFileUpLoadWindow = function (config) {
};
Ext.define('SysFileUpLoadWindow', {
extend: 'Ext.window.Window',
id: "SysFileUpLoadWindow",
height: 100,
width: 300,
title: '上传附件',
modal: true,
closeAction: "destroy",
initComponent: function () {
var me = this;
me.FileForm = new SysFileUpLoadForm({
});
Ext.applyIf(me, {
items: [
me.FileForm
],
buttons: [
{
text: '上传',
scope:this,
handler: function () {
if (!this.FileForm.form.isValid()) {
return;
}
Ext.Msg.show({
msg: "正在上传文档...",
progressText: "上传中...",
width: 300,
wait: true,
waitConfig: { interval: 200 },
animEl: "saving"
});
me.FileForm.getForm().submit({
url: cmdUrl,
method: 'POST',
params:this.params,
success: function (form, action) {
if (me.SuccessCallBack) {
var result;
try {
if (action.response.responseText == "") {
ErrorMessage("操作失败!");
return;
}
result = Ext.JSON.decode(action.response.responseText);
if (result.success) {
var fileName = result.rows[0].FileName;
me.SuccessCallBack("", fileName);
me.destroy();
}
else {
if (me.ErrorCallBack) {
me.ErrorCallBack("");
} else {
ErrorMessage("操作失败!");
}
}
}
catch (e) {
alert(e);
}
}
Ext.MessageBox.hide();
},
failure:function (form,action) {
ErrorMessage(action.response.responseText);
}
});
}
}, {
text: "关闭",
handler: function () {
Ext.getCmp(this.ownerCt.ownerCt.id).destroy();
}
}]
});
me.callParent(arguments);
}
});
Ext.define('SysFileUpLoadForm', {
extend: 'Ext.form.Panel',
id: "SysFileUpLoadForm",
border: false,
bodyStyle: "padding:6px 0px 0px 0px;background-color:transparent",
defaults: {
LabelName: "文件名",
labelSparator: ':',
labelWidth: 55,
labelAlign: 'right',
blankText: '请选择要上传的附件',
allowBlank: false,
msgTarget: 'side'
},
initComponent: function () {
var me = this;
Ext.applyIf(me, {
items: [
{
name: 'SysFileUpLoad',
id: 'SysFileUpLoad',
xtype: 'filefield',
width: 280,
fieldLabel: '文件名',
buttonText: '浏览...',
listeners: {
change: function (f, v) {
//Ext.getCmp("browseImage").setSrc("http://list.image.baidu.com/t/image/w_bizhi.jpg");
}
}
}
]
});
me.callParent(arguments);
}
});