Browse Source

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

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

2
src/components/formula/FormulaConfig.vue

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

10
src/components/formula/FormulaTable.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { syncSendCmd } from 'apis/system' import { syncSendCmd } from 'apis/system'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { onMounted, ref, watch, watchEffect } from 'vue'
import { onMounted, ref, watch } from 'vue'
import { FtMessage } from '@/libs/message' import { FtMessage } from '@/libs/message'
import { FtMessageBox } from '@/libs/messageBox' import { FtMessageBox } from '@/libs/messageBox'
@ -9,7 +9,7 @@ import { convertValuesToInt } from '@/libs/utils'
import { useFormulaStore } from '@/stores/formulaStore' import { useFormulaStore } from '@/stores/formulaStore'
const formulaStore = useFormulaStore() const formulaStore = useFormulaStore()
const selectedIndex = ref<number | null>(0)
const selectedIndex = ref<number | null>(formulaStore.selectedIndex)
const recipes = ref<Formula.FormulaItem[]>([]) const recipes = ref<Formula.FormulaItem[]>([])
const currectFormula = ref<Formula.FormulaItem>() const currectFormula = ref<Formula.FormulaItem>()
@ -28,7 +28,7 @@ onMounted(() => {
initFormulaList() initFormulaList()
}) })
watchEffect(() => {
watch(() => formulaStore.formulaList.length, () => {
recipes.value = formulaStore.formulaList recipes.value = formulaStore.formulaList
if (formulaStore.formulaList && formulaStore.formulaList.length > 0) { if (formulaStore.formulaList && formulaStore.formulaList.length > 0) {
selectedIndex.value = formulaStore.formulaList.length - 1 selectedIndex.value = formulaStore.formulaList.length - 1
@ -37,7 +37,7 @@ watchEffect(() => {
selectedIndex.value = null selectedIndex.value = null
} }
}) })
watch(selectedIndex, () => {
watch(() => selectedIndex.value, () => {
if (selectedIndex.value != null) { if (selectedIndex.value != null) {
const currentIndex: number = selectedIndex.value const currentIndex: number = selectedIndex.value
const selectItem: Formula.FormulaItem = recipes.value[currentIndex] const selectItem: Formula.FormulaItem = recipes.value[currentIndex]
@ -118,7 +118,7 @@ const deleteRecipe = (item: Formula.FormulaItem) => {
:class="{ selected: selectedIndex === index }" :class="{ selected: selectedIndex === index }"
@click="selectRecipe(item, index)" @click="selectRecipe(item, index)"
> >
<span class="formula-name">{{ item.name }}</span>
<span class="formula-name">{{ item.name }}</span>
<div class="actions"> <div class="actions">
<el-button class="view-button" @click.stop="onStartFormula(item)"> <el-button class="view-button" @click.stop="onStartFormula(item)">
执行配方 执行配方

Loading…
Cancel
Save