feat: custom types can bind a field layout (profile) - layout select in type editor, respected in record form
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Badge, Button, Card, Confirm, Dialog, Field, Input, Select, useToast
|
||||
} from '@/components/ui';
|
||||
import { TypeIcon, ICON_CHOICES } from '@/components/common/typeIcons';
|
||||
import { PROFILE_OPTIONS } from '@/lib/typeProfiles';
|
||||
|
||||
const PALETTE = ['#3056d3', '#7c3aed', '#0891b2', '#0f766e', '#16a34a', '#65a30d', '#d97706', '#dc2626', '#db2777', '#64748b'];
|
||||
|
||||
@@ -117,6 +118,7 @@ function TypeEditor({ source, onClose, onSaved }: { source: FootprintType | null
|
||||
const [sort, setSort] = useState(String(source?.sort ?? 100));
|
||||
const [closed, setClosed] = useState(source?.closed ?? false);
|
||||
const [fields, setFields] = useState<FormField[]>(source?.form_template ?? []);
|
||||
const [profile, setProfile] = useState(source?.profile ?? '');
|
||||
const [error, setError] = useState('');
|
||||
|
||||
const saveMut = useMutation({
|
||||
@@ -137,6 +139,7 @@ function TypeEditor({ source, onClose, onSaved }: { source: FootprintType | null
|
||||
icon, color,
|
||||
sort: Number(sort) || 100,
|
||||
form_template: fields,
|
||||
profile: profile || undefined,
|
||||
closed
|
||||
});
|
||||
},
|
||||
@@ -166,6 +169,7 @@ function TypeEditor({ source, onClose, onSaved }: { source: FootprintType | null
|
||||
>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="grid grid-cols-[1fr_120px_100px] gap-3">
|
||||
|
||||
<Field label="名称" required>
|
||||
<Input value={name} onChange={e => setName(e.target.value)} placeholder="如:学科竞赛" />
|
||||
</Field>
|
||||
@@ -225,7 +229,10 @@ function TypeEditor({ source, onClose, onSaved }: { source: FootprintType | null
|
||||
</Field>
|
||||
|
||||
<div className="border-t border-line pt-3">
|
||||
<div className="mb-2 flex items-center justify-between">
|
||||
<Field label="字段布局" hint="决定录入表单的核心字段组合(新建记录时的「类型要素」)">
|
||||
<Select value={profile} onChange={e => setProfile(e.target.value)} options={PROFILE_OPTIONS} />
|
||||
</Field>
|
||||
<div className="mb-2 mt-2 flex items-center justify-between">
|
||||
<span className="text-[12px] font-semibold text-ink-2">字段模板({fields.length})</span>
|
||||
<Button
|
||||
size="sm"
|
||||
|
||||
Reference in New Issue
Block a user