Files
his/openhis-ui-vue3/src/components/OpenHis/TraceNoDialog/index.vue
zhangfei 9c3e603b94 Fix Bug #443: 手术计费:点击签发耗材时异常报错
当手术计费弹窗中点击"签发"耗材时,因耗材的locationId(发放库房)为空导致后端异常。
在DoctorStationAdviceAppServiceImpl.handDevice方法中,当locationId为null时,使用登录用户的科室ID作为默认值,
与NurseBillingAppService中的处理方式保持一致。
2026-05-08 09:14:18 +08:00

232 lines
5.9 KiB
Vue
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-dialog
title="药品追溯码"
v-model="props.openDialog"
width="842"
append-to-body
destroy-on-close
:draggable="true"
@close="cancel"
@opened="
() => {
traceNoTempRef.focus();
}
"
>
<div>
<div style="font-size: 16px">
<div style="margin-bottom: 15px">药品名称 {{ props.ypName }}</div>
扫描追溯码
<el-input
ref="traceNoTempRef"
type="textarea"
:rows="1"
v-model="traceNoTemp"
style="width: 180px; margin-right: 20px"
@input="throttledGetList(traceNoTemp)"
/>
输入追溯码
<el-input
v-model="traceNoInput"
style="width: 180px; margin-right: 20px"
@keyup.enter="handelTraceNo(traceNoInput)"
/>
<el-button type="primary" plain icon="CircleClose" @click="handleReturn"> 撤回 </el-button>
<el-button type="danger" plain icon="CircleClose" @click="handleClear"> 清除 </el-button>
</div>
<!-- <el-input
ref="inputRef"
v-model="traceNo"
type="textarea"
:rows="15"
disabled
@input="throttledGetList"
style="width: 100%; margin-top: 10px; margin-right: 20px"
/> -->
<div
style="
background: #f5f7fa;
margin-top: 10px;
padding: 10px;
width: 780px;
height: 350px;
border: solid 1px #ebeef5;
overflow-y: auto;
"
>
<div style="display: flex; flex-wrap: wrap; gap: 8px">
<div
v-for="(item, index) in traceNoList"
:key="item + index"
style="
display: inline-flex;
align-items: center;
background: white;
padding: 4px 8px 4px 12px;
border-radius: 12px;
"
>
<span style="margin-right: 6px">
[{{ index + 1 }}]
<template v-if="index < 9">&nbsp;</template>
<template v-else></template>
{{ item }}
</span>
<div
@click="removeTraceNo(index)"
style="
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
background: #f56c6c;
border-radius: 50%;
cursor: pointer;
"
>
<el-icon size="10" color="white">
<Close />
</el-icon>
</div>
</div>
</div>
</div>
<div>
追溯码{{ existenceTraceNoList[rowData ? rowData.itemId : 0] }}
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submit"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import {watch} from 'vue';
import {searchTraceNo} from '@/api/public';
import {debounce} from 'lodash-es';
const props = defineProps({
openDialog: {
type: Boolean,
default: false,
},
ypName: {
type: String,
default: '',
},
rowData: {
type: Object,
default: () => {},
},
});
const openTraceNo = ref(false);
const traceNo = ref('');
const traceNoList = ref([]);
const existenceTraceNoList = ref([]);
const traceNoTemp = ref('');
const traceNoInput = ref('');
const traceNoTempRef = ref();
const emit = defineEmits(['submit', 'cancel']);
watch(
() => props.rowData,
async (newRowData) => {
if (newRowData && Object.keys(newRowData).length > 0) {
const { itemType, itemId, locationId, lotNumber } = newRowData;
try {
const response = await searchTraceNo({
itemType,
itemId,
locationId,
lotNumber,
});
// 处理返回数据,例如更新 traceNoList
existenceTraceNoList.value = response.data || [];
} catch (error) {
console.error('获取追溯码失败:', error);
}
}
},
{ deep: true, immediate: true }
);
// 撤回最后一条追溯码
function handleReturn() {
if (traceNoList.value.length !== 0) {
// 1. 从数组中移除最后一项
traceNoList.value.pop();
// 2. 重新构建显示文本
traceNo.value = traceNoList.value
.map((item, index) => {
return index < 9 ? `[${index + 1}] ${item}` : `[${index + 1}] ${item}`;
})
.join(', ');
if (traceNoList.value != 0) {
traceNo.value += '\n';
}
}
traceNoTempRef.value.focus();
}
function removeTraceNo(index) {
traceNoList.value.splice(index, 1);
traceNoTempRef.value.focus();
}
function formatValue(index) {
if (index >= 10) {
return `&nbsp;&nbsp;`;
} else {
return `&nbsp;`;
}
}
function handleClear() {
traceNo.value = '';
traceNoList.value = [];
}
const throttledGetList = debounce(handelTraceNo, 500);
function handelTraceNo(value) {
let list = value.trim().split('\n');
list.forEach((item) => {
if(traceNoList.value.indexOf(item) === -1) {
traceNoList.value.push(item);
}
});
traceNo.value = traceNoList.value
.map((item, index) => {
return index < 9 ? `[${index + 1}] ${item}` : `[${index + 1}] ${item}`;
})
.join(', ');
if (traceNoList.value != 0) {
traceNo.value += '\n';
}
traceNoTemp.value = '';
traceNoInput.value = '';
// let saveValue = value.substring(inputValue.length + 5, value.length);
// inputValue = value;
// console.log(value);
// console.log(saveValue);
// traceNoList.value.push(saveValue);
// traceNo.value = value + '[' + (traceNoList.value.length + 1) + ']' + ' ';
}
function cancel() {
emit('cancel');
traceNoList.value = [];
traceNo.value = '';
}
function submit() {
emit('submit', traceNoList.value.join(','));
openTraceNo.value = false;
traceNoList.value = [];
traceNo.value = '';
}
</script>