2021-06-07 17:22:07 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2023-07-06 20:59:22 +08:00
|
|
|
<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">
|
2021-06-07 17:22:07 +08:00
|
|
|
<template #default="{ node, data }">
|
|
|
|
|
<span class="custom-tree-node">
|
2023-07-06 20:59:22 +08:00
|
|
|
<span v-if="data.type == ResourceTypeEnum.Menu.value">{{ node.label }}</span>
|
|
|
|
|
<span v-if="data.type == ResourceTypeEnum.Permission.value" style="color: #67c23a">{{ node.label }}</span>
|
2023-11-24 12:12:47 +08:00
|
|
|
|
|
|
|
|
<el-popover :show-after="500" placement="right-start" title="资源分配信息" trigger="hover" :width="200">
|
|
|
|
|
<template #reference>
|
|
|
|
|
<el-link style="margin-left: 25px" icon="InfoFilled" type="info" :underline="false" />
|
|
|
|
|
</template>
|
|
|
|
|
<template #default>
|
|
|
|
|
<el-descriptions :column="1" size="small">
|
|
|
|
|
<el-descriptions-item label="资源名称">
|
|
|
|
|
{{ data.name }}
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
<el-descriptions-item label="分配账号">
|
|
|
|
|
{{ data.creator }}
|
|
|
|
|
</el-descriptions-item>
|
|
|
|
|
<el-descriptions-item label="分配时间">
|
2024-05-13 19:55:43 +08:00
|
|
|
{{ formatDate(data.createTime) }}
|
2023-11-24 12:12:47 +08:00
|
|
|
</el-descriptions-item>
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
</template>
|
|
|
|
|
</el-popover>
|
2021-06-07 17:22:07 +08:00
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-tree>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
<script lang="ts" setup>
|
2023-11-24 12:12:47 +08:00
|
|
|
import { toRefs, reactive, watch } from 'vue';
|
2023-07-06 20:59:22 +08:00
|
|
|
import { ResourceTypeEnum } from '../enums';
|
2024-05-13 19:55:43 +08:00
|
|
|
import { formatDate } from '@/common/utils/format';
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
const props = defineProps({
|
|
|
|
|
visible: {
|
|
|
|
|
type: Boolean,
|
2021-06-07 17:22:07 +08:00
|
|
|
},
|
2022-10-29 20:08:15 +08:00
|
|
|
resources: {
|
|
|
|
|
type: Array,
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2023-07-06 20:59:22 +08:00
|
|
|
});
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
//定义事件
|
2023-07-06 20:59:22 +08:00
|
|
|
const emit = defineEmits(['update:visible', 'update:resources']);
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
const defaultProps = {
|
|
|
|
|
children: 'children',
|
|
|
|
|
label: 'name',
|
2023-07-06 20:59:22 +08:00
|
|
|
};
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
const state = reactive({
|
|
|
|
|
dialogVisible: false,
|
2021-06-07 17:22:07 +08:00
|
|
|
});
|
2023-07-06 20:59:22 +08:00
|
|
|
const { dialogVisible } = toRefs(state);
|
2022-10-29 20:08:15 +08:00
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.visible,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
state.dialogVisible = newValue;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const closeDialog = () => {
|
|
|
|
|
emit('update:visible', false);
|
|
|
|
|
emit('update:resources', []);
|
|
|
|
|
};
|
2021-06-07 17:22:07 +08:00
|
|
|
</script>
|
|
|
|
|
|
2023-07-06 20:59:22 +08:00
|
|
|
<style></style>
|