diff --git a/changelog.md b/changelog.md index 5f8e085be6..b3ccc306ba 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-12) +- 文件上传控件新增API(setMaxFileLength)以动态设置最大上传文件数量 - Pane系列提供small和big两种大小的加载动画 - 同步树列表系列支持不显示节点连接线和展开收起图标 - 规范了下拉树trigger中显示值的显示顺序 diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index 3a8db85ae4..f9577f3739 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -71,6 +71,10 @@ BI.MultifileEditor = BI.inherit(BI.Widget, { this.file.reset(); }, + setMaxFileLength: function (v) { + this.file.setMaxFileLength(v); + }, + select: function () { this.file.select(); }, diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index 98918bd3d7..ea5024e9be 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -545,12 +545,12 @@ }, _events: function (wrap) { - var self = this; + var self = this, o = this.options; event.add(wrap.dom.input, "change", function () { event.del(wrap.dom.input, "change", arguments.callee); var input = wrap.dom.input.cloneNode(true); var files = F(wrap.dom.input); - if (wrap.maxLength !== -1 && wrap.maxLength < files.length) { + if (o.maxLength !== -1 && o.maxLength < files.length) { self.fireEvent(BI.File.EVENT_ERROR, { errorType: 2 }); @@ -654,6 +654,13 @@ }); }, + setMaxFileLength: function(v) { + this.options.maxLength = v; + if (this.wrap) { + this.wrap.maxLength = v; + } + }, + select: function () { this.wrap && BI.Widget._renderEngine.createElement(this.wrap.dom.input).click(); },