aa197a91 by yuanbo

增加注释

1 parent c5c9c87e
......@@ -54,12 +54,20 @@ export default {
computed: {
model: {
/**
* @description: get
* @author: renchao
*/
get () {
return this.isGroup
? this.store : this.value !== undefined
? this.value : this.selfModel;
},
/**
* @description: set
* @param {*} val
* @author: renchao
*/
set (val) {
if (this.isGroup) {
this.isLimitExceeded = false;
......@@ -80,6 +88,10 @@ export default {
}
},
/**
* @description: isChecked
* @author: renchao
*/
isChecked () {
if ({}.toString.call(this.model) === '[object Boolean]') {
return this.model;
......@@ -89,7 +101,10 @@ export default {
return this.model === this.trueLabel;
}
},
/**
* @description: isGroup
* @author: renchao
*/
isGroup () {
let parent = this.$parent;
while (parent) {
......@@ -102,29 +117,44 @@ export default {
}
return false;
},
/**
* @description: store
* @author: renchao
*/
store () {
return this._checkboxGroup ? this._checkboxGroup.value : this.value;
},
/* used to make the isDisabled judgment under max/min props */
/**
* @description: isLimitDisabled
* @author: renchao
*/
isLimitDisabled () {
const { max, min } = this._checkboxGroup;
return !!(max || min) &&
(this.model.length >= max && !this.isChecked) ||
(this.model.length <= min && this.isChecked);
},
/**
* @description: isDisabled
* @author: renchao
*/
isDisabled () {
return this.isGroup
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
: this.disabled || (this.elForm || {}).disabled;
},
/**
* @description: _elFormItemSize
* @author: renchao
*/
_elFormItemSize () {
return (this.elFormItem || {}).elFormItemSize;
},
/**
* @description: checkboxSize
* @author: renchao
*/
checkboxSize () {
const temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
return this.isGroup
......@@ -149,6 +179,10 @@ export default {
},
methods: {
/**
* @description: addToStore
* @author: renchao
*/
addToStore () {
if (
Array.isArray(this.model) &&
......@@ -159,6 +193,10 @@ export default {
this.model = this.trueLabel || true;
}
},
/**
* @description: handleChange
* @author: renchao
*/
handleChange (ev) {
if (this.isLimitExceeded) return;
let value;
......@@ -175,16 +213,26 @@ export default {
});
}
},
/**
* @description: created
* @author: renchao
*/
created () {
this.checked && this.addToStore();
},
/**
* @description: mounted
* @author: renchao
*/
mounted () { // 为indeterminate元素 添加aria-controls 属性
if (this.indeterminate) {
this.$el.setAttribute('aria-controls', this.controls);
}
},
/**
* @description: watch
* @author: renchao
*/
watch: {
value (value) {
this.dispatch('ElFormItem', 'el.form.change', value);
......