SAP UI5 文件上传读取xml返回参数
try {
if (file) {
this._bUploading = true;
var that = this;
// var _handleSuccess = function(data) {
var _handleSuccess = function(event, xhr, settings, data) {
that.UploadDialog.close();
var oFileTableModel = that.getView().getModel("MyFile");
var oFileTableRow = {
PERNR: "",
PRE_FILETYPE: "",
FILENAME_OLD: "",
FILENAME: "",
MIMETYPE: "",
SYUNAME: "",
SYDATE: "",
SYTIME: "",
VALUE: "",
URL: ""
},
oFileTableData;
if (oFileTableModel != undefined) {
oFileTableData = oFileTableModel.oData;
} else {
oFileTableData = [];
}
var oReturnList = event.childNodes.children["childNodes"];
for (var i = 0; i < oReturnList.length; i++) {
var oNodeName = oReturnList.nodeName,
oNodeValue = oReturnList.childNodes;
var oFieldName = oNodeName.split(':');
switch (oFieldName) {
case 'PERNR':
oFileTableRow.PERNR = oNodeValue.data;
break;
case 'PRE_FILETYPE':
oFileTableRow.PRE_FILETYPE = oNodeValue.data;
break;
case 'FILENAME':
oFileTableRow.FILENAME = oNodeValue.data;
break;
case 'FILENAME_OLD':
oFileTableRow.FILENAME_OLD = oNodeValue.data;
break;
case 'MIMETYPE':
oFileTableRow.MIMETYPE = oNodeValue.data;
break;
case 'SYUNAME':
oFileTableRow.SYUNAME = oNodeValue.data;
break;
case 'SYDATE':
oFileTableRow.SYDATE = oNodeValue.data;
break;
case 'SYTIME':
oFileTableRow.SYTIME = oNodeValue.data;
break;
case 'VALUE':
oFileTableRow.VALUE = oNodeValue.data;
break;
}
}
oFileTableData.push(oFileTableRow);
that.getView().setModel(new JSONModel(oFileTableData), "MyFile");
};
var _handleError = function(data) {
var errorMsg = '';
if (data.responseText) {
errorMsg = /<message>(.*?)<\/message>/.exec(data.responseText);
} else {
errorMsg = 'Something bad happened';
}
that.fireUploadComplete({
"response": "Error: " + errorMsg
});
that._bUploading = false;
};
var oHeaders = {
"x-csrf-token": this._csrfToken,
"slug": file.name, //this.changeFileName(),
"filename_old": file.name,
"pernr": this.getModel("PersonInfo").oData.PERNR,
"is_icon": '',
"FileType": this.oUploadFileType
};
jQuery.ajax({
type: 'POST',
url: this._url,
headers: oHeaders,
cache: false,
contentType: file.type,
processData: false,
data: file,
success: _handleSuccess,
error: _handleError
});
}
} catch (oException) {
jQuery.sap.log.error("导入失败:\n" + oException.message);
}
https://blog.51cto.com/u_15291229/4714083
页:
[1]