新增按钮权限,增加redis可独立配置 (#923)

* fix jwt to golang-jwt, gin to 1.7.0

* 增加按钮权限功能

* 增加redis可独立配置

Co-authored-by: helight <helight@helight.info>
This commit is contained in:
奇淼(piexlmax
2022-02-22 00:26:21 +08:00
committed by GitHub
co-authored by helight
parent f389ff701a
commit 6a97f39f66
33 changed files with 5024 additions and 542 deletions
@@ -28,9 +28,37 @@
{{ row.defaultRouter === data.name?"首页":"设为首页" }}
</el-button>
</span>
<span v-if="data.menuBtn.length">
<el-button
type="text"
size="small"
@click="() => OpenBtn(data)"
>
分配按钮
</el-button>
</span>
</span>
</template>
</el-tree>
<el-dialog v-model="btnVisible" title="分配按钮" destroy-on-close>
<el-table
ref="btnTableRef"
:data="btnData"
row-key="ID"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column label="按钮名称" prop="name" />
<el-table-column label="按钮备注" prop="desc" />
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeDialog">取 消</el-button>
<el-button size="small" type="primary" @click="enterDialog">确 定</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
@@ -39,7 +67,8 @@ import { getBaseMenuTree, getMenuAuthority, addMenuAuthority } from '@/api/menu'
import {
updateAuthority
} from '@/api/authority'
import { ref } from 'vue'
import { getAuthorityBtnApi, setAuthorityBtnApi } from '@/api/authorityBtn'
import { nextTick, ref } from 'vue'
import { ElMessage } from 'element-plus'
const props = defineProps({
row: {
@@ -66,7 +95,6 @@ const init = async() => {
// 获取所有菜单树
const res = await getBaseMenuTree()
menuTreeData.value = res.data.menus
const res1 = await getMenuAuthority({ authorityId: props.row.authorityId })
const menus = res1.data.menus
const arr = []
@@ -113,6 +141,55 @@ const relation = async() => {
defineExpose({ enterAndNext, needConfirm })
const btnVisible = ref(false)
const btnData = ref([])
const multipleSelection = ref([])
const btnTableRef = ref()
let menuID = ''
const OpenBtn = async(data) => {
menuID = data.ID
const res = await getAuthorityBtnApi({ menuID: menuID, authorityId: props.row.authorityId })
if (res.code === 0) {
openDialog(data)
await nextTick()
if (res.data.selected) {
res.data.selected.forEach(id => {
btnData.value.some(item => {
if (item.ID === id) {
btnTableRef.value.toggleRowSelection(item, true)
}
})
})
}
}
}
const handleSelectionChange = (val) => {
multipleSelection.value = val
}
const openDialog = (data) => {
btnVisible.value = true
btnData.value = data.menuBtn
}
const closeDialog = () => {
btnVisible.value = false
}
const enterDialog = async() => {
const selected = multipleSelection.value.map(item => item.ID)
const res = await setAuthorityBtnApi({
menuID,
selected,
authorityId: props.row.authorityId
})
if (res.code === 0) {
ElMessage({ type: 'success', message: '设置成功' })
btnVisible.value = false
}
}
</script>
<script>
@@ -121,3 +198,11 @@ export default {
name: 'Menus'
}
</script>
<style lang="scss" scope>
.custom-tree-node{
span+span{
margin-left: 12px;
}
}
</style>