fix(ui): 修复修改弹窗中 FormField 结构被破坏导致的上下文越界报错
This commit is contained in:
parent
a408cad494
commit
2395d792db
@ -47,6 +47,8 @@ interface Asset {
|
||||
}
|
||||
|
||||
const updateTransactionSchema = z.object({
|
||||
assetId: z.string(),
|
||||
txType: z.string(),
|
||||
quantity: z.string().regex(/^-?\d+(\.\d+)?$/, '数量必须是数字'),
|
||||
price: z.string().regex(/^-?\d+(\.\d+)?$/, '价格必须是数字'),
|
||||
fee: z.string().regex(/^-?\d+(\.\d+)?$/, '手续费必须是数字').default('0'),
|
||||
@ -85,6 +87,8 @@ export function UpdateTransactionDialog({
|
||||
const form = useForm<UpdateForm>({
|
||||
resolver: zodResolver(updateTransactionSchema),
|
||||
defaultValues: {
|
||||
assetId: '',
|
||||
txType: '',
|
||||
quantity: '',
|
||||
price: '',
|
||||
fee: '0',
|
||||
@ -96,6 +100,8 @@ export function UpdateTransactionDialog({
|
||||
useEffect(() => {
|
||||
if (transaction && open) {
|
||||
form.reset({
|
||||
assetId: transaction.assetId,
|
||||
txType: transaction.txType,
|
||||
quantity: transaction.quantity.toString(),
|
||||
price: transaction.price.toString(),
|
||||
fee: transaction.fee.toString(),
|
||||
@ -138,6 +144,10 @@ export function UpdateTransactionDialog({
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="assetId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>标的资产</FormLabel>
|
||||
<Select disabled>
|
||||
@ -154,7 +164,14 @@ export function UpdateTransactionDialog({
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="txType"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>交易类型</FormLabel>
|
||||
<Select disabled>
|
||||
@ -171,7 +188,10 @@ export function UpdateTransactionDialog({
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
|
||||
Loading…
Reference in New Issue
Block a user