<template>
|
<ProDialog title="设置角色" v-model="visible" @close="onDialogClose" destroy-on-close draggable>
|
<ProForm :model="form" ref="dialogForm" label-width="90px">
|
<ProFormItemV2 label="角色" prop="roleIds" :check-rules="[{ message: '请选择角色' }]">
|
<ProFormCheckbox
|
v-model="form.roleIds"
|
:value-enum="form.roles"
|
enumLabelKey="name"
|
enum-value-key="id"
|
></ProFormCheckbox>
|
</ProFormItemV2>
|
</ProForm>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="emit('onCancel')">取 消</el-button>
|
<el-button type="primary" @click="handleConfirm">确 定</el-button>
|
</span>
|
</template>
|
</ProDialog>
|
</template>
|
|
<script setup lang="ts">
|
import { FormInstance } from 'element-plus';
|
import { ProDialog, ProForm, ProFormItemV2, ProFormCheckbox } from '@bole-core/components';
|
|
defineOptions({
|
name: 'SetOperationUserRoleDialog',
|
});
|
|
type Form = {
|
userInfoId: string;
|
roleIds: string[];
|
roles: API.GetOperationUserInfosQueryResultItem[];
|
};
|
|
const form = defineModel<Form>('form');
|
const visible = defineModel({ type: Boolean });
|
|
const emit = defineEmits<{
|
(e: 'onConfirm'): void;
|
(e: 'onCancel'): void;
|
}>();
|
|
const dialogForm = ref<FormInstance>();
|
|
function onDialogClose() {
|
if (!dialogForm.value) return;
|
dialogForm.value.resetFields();
|
}
|
|
function handleConfirm() {
|
if (!dialogForm.value) return;
|
dialogForm.value.validate((valid) => {
|
if (valid) {
|
emit('onConfirm');
|
} else {
|
return;
|
}
|
});
|
}
|
</script>
|