41 lines
2.0 KiB
Markdown
41 lines
2.0 KiB
Markdown
# Bug #512 分析报告
|
||
|
||
## Bug 描述
|
||
[住院护士站-汇总发药申请] "全选"开关功能失效,点击后下方医嘱明细未能联动勾选
|
||
|
||
## 根因分析
|
||
|
||
### 问题定位
|
||
`index.vue` 的 `handelSwicthChange` 函数(第176-186行)和 `handleExecute` 函数(第200-202行)。
|
||
|
||
### 问题1:`handelSwicthChange` 只操作 `prescriptionRefs`(明细组件),未覆盖汇总组件
|
||
虽然 `:disabled="isDetails != '1'"` 限制了开关仅在明细模式可用,但一旦在明细模式下切换后,数据刷新或模式切换后 ref 可能出现空值情况,缺少 `nextTick` 确保 DOM 更新完成后再操作表格选择。
|
||
|
||
### 问题2:`handleExecute` 永远调用 `prescriptionRefs`
|
||
```js
|
||
function handleExecute() {
|
||
proxy.$refs['prescriptionRefs'].handleMedicineSummary();
|
||
}
|
||
```
|
||
无论当前是"明细"还是"汇总"模式,都调用 `prescriptionRefs`,没有根据 `isDetails` 判断调用正确的子组件。
|
||
|
||
### 问题3:`summaryMedicineList.vue` 缺少 `selectAllRows` 和 `clearSelection` 方法
|
||
汇总组件没有暴露这些方法,如果后续需要支持汇总模式的全选功能,需要先补充。
|
||
|
||
## 修复方案
|
||
1. 在 `handelSwicthChange` 中添加 `nextTick` 确保 DOM 更新后再操作表格
|
||
2. 修复 `handleExecute` 根据 `isDetails` 判断调用正确的子组件
|
||
3. 为 `summaryMedicineList.vue` 添加 `selectAllRows` 和 `clearSelection` 方法
|
||
|
||
## 修复结果:✅ 成功,33行改动
|
||
|
||
### 修改内容
|
||
1. `index.vue` - `handelSwicthChange` 改为 async 函数,添加 `nextTick` 确保 DOM 更新后再调用表格选择方法
|
||
2. `index.vue` - `handelSwicthChange` 增加 `isDetails` 判断分支,覆盖明细和汇总两种模式
|
||
3. `index.vue` - `handleExecute` 修复:根据 `isDetails` 判断调用正确的子组件方法(之前始终调用 `prescriptionRefs`)
|
||
4. `index.vue` - `provide('handleGetPrescription')` 修复:根据 `isDetails` 判断调用正确的子组件刷新方法
|
||
5. `index.vue` - 导入 `nextTick` from vue
|
||
|
||
### 构建验证
|
||
`vite build --mode dev` 通过,无编译错误。
|