-
Notifications
You must be signed in to change notification settings - Fork 19
/
FieldValue.vue
81 lines (78 loc) · 1.41 KB
/
FieldValue.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
<template>
<div class="field-item">
<b class="field-item-title">
{{ title }}{{ isRequired ? '*' : '' }}:
</b>
<div class="field-item-value">
{{ valueContent }}
</div>
<EyeIcon v-if="encryptValue && withInspection && !inspect"
:size="16"
class="field-item-inspect-btn"
@click="toggleInspection" />
<EyeOffIcon v-else-if="inspect"
:size="16"
class="field-item-inspect-off-btn"
@click="toggleInspection" />
</div>
</template>
<script>
import EyeIcon from 'vue-material-design-icons/Eye.vue'
import EyeOffIcon from 'vue-material-design-icons/EyeOff.vue'
export default {
name: 'FieldValue',
components: {
EyeIcon, EyeOffIcon,
},
props: {
title: {
type: String,
required: true,
},
value: {
type: String,
required: true,
},
isRequired: {
type: Boolean,
default: false,
},
encryptValue: {
type: Boolean,
default: false,
},
withInspection: {
type: Boolean,
default: false,
},
},
data: () => ({
inspect: false,
}),
computed: {
encryptedValue() {
return this.value.substring(0, 8) + '*'.repeat(15)
},
valueContent() {
return (this.encryptValue && !this.inspect)
? this.encryptedValue
: this.value
},
},
methods: {
toggleInspection() {
this.inspect = !this.inspect
},
},
}
</script>
<style lang="scss">
.field-item {
padding: 6px 0;
display: flex;
align-items: center;
&-value {
padding: 0 4px;
}
}
</style>