main
parent
7252ac8a5e
commit
57054b4eb6
@ -0,0 +1,83 @@
|
|||||||
|
<script setup>
|
||||||
|
import RPC from '@/utils/rpc'
|
||||||
|
const props = defineProps({
|
||||||
|
row: [Object],
|
||||||
|
authList: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['closed', 'onSuccess'])
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
|
||||||
|
const isAdd = computed(() => props.type === 'add')
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRef = ref(null)
|
||||||
|
const formField = ref({})
|
||||||
|
const formRules = reactive({})
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
function closed() {
|
||||||
|
emit('closed')
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitForm = async () => {
|
||||||
|
const checkedNodes = treeRef.value.getCheckedNodes() || []
|
||||||
|
loading.value = true
|
||||||
|
RPC.post('/assign_permissions', {
|
||||||
|
role_id: props.row.id,
|
||||||
|
permission_ids: checkedNodes.map((item) => item.id) || [],
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
ElMessage.success('操作成功')
|
||||||
|
emit('onSuccess')
|
||||||
|
emit('closed')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const authValue = ref(props.row?.permissions?.map((item) => item.id) || [])
|
||||||
|
|
||||||
|
const treeRef = ref()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
align-center
|
||||||
|
title="分配权限"
|
||||||
|
width="80%"
|
||||||
|
v-model="dialogVisible"
|
||||||
|
@closed="closed"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<el-tree
|
||||||
|
ref="treeRef"
|
||||||
|
:data="authList"
|
||||||
|
show-checkbox
|
||||||
|
check-strictly
|
||||||
|
node-key="id"
|
||||||
|
default-expand-all
|
||||||
|
:default-checked-keys="authValue"
|
||||||
|
:props="{
|
||||||
|
children: 'children',
|
||||||
|
label: 'name',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="closed"> 取 消 </el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="submitForm"> 确 定 </el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
<script setup>
|
||||||
|
import RPC from '@/utils/rpc'
|
||||||
|
const props = defineProps({
|
||||||
|
row: [Object],
|
||||||
|
roleList: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['closed', 'onSuccess'])
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
|
||||||
|
const isAdd = computed(() => props.type === 'add')
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRef = ref(null)
|
||||||
|
const formField = ref({})
|
||||||
|
const formRules = reactive({})
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
function closed() {
|
||||||
|
emit('closed')
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitForm = async () => {
|
||||||
|
loading.value = true
|
||||||
|
RPC.post('/assign_roles', { user_id: props.row.id, role_ids: checkList.value })
|
||||||
|
.then((res) => {
|
||||||
|
ElMessage.success('操作成功')
|
||||||
|
emit('onSuccess')
|
||||||
|
emit('closed')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const checkList = ref(props.row?.roles?.map((item) => item.id) || [])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
align-center
|
||||||
|
title="分配权限"
|
||||||
|
width="80%"
|
||||||
|
v-model="dialogVisible"
|
||||||
|
@closed="closed"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<el-checkbox-group v-model="checkList">
|
||||||
|
<el-checkbox v-for="item in roleList" :label="item.name" :value="item.id" />
|
||||||
|
</el-checkbox-group>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="closed"> 取 消 </el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="submitForm"> 确 定 </el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
Loading…
Reference in new issue