This repository has been archived on 2026-09-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
UserBaseFront/src/views/role-authz/EditRoleContainer.vue
T
chenxing 02f1fd2b14
deploy-userbase-front / build-and-deploy (push) Successful in 2m27s
修复重复弹msg的bug
2026-08-18 23:31:27 +08:00

57 lines
1.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<RoleForm v-model="visible" :initForm="detailData" :isEdit="true" :loading="submitting"
@submit="handleSubmit" @cancel="visible = false" />
</template>
<script lang="ts" setup>
import { ref } from "vue";
import RoleForm from "./RoleForm.vue";
const visible = ref(false);
const detailData = ref<Record<string, any>>({});
const currentId = ref<number | null>(null);
let onSuccessCallback: (() => void) | null = null;
// useForm 托管提交(角色编辑:仅可改 name/remark/disabled;allAppFlag 与 appId 后端禁止修改)
const { form, loading: submitting, send: sendForm, onSuccess, onError } = useForm(
(dto) => Apis.AppRole.roleEdit({ pathParams: { id: currentId.value! }, data: dto }),
{
initialForm: { name: "", appId: undefined, allAppFlag: false, remark: "", disabled: false },
resetAfterSubmiting: true,
}
);
onSuccess(() => {
Message.success("编辑角色成功!");
visible.value = false;
onSuccessCallback?.();
});
onError((event: any) => {
// 错误提示已由全局 alova 拦截器统一弹出,这里仅记录日志避免二次弹窗
console.warn('[EditRoleContainer] 编辑角色失败:', event?.error?.message || '编辑失败');
});
function open(id: number, row: any, onSuccess?: () => void) {
currentId.value = id;
// 直接用行数据回填(roleList 返回的字段与表单一致)
detailData.value = { ...row };
onSuccessCallback = onSuccess || null;
visible.value = true;
}
async function handleSubmit(formData: Record<string, any>) {
if (!currentId.value) return;
form.value = {
id: currentId.value,
name: formData.name,
appId: formData.appId,
allAppFlag: formData.allAppFlag,
remark: formData.remark,
disabled: formData.disabled,
};
await sendForm();
}
defineExpose({ open, visible });
</script>