123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <template>
- <!-- TODO @puhui999:左边不用有空隙哈 -->
- <div class="pt-20px">
- <el-timeline>
- <el-timeline-item
- v-for="(log, index) in logList"
- :key="index"
- :timestamp="formatDate(log.createTime)"
- placement="top"
- >
- <div class="el-timeline-right-content">
- <el-tag class="mr-10px" type="success">{{ log.userName }}</el-tag>
- {{ log.action }}
- </div>
- <template #dot>
- <span :style="{ backgroundColor: getUserTypeColor(log.userType) }" class="dot-node-style">
- {{ getDictLabel(DICT_TYPE.USER_TYPE, log.userType)[0] }}
- </span>
- </template>
- </el-timeline-item>
- </el-timeline>
- </div>
- </template>
- <script lang="ts" setup>
- import { OperateLogV2VO } from '@/api/system/operatelog'
- import { formatDate } from '@/utils/formatTime'
- import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
- import { ElTag } from 'element-plus'
- defineOptions({ name: 'OperateLogV2' })
- interface Props {
- logList: OperateLogV2VO[] // 操作日志列表
- }
- withDefaults(defineProps<Props>(), {
- logList: () => []
- })
- /** 获得 userType 颜色 */
- const getUserTypeColor = (type: number) => {
- const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
- switch (dict?.colorType) {
- case 'success':
- return '#67C23A'
- case 'info':
- return '#909399'
- case 'warning':
- return '#E6A23C'
- case 'danger':
- return '#F56C6C'
- }
- return '#409EFF'
- }
- </script>
- <style lang="scss" scoped>
- // 时间线样式调整
- :deep(.el-timeline) {
- margin: 10px 0 0 110px;
- .el-timeline-item__wrapper {
- position: relative;
- top: -20px;
- .el-timeline-item__timestamp {
- position: absolute !important;
- top: 10px;
- left: -150px;
- }
- }
- .el-timeline-right-content {
- display: flex;
- align-items: center;
- min-height: 30px;
- padding: 10px;
- background-color: #fff;
- &::before {
- position: absolute;
- top: 10px;
- left: 13px; /* 将伪元素水平居中 */
- border-color: transparent #fff transparent transparent; /* 尖角颜色,左侧朝向 */
- border-style: solid;
- border-width: 8px; /* 调整尖角大小 */
- content: ''; /* 必须设置 content 属性 */
- }
- }
- }
- .dot-node-style {
- position: absolute;
- left: -5px;
- display: flex;
- width: 20px;
- height: 20px;
- font-size: 10px;
- color: #fff;
- border-radius: 50%;
- justify-content: center;
- align-items: center;
- }
- </style>
|