Browse Source

角色必填校验

master_hella_20240701
yufei0306 6 months ago
parent
commit
6f19cf7afb
  1. 7
      src/views/system/user/UserAssignRoleForm.vue

7
src/views/system/user/UserAssignRoleForm.vue

@ -1,13 +1,13 @@
<template> <template>
<Dialog v-model="dialogVisible" title="分配角色"> <Dialog v-model="dialogVisible" title="分配角色">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="80px"> <el-form ref="formRef" v-loading="formLoading" :model="formData" :rules="formRules" label-width="80px">
<el-form-item label="用户名称"> <el-form-item label="用户名称">
<el-input v-model="formData.username" :disabled="true" /> <el-input v-model="formData.username" :disabled="true" />
</el-form-item> </el-form-item>
<el-form-item label="用户昵称"> <el-form-item label="用户昵称">
<el-input v-model="formData.nickname" :disabled="true" /> <el-input v-model="formData.nickname" :disabled="true" />
</el-form-item> </el-form-item>
<el-form-item label="角色"> <el-form-item label="角色" prop="roleIds">
<el-select v-model="formData.roleIds" multiple placeholder="请选择角色"> <el-select v-model="formData.roleIds" multiple placeholder="请选择角色">
<el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id" />
</el-select> </el-select>
@ -37,6 +37,9 @@ const formData = ref({
username: '', username: '',
roleIds: [] roleIds: []
}) })
const formRules = reactive({
roleIds: [{ required: true, message:'请选择角色', trigger: 'change' }]
})
const formRef = ref() // Ref const formRef = ref() // Ref
const roleList = ref([]) // const roleList = ref([]) //

Loading…
Cancel
Save