更新
This commit is contained in:
@@ -490,16 +490,17 @@ import { getDictData } from '@/api/app'
|
||||
import { getWeappConfig } from '@/api/channel/weapp'
|
||||
import feedback from '@/utils/feedback'
|
||||
import { hasPermission } from '@/utils/perm'
|
||||
import { Loading, Warning, List, CircleCheck, Clock, ArrowDown, RefreshRight, Picture, User, Document, Delete, CircleClose } from '@element-plus/icons-vue'
|
||||
import EditPopup from './edit.vue'
|
||||
import DetailPopup from './detail.vue'
|
||||
import AppointmentPopup from './appointment.vue'
|
||||
import AssistantWatchCallDialog from './components/AssistantWatchCallDialog.vue'
|
||||
import { Loading, Warning, List, CircleCheck, Clock, ArrowDown, Picture, User, Document, Delete, CircleClose } from '@element-plus/icons-vue'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { nextTick } from 'vue'
|
||||
import { defineAsyncComponent, onMounted, onUnmounted, watch } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const EditPopup = defineAsyncComponent(() => import('./edit.vue'))
|
||||
const DetailPopup = defineAsyncComponent(() => import('./detail.vue'))
|
||||
const AppointmentPopup = defineAsyncComponent(() => import('./appointment.vue'))
|
||||
const AssistantWatchCallDialog = defineAsyncComponent(() => import('./components/AssistantWatchCallDialog.vue'))
|
||||
|
||||
// 格式化时间戳为日期时间
|
||||
const formatDateTime = (timestamp: number | string) => {
|
||||
if (!timestamp) return '-'
|
||||
@@ -589,6 +590,26 @@ const fetchDateCounts = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 首屏优先主列表,错峰拉各日 tab 条数,减轻与 lists 并发争抢 */
|
||||
function scheduleDeferredDateCounts() {
|
||||
const run = () => fetchDateCounts()
|
||||
if (typeof requestIdleCallback === 'function') {
|
||||
requestIdleCallback(run, { timeout: 2500 })
|
||||
} else {
|
||||
setTimeout(run, 120)
|
||||
}
|
||||
}
|
||||
|
||||
const SILENT_LIST_POLL_MS = 10_000
|
||||
let silentListPollTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
/** 定时静默刷新:不打断表格 loading,标签页隐藏时不请求 */
|
||||
function silentRefreshListsAndDateCounts() {
|
||||
if (typeof document !== 'undefined' && document.hidden) return
|
||||
void getLists({ silent: true }).catch(() => {})
|
||||
void fetchDateCounts()
|
||||
}
|
||||
|
||||
// 日期快捷选项(computed 保证每日刷新)
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
const todayStr = computed(() => {
|
||||
@@ -709,8 +730,22 @@ const getRowClassName = ({ row }: { row: any }) => {
|
||||
const editRef = ref()
|
||||
const detailRef = ref()
|
||||
const appointmentRef = ref()
|
||||
/** 从路由带 id 进入时,诊单弹窗为异步组件,需在 ref 就绪后再 open */
|
||||
const pendingRouteDiagnosisId = ref<number | null>(null)
|
||||
const userStore = useUserStore()
|
||||
|
||||
watch(
|
||||
[editRef, pendingRouteDiagnosisId],
|
||||
() => {
|
||||
const id = pendingRouteDiagnosisId.value
|
||||
const opener = editRef.value as { open?: (mode: string, diagnosisId: number) => void } | undefined
|
||||
if (id == null || !opener?.open) return
|
||||
opener.open('edit', id)
|
||||
pendingRouteDiagnosisId.value = null
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
|
||||
const watchCallVisible = ref(false)
|
||||
const watchCallDiagnosisId = ref(0)
|
||||
|
||||
@@ -1241,16 +1276,27 @@ const handleDeleteRecord = async (id: number) => {
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
onMounted(async () => {
|
||||
await getDictOptions()
|
||||
onMounted(() => {
|
||||
// 默认展示当天挂号,突出重点
|
||||
formData.appointment_date = todayStr.value
|
||||
// 字典与列表并行,避免 await 字典阻塞首屏列表(LCP)
|
||||
getDictOptions()
|
||||
getLists()
|
||||
fetchDateCounts()
|
||||
// 从 URL 带 id 进入时自动打开诊单编辑(如:面诊结束通知点击跳转)
|
||||
const id = route.query.id
|
||||
if (id && editRef.value) {
|
||||
nextTick(() => editRef.value.open('edit', Number(id)))
|
||||
scheduleDeferredDateCounts()
|
||||
|
||||
silentListPollTimer = setInterval(silentRefreshListsAndDateCounts, SILENT_LIST_POLL_MS)
|
||||
|
||||
const raw = route.query.id
|
||||
if (raw != null && raw !== '') {
|
||||
const num = Number(raw)
|
||||
if (!Number.isNaN(num)) pendingRouteDiagnosisId.value = num
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (silentListPollTimer != null) {
|
||||
clearInterval(silentListPollTimer)
|
||||
silentListPollTimer = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user