增加注释
Showing
1 changed file
with
57 additions
and
9 deletions
| ... | @@ -54,12 +54,20 @@ export default { | ... | @@ -54,12 +54,20 @@ export default { |
| 54 | 54 | ||
| 55 | computed: { | 55 | computed: { |
| 56 | model: { | 56 | model: { |
| 57 | /** | ||
| 58 | * @description: get | ||
| 59 | * @author: renchao | ||
| 60 | */ | ||
| 57 | get () { | 61 | get () { |
| 58 | return this.isGroup | 62 | return this.isGroup |
| 59 | ? this.store : this.value !== undefined | 63 | ? this.store : this.value !== undefined |
| 60 | ? this.value : this.selfModel; | 64 | ? this.value : this.selfModel; |
| 61 | }, | 65 | }, |
| 62 | 66 | /** | |
| 67 | * @description: set | ||
| 68 | * @param {*} val | ||
| 69 | * @author: renchao | ||
| 70 | */ | ||
| 63 | set (val) { | 71 | set (val) { |
| 64 | if (this.isGroup) { | 72 | if (this.isGroup) { |
| 65 | this.isLimitExceeded = false; | 73 | this.isLimitExceeded = false; |
| ... | @@ -80,6 +88,10 @@ export default { | ... | @@ -80,6 +88,10 @@ export default { |
| 80 | } | 88 | } |
| 81 | }, | 89 | }, |
| 82 | 90 | ||
| 91 | /** | ||
| 92 | * @description: isChecked | ||
| 93 | * @author: renchao | ||
| 94 | */ | ||
| 83 | isChecked () { | 95 | isChecked () { |
| 84 | if ({}.toString.call(this.model) === '[object Boolean]') { | 96 | if ({}.toString.call(this.model) === '[object Boolean]') { |
| 85 | return this.model; | 97 | return this.model; |
| ... | @@ -89,7 +101,10 @@ export default { | ... | @@ -89,7 +101,10 @@ export default { |
| 89 | return this.model === this.trueLabel; | 101 | return this.model === this.trueLabel; |
| 90 | } | 102 | } |
| 91 | }, | 103 | }, |
| 92 | 104 | /** | |
| 105 | * @description: isGroup | ||
| 106 | * @author: renchao | ||
| 107 | */ | ||
| 93 | isGroup () { | 108 | isGroup () { |
| 94 | let parent = this.$parent; | 109 | let parent = this.$parent; |
| 95 | while (parent) { | 110 | while (parent) { |
| ... | @@ -102,29 +117,44 @@ export default { | ... | @@ -102,29 +117,44 @@ export default { |
| 102 | } | 117 | } |
| 103 | return false; | 118 | return false; |
| 104 | }, | 119 | }, |
| 105 | 120 | /** | |
| 121 | * @description: store | ||
| 122 | * @author: renchao | ||
| 123 | */ | ||
| 106 | store () { | 124 | store () { |
| 107 | return this._checkboxGroup ? this._checkboxGroup.value : this.value; | 125 | return this._checkboxGroup ? this._checkboxGroup.value : this.value; |
| 108 | }, | 126 | }, |
| 109 | 127 | ||
| 110 | /* used to make the isDisabled judgment under max/min props */ | 128 | /** |
| 129 | * @description: isLimitDisabled | ||
| 130 | * @author: renchao | ||
| 131 | */ | ||
| 111 | isLimitDisabled () { | 132 | isLimitDisabled () { |
| 112 | const { max, min } = this._checkboxGroup; | 133 | const { max, min } = this._checkboxGroup; |
| 113 | return !!(max || min) && | 134 | return !!(max || min) && |
| 114 | (this.model.length >= max && !this.isChecked) || | 135 | (this.model.length >= max && !this.isChecked) || |
| 115 | (this.model.length <= min && this.isChecked); | 136 | (this.model.length <= min && this.isChecked); |
| 116 | }, | 137 | }, |
| 117 | 138 | /** | |
| 139 | * @description: isDisabled | ||
| 140 | * @author: renchao | ||
| 141 | */ | ||
| 118 | isDisabled () { | 142 | isDisabled () { |
| 119 | return this.isGroup | 143 | return this.isGroup |
| 120 | ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled | 144 | ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled |
| 121 | : this.disabled || (this.elForm || {}).disabled; | 145 | : this.disabled || (this.elForm || {}).disabled; |
| 122 | }, | 146 | }, |
| 123 | 147 | /** | |
| 148 | * @description: _elFormItemSize | ||
| 149 | * @author: renchao | ||
| 150 | */ | ||
| 124 | _elFormItemSize () { | 151 | _elFormItemSize () { |
| 125 | return (this.elFormItem || {}).elFormItemSize; | 152 | return (this.elFormItem || {}).elFormItemSize; |
| 126 | }, | 153 | }, |
| 127 | 154 | /** | |
| 155 | * @description: checkboxSize | ||
| 156 | * @author: renchao | ||
| 157 | */ | ||
| 128 | checkboxSize () { | 158 | checkboxSize () { |
| 129 | const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size; | 159 | const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size; |
| 130 | return this.isGroup | 160 | return this.isGroup |
| ... | @@ -149,6 +179,10 @@ export default { | ... | @@ -149,6 +179,10 @@ export default { |
| 149 | }, | 179 | }, |
| 150 | 180 | ||
| 151 | methods: { | 181 | methods: { |
| 182 | /** | ||
| 183 | * @description: addToStore | ||
| 184 | * @author: renchao | ||
| 185 | */ | ||
| 152 | addToStore () { | 186 | addToStore () { |
| 153 | if ( | 187 | if ( |
| 154 | Array.isArray(this.model) && | 188 | Array.isArray(this.model) && |
| ... | @@ -159,6 +193,10 @@ export default { | ... | @@ -159,6 +193,10 @@ export default { |
| 159 | this.model = this.trueLabel || true; | 193 | this.model = this.trueLabel || true; |
| 160 | } | 194 | } |
| 161 | }, | 195 | }, |
| 196 | /** | ||
| 197 | * @description: handleChange | ||
| 198 | * @author: renchao | ||
| 199 | */ | ||
| 162 | handleChange (ev) { | 200 | handleChange (ev) { |
| 163 | if (this.isLimitExceeded) return; | 201 | if (this.isLimitExceeded) return; |
| 164 | let value; | 202 | let value; |
| ... | @@ -175,16 +213,26 @@ export default { | ... | @@ -175,16 +213,26 @@ export default { |
| 175 | }); | 213 | }); |
| 176 | } | 214 | } |
| 177 | }, | 215 | }, |
| 178 | 216 | /** | |
| 217 | * @description: created | ||
| 218 | * @author: renchao | ||
| 219 | */ | ||
| 179 | created () { | 220 | created () { |
| 180 | this.checked && this.addToStore(); | 221 | this.checked && this.addToStore(); |
| 181 | }, | 222 | }, |
| 223 | /** | ||
| 224 | * @description: mounted | ||
| 225 | * @author: renchao | ||
| 226 | */ | ||
| 182 | mounted () { // 为indeterminate元素 添加aria-controls 属性 | 227 | mounted () { // 为indeterminate元素 添加aria-controls 属性 |
| 183 | if (this.indeterminate) { | 228 | if (this.indeterminate) { |
| 184 | this.$el.setAttribute('aria-controls', this.controls); | 229 | this.$el.setAttribute('aria-controls', this.controls); |
| 185 | } | 230 | } |
| 186 | }, | 231 | }, |
| 187 | 232 | /** | |
| 233 | * @description: watch | ||
| 234 | * @author: renchao | ||
| 235 | */ | ||
| 188 | watch: { | 236 | watch: { |
| 189 | value (value) { | 237 | value (value) { |
| 190 | this.dispatch('ElFormItem', 'el.form.change', value); | 238 | this.dispatch('ElFormItem', 'el.form.change', value); | ... | ... |
-
Please register or sign in to post a comment