From 0128d7b03bc2c7897efaccf3905ed57bc5f16287 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Sat, 15 Nov 2025 18:01:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormDesigner/components/PropertyPanel.tsx | 6 +++ .../pages/Deploy/ScheduleJob/List/index.tsx | 44 +++++++++++++++---- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/FormDesigner/components/PropertyPanel.tsx b/frontend/src/components/FormDesigner/components/PropertyPanel.tsx index c74fc46a..ff1ace67 100644 --- a/frontend/src/components/FormDesigner/components/PropertyPanel.tsx +++ b/frontend/src/components/FormDesigner/components/PropertyPanel.tsx @@ -52,6 +52,9 @@ const PropertyPanel: React.FC = ({ React.useEffect(() => { if (selectedField) { + // 🔄 先重置表单,清除旧字段的状态 + form.resetFields(); + // 确保嵌套对象被正确设置到表单 const formValues: any = { ...selectedField, @@ -73,6 +76,9 @@ const PropertyPanel: React.FC = ({ }; form.setFieldsValue(formValues); + } else { + // 如果没有选中字段,也清空表单 + form.resetFields(); } }, [selectedField, form]); diff --git a/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx b/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx index b0aac419..9cc751e5 100644 --- a/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx +++ b/frontend/src/pages/Deploy/ScheduleJob/List/index.tsx @@ -59,6 +59,19 @@ const ScheduleJobList: React.FC = () => { } }; + // 局部更新单条记录(避免全量刷新导致滚动位置丢失) + const updateRecordInList = (id: number, updates: Partial) => { + setData(prevData => { + if (!prevData) return prevData; + return { + ...prevData, + content: prevData.content.map(item => + item.id === id ? { ...item, ...updates } : item + ) + }; + }); + }; + // 加载分类 const loadCategories = async () => { try { @@ -125,7 +138,8 @@ const ScheduleJobList: React.FC = () => { title: '暂停成功', description: `任务 "${record.jobName}" 已暂停`, }); - loadData(); + // 局部更新,避免页面滚动 + updateRecordInList(record.id, { status: 'PAUSED' }); } catch (error) { console.error('暂停失败:', error); toast({ @@ -144,7 +158,8 @@ const ScheduleJobList: React.FC = () => { title: '恢复成功', description: `任务 "${record.jobName}" 已恢复`, }); - loadData(); + // 局部更新,避免页面滚动 + updateRecordInList(record.id, { status: 'ENABLED' }); } catch (error) { console.error('恢复失败:', error); toast({ @@ -163,7 +178,7 @@ const ScheduleJobList: React.FC = () => { title: '触发成功', description: `任务 "${record.jobName}" 已立即触发执行`, }); - loadData(); + // 立即执行不改变任务状态,无需更新列表 } catch (error) { console.error('触发失败:', error); toast({ @@ -182,7 +197,8 @@ const ScheduleJobList: React.FC = () => { title: '禁用成功', description: `任务 "${record.jobName}" 已禁用`, }); - loadData(); + // 局部更新,避免页面滚动 + updateRecordInList(record.id, { status: 'DISABLED' }); } catch (error) { console.error('禁用失败:', error); toast({ @@ -201,7 +217,8 @@ const ScheduleJobList: React.FC = () => { title: '启用成功', description: `任务 "${record.jobName}" 已启用`, }); - loadData(); + // 局部更新,避免页面滚动 + updateRecordInList(record.id, { status: 'ENABLED' }); } catch (error) { console.error('启用失败:', error); toast({ @@ -309,11 +326,11 @@ const ScheduleJobList: React.FC = () => { 任务列表
- - @@ -360,11 +377,11 @@ const ScheduleJobList: React.FC = () => { 暂停 - -
@@ -440,6 +457,7 @@ const ScheduleJobList: React.FC = () => { <> {/* 暂停 */} {/* 禁用 */} {/* 立即执行 */} {/* 禁用 */}