DataListItem.vue
2.59 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
<template>
<section class="data-list-item" @click="$emit('click')">
<div class="item-title">
<div class="title-tag">
<slot name="tag"></slot>
</div>
<span class="title-content" v-indent="10">{{data.title}}</span>
</div>
<div class="item-bottom">
<div class="bottom-content">
<slot v-bind:value="data" name="bottomLeft" />
<template v-if="!$slots.bottomLeft">
<img class="bottom-icon" src="@/assets/icon/icon_clock.png">
<span class="bottom-text">{{dateText}}{{data.date}}</span>
</template>
</div>
<div class="bottom-content">
<slot v-bind:value="data" name="bottomRight" />
<template v-if="!$slots.bottomRight">
<img class="bottom-icon" src="@/assets/icon/icon_classify.png">
<span>{{data.dataType}}</span>
</template>
</div>
</div>
</section>
</template>
<script>
export default {
name: 'DataListItem',
props: {
data: {
type: Object,
default: () => { return {} }
},
dateText: {
type: String
},
tag: {
type: String
}
},
data () {
return {}
},
methods: {
},
directives: {
indent: {
inserted (el, binding) {
setTimeout(() => {
const nodes = el.previousElementSibling.childNodes
const data = { width: 0 }
for (const node of nodes) {
data.width = data.width + node.offsetWidth
}
if (!data.width) return
const indentSize = data.width + (binding.value || 0)
console.log(indentSize);
el.style.textIndent = `${indentSize}px`
}, 0);
}
}
}
}
</script>
<style lang="less" scoped>
@import '~@/assets/css/mixins.less';
@PaddingSize: 11px;
.data-list-item {
padding: @PaddingSize 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
.item-title {
display: flex;
flex-wrap: wrap;
align-items: center;
line-height: 25px;
position: relative;
.title-tag {
position: absolute;
left: 0;
top: 0;
bottom: 0;
// margin-right: 10px;
}
.title-content {
font-size: 16px;
color: #222222;
line-height: 25px;
.line-clamp(2);
}
}
.item-bottom {
padding-top: 10px;
display: flex;
justify-content: space-between;
.bottom-content {
display: flex;
align-items: center;
color: #999999;
line-height: 16px;
font-size: 12px;
@IconSize: 15px;
.bottom-icon {
width: @IconSize;
height: @IconSize;
margin-right: 7px;
}
}
}
}
</style>