From ce1635ec1ad6aba042ca327e937628c2b63f57bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 3 Jul 2025 10:32:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E6=96=B9=E6=96=B0=E5=A2=9E=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=97=E8=A1=A8=20=E9=85=8D?= =?UTF-8?q?=E6=96=B9=E6=96=B0=E5=A2=9E=E5=90=8E=E4=B8=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E6=96=B0=E5=A2=9E=E7=9A=84=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/formula/FormulaConfig.vue | 3 ++- src/components/formula/FormulaTable.vue | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/formula/FormulaConfig.vue b/src/components/formula/FormulaConfig.vue index 82dbe50..38cbc6b 100644 --- a/src/components/formula/FormulaConfig.vue +++ b/src/components/formula/FormulaConfig.vue @@ -269,6 +269,7 @@ const onAddFormula = () => { onEditFormula(item.formula_id, formulaForm as Formula.FormulaItem) } }) + formulaStore.initFormulaList() } /** @@ -386,7 +387,7 @@ defineExpose({
- + import { syncSendCmd } from 'apis/system' import { ElMessageBox } from 'element-plus' -import { onMounted, ref, watch } from 'vue' +import { onMounted, ref, watch, watchEffect } from 'vue' import { FtMessage } from '@/libs/message' import { FtMessageBox } from '@/libs/messageBox' @@ -28,18 +28,20 @@ onMounted(() => { initFormulaList() }) -watch(formulaStore.formulaList, () => { +watchEffect(() => { recipes.value = formulaStore.formulaList if (formulaStore.formulaList) { - if (formulaStore.selectedIndex != null) { - selectedIndex.value = formulaStore.selectedIndex - } - else { - selectedIndex.value = formulaStore.formulaList.length - 1 - } + selectedIndex.value = formulaStore.formulaList.length - 1 + } +}) +watch(selectedIndex, () => { + if (selectedIndex.value != null) { + const currentIndex: number = selectedIndex.value + const selectItem: Formula.FormulaItem = recipes.value[currentIndex] + const item = convertValuesToInt(selectItem) as Formula.FormulaItem + formulaStore.updateSelectedFormulaData(item) } }) - const initFormulaList = () => { if (formulaStore.formulaList && formulaStore.formulaList.length) { recipes.value = formulaStore.formulaList as Formula.FormulaItem[] @@ -48,7 +50,6 @@ const initFormulaList = () => { formulaStore.initFormulaList() } } -watch(selectedIndex, () => {}) const selectRecipe = (item: Formula.FormulaItem, index: number) => { selectedIndex.value = index formulaStore.updateSelectedIndex(index)