forked from ElemeFE/vue-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabel.vue
70 lines (57 loc) · 1.87 KB
/
label.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
<template>
<div class='d-field d-labelfield' :class="{ 'validate-error': hintType === 'error', required: isRequired, 'd-field-hashint': !hideHint }">
<label :style="{ width: labelWidth != null ? labelWidth + 'px' : '' }" v-show="!hideLabel">{{ labelText }}</label>
<div class="d-field-content" :style="{ marginLeft: labelWidth != null ? labelWidth + 'px' : '' }">
<div class="d-labelfield-content">
{{ textValue }}
</div>
<div class="d-field-hint" v-if="!hideHint">
<i class='d-icon' :class="{ 'd-icon-error': hintType === 'error', 'd-icon-warning': hintType === 'warning' }"></i>{{ hintMessage || '' }}
</div>
</div>
</div>
</template>
<style>
.d-labelfield {
}
.d-labelfield-content {
font-size: 14px;
padding-left: 4px;
padding-right: 24px;
box-sizing: border-box;
border-radius: 2px;
line-height: 28px;
height: 28px;
}
</style>
<script type="text/ecmascript-6">
import { merge, getPath } from '../../util';
import { default as common } from './field-common';
export default {
props: common.props,
computed: merge({
textValue() {
var mapping = this.mapping;
if (mapping) {
var reversedMap = {};
for (var label in mapping) {
if (mapping.hasOwnProperty(label)) {
var value = mapping[label];
reversedMap[value] = label;
}
}
var currentValue = getPath(this.model, this.property);
if (mapping && currentValue !== null && currentValue !== undefined) {
return reversedMap[currentValue];
}
}
return getPath(this.model, this.property);
}
}, common.computed),
events: common.events,
created: common.onCreated,
destroyed: common.onDestroyed,
compiled: common.onCompiled,
methods: common.methods
};
</script>