更新
This commit is contained in:
@@ -371,6 +371,7 @@ type JobInput = { diagnosis_id: number; days: Days; scenario: Scenario; assistan
|
||||
export type StaffScope = { assistant_id: number; days: Days }
|
||||
export const assistantAlerts = (
|
||||
params: Partial<Paging> & {
|
||||
assistant_id?: number
|
||||
keyword?: string
|
||||
status?: AlertStatus | 'all'
|
||||
severity?: AlertSeverity | 'all'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,647 @@
|
||||
<template>
|
||||
<section class="revisit-follow-panel" aria-label="复诊状态跟踪">
|
||||
<div class="revisit-toolbar">
|
||||
<div class="filter-group" role="group" aria-label="复诊状态筛选">
|
||||
<button
|
||||
v-for="item in stateFilters"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
:aria-pressed="stateFilter === item.value"
|
||||
:class="{ active: stateFilter === item.value }"
|
||||
@click="setStateFilter(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
<form class="search-form" @submit.prevent="doSearch">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
placeholder="搜索患者姓名"
|
||||
clearable
|
||||
size="default"
|
||||
@clear="doSearch"
|
||||
/>
|
||||
<el-button native-type="submit">查询</el-button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="error"
|
||||
:title="error"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-3"
|
||||
/>
|
||||
|
||||
<el-table
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
size="default"
|
||||
row-key="id"
|
||||
:row-class-name="rowClassName"
|
||||
empty-text="当前范围暂无复诊跟踪记录"
|
||||
>
|
||||
<el-table-column label="患者" min-width="120" fixed="left">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-main">{{ row.patient_name || '—' }}</div>
|
||||
<div class="cell-sub">诊单 #{{ row.diagnosis_id }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="assistantId <= 0" label="医助 / 部门" min-width="115">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-main">{{ assistantText(row) }}</div>
|
||||
<div class="cell-sub">{{ row.dept_name || '—' }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="诊次 / 开药" width="120">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-main">
|
||||
{{ slotText(row) }}
|
||||
<span v-if="Number(row.medication_days) > 0" class="days-badge">
|
||||
{{ row.medication_days }}天
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="Number(row.next_slot) > 0" class="cell-sub">
|
||||
待复诊第 {{ row.next_slot }} 诊
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="预计复诊" width="110">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-main">{{ row.due_date || '—' }}</div>
|
||||
<div v-if="row.anchor_date" class="cell-sub">
|
||||
起算 {{ formatRevisitMonthDay(row.anchor_date) }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="复诊状态" min-width="155">
|
||||
<template #default="{ row }">
|
||||
<div class="status-cell">
|
||||
<el-tag
|
||||
:type="revisitStateTagType(row.state)"
|
||||
:effect="revisitStateTagEffect(row.state)"
|
||||
size="small"
|
||||
:class="revisitStateChipClass(dueOf(row))"
|
||||
>
|
||||
{{ chipText(row) }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="Number(row.closed_state) === 4"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>
|
||||
人工关闭
|
||||
</el-tag>
|
||||
</div>
|
||||
<div v-if="overdueHint(row)" :class="['cell-sub', overdueHint(row)?.cls]">
|
||||
{{ overdueHint(row)?.text }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="跟进情况" min-width="135">
|
||||
<template #default="{ row }">
|
||||
<div class="follow-meta">
|
||||
<span :class="['snooze-num', snoozeClass(row)]">
|
||||
延迟 {{ Number(row.snooze_count ?? 0) }} 次
|
||||
</span>
|
||||
<span v-if="Number(row.escalation_level) > 0" class="level-tag">
|
||||
L{{ row.escalation_level }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="cell-sub">
|
||||
已联系 {{ Number(row.contact_count ?? 0) }} 次
|
||||
<template v-if="row.promised_date"> · 承诺 {{ formatRevisitMonthDay(row.promised_date) }}</template>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="210" fixed="right" align="right">
|
||||
<template #default="{ row }">
|
||||
<div class="action-links">
|
||||
<el-button
|
||||
v-if="canFollow(row)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openContact(row)"
|
||||
>
|
||||
已联系
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="isDueRow(row) && Number(row.closed_state) === 0"
|
||||
link
|
||||
type="warning"
|
||||
size="small"
|
||||
:loading="snoozingId === row.id"
|
||||
@click="doSnooze(row)"
|
||||
>
|
||||
延迟
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canFollow(row)"
|
||||
link
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="openClose(row)"
|
||||
>
|
||||
关闭
|
||||
</el-button>
|
||||
<el-button link type="info" size="small" @click="openLogs(row)">流水</el-button>
|
||||
<el-button link type="primary" size="small" @click="goDiagnosis(row)">诊单</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<footer class="revisit-footer">
|
||||
<span class="muted">
|
||||
按预计复诊与超期状态排序,到期未挂号 / 过号未面诊标红提示。
|
||||
</span>
|
||||
<el-pagination
|
||||
v-if="total > 0"
|
||||
v-model:current-page="pageNo"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
layout="total, prev, pager, next"
|
||||
@current-change="load"
|
||||
/>
|
||||
</footer>
|
||||
|
||||
<!-- 已联系弹窗 -->
|
||||
<el-dialog v-model="contactVisible" title="登记已联系" width="420px" destroy-on-close>
|
||||
<el-form label-width="88px">
|
||||
<el-form-item label="患者">
|
||||
<span>{{ activeRow?.patient_name || '—' }}(诊单 #{{ activeRow?.diagnosis_id }})</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="承诺复诊日" required>
|
||||
<el-date-picker
|
||||
v-model="contactForm.promised_date"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择患者承诺复诊日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input
|
||||
v-model="contactForm.remark"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
maxlength="200"
|
||||
placeholder="可选,记录沟通要点"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="contactVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="submitContact">确认登记</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 人工关闭弹窗 -->
|
||||
<el-dialog v-model="closeVisible" title="人工关闭复诊跟踪" width="420px" destroy-on-close>
|
||||
<el-form label-width="88px">
|
||||
<el-form-item label="患者">
|
||||
<span>{{ activeRow?.patient_name || '—' }}(诊单 #{{ activeRow?.diagnosis_id }})</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="关闭原因" required>
|
||||
<el-radio-group v-model="closeForm.reason">
|
||||
<el-radio value="lost">患者流失</el-radio>
|
||||
<el-radio value="other">其他原因</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="说明" required>
|
||||
<el-input
|
||||
v-model="closeForm.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
placeholder="请填写关闭原因说明(必填)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="closeVisible = false">取消</el-button>
|
||||
<el-button type="danger" :loading="submitting" @click="submitClose">确认关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 流水抽屉 -->
|
||||
<el-drawer v-model="logVisible" :title="logTitle" direction="rtl" size="500px" destroy-on-close>
|
||||
<div v-loading="logLoading" class="log-drawer-body">
|
||||
<el-timeline v-if="logRows.length">
|
||||
<el-timeline-item
|
||||
v-for="item in logRows"
|
||||
:key="item.id"
|
||||
:timestamp="item.create_time_text"
|
||||
placement="top"
|
||||
>
|
||||
<div class="log-event-title">
|
||||
{{ item.event_text }} · {{ item.operator_name || '系统' }}
|
||||
</div>
|
||||
<div class="cell-sub">
|
||||
延迟 {{ Number(item.snooze_count_after ?? 0) }} 次 · 等级 L{{ Number(item.level_after ?? 0) }}
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-else-if="!logLoading" description="暂无流水记录" :image-size="72" />
|
||||
</div>
|
||||
</el-drawer>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
revisitDueClose,
|
||||
revisitDueContact,
|
||||
revisitDueLists,
|
||||
revisitDueLogs,
|
||||
revisitDueSnooze,
|
||||
type RevisitDueListRow,
|
||||
type RevisitDueLogRow
|
||||
} from '@/api/revisitDue'
|
||||
import {
|
||||
formatRevisitMonthDay,
|
||||
normalizeRevisitDue,
|
||||
revisitRowClassName,
|
||||
revisitStateChipClass,
|
||||
revisitStateChipText,
|
||||
revisitStateTagEffect,
|
||||
revisitStateTagType,
|
||||
type RevisitDue
|
||||
} from '@/utils/revisitDue'
|
||||
import { errorText, isCancelled } from '../shared'
|
||||
|
||||
const props = defineProps<{
|
||||
assistantId: number
|
||||
refreshKey: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
summary: [payload: { total: number }]
|
||||
updated: []
|
||||
}>()
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const stateFilters = [
|
||||
{ value: '', label: '全部状态' },
|
||||
{ value: 'due', label: '超期 / 过号' },
|
||||
{ value: 'warning', label: '即将到期' },
|
||||
{ value: 'contacted', label: '已联系' },
|
||||
{ value: 'booked', label: '已挂号' },
|
||||
{ value: 'visited', label: '已面诊' },
|
||||
{ value: 'closed', label: '人工关闭' }
|
||||
]
|
||||
|
||||
const stateFilter = ref('')
|
||||
const keyword = ref('')
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 15
|
||||
const total = ref(0)
|
||||
const rows = ref<RevisitDueListRow[]>([])
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const snoozingId = ref(0)
|
||||
|
||||
const activeRow = ref<RevisitDueListRow | null>(null)
|
||||
const submitting = ref(false)
|
||||
const contactVisible = ref(false)
|
||||
const contactForm = reactive({ promised_date: '', remark: '' })
|
||||
const closeVisible = ref(false)
|
||||
const closeForm = reactive<{ reason: 'lost' | 'other'; remark: string }>({
|
||||
reason: 'lost',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const logVisible = ref(false)
|
||||
const logLoading = ref(false)
|
||||
const logRow = ref<RevisitDueListRow | null>(null)
|
||||
const logRows = ref<RevisitDueLogRow[]>([])
|
||||
const logTitle = computed(() =>
|
||||
logRow.value ? `${logRow.value.patient_name || '患者'} · 复诊跟踪流水` : '复诊跟踪流水'
|
||||
)
|
||||
|
||||
let revision = 0
|
||||
|
||||
async function load() {
|
||||
const token = ++revision
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res: any = await revisitDueLists({
|
||||
assistant_id: props.assistantId > 0 ? props.assistantId : '',
|
||||
state: stateFilter.value,
|
||||
keyword: keyword.value.trim(),
|
||||
page_no: pageNo.value,
|
||||
page_size: pageSize
|
||||
})
|
||||
if (token !== revision) return
|
||||
const list = Array.isArray(res?.lists) ? res.lists : []
|
||||
rows.value = list
|
||||
total.value = Number(res?.count ?? list.length ?? 0)
|
||||
emit('summary', { total: total.value })
|
||||
} catch (cause) {
|
||||
if (token !== revision || isCancelled(cause)) return
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
error.value = errorText(cause)
|
||||
} finally {
|
||||
if (token === revision) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function setStateFilter(value: string) {
|
||||
if (stateFilter.value === value) return
|
||||
stateFilter.value = value
|
||||
pageNo.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
pageNo.value = 1
|
||||
void load()
|
||||
}
|
||||
|
||||
const dueOf = (row: RevisitDueListRow): RevisitDue | null => normalizeRevisitDue(row)
|
||||
const rowClassName = ({ row }: { row: RevisitDueListRow }) => revisitRowClassName(dueOf(row))
|
||||
const assistantText = (row: RevisitDueListRow) =>
|
||||
row.assistant_name || (Number(row.assistant_id) > 0 ? `#${row.assistant_id}` : '—')
|
||||
const slotText = (row: RevisitDueListRow) => {
|
||||
const slot = Number(row.current_slot ?? 0)
|
||||
return slot > 0 ? `第 ${slot} 诊` : '未成交'
|
||||
}
|
||||
const chipText = (row: RevisitDueListRow) =>
|
||||
revisitStateChipText(dueOf(row)) || row.state_text || '—'
|
||||
const isDueRow = (row: RevisitDueListRow) => row.state === 'overdue' || row.state === 'missed'
|
||||
const canFollow = (row: RevisitDueListRow) =>
|
||||
Number(row.closed_state ?? 0) === 0 && ['overdue', 'missed', 'warning', 'contacted'].includes(row.state)
|
||||
|
||||
function overdueHint(row: RevisitDueListRow): { text: string; cls: string } | null {
|
||||
const od = row.overdue_days
|
||||
const dl = row.days_left
|
||||
if (isDueRow(row) && od !== null && od >= 0) {
|
||||
return {
|
||||
text: od === 0 ? '今日到期' : `已超期 ${od} 天`,
|
||||
cls: Number(row.severe) === 1 ? 'text-severe' : 'text-overdue'
|
||||
}
|
||||
}
|
||||
if (dl !== null && dl >= 0) {
|
||||
return { text: `距复诊还剩 ${dl} 天`, cls: '' }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function snoozeClass(row: RevisitDueListRow) {
|
||||
const level = Number(row.escalation_level ?? 0)
|
||||
if (level >= 3) return 'text-severe'
|
||||
if (level >= 1) return 'text-overdue'
|
||||
return ''
|
||||
}
|
||||
|
||||
function openContact(row: RevisitDueListRow) {
|
||||
activeRow.value = row
|
||||
contactForm.promised_date = row.promised_date || ''
|
||||
contactForm.remark = ''
|
||||
contactVisible.value = true
|
||||
}
|
||||
|
||||
async function submitContact() {
|
||||
if (!activeRow.value) return
|
||||
if (!contactForm.promised_date) {
|
||||
ElMessage.warning('请选择患者承诺复诊日期')
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await revisitDueContact({
|
||||
id: activeRow.value.id,
|
||||
promised_date: contactForm.promised_date,
|
||||
remark: contactForm.remark.trim()
|
||||
})
|
||||
contactVisible.value = false
|
||||
emit('updated')
|
||||
await load()
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doSnooze(row: RevisitDueListRow) {
|
||||
snoozingId.value = row.id
|
||||
try {
|
||||
await revisitDueSnooze({ id: row.id })
|
||||
emit('updated')
|
||||
await load()
|
||||
} finally {
|
||||
snoozingId.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function openClose(row: RevisitDueListRow) {
|
||||
activeRow.value = row
|
||||
closeForm.reason = 'lost'
|
||||
closeForm.remark = ''
|
||||
closeVisible.value = true
|
||||
}
|
||||
|
||||
async function submitClose() {
|
||||
if (!activeRow.value) return
|
||||
if (!closeForm.remark.trim()) {
|
||||
ElMessage.warning('请填写关闭原因说明')
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await revisitDueClose({
|
||||
id: activeRow.value.id,
|
||||
reason: closeForm.reason,
|
||||
remark: closeForm.remark.trim()
|
||||
})
|
||||
closeVisible.value = false
|
||||
emit('updated')
|
||||
await load()
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openLogs(row: RevisitDueListRow) {
|
||||
logRow.value = row
|
||||
logVisible.value = true
|
||||
logLoading.value = true
|
||||
logRows.value = []
|
||||
try {
|
||||
const res: any = await revisitDueLogs({ due_id: Number(row.id) })
|
||||
const list = Array.isArray(res) ? res : (res?.list ?? res?.lists ?? [])
|
||||
logRows.value = Array.isArray(list) ? list : []
|
||||
} finally {
|
||||
logLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function goDiagnosis(row: RevisitDueListRow) {
|
||||
const id = Number(row.diagnosis_id ?? 0)
|
||||
if (id > 0) router.push({ path: '/tcm/diagnosis', query: { id: String(id) } })
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.assistantId, props.refreshKey],
|
||||
() => {
|
||||
pageNo.value = 1
|
||||
void load()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.revisit-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.filter-group button {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 4px;
|
||||
padding: 6px 12px;
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-group button:hover {
|
||||
border-color: var(--el-color-primary-light-5);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.filter-group button.active {
|
||||
background: var(--el-color-primary-light-9);
|
||||
border-color: var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.cell-main {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--el-text-color-primary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.cell-sub {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.4;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.days-badge {
|
||||
display: inline-block;
|
||||
margin-left: 4px;
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.status-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.follow-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.snooze-num {
|
||||
font-weight: 500;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.level-tag {
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
background: var(--el-color-danger-light-9);
|
||||
color: var(--el-color-danger);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.text-overdue {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.text-severe {
|
||||
color: #b91c1c;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.action-links {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.revisit-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.muted {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.log-drawer-body {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.log-event-title {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,335 @@
|
||||
<template>
|
||||
<section class="staff-chat-panel" aria-label="站内沟通会话">
|
||||
<div class="chat-toolbar">
|
||||
<span class="freshness">近 {{ days }} 天患者沟通会话(站内聊天 / 通话 / 服务记录)</span>
|
||||
<div class="days-switch">
|
||||
<button
|
||||
v-for="d in ([7, 30, 90] as const)"
|
||||
:key="d"
|
||||
type="button"
|
||||
:class="{ active: days === d }"
|
||||
@click="changeDays(d)"
|
||||
>
|
||||
{{ d }} 天
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" show-icon class="mb-3" />
|
||||
<el-skeleton v-if="loading && !cases.length" :rows="5" animated />
|
||||
<el-empty
|
||||
v-else-if="!cases.length"
|
||||
:image-size="72"
|
||||
:description="`近 ${days} 天暂无站内聊天或沟通记录`"
|
||||
/>
|
||||
|
||||
<div v-else class="split">
|
||||
<ul class="conversations">
|
||||
<li v-for="item in cases" :key="item.diagnosis_id">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: selectedDiagnosisId === item.diagnosis_id }"
|
||||
@click="openCase(item)"
|
||||
>
|
||||
<div class="conv-head">
|
||||
<strong>{{ item.patient_name || '未命名患者' }}</strong>
|
||||
<small>#{{ item.diagnosis_id }}</small>
|
||||
</div>
|
||||
<small>
|
||||
聊天 {{ item.im_messages ?? 0 }} 条 · 记录 {{ item.manual_records }} 条
|
||||
</small>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="messages-wrap">
|
||||
<el-skeleton v-if="contextLoading" :rows="4" animated />
|
||||
<ol v-else-if="sources.length" class="messages">
|
||||
<li
|
||||
v-for="src in sources"
|
||||
:key="src.id"
|
||||
:class="src.speaker === 'patient' ? 'inbound' : 'outbound'"
|
||||
>
|
||||
<span class="msg-meta">
|
||||
{{ speakerLabel(src.speaker) }} · {{ channelLabel(src.channel) }} ·
|
||||
{{ shanghaiTime(src.occurred_at) }}
|
||||
</span>
|
||||
<p>{{ src.text }}</p>
|
||||
</li>
|
||||
</ol>
|
||||
<el-empty
|
||||
v-else-if="selectedDiagnosisId"
|
||||
:image-size="64"
|
||||
description="该患者近阶段暂无文字或转写明细"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
assistantContext,
|
||||
assistantStaffCases,
|
||||
type Days,
|
||||
type Source,
|
||||
type StaffCase
|
||||
} from '@/api/assistantService'
|
||||
import { errorText, isCancelled, shanghaiTime } from '../shared'
|
||||
|
||||
const props = defineProps<{
|
||||
assistantId: number
|
||||
refreshKey: number
|
||||
}>()
|
||||
|
||||
const days = ref<Days>(30)
|
||||
const cases = ref<StaffCase[]>([])
|
||||
const sources = ref<Source[]>([])
|
||||
const selectedDiagnosisId = ref(0)
|
||||
const loading = ref(false)
|
||||
const contextLoading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
let listRevision = 0
|
||||
let ctxRevision = 0
|
||||
|
||||
function speakerLabel(speaker: Source['speaker']) {
|
||||
if (speaker === 'patient') return '患者'
|
||||
if (speaker === 'service') return '员工'
|
||||
return '系统'
|
||||
}
|
||||
|
||||
function channelLabel(channel: string) {
|
||||
if (channel === 'im') return '站内聊天'
|
||||
if (channel === 'call') return '通话转写'
|
||||
if (channel === 'wecom') return '企微'
|
||||
if (channel === 'manual') return '服务记录'
|
||||
return channel || '记录'
|
||||
}
|
||||
|
||||
async function loadCases() {
|
||||
if (props.assistantId <= 0) {
|
||||
cases.value = []
|
||||
sources.value = []
|
||||
selectedDiagnosisId.value = 0
|
||||
return
|
||||
}
|
||||
const token = ++listRevision
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await assistantStaffCases({
|
||||
assistant_id: props.assistantId,
|
||||
days: days.value,
|
||||
page_no: 1,
|
||||
page_size: 30
|
||||
})
|
||||
if (token !== listRevision) return
|
||||
const sorted = [...(res.lists || [])].sort(
|
||||
(a, b) =>
|
||||
(b.im_messages ?? 0) + b.manual_records - ((a.im_messages ?? 0) + a.manual_records)
|
||||
)
|
||||
cases.value = sorted
|
||||
if (sorted.length) {
|
||||
const keep = sorted.find((c) => c.diagnosis_id === selectedDiagnosisId.value)
|
||||
await openCase(keep || sorted[0])
|
||||
} else {
|
||||
selectedDiagnosisId.value = 0
|
||||
sources.value = []
|
||||
}
|
||||
} catch (cause) {
|
||||
if (token !== listRevision || isCancelled(cause)) return
|
||||
cases.value = []
|
||||
sources.value = []
|
||||
error.value = errorText(cause)
|
||||
} finally {
|
||||
if (token === listRevision) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openCase(item: StaffCase) {
|
||||
selectedDiagnosisId.value = item.diagnosis_id
|
||||
const token = ++ctxRevision
|
||||
contextLoading.value = true
|
||||
try {
|
||||
const ctx = await assistantContext({
|
||||
diagnosis_id: item.diagnosis_id,
|
||||
days: days.value,
|
||||
assistant_id: props.assistantId
|
||||
})
|
||||
if (token !== ctxRevision) return
|
||||
sources.value = ctx.sources || []
|
||||
} catch (cause) {
|
||||
if (token !== ctxRevision || isCancelled(cause)) return
|
||||
sources.value = []
|
||||
} finally {
|
||||
if (token === ctxRevision) contextLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function changeDays(d: Days) {
|
||||
if (days.value === d) return
|
||||
days.value = d
|
||||
void loadCases()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.assistantId, props.refreshKey],
|
||||
() => {
|
||||
selectedDiagnosisId.value = 0
|
||||
void loadCases()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chat-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.freshness {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.days-switch {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.days-switch button {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 4px;
|
||||
padding: 4px 10px;
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.days-switch button.active {
|
||||
background: var(--el-color-primary-light-9);
|
||||
border-color: var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: 240px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
min-height: 360px;
|
||||
}
|
||||
|
||||
.conversations {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 6px;
|
||||
max-height: 480px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.conversations li + li {
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.conversations button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.conversations button:hover {
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.conversations button.active {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.conv-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.conversations strong {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.conversations small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.messages-wrap {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
max-height: 480px;
|
||||
overflow-y: auto;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.messages {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.messages li {
|
||||
max-width: 82%;
|
||||
padding: 8px 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.messages li.inbound {
|
||||
align-self: flex-start;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.messages li.outbound {
|
||||
align-self: flex-end;
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.msg-meta {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.messages p {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.split {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -3,11 +3,11 @@
|
||||
<header class="page-heading">
|
||||
<div>
|
||||
<p class="eyebrow">服务管理</p>
|
||||
<h1>{{ surface === 'alerts' ? '行为预警' : '今日维护' }}</h1>
|
||||
<h1>{{ surface === 'alerts' ? '预警中心' : '今日维护' }}</h1>
|
||||
<p class="page-description">
|
||||
{{
|
||||
surface === 'alerts'
|
||||
? '员工在聊天、通话转写和已绑定患者的企微里说出的命中内容会列在这里。患者说的话、没有转写的通话、没绑定患者的企微不记为已检查。'
|
||||
? '左侧按医助账户筛选,右侧查看复诊状态跟踪、行为预警与企微会话。'
|
||||
: '按医助查看今天应维护的患者。未发现文字联系,仍可能已通过电话或其他渠道联系。'
|
||||
}}
|
||||
</p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ final class AssistantServiceValidate
|
||||
'staffOverview' => ['assistant_id', 'days'], 'staffCases' => ['assistant_id', 'days', 'keyword', 'page_no', 'page_size'],
|
||||
'staffIssues' => ['assistant_id', 'days', 'page_no', 'page_size'],
|
||||
'staffDailyContacts' => ['assistant_id', 'status', 'page_no', 'page_size'],
|
||||
'alerts' => ['keyword', 'status', 'severity', 'role', 'page_no', 'page_size'],
|
||||
'alerts' => ['assistant_id', 'keyword', 'status', 'severity', 'role', 'page_no', 'page_size'],
|
||||
'wecomDirectory' => [],
|
||||
'wecomChats' => ['assistant_id', 'account'],
|
||||
'wecomMessages' => ['assistant_id', 'account', 'conversation_id', 'cursor'],
|
||||
|
||||
@@ -164,6 +164,21 @@ final class AssistantServiceAlert
|
||||
'scan' => self::scanStatus(), 'coverage' => self::coverage(), 'empty_reason' => ''];
|
||||
if (!$page['schema_ready']) { return $page; }
|
||||
$base = self::scoped($adminId, $actor);
|
||||
if (!empty($p['assistant_id'])) {
|
||||
$aid = (int) $p['assistant_id'];
|
||||
$patientSql = Db::name('tcm_diagnosis')
|
||||
->alias('d')
|
||||
->whereNull('d.delete_time')
|
||||
->where('d.status', 1)
|
||||
->where('d.assistant_id', $aid)
|
||||
->distinct(true)
|
||||
->field('d.patient_id')
|
||||
->buildSql();
|
||||
$base->where(static function ($nested) use ($aid, $patientSql): void {
|
||||
$nested->where('a.staff_admin_id', $aid)
|
||||
->whereOrRaw('a.patient_id IN ' . $patientSql);
|
||||
});
|
||||
}
|
||||
$page['summary'] = [
|
||||
'open' => self::count(clone $base, ['a.status' => 'open']),
|
||||
'high_open' => self::count(clone $base, ['a.status' => 'open', 'a.severity' => 'high']),
|
||||
|
||||
Reference in New Issue
Block a user