平台excelImport组件导入时选择的导入的excel文件名默认是获取不到的,如果需要获取如下操作:
1.修改/UI2/system/components/justep/excel/importExcel.js
(1).对getActionParam方法的实现的修改,加上file-name的设置
getActionParam : function(options) {
var param = new biz.Request.ActionParam();
var to = this.to;
var configParam = '<config use-default="'
+ (this.useDefault ? "true" : "false") + '" to="'
+ to + '" excel-file="' + options.value.excel
+ '" file-name="' + options.fileName
+ '" mapping-file="' + options.value.mapping + '">'
+ this.createConfigParam() + "<data>" + this.createDataParam() + "</data>"
+ "</config>";
param.setXml('config', new biz.Request.XMLParam(configParam));
param.setMap('createActionParam', this.getDataNewActionParam(this.getData()));
if(to == ToKind.DB){
param.setMap('saveActionParam', this.getDataSaveActionParam(this.getData()));
}
return param;
},
(2).把
var result = evt.response.data ? evt.response.data.value : evt.response;
修改为:
var result = {};
result.value = evt.response.data ? evt.response.data.value : evt.response;
result.fileName = evt.file.name;
修改组件的js文件参考:http://docs.wex5.com/bex5-ui-question-list-10013/
2./BIZ/SA/excel/logic/code/src/com/justep/excel/ImportConfig.java中添加下面的方法
public String getFileName() {
return configE.attributeValue("file-name");
}
通过上面操作就可以在process文件中导入相关的action事件上获取值如下:
public static void totalProcessAfterImportExcelBeforeAction() {
ImportConfig config = (ImportConfig)ModelUtils.getRequestContext().getActionContext().getParameter("config");
System.out.println("选择导入的excel文件名:"+config.getFileName());
}
评一波