Browse Source

配方切换页面可以定位到选中行

master
王梦远 2 weeks ago
parent
commit
317c035eed
  1. 2
      src/components/formula/FormulaConfig.vue
  2. 8
      src/components/formula/FormulaTable.vue

2
src/components/formula/FormulaConfig.vue

@ -296,9 +296,9 @@ const onAddFormula = () => {
// formulaForm.name = item.name
formulaForm.formula_id = item.formula_id
onEditFormula(item.formula_id, formulaForm as Formula.FormulaItem)
formulaStore.initFormulaList()
}
})
formulaStore.initFormulaList()
}
/**

8
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, watchEffect } from 'vue'
import { onMounted, ref, watch } from 'vue'
import { FtMessage } from '@/libs/message'
import { FtMessageBox } from '@/libs/messageBox'
@ -9,7 +9,7 @@ import { convertValuesToInt } from '@/libs/utils'
import { useFormulaStore } from '@/stores/formulaStore'
const formulaStore = useFormulaStore()
const selectedIndex = ref<number | null>(0)
const selectedIndex = ref<number | null>(formulaStore.selectedIndex)
const recipes = ref<Formula.FormulaItem[]>([])
const currectFormula = ref<Formula.FormulaItem>()
@ -28,7 +28,7 @@ onMounted(() => {
initFormulaList()
})
watchEffect(() => {
watch(() => formulaStore.formulaList.length, () => {
recipes.value = formulaStore.formulaList
if (formulaStore.formulaList && formulaStore.formulaList.length > 0) {
selectedIndex.value = formulaStore.formulaList.length - 1
@ -37,7 +37,7 @@ watchEffect(() => {
selectedIndex.value = null
}
})
watch(selectedIndex, () => {
watch(() => selectedIndex.value, () => {
if (selectedIndex.value != null) {
const currentIndex: number = selectedIndex.value
const selectItem: Formula.FormulaItem = recipes.value[currentIndex]

Loading…
Cancel
Save