mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2026-05-15 00:00:02 +08:00
修复角色分权限bug
This commit is contained in:
@@ -1,44 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<mb-tree ref="tree" :el="{ 'show-checkbox': true }" url="menu/tree" :search="true" search-width="230px" :select-values.sync="menus" />
|
<mb-tree ref="tree" :el="{ 'show-checkbox': true }" url="menu/tree" :search="true" search-width="230px" v-model:select-values="menus" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
|
import {getCurrentInstance, ref, defineExpose} from 'vue'
|
||||||
export default {
|
const { proxy } = getCurrentInstance()
|
||||||
name: 'RoleAssignPermissions',
|
const emit = defineEmits(['close'])
|
||||||
props: {
|
const props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
menus: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.$get('menu/by/role',{ roleId: this.id }).then(res => {
|
|
||||||
this.menus = res.data.join(',')
|
|
||||||
})
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
save(d) {
|
|
||||||
d.loading()
|
|
||||||
this.$post('role/save', {
|
|
||||||
id: this.id,
|
|
||||||
menus: this.menus
|
|
||||||
}).then((response) => {
|
|
||||||
d.hideLoading()
|
|
||||||
this.$notify({
|
|
||||||
title: '成功',
|
|
||||||
message: '分配成功',
|
|
||||||
type: 'success',
|
|
||||||
duration: 2000
|
|
||||||
})
|
|
||||||
this.$emit('close')
|
|
||||||
}).catch(() => d.hideLoading())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(props.id)
|
||||||
|
|
||||||
|
const menus = ref('')
|
||||||
|
|
||||||
|
proxy.$get('menu/by/role',{ roleId: props.id }).then(res => {
|
||||||
|
menus.value = res.data.join(',')
|
||||||
|
})
|
||||||
|
|
||||||
|
function save(d) {
|
||||||
|
d.loading()
|
||||||
|
proxy.$post('role/save', {
|
||||||
|
id: props.id,
|
||||||
|
menus: menus.value
|
||||||
|
}).then((response) => {
|
||||||
|
d.hideLoading()
|
||||||
|
proxy.$notify({
|
||||||
|
title: '成功',
|
||||||
|
message: '分配成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
emit('close')
|
||||||
|
}).catch(() => d.hideLoading())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ save })
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
<mb-dialog ref="assignPermissionsDialog" title="分配权限" width="550px" @confirm-click="assignPermissions.save($event)">
|
<mb-dialog ref="assignPermissionsDialog" title="分配权限" width="550px" @confirm-click="assignPermissions.save($event)">
|
||||||
<template #content>
|
<template #content>
|
||||||
<role-assign-permissions ref="assignPermissions" :key="Math.random()" :id="temp.id" @close="() => { assignPermissionsDialog.value.hide(); temp.id = '' }" />
|
<role-assign-permissions ref="assignPermissions" :key="temp.id" :id="temp.id" @close="() => { assignPermissionsDialog.hide(); temp.id = '' }" />
|
||||||
</template>
|
</template>
|
||||||
</mb-dialog>
|
</mb-dialog>
|
||||||
|
|
||||||
@@ -83,6 +83,7 @@ const permissionData = reactive([{
|
|||||||
label: '本级',
|
label: '本级',
|
||||||
value: '3'
|
value: '3'
|
||||||
}])
|
}])
|
||||||
|
const assignPermissions = ref()
|
||||||
const assignPermissionsDialog = ref()
|
const assignPermissionsDialog = ref()
|
||||||
const table = ref()
|
const table = ref()
|
||||||
const roleFormDialog = ref()
|
const roleFormDialog = ref()
|
||||||
@@ -150,7 +151,7 @@ const tableOptions = reactive({
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
icon: 'ElPlus',
|
icon: 'ElPlus',
|
||||||
click: (row) => {
|
click: (row) => {
|
||||||
temp.id = row.id
|
temp.value.id = row.id
|
||||||
assignPermissionsDialog.value.show()
|
assignPermissionsDialog.value.show()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user