gridItem.vue
3.18 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
<div class="row-wrapper">
<div v-for="item in schema"
:key="item.name"
class="col-wrapper van-col-wrapper"
:style="item.colStyle">
<Tooltip v-if="item.tips"
:content="item.tips"
:hide-after="1500"
:options="{
triggers: ['click'],
placement: 'top',
autoHide: true,
disabled: !item.tips,
}">
<div class="item-wrapper"
:class="{ special: item.special }"
:style="item.style">
<div class="label">
<div class="text-hide" style="margin-right:2px">
{{ item.label }}
</div>
<SvgIcon v-if="item.tips"
class="icon"
color="#DCDDE1"
name="form-tips"
size="16px" />
</div>
<div class="value text-hide ">
{{ getValue(item.name, item) }}
</div>
</div>
</Tooltip>
<div v-else
class="item-wrapper"
:class="{ special: item.special }"
:style="item.style">
<div class="label">
<div class="text-hide" style="margin-right:2px">
{{ item.label }}
</div>
<SvgIcon v-if="item.tips"
class="icon"
color="#DCDDE1"
name="form-tips"
size="16px" />
</div>
<div class="value text-hide ">
{{ getValue(item.name, item) }}
</div>
</div>
</div>
</div>
<!-- <van-row gutter="4">
<van-col v-for="item in schema"
:key="item.name"
class="van-col-wrapper"
:span="item.col">
</van-col>
</van-row> -->
</template>
<script>
import { get } from "lodash-es";
import { Col, Divider, Icon, Row } from "vant";
import SvgIcon from "@/components/svgIcon/index.vue";
import Tooltip from "@/components/tooltip/index.vue";
export default {
name: "",
components: {
[Col.name]: Col,
[Row.name]: Row,
[Divider.name]: Divider,
[Icon.name]: Icon,
SvgIcon,
Tooltip,
},
props: {
schema: {
type: Array,
default: () => ([]),
},
data: {
type: Object,
default: () => ({}),
},
},
data() {
return {
};
},
computed: {
},
mounted() {
},
methods: {
getValue(path, schema) {
return get(this.data, path) || schema.emptyValue || "-";
},
},
};
</script>
<style scoped lang="scss">
.row-wrapper {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.van-col-wrapper {
overflow: hidden;
flex-shrink: 0;
margin-right: 4px;
&:last-child {
margin-right: 0;
}
.item-wrapper {
background: #f8f8f8;
padding: 8px 12px;
overflow: hidden;
box-sizing: border-box;
.label {
font-weight: 400;
font-size: 12px;
line-height: 20px;
color: rgba(0, 0, 0, 0.26);
display: flex;
align-items: center;
flex-wrap: nowrap;
flex-shrink: 0;
.icon {
flex-shrink: 0;
}
}
.value {
margin-top: 4px;
font-family: numberNor;
font-weight: 500;
font-size: 16px;
line-height: 20px;
color: var(--themeColor);
flex-shrink: 0;
}
}
}
</style>