|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
- <Codes v-model="showCodesEditForm" :role="editRole" />
|
|
|
- <Edit v-model="showRoleEditForm" :role="editRole" />
|
|
|
+ <Codes v-model="isShowCodesEditForm" :role="editRole" />
|
|
|
+ <Edit v-model="isShowRoleEditForm" :role="editRole" :type="editType" />
|
|
|
<div>
|
|
|
<el-card class="box-card" v-loading="wholeLoading" element-loading-text="Loading..." style="height: 600px">
|
|
|
<template #header>
|
|
@@ -8,7 +8,7 @@
|
|
|
<span>权限管理</span>
|
|
|
<div>
|
|
|
<el-button type="default" @click="reflush()">刷新列表</el-button>
|
|
|
- <el-button type="primary" @click="create()">新增角色</el-button>
|
|
|
+ <el-button type="primary" @click="showEditDialog('create')">新增角色</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -22,8 +22,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="underlyingRoleManage">
|
|
|
-import { ref, reactive, onMounted, h } from 'vue'
|
|
|
-import { ElSwitch, ElTag, ElMessage, ElMessageBox, ElButton, TableV2FixedDir, roleTypes } from 'element-plus'
|
|
|
+import { ref, h } from 'vue'
|
|
|
+import { ElTag, ElMessage, ElMessageBox, ElButton, TableV2FixedDir } from 'element-plus'
|
|
|
import type { Column } from 'element-plus'
|
|
|
import { throttle } from 'lodash'
|
|
|
import { init, update, newRole } from '/@/api/role'
|
|
@@ -42,15 +42,19 @@ const wholeLoading = ref(false)
|
|
|
/**
|
|
|
* 编辑权限表单的显示控制
|
|
|
*/
|
|
|
-const showCodesEditForm = ref(false)
|
|
|
+const isShowCodesEditForm = ref(false)
|
|
|
/**
|
|
|
* 编辑角色表单的显示控制
|
|
|
*/
|
|
|
-const showRoleEditForm = ref(false)
|
|
|
+const isShowRoleEditForm = ref(false)
|
|
|
/**
|
|
|
* 需要编辑的角色
|
|
|
*/
|
|
|
const editRole = ref<Role>(newRole())
|
|
|
+/**
|
|
|
+ * 编辑类型
|
|
|
+ */
|
|
|
+const editType = ref<'update' | 'create'>('update')
|
|
|
|
|
|
/**
|
|
|
* 虚拟表格列信息
|
|
@@ -69,7 +73,8 @@ const columns: Column<any>[] = [
|
|
|
width: 400,
|
|
|
cellRenderer: ({ cellData: codes_cn }) => h(
|
|
|
'div',
|
|
|
- codes_cn?.map(cn => h(ElTag, { style: { 'margin-right': '5px' } }, cn))
|
|
|
+ { style: { 'overflow-y': 'auto', display: 'flex' } },
|
|
|
+ codes_cn?.map(cn => h(ElTag, { style: { 'margin-right': '5px' } }, cn)) || '暂无权限 ~ 点击权限以授权'
|
|
|
),
|
|
|
},
|
|
|
{
|
|
@@ -101,10 +106,10 @@ const columns: Column<any>[] = [
|
|
|
ElButton,
|
|
|
{
|
|
|
type: row.valid ? 'danger' : 'success',
|
|
|
- onClick: throttle(() => {
|
|
|
+ onClick: (throttle(() => {
|
|
|
row.valid = !row.valid
|
|
|
update(row)
|
|
|
- }),
|
|
|
+ })),
|
|
|
},
|
|
|
row.valid ? '禁用' : '启用'
|
|
|
),
|
|
@@ -114,8 +119,9 @@ const columns: Column<any>[] = [
|
|
|
{
|
|
|
type: 'primary',
|
|
|
onClick: throttle(() => {
|
|
|
- showCodesEditForm.value = true
|
|
|
editRole.value = row
|
|
|
+ editType.value = 'update'
|
|
|
+ isShowCodesEditForm.value = true
|
|
|
}),
|
|
|
},
|
|
|
'权限'
|
|
@@ -124,10 +130,7 @@ const columns: Column<any>[] = [
|
|
|
ElButton,
|
|
|
{
|
|
|
type: 'primary',
|
|
|
- onClick: throttle(() => {
|
|
|
- showRoleEditForm.value = true
|
|
|
- editRole.value = row
|
|
|
- }),
|
|
|
+ onClick: () => showEditDialog('update', row),
|
|
|
},
|
|
|
'编辑'
|
|
|
),
|
|
@@ -135,13 +138,12 @@ const columns: Column<any>[] = [
|
|
|
},
|
|
|
]
|
|
|
|
|
|
-/**
|
|
|
- * 创建
|
|
|
- */
|
|
|
-const create = throttle(() => {
|
|
|
- showRoleEditForm.value = true
|
|
|
- editRole.value = newRole()
|
|
|
+const showEditDialog = throttle((type: 'create' | 'update' = 'create', role: Role = newRole()) => {
|
|
|
+ editRole.value = role
|
|
|
+ editType.value = type
|
|
|
+ isShowRoleEditForm.value = true
|
|
|
})
|
|
|
+
|
|
|
/**
|
|
|
* 刷新
|
|
|
*/
|