|
|
@ -15,7 +15,7 @@ |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
placeholder="请输入样本条形码信息" |
|
|
|
@focus="showKeyboard('sampleBarcode')" |
|
|
|
@focus="openKeyboard('sampleBarcode')" |
|
|
|
style="width: 400px" |
|
|
|
:value="emergencyPosition.sampleBarcode" |
|
|
|
readonly |
|
|
@ -30,7 +30,7 @@ |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
placeholder="请输入患者ID信息" |
|
|
|
@focus="showKeyboard('userid')" |
|
|
|
@focus="openKeyboard('userid')" |
|
|
|
:value="emergencyPosition.userid" |
|
|
|
style="width: 400px" |
|
|
|
readonly |
|
|
@ -59,7 +59,7 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="project-title"> |
|
|
|
<span>血液类型</span> |
|
|
|
<span>样本类型</span> |
|
|
|
</div> |
|
|
|
<div class="type-list"> |
|
|
|
<div |
|
|
@ -81,20 +81,23 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 键盘 --> |
|
|
|
<transition name="slide-up"> |
|
|
|
|
|
|
|
<div class="keyboard" v-if="keyboardVisible"> |
|
|
|
<SimpleKeyboard |
|
|
|
:input="currentInputValue" |
|
|
|
@onChange="handleKeyboardInput" |
|
|
|
@onKeyPress="handleKeyPress" |
|
|
|
<SoftKeyboard |
|
|
|
ref="softKeyboardRef" |
|
|
|
v-model="inputValue" |
|
|
|
:is-visible="keyboardVisible" |
|
|
|
:keyboard-type="keyboardType" |
|
|
|
@update-keyboard-visible="(visible) => keyboardVisible = visible" |
|
|
|
@confirm="()=>{}" |
|
|
|
@close="keyboardVisible = false" |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</transition> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { ref, onMounted, onUnmounted } from 'vue' |
|
|
|
import { ref, onMounted, onUnmounted, watch } from 'vue' |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
import { insertEmergency } from '@/services/Index/index' |
|
|
|
import { |
|
|
@ -111,6 +114,34 @@ defineOptions({ |
|
|
|
name: 'EmergencyForm', |
|
|
|
}) |
|
|
|
|
|
|
|
const inputValue = ref('') |
|
|
|
const keyboardType = ref<'text' | 'number'>('text') |
|
|
|
const softKeyboardRef = ref() |
|
|
|
const currentFocusType = ref('') |
|
|
|
|
|
|
|
const openKeyboard = (type: 'sampleBarcode' | 'userid') => { |
|
|
|
inputValue.value = type === 'sampleBarcode' ? emergencyPosition.value.sampleBarcode : emergencyPosition.value.userid |
|
|
|
keyboardVisible.value = true |
|
|
|
setTimeout(() => { keyboardVisible.value = true}, 100) |
|
|
|
currentFocusType.value = type |
|
|
|
} |
|
|
|
|
|
|
|
watch(inputValue, (newVal: string) => { |
|
|
|
handleKeyboardInput(newVal) |
|
|
|
}) |
|
|
|
|
|
|
|
// 处理键盘输入 |
|
|
|
const handleKeyboardInput = (value: string) => { |
|
|
|
// 更新当前输入值 |
|
|
|
inputValue.value = value |
|
|
|
// 更新对应字段的值 |
|
|
|
if (currentFocusType.value === 'sampleBarcode') { |
|
|
|
emergencyPosition.value.sampleBarcode = value |
|
|
|
} else { |
|
|
|
emergencyPosition.value.userid = value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const consumableStore = useConsumablesStore() |
|
|
|
const emergencyStore = useEmergencyStore() |
|
|
|
const deviceStore = useDeviceStore() |
|
|
@ -206,54 +237,13 @@ onMounted(() => { |
|
|
|
}) |
|
|
|
// 键盘相关状态 |
|
|
|
const keyboardVisible = ref(false) |
|
|
|
const currentInputValue = ref('') |
|
|
|
const currentInputField = ref<'sampleBarcode' | 'userid' | ''>('') |
|
|
|
|
|
|
|
// 显示键盘 |
|
|
|
const showKeyboard = (field: 'sampleBarcode' | 'userid') => { |
|
|
|
// 清空当前输入值,避免累加 |
|
|
|
if (field == 'sampleBarcode') { |
|
|
|
currentInputValue.value = emergencyPosition.value.sampleBarcode |
|
|
|
} |
|
|
|
if (field == 'userid') { |
|
|
|
currentInputValue.value = emergencyPosition.value.userid |
|
|
|
} |
|
|
|
currentInputField.value = field |
|
|
|
keyboardVisible.value = true |
|
|
|
} |
|
|
|
|
|
|
|
// 处理键盘输入 |
|
|
|
const handleKeyboardInput = (value: string) => { |
|
|
|
if (!currentInputField.value) return |
|
|
|
// 更新当前输入值 |
|
|
|
currentInputValue.value = value |
|
|
|
// 更新对应字段的值 |
|
|
|
if (currentInputField.value === 'sampleBarcode') { |
|
|
|
emergencyPosition.value.sampleBarcode = value |
|
|
|
} else { |
|
|
|
emergencyPosition.value.userid = value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 处理键盘按键 |
|
|
|
const handleKeyPress = (button: string) => { |
|
|
|
if (button === '{enter}') { |
|
|
|
hideKeyboard() |
|
|
|
} else if (button === '{bksp}') { |
|
|
|
// 处理退格键 |
|
|
|
const value = currentInputValue.value |
|
|
|
if (value.length > 0) { |
|
|
|
const newValue = value.slice(0, -1) |
|
|
|
handleKeyboardInput(newValue) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 隐藏键盘 |
|
|
|
const hideKeyboard = () => { |
|
|
|
keyboardVisible.value = false |
|
|
|
currentInputField.value = '' |
|
|
|
currentInputValue.value = '' |
|
|
|
inputValue.value = '' |
|
|
|
currentFocusType.value = '' |
|
|
|
} |
|
|
|
|
|
|
|
// 在组件卸载时清理状态 |
|
|
|