|
|
@ -1,5 +1,5 @@ |
|
|
|
<template> |
|
|
|
<div id="changeUser-container"> |
|
|
|
<div id="changeUser-container" :key="refreshKey"> |
|
|
|
<!-- 顶部导航 --> |
|
|
|
<div class="header"> |
|
|
|
<div class="header-left"> |
|
|
@ -74,7 +74,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { onMounted, ref, watchEffect } from 'vue' |
|
|
|
import { onMounted, ref, watchEffect, onUnmounted, onActivated } from 'vue' |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
import { useTestTubeStore, useConsumablesStore, useSettingTestTubeStore } from '../../../store' |
|
|
|
import SimpleKeyboard from '../../../components/SimpleKeyboard.vue' |
|
|
@ -89,8 +89,8 @@ import { |
|
|
|
processTubeSettings, |
|
|
|
generateSampleBackground, |
|
|
|
} from '../utils' |
|
|
|
import { updateTubeConfig } from '../../../services/Index/Test-tube/test-tube' |
|
|
|
|
|
|
|
import { updateTubeConfig } from '../../../services' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
const testTubeStore = useTestTubeStore() |
|
|
|
const consumableStore = useConsumablesStore() |
|
|
|
const router = useRouter() |
|
|
@ -110,10 +110,24 @@ const currentInput = ref<{ |
|
|
|
item: null |
|
|
|
}) |
|
|
|
const settingTestTubeStore = useSettingTestTubeStore() |
|
|
|
|
|
|
|
const refreshKey = ref(0) |
|
|
|
const modifiedTubes = ref(new Map<number, any>()) |
|
|
|
onMounted(() => { |
|
|
|
// startPolling() |
|
|
|
tubeInfo.value = testTubeStore.tubeInfo |
|
|
|
console.log("🚀 ~ onMounted ~ tubeInfo.value:", tubeInfo.value) |
|
|
|
tubeSettings.value = processTubeSettings( |
|
|
|
tubeInfo.value.tubeSettings, |
|
|
|
plates.value, |
|
|
|
getBloodTypeLabel, |
|
|
|
) |
|
|
|
processedTubeInfo.value = { |
|
|
|
...tubeInfo.value, |
|
|
|
tubeSettings: tubeSettings.value, |
|
|
|
} |
|
|
|
}) |
|
|
|
onActivated(() => { |
|
|
|
tubeInfo.value = testTubeStore.tubeInfo |
|
|
|
console.log("🚀 ~ onActivated ~ tubeInfo.value:", tubeInfo.value) |
|
|
|
tubeSettings.value = processTubeSettings( |
|
|
|
tubeInfo.value.tubeSettings, |
|
|
|
plates.value, |
|
|
@ -126,7 +140,6 @@ onMounted(() => { |
|
|
|
}) |
|
|
|
//返回试管页面 |
|
|
|
const goBack = () => { |
|
|
|
// stopPolling() |
|
|
|
router.push('/index/regular/test-tube') |
|
|
|
} |
|
|
|
// 选择样本的函数 |
|
|
@ -158,11 +171,32 @@ watchEffect(() => { |
|
|
|
}) |
|
|
|
//确认事件 |
|
|
|
const confirmChange = async () => { |
|
|
|
const { uuid, setting } = settingTestTubeStore.currentConfig |
|
|
|
const res = await updateTubeConfig({ uuid, setting }) |
|
|
|
if (res.success) { |
|
|
|
settingTestTubeStore.clearConfig() |
|
|
|
const modifiedSettings = Array.from(modifiedTubes.value.values()) |
|
|
|
|
|
|
|
if (modifiedSettings.length > 0) { |
|
|
|
try { |
|
|
|
const updatePromises = modifiedSettings.map(setting => |
|
|
|
updateTubeConfig({ |
|
|
|
uuid: processedTubeInfo.value.uuid, |
|
|
|
setting |
|
|
|
}) |
|
|
|
) |
|
|
|
const results = await Promise.all(updatePromises) |
|
|
|
|
|
|
|
const allSuccess = results.every(res => res && res.success) |
|
|
|
|
|
|
|
if (allSuccess) { |
|
|
|
ElMessage.success('所有修改已保存') |
|
|
|
goBack() |
|
|
|
} else { |
|
|
|
ElMessage.error('部分修改保存失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('保存修改失败:', error) |
|
|
|
ElMessage.error('保存失败') |
|
|
|
} |
|
|
|
} else { |
|
|
|
ElMessage.warning('没有需要保存的修改') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -177,25 +211,40 @@ const showKeyboard = (type: 'barcode' | 'userid', item: any) => { |
|
|
|
const handleKeyboardInput = (input: string) => { |
|
|
|
if (!currentInput.value.item) return |
|
|
|
|
|
|
|
settingTestTubeStore.updateTubeSetting(tubeInfo.value.uuid, { |
|
|
|
tubeIndex: currentInput.value.item.tubeIndex, |
|
|
|
[currentInput.value.type === 'userid' ? 'userid' : 'sampleBarcode']: input |
|
|
|
}) |
|
|
|
|
|
|
|
// 更新UI显示 |
|
|
|
if (currentInput.value.type === 'barcode') { |
|
|
|
currentInput.value.item.sampleBarcode = input |
|
|
|
} else { |
|
|
|
currentInput.value.item.userid = input |
|
|
|
} |
|
|
|
|
|
|
|
currentInputValue.value = input |
|
|
|
|
|
|
|
modifiedTubes.value.set(currentInput.value.item.tubeIndex, { |
|
|
|
tubeIndex: currentInput.value.item.tubeIndex, |
|
|
|
userid: currentInput.value.item.userid, |
|
|
|
sampleBarcode: currentInput.value.item.sampleBarcode, |
|
|
|
projId: currentInput.value.item.projId?.map((p: ReactionPlate) => p.projId) || [], |
|
|
|
bloodType: currentInput.value.item.bloodType, |
|
|
|
}) |
|
|
|
|
|
|
|
settingTestTubeStore.updateTubeSetting(tubeInfo.value.uuid, { |
|
|
|
tubeIndex: currentInput.value.item.tubeIndex, |
|
|
|
[currentInput.value.type === 'userid' ? 'userid' : 'sampleBarcode']: input |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 处理键盘按键 |
|
|
|
const handleKeyPress = (button: string) => { |
|
|
|
if (button === '{enter}') { |
|
|
|
keyboardVisible.value = false |
|
|
|
currentInputValue.value = '' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 在组件卸载时清理 |
|
|
|
onUnmounted(() => { |
|
|
|
modifiedTubes.value.clear() |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="less" scoped> |
|
|
|