增加审批组件

This commit is contained in:
dengqichen 2025-10-25 16:40:07 +08:00
parent 0a64cfc339
commit 07db17faf6
2 changed files with 43 additions and 16 deletions

View File

@ -4,7 +4,35 @@ import { X } from "lucide-react"
import { cn } from "@/lib/utils"
const Dialog = DialogPrimitive.Root
/**
* Radix UI Dialog body.style.pointerEvents
* Dialog body
*/
const Dialog: React.FC<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>> = ({ open, onOpenChange, ...props }) => {
// 监听 open 状态变化,关闭时清理 body 样式
React.useEffect(() => {
if (open === false) {
// 延迟执行,确保在 Dialog 关闭动画之后
const timer = setTimeout(() => {
// 强制移除 body 的 pointer-events 限制
if (document.body.style.pointerEvents === 'none') {
document.body.style.pointerEvents = '';
}
}, 350); // 稍微比 Dialog 动画时间200ms长一点
return () => clearTimeout(timer);
}
}, [open]);
return (
<DialogPrimitive.Root
open={open}
onOpenChange={onOpenChange}
{...props}
/>
);
};
Dialog.displayName = "Dialog"
const DialogTrigger = DialogPrimitive.Trigger

View File

@ -47,21 +47,20 @@ const FormBasicInfoModal: React.FC<FormBasicInfoModalProps> = ({
// 加载分类列表和初始化数据
useEffect(() => {
if (visible) {
loadCategories();
if (mode === 'edit' && record) {
setFormData({
name: record.name,
key: record.key,
categoryId: record.categoryId,
description: record.description || '',
isTemplate: record.isTemplate || false,
});
} else if (mode === 'create') {
resetForm();
}
} else {
// 弹窗关闭时重置表单数据
// 只在弹窗打开时初始化数据
if (!visible) return;
loadCategories();
if (mode === 'edit' && record) {
setFormData({
name: record.name,
key: record.key,
categoryId: record.categoryId,
description: record.description || '',
isTemplate: record.isTemplate || false,
});
} else if (mode === 'create') {
resetForm();
}
}, [visible, mode, record?.id]); // 只依赖 record.id 而不是整个 record 对象