Select support Form's disabled

This commit is contained in:
梁灏 2019-09-16 21:34:28 +08:00
parent 763f08da5a
commit 61b3fd893e
2 changed files with 12 additions and 10 deletions

View file

@ -7,6 +7,7 @@
</template> </template>
<script> <script>
import Emitter from '../../mixins/emitter'; import Emitter from '../../mixins/emitter';
import mixinsForm from '../../mixins/form';
import { findComponentUpward } from '../../utils/assist'; import { findComponentUpward } from '../../utils/assist';
const prefixCls = 'ivu-select-item'; const prefixCls = 'ivu-select-item';
@ -14,7 +15,7 @@
export default { export default {
name: 'iOption', name: 'iOption',
componentName: 'select-item', componentName: 'select-item',
mixins: [ Emitter ], mixins: [ Emitter, mixinsForm ],
props: { props: {
value: { value: {
type: [String, Number], type: [String, Number],
@ -51,7 +52,7 @@
return [ return [
`${prefixCls}`, `${prefixCls}`,
{ {
[`${prefixCls}-disabled`]: this.disabled, [`${prefixCls}-disabled`]: this.itemDisabled,
[`${prefixCls}-selected`]: this.selected && !this.autoComplete, [`${prefixCls}-selected`]: this.selected && !this.autoComplete,
[`${prefixCls}-focus`]: this.isFocused [`${prefixCls}-focus`]: this.isFocused
} }
@ -66,7 +67,7 @@
}, },
methods: { methods: {
select () { select () {
if (this.disabled) return false; if (this.itemDisabled) return false;
this.dispatch('iSelect', 'on-select-selected', { this.dispatch('iSelect', 'on-select-selected', {
value: this.value, value: this.value,

View file

@ -35,7 +35,7 @@
:values="values" :values="values"
:clearable="canBeCleared" :clearable="canBeCleared"
:prefix="prefix" :prefix="prefix"
:disabled="disabled" :disabled="itemDisabled"
:remote="remote" :remote="remote"
:input-element-id="elementId" :input-element-id="elementId"
:initial-label="initialLabel" :initial-label="initialLabel"
@ -91,6 +91,7 @@
import TransferDom from '../../directives/transfer-dom'; import TransferDom from '../../directives/transfer-dom';
import { oneOf, findComponentsDownward } from '../../utils/assist'; import { oneOf, findComponentsDownward } from '../../utils/assist';
import Emitter from '../../mixins/emitter'; import Emitter from '../../mixins/emitter';
import mixinsForm from '../../mixins/form';
import Locale from '../../mixins/locale'; import Locale from '../../mixins/locale';
import SelectHead from './select-head.vue'; import SelectHead from './select-head.vue';
import FunctionalOptions from './functional-options.vue'; import FunctionalOptions from './functional-options.vue';
@ -163,7 +164,7 @@
export default { export default {
name: 'iSelect', name: 'iSelect',
mixins: [ Emitter, Locale ], mixins: [ Emitter, Locale, mixinsForm ],
components: { FunctionalOptions, Drop, SelectHead, Icon }, components: { FunctionalOptions, Drop, SelectHead, Icon },
directives: { clickOutside, TransferDom }, directives: { clickOutside, TransferDom },
props: { props: {
@ -307,7 +308,7 @@
`${prefixCls}`, `${prefixCls}`,
{ {
[`${prefixCls}-visible`]: this.visible, [`${prefixCls}-visible`]: this.visible,
[`${prefixCls}-disabled`]: this.disabled, [`${prefixCls}-disabled`]: this.itemDisabled,
[`${prefixCls}-multiple`]: this.multiple, [`${prefixCls}-multiple`]: this.multiple,
[`${prefixCls}-single`]: !this.multiple, [`${prefixCls}-single`]: !this.multiple,
[`${prefixCls}-show-clear`]: this.showCloseIcon, [`${prefixCls}-show-clear`]: this.showCloseIcon,
@ -379,7 +380,7 @@
}, },
canBeCleared(){ canBeCleared(){
const uiStateMatch = this.hasMouseHoverHead || this.active; const uiStateMatch = this.hasMouseHoverHead || this.active;
const qualifiesForClear = !this.multiple && !this.disabled && this.clearable; const qualifiesForClear = !this.multiple && !this.itemDisabled && this.clearable;
return uiStateMatch && qualifiesForClear && this.reset; // we return a function return uiStateMatch && qualifiesForClear && this.reset; // we return a function
}, },
selectOptions() { selectOptions() {
@ -446,7 +447,7 @@
return extractOptions(this.selectOptions); return extractOptions(this.selectOptions);
}, },
selectTabindex(){ selectTabindex(){
return this.disabled || this.filterable ? -1 : 0; return this.itemDisabled || this.filterable ? -1 : 0;
}, },
remote(){ remote(){
return typeof this.remoteMethod === 'function'; return typeof this.remoteMethod === 'function';
@ -526,7 +527,7 @@
}, },
toggleMenu (e, force) { toggleMenu (e, force) {
if (this.disabled) { if (this.itemDisabled) {
return false; return false;
} }
@ -710,7 +711,7 @@
this.filterQueryChange = true; this.filterQueryChange = true;
}, },
toggleHeaderFocus({type}){ toggleHeaderFocus({type}){
if (this.disabled) { if (this.itemDisabled) {
return; return;
} }
this.isFocused = type === 'focus'; this.isFocused = type === 'focus';