2021-06-07 17:22:07 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2022-10-29 20:08:15 +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">
|
2022-10-29 20:08:15 +08:00
|
|
|
<span v-if="data.type == enums.ResourceTypeEnum['MENU'].value">{{ node.label }}</span>
|
|
|
|
|
<span v-if="data.type == enums.ResourceTypeEnum['PERMISSION'].value" style="color: #67c23a">{{
|
|
|
|
|
node.label
|
|
|
|
|
}}</span>
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2023-06-15 19:18:29 +08:00
|
|
|
<!-- <el-link @click.prevent="info(data)" style="margin-left: 25px" icon="InfoFilled" type="info"
|
|
|
|
|
:underline="false" /> -->
|
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>
|
|
|
|
|
import { getCurrentInstance, toRefs, reactive, watch } from 'vue';
|
2021-06-07 17:22:07 +08:00
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
|
|
import enums from '../enums';
|
|
|
|
|
|
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,
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +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 { proxy } = getCurrentInstance() as any;
|
2021-06-07 17:22:07 +08:00
|
|
|
|
2022-10-29 20:08:15 +08:00
|
|
|
const defaultProps = {
|
|
|
|
|
children: 'children',
|
|
|
|
|
label: 'name',
|
|
|
|
|
}
|
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
|
|
|
});
|
2022-10-29 20:08:15 +08:00
|
|
|
const {
|
|
|
|
|
dialogVisible,
|
|
|
|
|
} = toRefs(state)
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.visible,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
state.dialogVisible = newValue;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const info = (info: any) => {
|
|
|
|
|
ElMessageBox.alert(
|
|
|
|
|
'<strong style="margin-right: 18px">资源名称:</strong>' +
|
|
|
|
|
info.name +
|
|
|
|
|
' <br/><strong style="margin-right: 18px">分配账号:</strong>' +
|
|
|
|
|
info.creator +
|
|
|
|
|
' <br/><strong style="margin-right: 18px">分配时间:</strong>' +
|
|
|
|
|
proxy.$filters.dateFormat(info.createTime) +
|
|
|
|
|
'',
|
|
|
|
|
'分配信息',
|
|
|
|
|
{
|
|
|
|
|
type: 'info',
|
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
|
closeOnClickModal: true,
|
|
|
|
|
showConfirmButton: false,
|
|
|
|
|
}
|
|
|
|
|
).catch(() => { });
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeDialog = () => {
|
|
|
|
|
emit('update:visible', false);
|
|
|
|
|
emit('update:resources', []);
|
|
|
|
|
};
|
2021-06-07 17:22:07 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
2022-10-29 20:08:15 +08:00
|
|
|
|
2021-06-07 17:22:07 +08:00
|
|
|
</style>
|