优化平台端租户端
This commit is contained in:
@@ -70,6 +70,23 @@
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 角色(关联 yz_system_admin_role, cid=2) -->
|
||||
<el-form-item label="角色">
|
||||
<el-select
|
||||
v-model="form.group_id"
|
||||
placeholder="请选择角色(未分配则拥有全部功能权限)"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="role in roles"
|
||||
:key="role.id"
|
||||
:label="role.name"
|
||||
:value="role.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 对话框脚部 -->
|
||||
@@ -84,6 +101,7 @@
|
||||
import { ref, computed, watch } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { addUser, editUser, getUserInfo } from "@/api/user";
|
||||
import { getAllRoles } from "@/api/role";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -117,8 +135,26 @@ const form = ref<any>({
|
||||
confirmPassword: "",
|
||||
email: "",
|
||||
status: 1,
|
||||
group_id: undefined,
|
||||
});
|
||||
|
||||
interface RoleOption {
|
||||
id: number;
|
||||
name: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
const roles = ref<RoleOption[]>([]);
|
||||
|
||||
const fetchRoles = async () => {
|
||||
try {
|
||||
const res = await getAllRoles();
|
||||
roles.value = (res.data || []).filter((r: RoleOption) => r.status !== 0);
|
||||
} catch (e) {
|
||||
roles.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
return isAdd.value ? "添加用户" : "编辑用户";
|
||||
});
|
||||
@@ -189,6 +225,9 @@ watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
visible.value = newVal;
|
||||
if (newVal) {
|
||||
fetchRoles();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -240,6 +279,7 @@ const loadUserData = async (user: any) => {
|
||||
confirmPassword: "",
|
||||
email: data.email,
|
||||
status: statusValue,
|
||||
group_id: data.group_id ? Number(data.group_id) : undefined,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.error("Failed to load user data:", e);
|
||||
@@ -299,6 +339,7 @@ const handleSubmit = async () => {
|
||||
email: form.value.email,
|
||||
status: form.value.status,
|
||||
password: form.value.password,
|
||||
group_id: form.value.group_id,
|
||||
};
|
||||
|
||||
await addUser(submitData);
|
||||
@@ -319,6 +360,7 @@ const handleSubmit = async () => {
|
||||
sex: form.value.sex,
|
||||
email: form.value.email,
|
||||
status: form.value.status,
|
||||
group_id: form.value.group_id,
|
||||
};
|
||||
|
||||
// 只有在填写了密码时才添加到提交数据中
|
||||
@@ -354,6 +396,7 @@ defineExpose({
|
||||
confirmPassword: "",
|
||||
email: "",
|
||||
status: 1,
|
||||
group_id: undefined,
|
||||
};
|
||||
visible.value = true;
|
||||
// 清除表单验证
|
||||
|
||||
Reference in New Issue
Block a user