mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-04-02 11:22:40 +08:00
修复角色分权限bug
This commit is contained in:
parent
c64302caac
commit
f78ca68b2e
@ -1,44 +1,43 @@
|
||||
<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>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'RoleAssignPermissions',
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
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())
|
||||
}
|
||||
<script setup>
|
||||
import {getCurrentInstance, ref, defineExpose} from 'vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
const emit = defineEmits(['close'])
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
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>
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
<mb-dialog ref="assignPermissionsDialog" title="分配权限" width="550px" @confirm-click="assignPermissions.save($event)">
|
||||
<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>
|
||||
</mb-dialog>
|
||||
|
||||
@ -83,6 +83,7 @@ const permissionData = reactive([{
|
||||
label: '本级',
|
||||
value: '3'
|
||||
}])
|
||||
const assignPermissions = ref()
|
||||
const assignPermissionsDialog = ref()
|
||||
const table = ref()
|
||||
const roleFormDialog = ref()
|
||||
@ -150,7 +151,7 @@ const tableOptions = reactive({
|
||||
type: 'text',
|
||||
icon: 'ElPlus',
|
||||
click: (row) => {
|
||||
temp.id = row.id
|
||||
temp.value.id = row.id
|
||||
assignPermissionsDialog.value.show()
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user