Browse Source

Pull request #2736: 无jira 上传文件大小报错国际化

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit '1833843bec94484ac999c41aed79686c7d6746ec':
  无jira 上传文件大小报错支持errorText属性
  无jira 上传文件大小报错支持errorText属性
  无jira 上传文件大小报错国际化
es6
Dailer 2 years ago
parent
commit
f815e9dc87
  1. 3
      src/base/single/editor/editor.multifile.js
  2. 18
      src/base/single/input/file.js

3
src/base/single/editor/editor.multifile.js

@ -31,7 +31,8 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
accept: o.accept, accept: o.accept,
maxSize: o.maxSize, maxSize: o.maxSize,
maxLength: o.maxLength, maxLength: o.maxLength,
title: o.title title: o.title,
errorText: o.errorText,
}); });
this.file.on(BI.File.EVENT_CHANGE, function () { this.file.on(BI.File.EVENT_CHANGE, function () {
self.fireEvent(BI.MultifileEditor.EVENT_CHANGE, arguments); self.fireEvent(BI.MultifileEditor.EVENT_CHANGE, arguments);

18
src/base/single/input/file.js

@ -445,8 +445,9 @@
url: "", url: "",
multiple: true, multiple: true,
accept: "", // .png,.pdf,image/jpg,image/* 等 accept: "", // .png,.pdf,image/jpg,image/* 等
maxSize: -1, // 1024 * 1024 maxSize: -1, // 1024 * 1024 单位b
maxLength: -1 // 无限制, 与multiple配合使用 maxLength: -1, // 无限制, 与multiple配合使用
errorText: BI.emptyFn,
}); });
}, },
@ -472,12 +473,10 @@
// handlers // handlers
_wrap.onloadstart = function (rpe, xhr) { _wrap.onloadstart = function (rpe, xhr) {
// BI.Msg.toast("loadstart");
self.fireEvent(BI.File.EVENT_UPLOADSTART, arguments); self.fireEvent(BI.File.EVENT_UPLOADSTART, arguments);
}; };
_wrap.onprogress = function (rpe, xhr) { _wrap.onprogress = function (rpe, xhr) {
// BI.Msg.toast("onprogress");
// percent for each bar // percent for each bar
// fileSize is -1 only if browser does not support file info access // fileSize is -1 only if browser does not support file info access
@ -561,21 +560,26 @@
var validateFileType = fileTypeValidate(value, wrap.fileType); var validateFileType = fileTypeValidate(value, wrap.fileType);
if (!validateFileType) { if (!validateFileType) {
// 文件类型不支持 // 文件类型不支持
BI.Msg.toast(BI.i18nText("BI-Upload_File_Type_Error", wrap.fileType), { level: "error" }); BI.Msg.toast(o.errorText({
errorType: 0,
file: item
}) || BI.i18nText("BI-Upload_File_Type_Error", wrap.fileType), { level: "error" });
self.fireEvent(BI.File.EVENT_ERROR, { self.fireEvent(BI.File.EVENT_ERROR, {
errorType: 0, errorType: 0,
file: item file: item
}); });
} else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) { } else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) {
// 文件大小不支持 // 文件大小不支持
BI.Msg.toast(BI.i18nText("BI-Upload_File_Size_Error", wrap.maxSize), { level: "error" }); BI.Msg.toast(o.errorText({
errorType: 1,
file: item
}) || BI.i18nText("BI-Upload_File_Size_Error", Math.ceil(wrap.maxSize / 1024 / 1024)), { level: "error" });
self.fireEvent(BI.File.EVENT_ERROR, { self.fireEvent(BI.File.EVENT_ERROR, {
errorType: 1, errorType: 1,
file: item file: item
}); });
} else { } else {
wrap.files.unshift(item); wrap.files.unshift(item);
// BI.Msg.toast(value);
} }
} }
} }

Loading…
Cancel
Save