Commit d58029c6 by skynono Committed by GitHub

fix(model-pricing): 修复可视化模型定价列表项无法删除 (#5628)

删除时已从草稿中移除模型,但列表为 saved∪draft 并集且优先取 saved,
导致行不消失(isDraftDeleted 计算后未被使用),表现为无法删除。改为过滤
掉已暂存删除的行;并在删除当前正在编辑的行时关闭编辑器,避免从残留面板
保存又把模型写回。
parent 0c6c1b37
...@@ -225,6 +225,7 @@ const ModelRatioVisualEditorComponent = forwardRef< ...@@ -225,6 +225,7 @@ const ModelRatioVisualEditorComponent = forwardRef<
isDraftNew: Boolean(!saved && draft), isDraftNew: Boolean(!saved && draft),
} }
}) })
.filter((row) => !row.isDraftDeleted)
.sort((a, b) => a.name.localeCompare(b.name)) .sort((a, b) => a.name.localeCompare(b.name))
}, [ }, [
savedModelPrice, savedModelPrice,
...@@ -392,6 +393,12 @@ const ModelRatioVisualEditorComponent = forwardRef< ...@@ -392,6 +393,12 @@ const ModelRatioVisualEditorComponent = forwardRef<
'billing_setting.billing_expr', 'billing_setting.billing_expr',
JSON.stringify(billingExprMap, null, 2) JSON.stringify(billingExprMap, null, 2)
) )
if (editData?.name === name) {
setEditData(null)
setEditorOpen(false)
setSheetOpen(false)
}
}, },
[ [
modelPrice, modelPrice,
...@@ -405,6 +412,7 @@ const ModelRatioVisualEditorComponent = forwardRef< ...@@ -405,6 +412,7 @@ const ModelRatioVisualEditorComponent = forwardRef<
billingMode, billingMode,
billingExpr, billingExpr,
onChange, onChange,
editData,
] ]
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment