Browse Source

配方新增后不刷新列表

配方新增后不自动选中新增的列
master
王梦远 2 weeks ago
parent
commit
ce1635ec1a
  1. 3
      src/components/formula/FormulaConfig.vue
  2. 17
      src/components/formula/FormulaTable.vue

3
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({
<transition name="slide-right">
<div v-if="isFlip" class="formula-form">
<el-form ref="formRef" :model="formData" label-width="auto" label-position="right" :size="size" inline>
<el-form-item v-if="type !== 'setting'" label="配方名称" style="width: 100%;">
<el-form-item v-if="type !== 'setting'" label="配方名称" style="width: 93%;">
<el-input
v-model="formData.name"
v-prevent-keyboard

17
src/components/formula/FormulaTable.vue

@ -1,7 +1,7 @@
<script lang="ts" setup>
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
}
})
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)

Loading…
Cancel
Save