From 6830366510995d5817bfd01068df053f3f822b63 Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Wed, 15 Jan 2025 14:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=97=E6=9D=90store=E6=B7=BB=E5=8A=A0=20pro?= =?UTF-8?q?jectsAvailable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Index/Regular/TestTube.vue | 24 ++---------------------- src/pages/Index/TestTube/TubeUserId.vue | 17 ----------------- src/store/modules/consumables.ts | 28 ++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/pages/Index/Regular/TestTube.vue b/src/pages/Index/Regular/TestTube.vue index 08a6677..5da939a 100644 --- a/src/pages/Index/Regular/TestTube.vue +++ b/src/pages/Index/Regular/TestTube.vue @@ -10,7 +10,7 @@

项目选择

-
+
{ } } -const projectsAvailable = computed(() => { - const group = R.groupBy( - (p) => p.projName, - consumables.consumableData.reactionPlateGroup, - ) - const pNames = R.keys(group).filter((n) => n !== 'null') - - const projArr = pNames.map((n) => - R.reduce( - (acc, curr) => { - return { ...curr, num: acc.num + curr.num } - }, - { num: 0 }, - group[n], - ), - ) - - return projArr -}) - const projIdCntMap = computed(() => { return R.reduce( (acc, curr) => { diff --git a/src/pages/Index/TestTube/TubeUserId.vue b/src/pages/Index/TestTube/TubeUserId.vue index 2a69d1d..fc8a0e6 100644 --- a/src/pages/Index/TestTube/TubeUserId.vue +++ b/src/pages/Index/TestTube/TubeUserId.vue @@ -107,23 +107,6 @@ const tubeGroups = ref([ R.clone(tubeStore.tubeRack.tubeSettings.slice(5, 10)), ]) -const projectsAvailable = computed(() => { - const group = R.groupBy((p) => p.projName, consumables.consumableData.reactionPlateGroup) - const pNames = R.keys(group).filter(n => n !== 'null') - - const projArr = pNames.map((n) => - R.reduce( - (acc, curr) => { - return { ...curr, num: acc.num + curr.num } - }, - { num: 0 }, - group[n], - ), - ) - - return projArr -}) - const keyboardVisible = ref(false) const currentInputValue = ref('') const currentInput = ref({ diff --git a/src/store/modules/consumables.ts b/src/store/modules/consumables.ts index fd1ba58..dbaf33a 100644 --- a/src/store/modules/consumables.ts +++ b/src/store/modules/consumables.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' -import { ref } from 'vue' +import { ref,computed } from 'vue' +import * as R from 'ramda' // import type { // BottleGroup, // ConsumableState, @@ -7,7 +8,7 @@ import { ref } from 'vue' // Tip, // } from '../../types/Index' // import type { PersistenceOptions } from 'pinia-plugin-persistedstate' -import type { ConsumablesStateMessage } from '../../websocket/socket' +import type { ConsumablesStateMessage, ReactionPlateGroup } from '../../websocket/socket' export const useConsumablesStore = defineStore( 'consumables', @@ -58,6 +59,25 @@ export const useConsumablesStore = defineStore( isIdCardInserted.value = status } + const projectsAvailable = computed(() => { + // @ts-ignore + const group = R.groupBy( + (p) => p.projName, + consumableData.value.reactionPlateGroup, + ) + const pNames = R.keys(group).filter((n) => n !== 'null') + + const projArr = pNames.map((n) => + R.reduce( + (acc, curr) => { + return { ...curr, num: acc.num + (curr.num || 0) } + }, + { num: 0 }, + group[n] as ReactionPlateGroup[], + ), + ) + return projArr + }) //所有耗材都存在 let hasAllConsumables = ref(false) @@ -70,8 +90,8 @@ export const useConsumablesStore = defineStore( updateReactionPlateNum, updateTipNum, - // updateWasteStatus, - // wasteStatus, + projectsAvailable, + hasAllConsumables, } },