113 lines
2.5 KiB
Vue
113 lines
2.5 KiB
Vue
<script setup>
|
|
import { ref } from "vue";
|
|
|
|
const tableData = ref([
|
|
{
|
|
id: 1,
|
|
name: "超级管理员",
|
|
description: "系统最高权限",
|
|
permissions: ["all"],
|
|
createTime: "2024-03-20",
|
|
},
|
|
{
|
|
id: 2,
|
|
name: "管理人员",
|
|
description: "日常运维管理",
|
|
permissions: ["monitor", "patrol"],
|
|
createTime: "2024-03-20",
|
|
},
|
|
]);
|
|
|
|
const handleEdit = (row) => {
|
|
console.log("编辑角色:", row);
|
|
};
|
|
|
|
const handleDelete = (row) => {
|
|
console.log("删除角色:", row);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="role-container">
|
|
<el-card>
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span>角色管理</span>
|
|
<el-button type="primary">新增角色</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<el-table :data="tableData" style="width: 100%">
|
|
<el-table-column prop="id" label="ID" width="80" />
|
|
<el-table-column prop="name" label="角色名称" width="120" />
|
|
<el-table-column prop="description" label="描述" />
|
|
<el-table-column label="权限" width="200">
|
|
<template #default="{ row }">
|
|
<el-tag v-for="perm in row.permissions" :key="perm" class="permission-tag">
|
|
{{ perm }}
|
|
</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="createTime" label="创建时间" width="180" />
|
|
<el-table-column label="操作" width="180">
|
|
<template #default="{ row }">
|
|
<el-button type="primary" size="small" @click="handleEdit(row)">
|
|
编辑
|
|
</el-button>
|
|
<el-button type="danger" size="small" @click="handleDelete(row)">
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-card>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
@use "../../../styles/variables.scss" as *;
|
|
|
|
.role-container {
|
|
.el-card {
|
|
background: #ffffff;
|
|
border: none;
|
|
border-radius: 4px;
|
|
box-shadow: $box-shadow;
|
|
|
|
.el-card__header {
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid $border-color;
|
|
}
|
|
}
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
|
|
span {
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
color: $text-primary;
|
|
}
|
|
}
|
|
|
|
.permission-tag {
|
|
margin-right: 8px;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
:deep(.el-table) {
|
|
th.el-table__cell {
|
|
background-color: #fafafa;
|
|
color: $text-primary;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.el-button--small {
|
|
padding: 6px 16px;
|
|
}
|
|
}
|
|
</style>
|