Files
iot-device-management-frontend/apps/web-antd/src/components/operate-log/operate-log.vue

52 lines
1.5 KiB
Vue
Raw Normal View History

2025-06-03 18:44:13 +08:00
<script setup lang="ts">
// TODO @xingyu要不要改成 yudao-ui-admin-vue3/src/components/OperateLogV2/src/OperateLogV2.vue 这种一行时间、userType、userName、action
2025-06-03 18:44:13 +08:00
import type { OperateLogProps } from './typing';
2025-09-04 20:42:56 +08:00
import { DICT_TYPE } from '@vben/constants';
import { getDictLabel, getDictObj } from '@vben/hooks';
2025-06-06 12:33:02 +08:00
import { formatDateTime } from '@vben/utils';
import { Tag, Timeline } from 'ant-design-vue';
2025-06-03 18:44:13 +08:00
defineOptions({ name: 'OperateLogV2' });
withDefaults(defineProps<OperateLogProps>(), {
logList: () => [],
});
function getUserTypeColor(userType: number) {
const dict = getDictObj(DICT_TYPE.USER_TYPE, userType);
2025-10-17 15:29:51 +08:00
if (dict && dict.colorType) {
return `hsl(var(--${dict.colorType}))`;
2025-06-03 18:44:13 +08:00
}
2025-10-17 15:29:51 +08:00
return 'hsl(var(--primary))';
2025-06-03 18:44:13 +08:00
}
</script>
<template>
<div>
<Timeline>
<Timeline.Item
v-for="log in logList"
:key="log.id"
:color="getUserTypeColor(log.userType)"
>
2025-06-06 12:33:02 +08:00
<template #dot>
<p
:style="{ backgroundColor: getUserTypeColor(log.userType) }"
2025-10-17 15:29:51 +08:00
class="absolute left-1 top-0 flex h-5 w-5 items-center justify-center rounded-full text-xs text-white"
2025-06-06 12:33:02 +08:00
>
{{ getDictLabel(DICT_TYPE.USER_TYPE, log.userType)[0] }}
</p>
</template>
2025-10-17 15:29:51 +08:00
<p class="ml-2">{{ formatDateTime(log.createTime) }}</p>
<p class="ml-2 mt-2">
2025-06-06 12:33:02 +08:00
<Tag :color="getUserTypeColor(log.userType)">
{{ log.userName }}
</Tag>
{{ log.action }}
</p>
2025-06-03 18:44:13 +08:00
</Timeline.Item>
</Timeline>
</div>
</template>