diff --git a/changelog.md b/changelog.md index 2e34e399f..554d388df 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-12) +- 文件上传控件新增API(setMaxFileLength)以动态设置最大上传文件数量 - 复选下拉树显示查看已选效果改成和复选下拉列表一致 - Pane系列提供small和big两种大小的加载动画 - 同步树列表系列支持不显示节点连接线和展开收起图标 diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index 3a8db85ae..f9577f373 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 98918bd3d..ea5024e9b 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(); },