Files
mayfly-go/frontend/src/views/system/role/ShowResource.vue

82 lines
2.9 KiB
Vue
Raw Normal View History

<template>
<div>
<el-dialog @close="closeDialog" :title="title" :before-close="closeDialog" v-model="dialogVisible" width="400px">
2022-03-09 17:07:35 +08:00
<el-tree style="height: 50vh; overflow: auto" :data="resources" node-key="id" :props="defaultProps">
<template #default="{ node, data }">
<span class="custom-tree-node">
<SvgIcon :name="getMenuIcon(data)" class="mb-0.5 mr-0.5" />
2024-11-20 22:43:53 +08:00
<span v-if="data.type == ResourceTypeEnum.Menu.value">{{ $t(node.label) }}</span>
<span v-if="data.type == ResourceTypeEnum.Permission.value" style="color: #67c23a">{{ $t(node.label) }}</span>
2023-11-24 12:12:47 +08:00
2024-11-20 22:43:53 +08:00
<el-popover :show-after="500" placement="right-start" :title="$t('system.role.permissionInfo')" trigger="hover" :width="300">
2023-11-24 12:12:47 +08:00
<template #reference>
<el-link style="margin-left: 25px" icon="InfoFilled" type="info" :underline="false" />
</template>
<template #default>
<el-descriptions :column="1" size="small">
2024-11-20 22:43:53 +08:00
<el-descriptions-item :label="$t('common.name')">
{{ $t(data.name) }}
2023-11-24 12:12:47 +08:00
</el-descriptions-item>
2024-11-20 22:43:53 +08:00
<el-descriptions-item :label="$t('system.role.assigner')">
2023-11-24 12:12:47 +08:00
{{ data.creator }}
</el-descriptions-item>
2024-11-20 22:43:53 +08:00
<el-descriptions-item :label="$t('system.role.allocateTime')">
{{ formatDate(data.createTime) }}
2023-11-24 12:12:47 +08:00
</el-descriptions-item>
</el-descriptions>
</template>
</el-popover>
</span>
</template>
</el-tree>
</el-dialog>
</div>
</template>
<script lang="ts" setup>
2023-11-24 12:12:47 +08:00
import { toRefs, reactive, watch } from 'vue';
import { ResourceTypeEnum } from '../enums';
import { formatDate } from '@/common/utils/format';
import { getMenuIcon } from '../resource/index';
const props = defineProps({
visible: {
type: Boolean,
},
resources: {
type: Array,
},
title: {
type: String,
},
});
//定义事件
const emit = defineEmits(['update:visible', 'update:resources']);
const defaultProps = {
children: 'children',
label: 'name',
};
const state = reactive({
dialogVisible: false,
});
const { dialogVisible } = toRefs(state);
watch(
() => props.visible,
(newValue) => {
state.dialogVisible = newValue;
}
);
const closeDialog = () => {
emit('update:visible', false);
emit('update:resources', []);
};
</script>
<style></style>