forked from N3-components/N3-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
n3Textarea.vue
117 lines (108 loc) · 2.24 KB
/
n3Textarea.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<div :class="classObj" :style="{width:width}">
<textarea
class="{{prefixCls}}-form-control"
:disabled="disabled"
:readonly="readonly"
:maxlength="maxLength"
:style="styleObj"
:name="name"
:placeholder="placeholder"
v-model="value">
</textarea>
<validate
:name="name"
:valid-status.sync="validStatus"
:rules="rules"
:custom-validate="customValidate"
:value="value"
:results.sync="validateResults">
</validate>
</div>
</template>
<script>
import validate from './validate'
export default {
props: {
name: {
type: String
},
disabled: {
type: Boolean
},
readonly: {
type: Boolean
},
placeholder: {
type: String,
default: ''
},
resize: {
type: Boolean,
default: true
},
width: {
type: String,
default: '220px'
},
maxLength: {
type: Number
},
maxHeight: {
type: String
},
minHeight: {
type: String
},
value: {
type: String,
twoway: true
},
validStatus: {
type: String,
twoway: true,
default: ''
},
customValidate: {
type: Function
},
rules: {
type: Array
},
prefixCls: {
type: String,
default: 'n3'
}
},
data () {
return {
validateResults: {}
}
},
components: {
validate
},
computed: {
styleObj () {
let {resize, maxHeight, minHeight} = this
let style = {}
style['maxWidth'] = '100%'
style['width'] = '100%'
style['maxHeight'] = maxHeight
style['minHeight'] = minHeight
!resize ? style['resize'] = 'none' : ''
return style
},
classObj () {
let {prefixCls, validStatus} = this
let klass = {}
klass[prefixCls + '-has-error'] = validStatus === 'error'
klass[prefixCls + '-has-success'] = validStatus === 'success'
klass[prefixCls + '-has-warn'] = validStatus === 'warn'
klass[prefixCls + '-textarea-con'] = true
klass['inline'] = true
return klass
}
}
}
</script>