更新
This commit is contained in:
@@ -129,12 +129,9 @@
|
||||
</el-button>
|
||||
<el-table :data="formData.herbs" class="mt-2" border>
|
||||
<el-table-column label="序号" type="index" width="60" />
|
||||
<el-table-column label="药材名称" min-width="150">
|
||||
<el-table-column label="药材名称" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<el-input
|
||||
v-model="row.name"
|
||||
placeholder="请输入药材名称"
|
||||
/>
|
||||
<MedicineNameSelect v-model="row.name" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剂量(克)" min-width="120">
|
||||
@@ -301,6 +298,7 @@
|
||||
import { prescriptionAdd } from '@/api/tcm'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import MedicineNameSelect from '@/components/medicine-name-select/index.vue'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
size="small"
|
||||
@click="handleChat(row)"
|
||||
>
|
||||
聊天
|
||||
通话
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['doctor.appointment/complete']"
|
||||
@@ -456,7 +456,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 编辑患者弹窗 -->
|
||||
<edit-popup ref="editRef" @success="getLists" />
|
||||
<edit-popup ref="editRef" @success="loadData" />
|
||||
|
||||
<!-- 中医处方单 -->
|
||||
<tcm-prescription ref="prescriptionRef" @success="onPrescriptionSuccess" />
|
||||
@@ -506,14 +506,16 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { watch } from 'vue'
|
||||
import { defineAsyncComponent, onMounted, watch } from 'vue'
|
||||
import { appointmentLists, cancelAppointment, completeAppointment, appointmentDetail } from '@/api/doctor'
|
||||
import { getCallSignature, generateMiniProgramQrcode, tcmDiagnosisDetail, prescriptionGetByAppointment } from '@/api/tcm'
|
||||
import { getDictData } from '@/api/app'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from '../diagnosis/edit.vue'
|
||||
import TcmPrescription from '@/components/tcm-prescription/index.vue'
|
||||
import ChatDialog from '@/components/chat-dialog/index.vue'
|
||||
|
||||
// 重组件异步加载,避免与列表同 chunk 阻塞路由进入与首帧渲染
|
||||
const EditPopup = defineAsyncComponent(() => import('../diagnosis/edit.vue'))
|
||||
const TcmPrescription = defineAsyncComponent(() => import('@/components/tcm-prescription/index.vue'))
|
||||
const ChatDialog = defineAsyncComponent(() => import('@/components/chat-dialog/index.vue'))
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import { getWeappConfig } from '@/api/channel/weapp'
|
||||
import {
|
||||
@@ -554,7 +556,9 @@ const formData = reactive({
|
||||
start_date: '',
|
||||
end_date: '',
|
||||
date_preset: 'today' as '' | 'today' | 'tomorrow' | 'day_after',
|
||||
diagnosis_confirmed: '' as '' | '0' | '1' // ''=全部 1=已确认 0=未确认
|
||||
diagnosis_confirmed: '' as '' | '0' | '1', // ''=全部 1=已确认 0=未确认
|
||||
/** 为 1 时后端 extend 返回各状态数量,避免额外 4 次列表请求 */
|
||||
include_status_counts: 0 as 0 | 1
|
||||
})
|
||||
|
||||
const activeTab = ref('1')
|
||||
@@ -568,7 +572,8 @@ const statusCount = ref<Record<number, number>>({
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||
fetchFun: appointmentLists,
|
||||
params: formData
|
||||
params: formData,
|
||||
firstLoading: true
|
||||
})
|
||||
|
||||
// 手动修改日期范围时清除快捷日期
|
||||
@@ -593,29 +598,6 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
// 获取各状态数量
|
||||
const getStatusCount = async () => {
|
||||
try {
|
||||
// 获取各状态的数量
|
||||
const promises = [1, 2, 3, 4].map(async (status) => {
|
||||
const res = await appointmentLists({
|
||||
...formData,
|
||||
status,
|
||||
page_no: 1,
|
||||
page_size: 1
|
||||
})
|
||||
return { status, count: res.count || 0 }
|
||||
})
|
||||
|
||||
const results = await Promise.all(promises)
|
||||
results.forEach(({ status, count }) => {
|
||||
statusCount.value[status] = count
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('获取状态数量失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 待接诊行高亮
|
||||
const getRowClassName = ({ row }: { row: any }) => {
|
||||
return row.status === 1 ? 'row-pending' : ''
|
||||
@@ -631,10 +613,24 @@ const handleTabChange = (tabName: string | number) => {
|
||||
resetPage()
|
||||
}
|
||||
|
||||
// 重写getLists,同时更新状态数量
|
||||
// 列表 + Tab 角标:一次请求(后端 extend.status_count),翻页等仅 getLists 不重复统计
|
||||
const loadData = async () => {
|
||||
await getLists()
|
||||
await getStatusCount()
|
||||
formData.include_status_counts = 1
|
||||
try {
|
||||
await getLists()
|
||||
const ext = pager.extend as { status_count?: Record<number | string, number> }
|
||||
const sc = ext?.status_count
|
||||
if (sc) {
|
||||
for (const k of [1, 2, 3, 4] as const) {
|
||||
const n = sc[k] ?? sc[String(k)]
|
||||
if (typeof n === 'number') {
|
||||
statusCount.value[k] = n
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
formData.include_status_counts = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 更多下拉命令
|
||||
@@ -730,17 +726,24 @@ const getPastHistoryLabels = (values: string[] | string) => {
|
||||
}
|
||||
|
||||
const loadDetailDictOptions = async () => {
|
||||
const [dt, st, db, ph] = await Promise.all([
|
||||
getDictData({ type: 'diagnosis_type' }),
|
||||
getDictData({ type: 'syndrome_type' }),
|
||||
getDictData({ type: 'diabetes_type' }),
|
||||
getDictData({ type: 'past_history' })
|
||||
])
|
||||
diagnosisTypeOptions.value = dt?.diagnosis_type || []
|
||||
syndromeTypeOptions.value = st?.syndrome_type || []
|
||||
diabetesTypeOptions.value = db?.diabetes_type || []
|
||||
pastHistoryOptions.value = ph?.past_history || []
|
||||
}
|
||||
|
||||
const detailDictReady = ref(false)
|
||||
const ensureDetailDictOptions = async () => {
|
||||
if (detailDictReady.value) return
|
||||
try {
|
||||
const [dt, st, db, ph] = await Promise.all([
|
||||
getDictData({ type: 'diagnosis_type' }),
|
||||
getDictData({ type: 'syndrome_type' }),
|
||||
getDictData({ type: 'diabetes_type' }),
|
||||
getDictData({ type: 'past_history' })
|
||||
])
|
||||
diagnosisTypeOptions.value = dt?.diagnosis_type || []
|
||||
syndromeTypeOptions.value = st?.syndrome_type || []
|
||||
diabetesTypeOptions.value = db?.diabetes_type || []
|
||||
pastHistoryOptions.value = ph?.past_history || []
|
||||
await loadDetailDictOptions()
|
||||
detailDictReady.value = true
|
||||
} catch (e) {
|
||||
console.error('加载字典失败:', e)
|
||||
}
|
||||
@@ -785,7 +788,8 @@ const handleAction = (command: string, row: any) => {
|
||||
// 查看详情(含患者诊单完整信息)
|
||||
const handleDetail = async (row: any) => {
|
||||
try {
|
||||
const res = await appointmentDetail({ id: row.id })
|
||||
const detailBundle = await Promise.all([ensureDetailDictOptions(), appointmentDetail({ id: row.id })])
|
||||
const res = detailBundle[1]
|
||||
detailData.value = res
|
||||
// 有 patient_id(即诊单ID)时,拉取患者完整信息
|
||||
if (res.patient_id) {
|
||||
@@ -966,8 +970,9 @@ formData.start_date = `${_today.getFullYear()}-${_pad(_today.getMonth() + 1)}-${
|
||||
formData.end_date = formData.start_date
|
||||
formData.status = 1
|
||||
|
||||
loadData()
|
||||
loadDetailDictOptions()
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user