解决医嘱类型选中开单后变成数字问题。

This commit is contained in:
Auora
2025-11-11 16:05:18 +08:00
parent a8e170ea45
commit 3e32458b7f

View File

@@ -523,17 +523,18 @@
<el-select <el-select
v-model="scope.row.adviceType" v-model="scope.row.adviceType"
:ref="'adviceTypeRef' + scope.$index" :ref="'adviceTypeRef' + scope.$index"
@change="handleAdviceTypeChange(scope.row, scope.$index)"
placeholder="请选择" placeholder="请选择"
style="width: 100%"> style="width: 100%"
:value-key="'value'">
<el-option <el-option
v-for="dict in drord_doctor_type" v-for="dict in drord_doctor_type"
:key="dict.key" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</template> </template>
<!-- 非编辑模式下使用getAdviceTypeText函数确保显示正确的文本 -->
<span v-else>{{ getAdviceTypeText(scope.row.adviceType) }}</span> <span v-else>{{ getAdviceTypeText(scope.row.adviceType) }}</span>
</template> </template>
</el-table-column> </el-table-column>
@@ -821,12 +822,14 @@ watch(
); );
// 获取医嘱类别显示文本 // 获取医嘱类别显示文本
function getAdviceTypeText(adviceType) { function getAdviceTypeText(adviceType) {
// 转换为字符串进行查找,确保无论输入是数字还是字符串都能正确匹配
const typeMap = { const typeMap = {
1: '西药中成药', '1': '西药中成药',
2: '耗材', '2': '耗材',
3: '诊疗' '3': '诊疗'
}; };
return typeMap[adviceType] || '未知'; // 先将adviceType转换为字符串再查找映射
return typeMap[String(adviceType)] || '未知';
} }
function handleTotalAmount() { function handleTotalAmount() {
totalAmount.value = prescriptionList.value.reduce((accumulator, currentRow) => { totalAmount.value = prescriptionList.value.reduce((accumulator, currentRow) => {
@@ -1012,9 +1015,15 @@ function selectAdviceBase(key, row) {
type: 'minUnit', type: 'minUnit',
}); });
} }
// 保存当前已选择的医嘱类型
const currentAdviceType = prescriptionList.value[rowIndex.value].adviceType;
prescriptionList.value[rowIndex.value] = { prescriptionList.value[rowIndex.value] = {
...prescriptionList.value[rowIndex.value], ...prescriptionList.value[rowIndex.value],
...JSON.parse(JSON.stringify(row)), ...JSON.parse(JSON.stringify(row)),
// 如果用户已经选择了医嘱类型,则保留用户的选择,否则使用项目默认的类型
adviceType: currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' ?
currentAdviceType : row.adviceType,
}; };
prescriptionList.value[rowIndex.value].orgId = undefined; prescriptionList.value[rowIndex.value].orgId = undefined;
prescriptionList.value[rowIndex.value].dose = undefined; prescriptionList.value[rowIndex.value].dose = undefined;
@@ -1415,6 +1424,8 @@ function setValue(row) {
prescriptionList.value[rowIndex.value] = { prescriptionList.value[rowIndex.value] = {
...prescriptionList.value[rowIndex.value], ...prescriptionList.value[rowIndex.value],
...JSON.parse(JSON.stringify(row)), ...JSON.parse(JSON.stringify(row)),
// 确保adviceType为数字类型避免类型不匹配导致的显示问题
adviceType: Number(row.adviceType),
}; };
prescriptionList.value[rowIndex.value].orgId = undefined; prescriptionList.value[rowIndex.value].orgId = undefined;
prescriptionList.value[rowIndex.value].dose = undefined; prescriptionList.value[rowIndex.value].dose = undefined;