From c038d66ceb3dfb007be810b6acbf21beac5e56ed Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Tue, 21 Jan 2025 20:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=93=B6=E7=BC=93=E5=86=B2=E6=B6=B2?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=BB=91=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Index/Regular/Consumables.vue | 49 ++++++++++++++++++++-- .../Index/components/Consumables/MainComponent.vue | 35 ++++++++++++++-- src/store/modules/consumables.ts | 6 +++ 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/pages/Index/Regular/Consumables.vue b/src/pages/Index/Regular/Consumables.vue index e7b2801..b4a8442 100644 --- a/src/pages/Index/Regular/Consumables.vue +++ b/src/pages/Index/Regular/Consumables.vue @@ -83,6 +83,7 @@ @@ -243,6 +245,41 @@ const handleUnloadConsumable = async (index: number) => { } } +const updateLittleBottomNum = async ({ + index, + bottleNum, + sync, +}: { + index: number + bottleNum: number + sync: boolean +}) => { + if (bottleNum < 0) { + return + } + if (deviceStore.deviceState.workState !== 'WORKING') { + consumableStore.setDisableUpdateConsumableData(true) + consumableStore.updateLittleBottomNum(index, bottleNum) + if (sync) { + console.log(`🚀 ~ updatePlateNum ~ order ${index + 1}, num ${bottleNum}`) + try { + const res = await updateConsumables({ + group: `CG${index + 1}`, + num: bottleNum, + }) + if (!res.success) { + errMsg$.next(res.data.info || '修改耗材数量失败') + } + } catch (error) { + console.error('修改耗材数量失败:', error) + } + consumableStore.setDisableUpdateConsumableData(false) + } + } else { + errMsg$.next('设备正在工作,无法修改数值') + } +} + const updateReactionPlateNum = async ({ index, plateNum, @@ -261,7 +298,10 @@ const updateReactionPlateNum = async ({ if (sync) { console.log(`🚀 ~ updatePlateNum ~ order ${index + 1}, num ${plateNum}`) try { - const res = await updateConsumables({ group: `CG${index + 1}`, num: plateNum }) + const res = await updateConsumables({ + group: `CG${index + 1}`, + num: plateNum, + }) if (!res.success) { errMsg$.next(res.data.info || '修改耗材数量失败') } @@ -293,7 +333,10 @@ const updateTipNum = async ({ if (sync) { console.log(`🚀 ~ updateTipNum ~ order ${index + 1}, num ${tipNum}`) try { - const res = await updateTipsNum({ group: `TipG${index + 1}`, num: tipNum }) + const res = await updateTipsNum({ + group: `TipG${index + 1}`, + num: tipNum, + }) if (!res.success) { errMsg$.next(res.data.info || '修改耗材数量失败') } @@ -301,7 +344,7 @@ const updateTipNum = async ({ console.error('修改耗材数量失败:', error) } consumableStore.setDisableUpdateConsumableData(false) - } + } } else { errMsg$.next('设备正在工作,无法修改数值') } diff --git a/src/pages/Index/components/Consumables/MainComponent.vue b/src/pages/Index/components/Consumables/MainComponent.vue index 5021592..b4313dd 100644 --- a/src/pages/Index/components/Consumables/MainComponent.vue +++ b/src/pages/Index/components/Consumables/MainComponent.vue @@ -1,11 +1,26 @@ @@ -15,6 +30,9 @@ import InfoBar from './InfoBar.vue' // 引入项目信息组件 // Props 定义 const props = defineProps({ + order: { + type: Number, + }, projectName: { type: String, // required: true, @@ -53,9 +71,18 @@ const props = defineProps({ }, inUse: { type: Boolean, - default: true + default: true, }, }) +const emit = defineEmits(['updateBottleNum']) + +const handleUpdateBottleNum = ( + remainingCount, + order, + sync, +) => { + emit('updateBottleNum', { index: order - 1, bottleNum: remainingCount, sync }) +}