修复接单模板无法新增
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router'
|
||||
|
||||
import {
|
||||
@@ -51,6 +51,7 @@ export default function ProductRulesPanel() {
|
||||
const [form] = Form.useForm()
|
||||
const navigate = useNavigate()
|
||||
const [searchParams] = useSearchParams()
|
||||
const hasInitializedRuleSelection = useRef(false)
|
||||
|
||||
const [editingRule, setEditingRule] = useState<WorkProductRule | null>(null)
|
||||
const [activeMappingId, setActiveMappingId] = useState<number | 'new' | null>(null)
|
||||
@@ -113,9 +114,10 @@ export default function ProductRulesPanel() {
|
||||
]),
|
||||
)
|
||||
|
||||
// Default select first rule if none selected when list loads
|
||||
// 首次加载时默认选中第一条;新建时必须保留空表单,不能再次自动选回旧模板。
|
||||
useEffect(() => {
|
||||
if (!editingRule && rules.length > 0) {
|
||||
if (!hasInitializedRuleSelection.current && !editingRule && rules.length > 0) {
|
||||
hasInitializedRuleSelection.current = true
|
||||
editRule(rules[0])
|
||||
}
|
||||
}, [rules, editingRule])
|
||||
|
||||
Reference in New Issue
Block a user