文件上传时用window弹窗第二次以后fieldLabel值显示重复
今天在项目中遇到一个棘手的问题,在上传附件的时候,window弹窗,,第一次的时候是正常的,win.hide() 后,第二次fieldLabel值会重复显示,如下图:
因为window窗口中只有“附件”重复了,“备注”字段没有重复,所以怀疑是因为“附件”的写法有问题
“附件”字段对应的代码如下,用的 inpuType:‘file‘
name : "uploadFile", // id : "uploadFile", inputType : 'file', fieldLabel : "<font color='red'>*</font>附件", style :"margin:4px", height : 20, buttonText: '浏览', allowBlank : false, blankText : "附件不能为空", emptyText : "请选择附件..."
现在改变文件类型的写法,
inputType : ‘file‘ 改成 xtype:‘fileuploadfield‘
由于程序中用的dwr,这样改后无法上传文件,具体原因可以参考另一篇博客,有具体的修改方式
这样再次打开window后显示正常:
详细代码如下:
<span style="white-space:pre"> </span>js代码//文件panel
fileFormPanel = new Ext.form.FormPanel({
name : "fileFormPanel",
id : "fileFormPanel",
labelWidth : 70,
defaultType : "textfield",
baseCls : 'x-plain',
bodyStyle : 'padding:5px 5px 0',
width : 390,
buttonAlign:'center',
fileUpload: true
loadMask : new Ext.LoadMask(Ext.getBody(), {
msg : '请稍候,正在查询....'
}),
waitMsg : '请稍候,正在查询....',
onSubmit: Ext.emptyFn,
border : false,
defaults : {
width : 230
},
items : [
{
name : "uploadFile",
//
id : "uploadFile",
//
inputType : 'file',
xtype:'fileuploadfield',
fieldLabel : "<font color='red'>*</font>附件",
style :"margin:4px",
height : 20,
buttonText: '浏览',
allowBlank : false,
blankText : "附件不能为空",
emptyText : "请选择附件..."
}
,{
name : 'fileRemark',
id : 'fileRemark',
xtype : 'textarea',
fieldLabel: '备注',
collapsible : true,
style : 'margin:4px;margin-bottom:10px;',
width : 230,
height: 100
}],
buttons : [{
name : 'fileSureBtn',
id : 'fileSureBtn',
text : "确定",
handler : function(){
if (!fileWin.getComponent('fileFormPanel').form.isValid()) {
selInfo("请完整填写表单!");
return;
}
//取消遮罩
//fileFormPanel.getEl().mask('请稍后,正在上传附件……');
//进度框
Ext.Msg.wait('请稍后,正在上传附件……', '', {animate : true});
var uploadFile = fileFormPanel.getForm().findField("uploadFile").getValue();
var remark = fileFormPanel.getForm().findField("fileRemark").getValue();
//当前节点对象
var row =grid.getSelectionModel().getSelected();//获取一行
var fId = row.get('FolderId');
var dId = row.get('DocId');
var file = dwr.util.getValue("uploadFile");
//构造参数对象
var parObj = {
docId : dId,
folderId : fId,
fileCode : '', //附件编码先不做(预留字段)
fileName : fileName,
//文件的名称
uploadFile : uploadFile, //上传的文件全路径
userId : userId,
remark : remark
};
//调用DWR方法
FolderHandlerBean.createFile(file,parObj,function(data){
if(data.flag == '1'){
alert("111");
//隐藏窗口
//
Ext.getCmp('uploadFile').setValue('');
fileFormPanel.getForm().findField("uploadFile").setValue('');
fileWin.hide();
//刷新grid
//
selOk(data.msg);
Ext.MessageBox.show({
title : '提示',
msg : '添加成功!',
modal : true,
buttons : Ext.Msg.OK,
icon : Ext.Msg.INFO,
width : 200,
fn : function() {
fileGrid.getStore().reload();
}
});
}else{
Ext.getCmp('uploadFile').setValue('');
fileWin.hide();
selError(data.msg);
}
});
}
}, {
text : "取消",
handler : function() {
//清除数据
Ext.getCmp('uploadFile').setValue('');
Ext.getCmp('fileRemark').setValue('');
//隐藏窗口
fileWin.hide();
}
}]
});
//文件窗口
fileWin = new Ext.Window({
id : "fileWin",
title : "附件编辑",
width : 460,
height : 450,
bodyStyle : 'padding:5px;',
maximizable : false,
closeAction : 'hide',
closable : true, //是否关闭
collapsible : true, //是否可以收缩
draggable : true, //是否可以拖拽
resizable : false, //是否可以调整大小
modal : true,
//是否遮罩(true的时候,后面的页面不能使用)
buttonAlign : "center",
items : fileFormPanel
});
java实现类
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/69521.html