support success validate status

pull/7109/head
baiyaaaaa 2017-09-14 19:34:15 +08:00 committed by 杨奕
parent 5c17f57995
commit 6e31e61516
7 changed files with 69 additions and 41 deletions

View File

@ -15,7 +15,7 @@
@change.native="displayValue = $event.target.value" @change.native="displayValue = $event.target.value"
:validateEvent="false" :validateEvent="false"
ref="reference"> ref="reference">
<i slot="icon" <i slot="suffix"
class="el-input__icon" class="el-input__icon"
@click="handleClickIcon" @click="handleClickIcon"
:class="[showClose ? 'el-icon-close' : triggerClass]" :class="[showClose ? 'el-icon-close' : triggerClass]"

View File

@ -52,6 +52,12 @@
mixins: [emitter], mixins: [emitter],
provide() {
return {
formItem: this
};
},
props: { props: {
label: String, label: String,
labelWidth: String, labelWidth: String,

View File

@ -36,11 +36,17 @@
@blur="handleBlur" @blur="handleBlur"
> >
<!-- 后置内容 --> <!-- 后置内容 -->
<span class="el-input__suffix" v-if="$slots.suffix || suffixIcon"> <span class="el-input__suffix" v-if="$slots.suffix || suffixIcon || validateState">
<slot name="suffix"></slot> <span class="el-input__suffix-inner">
<slot name="suffix"></slot>
<i class="el-input__icon"
v-if="suffixIcon"
:class="['el-icon-' + suffixIcon]">
</i>
</span>
<i class="el-input__icon" <i class="el-input__icon"
v-if="suffixIcon" v-if="validateState"
:class="['el-icon-' + suffixIcon]"> :class="['el-input__validateIcon', validateIcon]">
</i> </i>
</span> </span>
<!-- 后置元素 --> <!-- 后置元素 -->
@ -74,6 +80,8 @@
mixins: [emitter, Focus('input')], mixins: [emitter, Focus('input')],
inject: ['formItem'],
data() { data() {
return { return {
currentValue: this.value, currentValue: this.value,
@ -123,8 +131,15 @@
}, },
computed: { computed: {
validating() { validateState() {
return this.$parent.validateState === 'validating'; return this.formItem ? this.formItem.validateState : '';
},
validateIcon() {
return {
validating: 'el-icon-loading',
success: 'el-icon-circle-check',
error: 'el-icon-circle-cross'
}[this.validateState];
}, },
textareaStyle() { textareaStyle() {
return merge({}, this.textareaCalcStyle, { resize: this.resize }); return merge({}, this.textareaCalcStyle, { resize: this.resize });

View File

@ -65,7 +65,7 @@
@mouseenter.native="inputHovering = true" @mouseenter.native="inputHovering = true"
@mouseleave.native="inputHovering = false"> @mouseleave.native="inputHovering = false">
<i slot="suffix" <i slot="suffix"
:class="['el-input__icon', 'el-icon-' + iconClass]" :class="['el-select__caret', 'el-input__icon', 'el-icon-' + iconClass]"
@click="handleIconClick" @click="handleIconClick"
></i> ></i>
</el-input> </el-input>

View File

@ -80,7 +80,9 @@
@include when(error) { @include when(error) {
& .el-input__inner, & .el-input__inner,
& .el-textarea__inner { & .el-textarea__inner {
border-color: $--color-danger; &:focus {
border-color: $--color-danger;
}
} }
& .el-input-group__append, & .el-input-group__append,
& .el-input-group__prepend { & .el-input-group__prepend {
@ -88,5 +90,25 @@
border-color: transparent; border-color: transparent;
} }
} }
.el-input__validateIcon {
color: $--color-danger;
}
}
@include when(success) {
& .el-input__inner,
& .el-textarea__inner {
&, &:focus {
border-color: $--color-success;
}
}
& .el-input-group__append,
& .el-input-group__prepend {
& .el-input__inner {
border-color: transparent;
}
}
.el-input__validateIcon {
color: $--color-success;
}
} }
} }

View File

@ -41,48 +41,30 @@
@include e(suffix) { @include e(suffix) {
position: absolute; position: absolute;
height: 100%; height: 100%;
right: 0; right: 5px;
top: 0; top: 0;
text-align: center; text-align: center;
color: $--input-icon-color; color: $--input-icon-color;
transition: all .3s; transition: all .3s;
pointer-events: none;
// @include when(clickable) { }
// &:hover { @include e(suffix-inner) {
// cursor: pointer; pointer-events: all;
// color: $--input-hover-border;
// & + .el-input__inner {
// border-color: $--input-hover-border;
// }
// }
// }
} }
@include e(prefix) { @include e(prefix) {
position: absolute; position: absolute;
height: 100%; height: 100%;
left: 0; left: 5px;
top: 0; top: 0;
text-align: center; text-align: center;
color: $--input-icon-color; color: $--input-icon-color;
transition: all .3s; transition: all .3s;
// @include when(clickable) {
// &:hover {
// cursor: pointer;
// color: $--input-hover-border;
// & + .el-input__inner {
// border-color: $--input-hover-border;
// }
// }
// }
} }
@include e(icon) { @include e(icon) {
height: 100%; height: 100%;
width: 30px; width: 25px;
text-align: center; text-align: center;
// color: $--input-icon-color; // color: $--input-icon-color;
transition: all .3s; transition: all .3s;
@ -96,6 +78,10 @@
} }
} }
@include e(validateIcon) {
pointer-events: none;
}
@include when(active) { @include when(active) {
.el-input__inner { .el-input__inner {
outline: none; outline: none;
@ -121,12 +107,12 @@
} }
@include m(suffix) { @include m(suffix) {
.el-input__inner { .el-input__inner {
padding-right: 30px; padding-right: 25px;
} }
} }
@include m(prefix) { @include m(prefix) {
.el-input__inner { .el-input__inner {
padding-left: 30px; padding-left: 25px;
} }
} }
@include m(large) { @include m(large) {

View File

@ -27,13 +27,12 @@
} }
& .el-input { & .el-input {
& .el-input__icon { & .el-select__caret {
color: $--select-input-color; color: $--select-input-color;
font-size: $--select-input-font-size; font-size: $--select-input-font-size;
transition: transform .3s; transition: transform .3s;
transform: rotateZ(180deg); transform: rotateZ(180deg);
line-height: 16px; line-height: 16px;
top: 50%;
cursor: pointer; cursor: pointer;
@include when(reverse) { @include when(reverse) {
@ -42,10 +41,10 @@
@include when(show-close) { @include when(show-close) {
transition: 0s; transition: 0s;
height: 16px; // height: 16px;
width: 16px; // width: 16px;
font-size: $--select-font-size; font-size: $--select-font-size;
right: 8px; // right: 8px;
text-align: center; text-align: center;
transform: rotateZ(180deg); transform: rotateZ(180deg);
border-radius: $--border-radius-circle; border-radius: $--border-radius-circle;