diff --git a/api/reception.js b/api/reception.js index 14d9638..b48a165 100644 --- a/api/reception.js +++ b/api/reception.js @@ -246,6 +246,7 @@ export function getCommonPrescriptionListApi(storeId) { } // 获取常用方详情 +// 注意:prescription_v2 选用常用方已改走 list(与 PC 对齐,主表行 + 平行药品行一次返回),不再调用此接口 export function getCommonPrescriptionDetailApi(id, type) { return req.request({ url: '/newApi/common-prescription/detail', diff --git a/subPackages/sub_workbench/prescription_v2/components/modals/CommonPrescriptionModal.vue b/subPackages/sub_workbench/prescription_v2/components/modals/CommonPrescriptionModal.vue index 0370ada..b46c8f9 100644 --- a/subPackages/sub_workbench/prescription_v2/components/modals/CommonPrescriptionModal.vue +++ b/subPackages/sub_workbench/prescription_v2/components/modals/CommonPrescriptionModal.vue @@ -20,8 +20,8 @@ @@ -36,7 +36,7 @@ 药品: @@ -46,7 +46,7 @@ 移除 - 使用 + 使用 @@ -58,14 +58,28 @@ - - + 取消 - 新建常用方 @@ -104,6 +118,8 @@ export default { return { show: false, prescriptionList: [], + // 与 prescriptionList 平行的药品数组:list 接口里 west/chinese/granular 字段,按下标一一对应 + recipesByIndex: [], loading: false }; }, @@ -162,16 +178,20 @@ export default { const res = await getCommonPrescriptionListApi(storeId); if (res && res.code === 0) { - // 根据类型过滤常用方 + // 根据类型过滤常用方主表行 + 平行药品行 const listKey = this.getListKey(type); this.prescriptionList = res.result?.[listKey] || []; + // type 即 west/chinese/granular,正好是 list 接口里平行药品数组的 key + this.recipesByIndex = res.result?.[type] || []; } else { this.prescriptionList = []; + this.recipesByIndex = []; } } catch (error) { console.error('获取常用方列表失败:', error); this.$toast('获取常用方列表失败'); this.prescriptionList = []; + this.recipesByIndex = []; } finally { this.loading = false; } @@ -208,18 +228,14 @@ export default { }, /** - * 获取药品列表 - * @param {Object} prescription - 常用方数据 + * 获取某条常用方对应的药品列表 + * 与 PC 一致:list 接口返回的主表行与药品行按下标对齐,从 recipesByIndex[index] 取 + * @param {Object} _prescription - 主表行(保留参数为可调试用,未使用) + * @param {number} index - 列表中的下标 * @returns {Array} 药品列表 */ - getDrugList(prescription) { - // 根据常用方类型获取对应的药品列表 - const type = this.getCommonPrescriptionType(this.prescriptionType); - const listKey = type === 'chinese' ? 'chinese' : type === 'west' ? 'west' : 'granular'; - - // 从常用方数据中获取药品列表 - // 这里需要根据实际数据结构调整 - return prescription.drugs || prescription[listKey] || []; + getDrugList(_prescription, index) { + return this.recipesByIndex[index] || []; }, /** @@ -262,11 +278,13 @@ export default { /** * 选择常用方 - * @param {Object} prescription - 常用方数据 - * 职责:触发select事件,传递选中的常用方 + * 直接 emit 整条主表行(已包含后端组装好的 apply_payload), + * 父组件读 item.apply_payload 即可直接 spread 覆盖编辑区。 + * @param {Object} item - 主表行(含 apply_payload) + * @param {number} _index - 列表中的下标(保留以维持模板调用兼容,未使用) */ - handleSelectPrescription(prescription) { - this.$emit('select', prescription); + handleSelectPrescription(item, _index) { + this.$emit('select', item); this.handleClose(); }, @@ -439,13 +457,10 @@ export default { .modal-footer { display: flex; - gap: 24rpx; + justify-content: space-between; + align-items: center; padding: 32rpx; border-top: 1rpx solid #eee; - - .u-button { - flex: 1; - } } .white { diff --git a/subPackages/sub_workbench/prescription_v2/components/modals/DiagnosisModal.vue b/subPackages/sub_workbench/prescription_v2/components/modals/DiagnosisModal.vue index 32c0d3c..debafa7 100644 --- a/subPackages/sub_workbench/prescription_v2/components/modals/DiagnosisModal.vue +++ b/subPackages/sub_workbench/prescription_v2/components/modals/DiagnosisModal.vue @@ -99,14 +99,28 @@ - - + 取消 - 确定 @@ -506,12 +520,9 @@ export default { .modal-footer { display: flex; - gap: 24rpx; + justify-content: space-between; + align-items: center; padding: 32rpx; border-top: 1rpx solid #eee; - - .u-button { - flex: 1; - } } diff --git a/subPackages/sub_workbench/prescription_v2/components/modals/DoctorOrderModal.vue b/subPackages/sub_workbench/prescription_v2/components/modals/DoctorOrderModal.vue index d4f4410..87c3f9f 100644 --- a/subPackages/sub_workbench/prescription_v2/components/modals/DoctorOrderModal.vue +++ b/subPackages/sub_workbench/prescription_v2/components/modals/DoctorOrderModal.vue @@ -85,14 +85,28 @@ - - + 取消 - 确定 @@ -412,12 +426,9 @@ export default { .modal-footer { display: flex; - gap: 24rpx; + justify-content: space-between; + align-items: center; padding: 32rpx; border-top: 1rpx solid #eee; - - .u-button { - flex: 1; - } } diff --git a/subPackages/sub_workbench/prescription_v2/index.vue b/subPackages/sub_workbench/prescription_v2/index.vue index 79b2a58..e94bd7c 100644 --- a/subPackages/sub_workbench/prescription_v2/index.vue +++ b/subPackages/sub_workbench/prescription_v2/index.vue @@ -31,7 +31,7 @@ - + - + - + { - if (this.activeCategory === 1) { - // 中药 - return { - id: recipe.drug_id || recipe.id, - drug_id: recipe.drug_id || recipe.id, - drug_name: recipe.drug_name || recipe.name, - number: recipe.number || 1, - price: recipe.price || 0, - way_id: recipe.way_id || 0 - }; - } else { - // 西药 - return { - id: recipe.drug_id || recipe.id, - drug_id: recipe.drug_id || recipe.id, - drug_name: recipe.drug_name, - number: recipe.number || 1, - select_number: recipe.select_number || 1, - price: recipe.price || 0, - time_id: recipe.time_id || 0, - type_id: recipe.type_id || 0, - frequency_id: recipe.frequency_id || 0, - unit_id: recipe.unit_id || 0, - image: recipe.image || '', - instruction: recipe.instruction || '' - }; + + this.currentDrugs.splice(0, this.currentDrugs.length, ...payload.drugs); + + if (payload.diagnosisText) { + this.diagnosisText = payload.diagnosisText; + const names = payload.diagnosisText.split(',').filter(Boolean); + this.diagnoses = names.map((name, index) => ({ + id: `temp_${index}`, + name + })); + } + if (payload.medicalAdvice) { + this.medicalAdvice = payload.medicalAdvice; + } + + if (this.activeCategory === 1 && payload.chineseConfig) { + this.chineseConfig = { + ...this.chineseConfig, + ...payload.chineseConfig + }; + if (this.chineseConfig.processRuleId) { + await this.loadProcessRuleList(this.chineseConfig.processRuleId, 0); } - }); - - // 填充诊断和医嘱 - if (detailRes.prescription) { - if (detailRes.prescription.clinical_diagnose) { - this.diagnosisText = detailRes.prescription.clinical_diagnose; - const diagnosisNames = this.diagnosisText.split(',').filter(Boolean); - this.diagnoses = diagnosisNames.map((name, index) => ({ - id: `temp_${index}`, - name: name - })); - } - if (detailRes.prescription.doctor_order) { - this.medicalAdvice = detailRes.prescription.doctor_order; - } - - // 填充中药配置 - if (this.activeCategory === 1 && detailRes.prescription) { - this.chineseConfig = { - ...this.chineseConfig, - ruleType: detailRes.prescription.rule_type || 1, - dosage: detailRes.prescription.dosage || 7, - dayDosage: detailRes.prescription.day_dosage || 2, - packageMethodId: detailRes.prescription.package_method_id || null, - processRuleId: detailRes.prescription.process_rule_id || null, - childProcessRuleId: detailRes.prescription.child_process_rule_id || null, - processRuleNoteId: detailRes.prescription.process_rule_note_id || null - }; - - // 加载加工规则列表 - if (this.chineseConfig.processRuleId) { - await this.loadProcessRuleList(this.chineseConfig.processRuleId, 0); - } - if (this.chineseConfig.childProcessRuleId) { - await this.loadProcessRuleList(0, this.chineseConfig.childProcessRuleId); - } + if (this.chineseConfig.childProcessRuleId) { + await this.loadProcessRuleList(0, this.chineseConfig.childProcessRuleId); } } - - // 保存到本地存储 + this.saveToLocalStorage(); - this.$toast('常用方已填充'); } catch (error) { console.error('选择常用方失败:', error);