Timeline.vue
3.9 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
154
155
156
<template>
<el-dialog title="新增信息" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
<div class="dialog-body">
<el-timeline v-if="lineList.length">
<el-timeline-item :timestamp="line.time" placement="top" v-for="(line, index) in lineList" :key="index"">
<div class=" card-box">
<div class="card-item" v-for="(card, cardIndex) in line.list"" :key="cardIndex">
<div class=" card-content">运营{{ card.createdBy }}</div>
<div class="card-content" v-if="card.opType == 0">原保管人:{{ card.oldCustodian }}</div>
<div class="card-content">
现保管人:{{ card.newCustodian }}<span v-if="card.opType == 1">派发时间:{{ card.disDate }}</span>
</div>
<div class="card-content" v-if="card.remark">备注:{{ card.remark }}</div>
<div class="card-content">{{ card.createdTime }}</div>
<div class="card-btn">
{{ card.opType === 1 ? '新增' : '变更' }}
</div>
</div>
</div>
</el-timeline-item>
</el-timeline>
<div class="empty-box" v-else>
<img src="@/assets/empty.png">
<div class="empty-text">暂无记录</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button type="primary" @click="handleClose">确 定</el-button>
</span>
</el-dialog>
</template>
<script type="text/ecmascript-6">
import { Util } from "@/common/util"
import { findAllRecord } from "@api/tablet"
export default {
name: 'Timeline',
props: {
dialogVisible: {
type: Boolean,
default: true
},
recordId: [Number, String]
},
data() {
return {
lineList: [{
time: '2020-10-02',
cardList: [1, 2, 3]
}, {
time: '2020-10-02',
cardList: [1, 2, 3]
}]
}
},
watch: {
dialogVisible(val) {
if (val) {
this.findAllRecord()
}
}
},
mounted() {
},
methods: {
findAllRecord() {
findAllRecord({ id: this.recordId }).then((res) => {
const groupedByDisDate = res.reduce((acc, current) => {
current.disDate = Util.dateFormate(current.disDate, "YYYY-MM-DD")
current.createdTime = Util.dateFormate(current.createdTime, "YYYY-MM-DD HH:mm:ss")
current.time = Util.dateFormate(current.createdTime, "YYYY-MM-DD")
if (!acc[current.time]) {
acc[current.time] = [];
}
acc[current.time].push(current);
return acc;
}, {});
const result = Object.values(groupedByDisDate);
console.log(groupedByDisDate);
const resultWithListField = Object.keys(groupedByDisDate).map(time => ({
time,
list: groupedByDisDate[time]
}));
this.lineList = resultWithListField
})
},
handleClose() {
this.$emit('close')
}
}
}
</script>
<style scoped lang="scss">
.dialog-body {
max-height: calc(100vh - 400px);
overflow-y: auto;
.card-box {
.card-item {
width: 90%;
padding: 12px;
opacity: 1;
border: 1px solid #e5e5e5;
background: #ffffff6b;
margin-bottom: 8px;
position: relative;
.card-btn {
background: #e7eefe;
line-height: 20px;
text-align: center;
position: absolute;
width: 40px;
height: 20px;
border-radius: 2px;
opacity: 1;
background: #e7eefe;
color: #185efe;
font-size: 12px;
right: 0px;
top: 0px;
}
.card-content {
color: #666666;
font-size: 12px;
line-height: 26px;
span {
margin-left: 20px;
}
}
}
}
}
.empty-box {
text-align: center;
img {
width: 64px;
height: 40px;
margin-top: 100px;
}
.empty-text {
color: #666666;
}
}
</style>