Fix Bug #589: AI修复
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="advice-form-container">
|
||||
<el-form :model="adviceData" label-width="80px" class="main-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="adviceData.orderType" class="order-type-select" @change="onTypeChange">
|
||||
<el-option label="西药" value="WESTERN_MED" />
|
||||
<el-option label="中成药" value="CHINESE_PATENT" />
|
||||
<el-option label="诊疗" value="TREATMENT" />
|
||||
<el-option label="手术" value="SURGERY" />
|
||||
<el-option label="文字医嘱" value="TEXT" />
|
||||
<el-option label="出院带药" value="DISCHARGE_MED" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="长期/临时">
|
||||
<el-radio-group v-model="adviceData.frequencyType" :disabled="isDischargeMed">
|
||||
<el-radio label="长期">长期</el-radio>
|
||||
<el-radio label="临时">临时</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<!-- Bug #589: 联动专属面板 -->
|
||||
<DischargeMedPanel
|
||||
v-if="adviceData.orderType === 'DISCHARGE_MED'"
|
||||
:visible="true"
|
||||
@confirm="onPanelConfirm"
|
||||
@cancel="onPanelCancel"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import DischargeMedPanel from './DischargeMedPanel.vue'
|
||||
|
||||
const adviceData = reactive({
|
||||
orderType: '',
|
||||
frequencyType: '临时'
|
||||
})
|
||||
|
||||
const isDischargeMed = ref(false)
|
||||
|
||||
const onTypeChange = (val) => {
|
||||
if (val === 'DISCHARGE_MED') {
|
||||
isDischargeMed.value = true
|
||||
adviceData.frequencyType = '临时' // 强制锁定临时
|
||||
} else {
|
||||
isDischargeMed.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onPanelConfirm = (panelData) => {
|
||||
// 将面板数据映射至主列表行
|
||||
console.log('同步至医嘱主列表:', panelData)
|
||||
// 实际业务:调用父组件方法更新表格数据,收起面板
|
||||
adviceData.orderType = '' // 触发收起
|
||||
isDischargeMed.value = false
|
||||
}
|
||||
|
||||
const onPanelCancel = () => {
|
||||
// 还原主列表行状态
|
||||
adviceData.orderType = ''
|
||||
isDischargeMed.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.advice-form-container { padding: 12px; border: 1px solid #ebeef5; border-radius: 4px; }
|
||||
.main-form { margin-bottom: 0; }
|
||||
</style>
|
||||
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<div class="discharge-med-panel" v-if="visible">
|
||||
<el-form :model="form" :rules="rules" ref="formRef" label-width="100px" class="med-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="药品检索" prop="drugId">
|
||||
<el-select v-model="form.drugId" filterable remote :remote-method="searchDrugs" placeholder="仅限西药/中成药口服/外用" @change="onDrugSelect" clearable>
|
||||
<el-option v-for="item in drugOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="单次用量" prop="singleDosage">
|
||||
<el-input v-model.number="form.singleDosage" placeholder="输入数值">
|
||||
<template #append>
|
||||
<el-select v-model="form.unit" style="width: 80px">
|
||||
<el-option label="片" value="片" />
|
||||
<el-option label="盒" value="盒" />
|
||||
<el-option label="支" value="支" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="给药途径" prop="route">
|
||||
<el-select v-model="form.route" placeholder="选择途径">
|
||||
<el-option label="口服" value="口服" />
|
||||
<el-option label="擦皮肤" value="擦皮肤" />
|
||||
<el-option label="外用" value="外用" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="用药频次" prop="frequency">
|
||||
<el-input v-model="form.frequency" placeholder="如:每日两次" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="用药天数" prop="medicationDays">
|
||||
<el-input v-model.number="form.medicationDays" placeholder="≤7或≤30" @input="calculateTotal" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="总量" prop="totalAmount">
|
||||
<el-input v-model.number="form.totalAmount" placeholder="自动计算可微调" @input="onTotalChange" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="16" class="info-row">
|
||||
<el-col :span="6">
|
||||
<span class="info-label">单价:</span> {{ form.price || '0.00' }}元
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<span class="info-label">库房:</span> {{ form.warehouse || '中心药房' }}
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<span class="info-label">批号库存:</span> {{ form.batchStock || '充足' }}
|
||||
</el-col>
|
||||
<el-col :span="6" class="total-price">
|
||||
总金额: {{ (form.totalAmount * (form.price || 0)).toFixed(2) }}元
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="16" class="action-row">
|
||||
<el-col :span="24" style="text-align: right;">
|
||||
<el-checkbox v-model="form.isChronicDisease" label="慢性病用药" @change="onChronicChange" />
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" @click="handleConfirm">确定</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, watch, nextTick } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
visible: { type: Boolean, default: false }
|
||||
})
|
||||
const emit = defineEmits(['confirm', 'cancel'])
|
||||
|
||||
const formRef = ref(null)
|
||||
const drugOptions = ref([])
|
||||
const form = reactive({
|
||||
drugId: null,
|
||||
singleDosage: null,
|
||||
unit: '片',
|
||||
route: '',
|
||||
frequency: '',
|
||||
medicationDays: null,
|
||||
totalAmount: null,
|
||||
price: 0,
|
||||
warehouse: '',
|
||||
batchStock: '',
|
||||
isChronicDisease: false
|
||||
})
|
||||
|
||||
const rules = {
|
||||
drugId: [{ required: true, message: '请选择药品', trigger: 'change' }],
|
||||
singleDosage: [{ required: true, message: '请输入单次用量', trigger: 'blur' }],
|
||||
route: [{ required: true, message: '请选择给药途径', trigger: 'change' }],
|
||||
medicationDays: [{ required: true, message: '请输入用药天数', trigger: 'blur' }],
|
||||
totalAmount: [{ required: true, message: '总量为必填项', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const searchDrugs = async (query) => {
|
||||
// 模拟检索接口,实际应调用后端API限制西药/中成药/非注射剂型
|
||||
if (!query) return
|
||||
drugOptions.value = [
|
||||
{ id: 101, name: '阿莫西林胶囊(西药)', price: 12.5, type: '西药' },
|
||||
{ id: 102, name: '复方丹参滴丸(中成药)', price: 28.0, type: '中成药' }
|
||||
].filter(d => d.name.includes(query))
|
||||
}
|
||||
|
||||
const onDrugSelect = (id) => {
|
||||
const drug = drugOptions.value.find(d => d.id === id)
|
||||
if (drug) {
|
||||
form.price = drug.price
|
||||
form.warehouse = '门诊西药房'
|
||||
form.batchStock = '202405A (库存: 500)'
|
||||
}
|
||||
}
|
||||
|
||||
const calculateTotal = () => {
|
||||
if (form.singleDosage && form.frequency && form.medicationDays) {
|
||||
// 频次解析:提取数字,如"每日两次"->2,"bid"->2,纯数字直接乘
|
||||
const freqNum = parseInt(form.frequency.replace(/\D/g, '')) || 1
|
||||
form.totalAmount = Math.ceil(form.singleDosage * freqNum * form.medicationDays)
|
||||
}
|
||||
}
|
||||
|
||||
const onTotalChange = () => {
|
||||
// 允许手动微调,不覆盖
|
||||
}
|
||||
|
||||
const onChronicChange = (val) => {
|
||||
if (form.medicationDays) {
|
||||
validateDays()
|
||||
}
|
||||
}
|
||||
|
||||
const validateDays = () => {
|
||||
const days = form.medicationDays
|
||||
if (form.isChronicDisease) {
|
||||
if (days > 30) {
|
||||
ElMessage.error('慢性病出院带药天数不得超过30天')
|
||||
form.medicationDays = 30
|
||||
}
|
||||
} else {
|
||||
if (days > 7) {
|
||||
ElMessage.error('非慢性病出院带药天数不得超过7天')
|
||||
form.medicationDays = 7
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
validateDays()
|
||||
emit('confirm', { ...form })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
formRef.value?.resetFields()
|
||||
Object.assign(form, { drugId: null, singleDosage: null, unit: '片', route: '', frequency: '', medicationDays: null, totalAmount: null, price: 0, warehouse: '', batchStock: '', isChronicDisease: false })
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
defineExpose({ handleCancel })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.discharge-med-panel {
|
||||
background: #f8f9fa;
|
||||
padding: 16px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.med-form .el-form-item { margin-bottom: 14px; }
|
||||
.info-row { margin-top: 8px; font-size: 13px; color: #606266; }
|
||||
.info-label { font-weight: 500; margin-right: 4px; }
|
||||
.total-price { font-weight: bold; color: #e6a23c; text-align: right; }
|
||||
.action-row { margin-top: 12px; border-top: 1px dashed #dcdfe6; padding-top: 12px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user