From b6af34cf347278646c55ab2cf8fe9bb75650e49a Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 28 Mar 2022 18:25:18 +0800 Subject: [PATCH 1/4] feature: disabled --- src/core/4.widget.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index deb7758ab..306975294 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -42,11 +42,11 @@ key: null, tag: null, - disabled: false, + disabled: null, invisible: false, animation: "", animationDuring: 0, - invalid: false, + invalid: null, baseCls: "", extraCls: "", cls: "", @@ -398,6 +398,10 @@ lifeHook !== false && !this.__async && callLifeHook(this, "beforeMount"); this._isMounted = true; this.__isMounting = false; + for (var key in this._children) { + var child = this._children[key]; + child._mount && child._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1); + } if (this._parent) { if (!this._parent.isEnabled()) { this._setEnable(false); @@ -406,10 +410,6 @@ this._setValid(false); } } - for (var key in this._children) { - var child = this._children[key]; - child._mount && child._mount(deep ? force : false, deep, lifeHook, predicate, layer + 1); - } this._mountChildren && this._mountChildren(); if (layer === 0) { // mounted里面会执行scrollTo之类的方法,如果放宏任务里会闪 @@ -461,9 +461,9 @@ _setEnable: function (enable) { if (enable === true) { - this.options.disabled = false; + this.options._disabled = false; } else if (enable === false) { - this.options.disabled = true; + this.options._disabled = true; } // 递归将所有子组件使能 BI.each(this._children, function (i, child) { @@ -473,9 +473,9 @@ _setValid: function (valid) { if (valid === true) { - this.options.invalid = false; + this.options._invalid = false; } else if (valid === false) { - this.options.invalid = true; + this.options._invalid = true; } // 递归将所有子组件使有效 BI.each(this._children, function (i, child) { @@ -493,6 +493,7 @@ setEnable: function (enable) { this._manualSetEnable = true; + this.options.disabled = !enable; this._setEnable(enable); if (enable === true) { this.element.removeClass("base-disabled disabled"); @@ -555,6 +556,7 @@ setValid: function (valid) { this._manualSetValid = true; + this.options.invalid = !valid; this._setValid(valid); if (valid === true) { this.element.removeClass("base-invalid invalid"); @@ -597,12 +599,6 @@ throw new Error("组件:组件名已存在,不能进行添加"); } widget._setParent && widget._setParent(this); - // if (this.options.disabled) { - // widget.options && (widget.options.disabled = true); - // } - // if (this.options.invalid) { - // widget.options && (widget.options.invalid = true); - // } widget.on(BI.Events.DESTROY, function () { BI.remove(self._children, this); }); @@ -689,11 +685,11 @@ }, isEnabled: function () { - return !this.options.disabled; + return this.options.disabled !== null ? !this.options.disabled : !this.options._disabled; }, isVisible: function () { - return !this.options.invisible; + return this.options.invalid !== null ? !this.options.invalid : !this.options._invalid; }, disable: function () { From 6703e315f3d9312553349e25637e4d100a566057 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 28 Mar 2022 18:35:39 +0800 Subject: [PATCH 2/4] feature: disabled --- src/core/4.widget.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 306975294..cee59c0cf 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -581,10 +581,6 @@ return this.options.height; }, - isValid: function () { - return !this.options.invalid; - }, - addWidget: function (name, widget) { var self = this; if (name instanceof BI.Widget) { @@ -685,11 +681,15 @@ }, isEnabled: function () { - return this.options.disabled !== null ? !this.options.disabled : !this.options._disabled; + return this.options.disabled === true ? false: !this.options._disabled; + }, + + isValid: function () { + return this.options.invalid === true ? false: !this.options._invalid; }, isVisible: function () { - return this.options.invalid !== null ? !this.options.invalid : !this.options._invalid; + return !this.options.invisible }, disable: function () { From 32d403ab8486a190cd5a552d8ef54de0f708e92e Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 28 Mar 2022 18:36:30 +0800 Subject: [PATCH 3/4] feature: disabled --- src/core/4.widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index cee59c0cf..a58d4380b 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -42,11 +42,11 @@ key: null, tag: null, - disabled: null, + disabled: false, invisible: false, animation: "", animationDuring: 0, - invalid: null, + invalid: false, baseCls: "", extraCls: "", cls: "", From e7688542c331045a82150de687a77efa933c3b19 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 28 Mar 2022 19:24:51 +0800 Subject: [PATCH 4/4] feature: disabled --- src/core/4.widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/4.widget.js b/src/core/4.widget.js index a58d4380b..861fce38f 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -689,7 +689,7 @@ }, isVisible: function () { - return !this.options.invisible + return !this.options.invisible; }, disable: function () {