7fa943eb
梁灏
init
|
1
|
<template>
|
7d5431d8
梁灏
update some style
|
2
|
<div :class="wrapClasses">
|
0f822c9b
梁灏
add Input component
|
3
|
<template v-if="type !== 'textarea'">
|
6ff31952
梁灏
optimize Input sh...
|
4
|
<div :class="[prefixCls + '-group-prepend']" v-if="prepend" v-show="slotReady" v-el:prepend><slot name="prepend"></slot></div>
|
0f822c9b
梁灏
add Input component
|
5
|
<i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon']" v-if="icon" @click="handleIconClick"></i>
|
20766f28
梁灏
update Input
|
6
|
<i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-else transition="fade"></i>
|
0f822c9b
梁灏
add Input component
|
7
|
<input
|
6c145a04
梁灏
fixed #77
|
8
|
:type="type"
|
0f822c9b
梁灏
add Input component
|
9
10
11
12
|
:class="inputClasses"
:placeholder="placeholder"
:disabled="disabled"
:maxlength="maxlength"
|
0a48ac45
梁灏
Input add readonl...
|
13
|
:readonly="readonly"
|
731d69a2
梁灏
fixed #101
|
14
|
:name="name"
|
0f822c9b
梁灏
add Input component
|
15
|
v-model="value"
|
c3a9f389
梁灏
update Input
|
16
|
:number="number"
|
0a48ac45
梁灏
Input add readonl...
|
17
18
|
@keyup.enter="handleEnter"
@focus="handleFocus"
|
c46f385a
梁灏
update DatePicker
|
19
20
|
@blur="handleBlur"
@change="handleChange">
|
6ff31952
梁灏
optimize Input sh...
|
21
|
<div :class="[prefixCls + '-group-append']" v-if="append" v-show="slotReady" v-el:append><slot name="append"></slot></div>
|
0f822c9b
梁灏
add Input component
|
22
23
24
25
26
27
|
</template>
<textarea
v-else
v-el:textarea
:class="textareaClasses"
:style="textareaStyles"
|
7d5431d8
梁灏
update some style
|
28
|
:placeholder="placeholder"
|
0f822c9b
梁灏
add Input component
|
29
30
31
|
:disabled="disabled"
:rows="rows"
:maxlength="maxlength"
|
0a48ac45
梁灏
Input add readonl...
|
32
|
:readonly="readonly"
|
731d69a2
梁灏
fixed #101
|
33
|
:name="name"
|
0f822c9b
梁灏
add Input component
|
34
|
v-model="value"
|
0a48ac45
梁灏
Input add readonl...
|
35
36
|
@keyup.enter="handleEnter"
@focus="handleFocus"
|
c46f385a
梁灏
update DatePicker
|
37
38
|
@blur="handleBlur"
@change="handleChange">
|
0f822c9b
梁灏
add Input component
|
39
|
</textarea>
|
7d5431d8
梁灏
update some style
|
40
|
</div>
|
7fa943eb
梁灏
init
|
41
42
43
|
</template>
<script>
import { oneOf } from '../../utils/assist';
|
0f822c9b
梁灏
add Input component
|
44
|
import calcTextareaHeight from '../../utils/calcTextareaHeight';
|
7fa943eb
梁灏
init
|
45
46
47
48
49
50
|
const prefixCls = 'ivu-input';
export default {
props: {
type: {
|
0f822c9b
梁灏
add Input component
|
51
|
validator (value) {
|
6c145a04
梁灏
fixed #77
|
52
|
return oneOf(value, ['text', 'textarea', 'password']);
|
0f822c9b
梁灏
add Input component
|
53
|
},
|
7fa943eb
梁灏
init
|
54
55
56
57
58
|
default: 'text'
},
value: {
type: [String, Number],
default: '',
|
c46f385a
梁灏
update DatePicker
|
59
|
// twoWay: true
|
7fa943eb
梁灏
init
|
60
|
},
|
7fa943eb
梁灏
init
|
61
62
63
64
|
size: {
validator (value) {
return oneOf(value, ['small', 'large']);
}
|
0f822c9b
梁灏
add Input component
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
},
placeholder: {
type: String,
default: ''
},
maxlength: {
type: Number
},
disabled: {
type: Boolean,
default: false
},
icon: String,
autosize: {
type: [Boolean, Object],
default: false
},
rows: {
type: Number,
default: 2
|
0a48ac45
梁灏
Input add readonl...
|
85
86
87
88
|
},
readonly: {
type: Boolean,
default: false
|
731d69a2
梁灏
fixed #101
|
89
90
91
|
},
name: {
type: String
|
c3a9f389
梁灏
update Input
|
92
93
94
95
|
},
number: {
type: Boolean,
default: false
|
7fa943eb
梁灏
init
|
96
97
98
99
|
}
},
data () {
return {
|
0f822c9b
梁灏
add Input component
|
100
101
102
|
prefixCls: prefixCls,
prepend: true,
append: true,
|
6ff31952
梁灏
optimize Input sh...
|
103
|
slotReady: false,
|
0f822c9b
梁灏
add Input component
|
104
|
textareaStyles: {}
|
b0893113
jingsam
add eslint
|
105
|
};
|
7fa943eb
梁灏
init
|
106
107
|
},
computed: {
|
7d5431d8
梁灏
update some style
|
108
|
wrapClasses () {
|
0f822c9b
梁灏
add Input component
|
109
110
111
|
return [
`${prefixCls}-wrapper`,
{
|
12418c6a
梁灏
fixed #74
|
112
|
[`${prefixCls}-wrapper-${this.size}`]: !!this.size,
|
0f822c9b
梁灏
add Input component
|
113
114
115
116
|
[`${prefixCls}-type`]: this.type,
[`${prefixCls}-group`]: this.prepend || this.append,
[`${prefixCls}-group-${this.size}`]: (this.prepend || this.append) && !!this.size
}
|
b0893113
jingsam
add eslint
|
117
|
];
|
0f822c9b
梁灏
add Input component
|
118
119
120
121
122
123
124
125
|
},
inputClasses () {
return [
`${prefixCls}`,
{
[`${prefixCls}-${this.size}`]: !!this.size,
[`${prefixCls}-disabled`]: this.disabled
}
|
b0893113
jingsam
add eslint
|
126
|
];
|
7d5431d8
梁灏
update some style
|
127
|
},
|
0f822c9b
梁灏
add Input component
|
128
|
textareaClasses () {
|
7fa943eb
梁灏
init
|
129
130
131
|
return [
`${prefixCls}`,
{
|
0f822c9b
梁灏
add Input component
|
132
|
[`${prefixCls}-disabled`]: this.disabled
|
7fa943eb
梁灏
init
|
133
|
}
|
b0893113
jingsam
add eslint
|
134
|
];
|
7fa943eb
梁灏
init
|
135
|
}
|
0f822c9b
梁灏
add Input component
|
136
137
138
139
140
141
142
143
|
},
methods: {
handleEnter () {
this.$emit('on-enter');
},
handleIconClick () {
this.$emit('on-click');
},
|
0a48ac45
梁灏
Input add readonl...
|
144
145
146
147
148
|
handleFocus () {
this.$emit('on-focus');
},
handleBlur () {
this.$emit('on-blur');
|
578ca325
梁灏
fixed Radio bug
|
149
|
this.$dispatch('on-form-blur', this.value);
|
0a48ac45
梁灏
Input add readonl...
|
150
|
},
|
e1874103
梁灏
update DatePicker
|
151
152
|
handleChange (event) {
this.$emit('on-change', event);
|
c46f385a
梁灏
update DatePicker
|
153
|
},
|
0f822c9b
梁灏
add Input component
|
154
155
156
157
158
159
160
161
162
163
|
resizeTextarea () {
const autosize = this.autosize;
if (!autosize || this.type !== 'textarea') {
return false;
}
const minRows = autosize.minRows;
const maxRows = autosize.maxRows;
this.textareaStyles = calcTextareaHeight(this.$els.textarea, minRows, maxRows);
|
b89a982e
梁灏
fixed #205
|
164
165
166
167
168
169
170
171
172
173
174
|
},
init () {
if (this.type !== 'textarea') {
this.prepend = this.$els.prepend.innerHTML !== '';
this.append = this.$els.append.innerHTML !== '';
} else {
this.prepend = false;
this.append = false;
}
this.slotReady = true;
this.resizeTextarea();
|
0f822c9b
梁灏
add Input component
|
175
176
177
|
}
},
watch: {
|
c46f385a
梁灏
update DatePicker
|
178
|
value () {
|
0f822c9b
梁灏
add Input component
|
179
180
181
|
this.$nextTick(() => {
this.resizeTextarea();
});
|
8bca1070
梁灏
update Input on-f...
|
182
|
this.$dispatch('on-form-change', this.value);
|
0f822c9b
梁灏
add Input component
|
183
184
|
}
},
|
b89a982e
梁灏
fixed #205
|
185
186
|
compiled () {
this.$nextTick(() => this.init());
|
7fa943eb
梁灏
init
|
187
|
}
|
b0893113
jingsam
add eslint
|
188
189
|
};
</script>
|