处方模板数据未回显问题 (2025-08-07 01:30Z)
User
@/views @/patients @/enteralNutrition 添加预包装处方时,点击处方模板,选中对应处方以后点击确认,表格中并未回显对应的数据
Assistant
我需要先分析一下肠内营养模块的预包装处方模板功能,特别是模板选择后数据回显的问题。让我先探索相关的组件结构和代码。
Todo List
Read file: src/views/patients/enteralNutrition/components/table/PackageTable.vue
Todo List
现在我发现了问题的关键。通过分析代码,我发现问题在于LeftCard.vue
中的handleTemplateSelected
函数里对预包装处方模板的数据处理有问题。让我仔细分析:
- 在
LeftCard.vue
的第197行,当处方类型是'package'
时,调用了handlePackageTemplateData
函数
- 但是在第382行,检查条件是
prescriptionType.value == 'package'
,而实际上预包装处方的类型应该是'3'
Grep search for "prescriptionType.*package" • **2** files
| File | Line | Match |
|------|------|-------|
| `file:///e%3A/CodeProjects/Cursor/wkx-his-web/src/views/patients/enteralNutrition/components/LeftCard.vue` | L197 | `if (prescriptionType.value === 'package') {` |
| `file:///e%3A/CodeProjects/Cursor/wkx-his-web/src/views/patients/enteralNutrition/components/LeftCard.vue` | L395 | `} else if (prescriptionType.value == 'package') {` |
| `file:///e%3A/CodeProjects/Cursor/wkx-his-web/src/views/patients/enteralNutrition/components/LeftCard.vue` | L197 | `if (prescriptionType.value === 'package') {` |
| `file:///e%3A/CodeProjects/Cursor/wkx-his-web/src/views/patients/enteralNutrition/components/LeftCard.vue` | L395 | `} else if (prescriptionType.value == 'package') {` |
Grep search for "prescriptionType\.value.*[\"']3[\"']" • **1** files
| File | Line | Match |
|------|------|-------|
| `file:///e%3A/CodeProjects/Cursor/wkx-his-web/src/views/patients/enteralNutrition/components/LeftCard.vue` | L495 | `prescriptionType.value = '3';` |
Todo List
现在我找到了问题的根源!在LeftCard.vue
中:
- 添加预包装处方时,
prescriptionType.value
被设置为'3'
(第494行)
- 但是在
handleTemplateSelected
函数中,判断预包装处方使用的是'package'
字符串(第196行和第394行)
- 这导致模板数据无法正确处理和回显到
PackageTable
让我修复这个问题:
Edit file: src/views/patients/enteralNutrition/components/LeftCard.vue
undefined
**Chunk 1**
Lines added: 1, lines removed: 1
```diff
@@ -195,5 +195,5 @@
// 根据处方类型处理模板数据
- if (prescriptionType.value === 'package') {
+ if (prescriptionType.value === '3') {
// 预包装处方:直接更新packageData
handlePackageTemplateData(contentData);
```
Edit file: src/views/patients/enteralNutrition/components/LeftCard.vue
undefined
**Chunk 1**
Lines added: 1, lines removed: 1
```diff
@@ -380,5 +380,5 @@
param.value.status = status;
- if (prescriptionType.value == 'normal') {
+ if (prescriptionType.value == '2') {
param.value.chargeType = '3';
if (!configData.value || configData.value.length == 0) {
```
**Chunk 2**
Lines added: 1, lines removed: 1
```diff
@@ -393,5 +393,5 @@
}
param.value.consumableList = JSON.parse(materialData.value);
- } else if (prescriptionType.value == 'package') {
+ } else if (prescriptionType.value == '3') {
param.value.chargeType = '2';
if (!packageData.value || packageData.value.length == 0) {
```
但是我发现还有一个问题,在handlePackageTemplateData
函数中,数据结构的处理可能不正确。让我检查PackageTable
期望的数据格式:
Read file: src/views/patients/enteralNutrition/components/LeftCard.vue
现在我需要检查PackageTable
的数据结构,看看创建默认行的方法:
Read file: src/views/patients/enteralNutrition/components/table/PackageTable.vue
我看到问题了!在PackageTable
中,createDefaultRow
函数创建的数据结构有products
数组,但在handlePackageTemplateData
中没有包含这个结构。让我修复这个问题:
Edit file: src/views/patients/enteralNutrition/components/LeftCard.vue
undefined
**Chunk 1**
Lines added: 1, lines removed: 1
```diff
@@ -141,5 +141,5 @@
contentData.product.forEach((product, index) => {
const packageRow = {
- // PackageTable使用扁平结构,不是products数组
+ // PackageTable需要这些直接字段
nutritionProductId: product.id ? `${product.id}_${index}` : '',
quantity: product.quantity || 1,
```
**Chunk 2**
Lines added: 5, lines removed: undefined
```diff
@@ -164,4 +164,9 @@
totalDose: product.totalDose || '',
productSpecUnit: product.productSpecUnit || 'g',
+ // PackageTable也需要products数组(兼容TableRow接口)
+ products: [{
+ specification: product.specification || '',
+ dosePerDay: product.dosePerDay || ''
+ }],
sn: index,
tableId: Date.now() + index
```
现在让我检查一下还有什么需要修复的。让我查看一下模板的数据结构,以及PackageTable
如何处理接收到的数据:
Read file: src/views/patients/enteralNutrition/components/table/PackageTable.vue
看起来数据处理应该是正确的。现在让我也检查一下导入缺失的导入语句,因为我注意到linter有错误:
Edit file: src/views/patients/enteralNutrition/components/LeftCard.vue
undefined
**Chunk 1**
Lines added: 2, lines removed: 1
```diff
@@ -76,5 +76,6 @@