提交 | 用户 | 时间
|
314507
|
1 |
<!-- 某个记录的操作日志列表,目前主要用于 CRM 客户、商机等详情界面 --> |
H |
2 |
<template> |
|
3 |
<div class="pt-20px"> |
|
4 |
<el-timeline> |
|
5 |
<el-timeline-item |
|
6 |
v-for="(log, index) in logList" |
|
7 |
:key="index" |
|
8 |
:timestamp="formatDate(log.createTime)" |
|
9 |
placement="top" |
|
10 |
> |
|
11 |
<div class="el-timeline-right-content"> |
|
12 |
<el-tag class="mr-10px" type="success">{{ log.userName }}</el-tag> |
|
13 |
{{ log.action }} |
|
14 |
</div> |
|
15 |
<template #dot> |
|
16 |
<span :style="{ backgroundColor: getUserTypeColor(log.userType) }" class="dot-node-style"> |
|
17 |
{{ getDictLabel(DICT_TYPE.USER_TYPE, log.userType)[0] }} |
|
18 |
</span> |
|
19 |
</template> |
|
20 |
</el-timeline-item> |
|
21 |
</el-timeline> |
|
22 |
</div> |
|
23 |
</template> |
|
24 |
|
|
25 |
<script lang="ts" setup> |
|
26 |
import { OperateLogVO } from '@/api/system/operatelog' |
|
27 |
import { formatDate } from '@/utils/formatTime' |
|
28 |
import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict' |
|
29 |
import { ElTag } from 'element-plus' |
|
30 |
|
|
31 |
defineOptions({ name: 'OperateLogV2' }) |
|
32 |
|
|
33 |
interface Props { |
|
34 |
logList: OperateLogVO[] // 操作日志列表 |
|
35 |
} |
|
36 |
|
|
37 |
withDefaults(defineProps<Props>(), { |
|
38 |
logList: () => [] |
|
39 |
}) |
|
40 |
|
|
41 |
/** 获得 userType 颜色 */ |
|
42 |
const getUserTypeColor = (type: number) => { |
|
43 |
const dict = getDictObj(DICT_TYPE.USER_TYPE, type) |
|
44 |
switch (dict?.colorType) { |
|
45 |
case 'success': |
|
46 |
return '#67C23A' |
|
47 |
case 'info': |
|
48 |
return '#909399' |
|
49 |
case 'warning': |
|
50 |
return '#E6A23C' |
|
51 |
case 'danger': |
|
52 |
return '#F56C6C' |
|
53 |
} |
|
54 |
return '#409EFF' |
|
55 |
} |
|
56 |
</script> |
|
57 |
|
|
58 |
<style lang="scss" scoped> |
|
59 |
// 时间线样式调整 |
|
60 |
:deep(.el-timeline) { |
|
61 |
margin: 10px 0 0 110px; |
|
62 |
|
|
63 |
.el-timeline-item__wrapper { |
|
64 |
position: relative; |
|
65 |
top: -20px; |
|
66 |
|
|
67 |
.el-timeline-item__timestamp { |
|
68 |
position: absolute !important; |
|
69 |
top: 10px; |
|
70 |
left: -150px; |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
.el-timeline-right-content { |
|
75 |
display: flex; |
|
76 |
align-items: center; |
|
77 |
min-height: 30px; |
|
78 |
padding: 10px; |
|
79 |
background-color: #fff; |
|
80 |
|
|
81 |
&::before { |
|
82 |
position: absolute; |
|
83 |
top: 10px; |
|
84 |
left: 13px; /* 将伪元素水平居中 */ |
|
85 |
border-color: transparent #fff transparent transparent; /* 尖角颜色,左侧朝向 */ |
|
86 |
border-style: solid; |
|
87 |
border-width: 8px; /* 调整尖角大小 */ |
|
88 |
content: ''; /* 必须设置 content 属性 */ |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
.dot-node-style { |
|
94 |
position: absolute; |
|
95 |
left: -5px; |
|
96 |
display: flex; |
|
97 |
width: 20px; |
|
98 |
height: 20px; |
|
99 |
font-size: 10px; |
|
100 |
color: #fff; |
|
101 |
border-radius: 50%; |
|
102 |
justify-content: center; |
|
103 |
align-items: center; |
|
104 |
} |
|
105 |
</style> |