Input support Form's disabled

This commit is contained in:
梁灏 2019-09-16 19:15:38 +08:00
parent 573eecd487
commit f7f276b419

View file

@ -2,7 +2,7 @@
<div :class="wrapClasses"> <div :class="wrapClasses">
<template v-if="type !== 'textarea'"> <template v-if="type !== 'textarea'">
<div :class="[prefixCls + '-group-prepend']" v-if="prepend" v-show="slotReady"><slot name="prepend"></slot></div> <div :class="[prefixCls + '-group-prepend']" v-if="prepend" v-show="slotReady"><slot name="prepend"></slot></div>
<i class="ivu-icon" :class="['ivu-icon-ios-close-circle', prefixCls + '-icon', prefixCls + '-icon-clear' , prefixCls + '-icon-normal']" v-if="clearable && currentValue && !disabled" @click="handleClear"></i> <i class="ivu-icon" :class="['ivu-icon-ios-close-circle', prefixCls + '-icon', prefixCls + '-icon-clear' , prefixCls + '-icon-normal']" v-if="clearable && currentValue && !itemDisabled" @click="handleClear"></i>
<i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon', prefixCls + '-icon-normal']" v-else-if="icon" @click="handleIconClick"></i> <i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon', prefixCls + '-icon-normal']" v-else-if="icon" @click="handleIconClick"></i>
<i class="ivu-icon ivu-icon-ios-search" :class="[prefixCls + '-icon', prefixCls + '-icon-normal', prefixCls + '-search-icon']" v-else-if="search && enterButton === false" @click="handleSearch"></i> <i class="ivu-icon ivu-icon-ios-search" :class="[prefixCls + '-icon', prefixCls + '-icon-normal', prefixCls + '-search-icon']" v-else-if="search && enterButton === false" @click="handleSearch"></i>
<span class="ivu-input-suffix" v-else-if="showSuffix"><slot name="suffix"><i class="ivu-icon" :class="['ivu-icon-' + suffix]" v-if="suffix"></i></slot></span> <span class="ivu-input-suffix" v-else-if="showSuffix"><slot name="suffix"><i class="ivu-icon" :class="['ivu-icon-' + suffix]" v-if="suffix"></i></slot></span>
@ -22,7 +22,7 @@
:type="currentType" :type="currentType"
:class="inputClasses" :class="inputClasses"
:placeholder="placeholder" :placeholder="placeholder"
:disabled="disabled" :disabled="itemDisabled"
:maxlength="maxlength" :maxlength="maxlength"
:readonly="readonly" :readonly="readonly"
:name="name" :name="name"
@ -57,7 +57,7 @@
:class="textareaClasses" :class="textareaClasses"
:style="textareaStyles" :style="textareaStyles"
:placeholder="placeholder" :placeholder="placeholder"
:disabled="disabled" :disabled="itemDisabled"
:rows="rows" :rows="rows"
:maxlength="maxlength" :maxlength="maxlength"
:readonly="readonly" :readonly="readonly"
@ -83,12 +83,13 @@
import { oneOf, findComponentUpward } from '../../utils/assist'; import { oneOf, findComponentUpward } from '../../utils/assist';
import calcTextareaHeight from '../../utils/calcTextareaHeight'; import calcTextareaHeight from '../../utils/calcTextareaHeight';
import Emitter from '../../mixins/emitter'; import Emitter from '../../mixins/emitter';
import mixinsForm from '../../mixins/form';
const prefixCls = 'ivu-input'; const prefixCls = 'ivu-input';
export default { export default {
name: 'Input', name: 'Input',
mixins: [ Emitter ], mixins: [ Emitter, mixinsForm ],
props: { props: {
type: { type: {
validator (value) { validator (value) {
@ -247,7 +248,7 @@
`${prefixCls}`, `${prefixCls}`,
{ {
[`${prefixCls}-${this.size}`]: !!this.size, [`${prefixCls}-${this.size}`]: !!this.size,
[`${prefixCls}-disabled`]: this.disabled, [`${prefixCls}-disabled`]: this.itemDisabled,
[`${prefixCls}-with-prefix`]: this.showPrefix, [`${prefixCls}-with-prefix`]: this.showPrefix,
[`${prefixCls}-with-suffix`]: this.showSuffix || (this.search && this.enterButton === false) [`${prefixCls}-with-suffix`]: this.showSuffix || (this.search && this.enterButton === false)
} }
@ -257,7 +258,7 @@
return [ return [
`${prefixCls}`, `${prefixCls}`,
{ {
[`${prefixCls}-disabled`]: this.disabled [`${prefixCls}-disabled`]: this.itemDisabled
} }
]; ];
}, },
@ -362,12 +363,12 @@
this.$emit('on-clear'); this.$emit('on-clear');
}, },
handleSearch () { handleSearch () {
if (this.disabled) return false; if (this.itemDisabled) return false;
this.$refs.input.focus(); this.$refs.input.focus();
this.$emit('on-search', this.currentValue); this.$emit('on-search', this.currentValue);
}, },
handleToggleShowPassword () { handleToggleShowPassword () {
if (this.disabled) return false; if (this.itemDisabled) return false;
this.showPassword = !this.showPassword; this.showPassword = !this.showPassword;
this.focus(); this.focus();
const len = this.currentValue.length; const len = this.currentValue.length;