form-field-textarea.js
860 Bytes
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
Component({
properties: {
field: {
type: Object,
value: {}
},
value: {
type: String,
value: ''
},
disabled: {
type: Boolean,
value: false
},
error: {
type: String,
value: ''
},
groupKey: { type: String, value: '' },
rowIndex: { type: Number, value: -1 }
},
data: {
currentLength: 0
},
observers: {
value: function (value) {
this.setData({
currentLength: (value || '').length
})
}
},
methods: {
onInput(e) {
if (this.data.disabled) return
const detail = { key: this.data.field.key, value: e.detail.value }
if (this.properties.groupKey) {
detail.groupKey = this.properties.groupKey
const rowIndex = Number(this.properties.rowIndex)
if (!Number.isNaN(rowIndex) && rowIndex >= 0) {
detail.rowIndex = rowIndex
}
}
this.triggerEvent('change', detail)
}
}
})