feat(admin): 联动用户、预约、排班和部门统计的只读预览
This commit is contained in:
@@ -1,20 +1,39 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-page-header content="用户详情" @back="$router.back()" />
|
||||
<div class="consumer-profile">
|
||||
<header v-if="isArt" class="profile-heading">
|
||||
<div>
|
||||
<h1>用户详情</h1>
|
||||
<p>查看注册资料、账户余额与最近登录时间。</p>
|
||||
</div>
|
||||
<el-button @click="goBack">{{ isPreview ? '返回用户列表' : '返回' }}</el-button>
|
||||
</header>
|
||||
<el-card v-else class="!border-none" shadow="never">
|
||||
<el-page-header content="用户详情" @back="goBack" />
|
||||
</el-card>
|
||||
<el-card class="mt-4 !border-none" header="基本资料" shadow="never">
|
||||
<el-card v-if="loadFailed" class="!border-none" shadow="never">
|
||||
<el-empty description="未能读取该用户的资料">
|
||||
<el-button @click="goBack">{{ isPreview ? '返回用户列表' : '返回' }}</el-button>
|
||||
</el-empty>
|
||||
</el-card>
|
||||
<el-card v-else v-loading="loading" class="mt-4 !border-none profile-card" header="基本资料" shadow="never">
|
||||
<el-form ref="formRef" class="ls-form" :model="formData" label-width="120px">
|
||||
<div class="bg-page flex py-5 mb-10 items-center">
|
||||
<div class="basis-40 flex flex-col justify-center items-center">
|
||||
<div class="mb-2 text-tx-regular">用户头像</div>
|
||||
<el-avatar :src="formData.avatar" :size="58" />
|
||||
<div class="bg-page flex py-5 mb-10 items-center profile-summary">
|
||||
<div class="basis-40 flex flex-col justify-center items-center profile-identity">
|
||||
<div v-if="!isArt" class="mb-2 text-tx-regular">用户头像</div>
|
||||
<el-avatar :src="formData.avatar" :size="58">
|
||||
<template v-if="isArt">{{ formData.nickname?.slice(0, 1) || '用' }}</template>
|
||||
</el-avatar>
|
||||
<div v-if="isArt">
|
||||
<strong>{{ formData.nickname || '—' }}</strong>
|
||||
<small>用户编号:{{ formData.sn || '—' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="basis-40 flex flex-col justify-center items-center">
|
||||
<div class="basis-40 flex flex-col justify-center items-center profile-balance">
|
||||
<div class="text-tx-regular">账户余额</div>
|
||||
<div class="mt-2 flex items-center">
|
||||
¥{{ formData.user_money }}
|
||||
<el-button
|
||||
v-if="!isPreview"
|
||||
v-perms="['user.user/adjustMoney']"
|
||||
type="primary"
|
||||
link
|
||||
@@ -25,82 +44,98 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-form-item label="用户昵称:">
|
||||
{{ formData.nickname }}
|
||||
</el-form-item>
|
||||
<el-form-item label="账号:">
|
||||
{{ formData.account }}
|
||||
<popover-input
|
||||
class="ml-[10px]"
|
||||
@confirm="handleEdit($event, 'account')"
|
||||
:limit="32"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="真实姓名:">
|
||||
{{ formData.real_name || '-' }}
|
||||
<popover-input
|
||||
class="ml-[10px]"
|
||||
@confirm="handleEdit($event, 'real_name')"
|
||||
:limit="32"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别:">
|
||||
{{ formData.sex }}
|
||||
<popover-input
|
||||
class="ml-[10px]"
|
||||
type="select"
|
||||
:options="[
|
||||
{
|
||||
label: '未知',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: '男',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 2
|
||||
}
|
||||
]"
|
||||
@confirm="handleEdit($event, 'sex')"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话:">
|
||||
{{ formData.mobile || '-' }}
|
||||
<popover-input
|
||||
class="ml-[10px]"
|
||||
type="number"
|
||||
@confirm="handleEdit($event, 'mobile')"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="注册来源:"> {{ formData.channel }} </el-form-item>
|
||||
<el-form-item label="注册时间:"> {{ formData.create_time }} </el-form-item>
|
||||
<el-form-item label="最近登录时间:"> {{ formData.login_time }} </el-form-item>
|
||||
<div class="profile-fields">
|
||||
<el-form-item label="用户昵称:">
|
||||
{{ formData.nickname }}
|
||||
</el-form-item>
|
||||
<el-form-item label="账号:">
|
||||
{{ formData.account }}
|
||||
<popover-input
|
||||
v-if="!isPreview"
|
||||
class="ml-[10px]"
|
||||
@confirm="handleEdit($event, 'account')"
|
||||
:limit="32"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="真实姓名:">
|
||||
{{ formData.real_name || '-' }}
|
||||
<popover-input
|
||||
v-if="!isPreview"
|
||||
class="ml-[10px]"
|
||||
@confirm="handleEdit($event, 'real_name')"
|
||||
:limit="32"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别:">
|
||||
{{ formData.sex }}
|
||||
<popover-input
|
||||
v-if="!isPreview"
|
||||
class="ml-[10px]"
|
||||
type="select"
|
||||
:options="[
|
||||
{
|
||||
label: '未知',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: '男',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: 2
|
||||
}
|
||||
]"
|
||||
@confirm="handleEdit($event, 'sex')"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话:">
|
||||
{{ formData.mobile || '-' }}
|
||||
<popover-input
|
||||
v-if="!isPreview"
|
||||
class="ml-[10px]"
|
||||
type="number"
|
||||
@confirm="handleEdit($event, 'mobile')"
|
||||
v-perms="['user.user/edit']"
|
||||
>
|
||||
<el-button type="primary" link>
|
||||
<icon name="el-icon-EditPen" />
|
||||
</el-button>
|
||||
</popover-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="注册来源:"> {{ formData.channel }} </el-form-item>
|
||||
<el-form-item label="注册时间:"> {{ formData.create_time }} </el-form-item>
|
||||
<el-form-item label="最近登录时间:"> {{ formData.login_time || '—' }} </el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-if="isPreview && !loadFailed && linkedPatient.id" class="mt-4 !border-none profile-linked" header="关联演示档案" shadow="never">
|
||||
<div class="profile-linked-row">
|
||||
<span>{{ linkedPatient.name }}</span>
|
||||
<div class="profile-links">
|
||||
<router-link v-if="linkedPatient.appointments" :to="{ path: '/appointments', query: { patient_id: linkedPatient.id } }">查看关联预约</router-link>
|
||||
<router-link v-if="linkedPatient.orders" v-perms="['order.order/lists']" :to="{ path: '/order', query: { patient_keyword: linkedPatient.name } }">查看关联订单</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<account-adjust
|
||||
v-if="!isPreview"
|
||||
v-model:show="adjustState.show"
|
||||
:value="adjustState.value"
|
||||
@confirm="handleConfirmAdjust"
|
||||
@@ -112,11 +147,23 @@
|
||||
import type { FormInstance } from 'element-plus'
|
||||
|
||||
import { adjustMoney, getUserDetail, userEdit } from '@/api/consumer'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import { isEmpty } from '@/utils/util'
|
||||
|
||||
import AccountAdjust from '../components/account-adjust.vue'
|
||||
|
||||
const isPreview = import.meta.env.MODE === 'local-preview'
|
||||
const settings = useSettingStore()
|
||||
const isArt = computed(() => settings.adminUi === 'v2')
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const loadFailed = ref(false)
|
||||
const linkedPatient = reactive({ id: 0, name: '', appointments: 0, orders: 0 })
|
||||
function goBack() {
|
||||
if (isPreview && window.history.state?.back !== '/members') return router.replace('/members')
|
||||
router.back()
|
||||
}
|
||||
const formData = reactive({
|
||||
avatar: '',
|
||||
channel: '',
|
||||
@@ -138,17 +185,23 @@ const adjustState = reactive({
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
|
||||
const getDetails = async () => {
|
||||
const data = await getUserDetail({
|
||||
id: route.query.id
|
||||
})
|
||||
Object.keys(formData).forEach((key) => {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
})
|
||||
loading.value = true
|
||||
loadFailed.value = false
|
||||
try {
|
||||
const data = await getUserDetail({ id: route.query.id })
|
||||
Object.assign(formData, Object.fromEntries(Object.keys(formData).map(key => [key, data[key]])))
|
||||
if (isPreview) {
|
||||
Object.assign(linkedPatient, { id: data.patient_id, name: data.patient_name, appointments: data.appointment_count, orders: data.order_count })
|
||||
}
|
||||
} catch {
|
||||
loadFailed.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleEdit = async (value: string, field: string) => {
|
||||
if (isEmpty(value)) return
|
||||
if (isPreview || isEmpty(value)) return
|
||||
await userEdit({
|
||||
id: route.query.id,
|
||||
field,
|
||||
@@ -158,13 +211,55 @@ const handleEdit = async (value: string, field: string) => {
|
||||
}
|
||||
|
||||
const handleAdjust = (value: string) => {
|
||||
if (isPreview) return
|
||||
adjustState.show = true
|
||||
adjustState.value = value
|
||||
}
|
||||
const handleConfirmAdjust = async (value: any) => {
|
||||
if (isPreview) return
|
||||
await adjustMoney({ user_id: route.query.id, ...value })
|
||||
adjustState.show = false
|
||||
getDetails()
|
||||
}
|
||||
getDetails()
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.consumer-profile .profile-linked-row, .consumer-profile .profile-links {
|
||||
display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
|
||||
}
|
||||
.consumer-profile .profile-links a { color: var(--el-color-primary); }
|
||||
html[data-admin-ui='v2'] .consumer-profile {
|
||||
min-width: 0; color: var(--zyt-text);
|
||||
.profile-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
|
||||
h1 { margin: 0 0 6px; font-size: clamp(22px, 2vw, 28px); line-height: 1.25; font-weight: 700; color: var(--zyt-ink); }
|
||||
.profile-heading p, .profile-identity small { margin: 0; font-size: 13px; color: var(--zyt-muted); }
|
||||
> .el-card { border: 1px solid var(--zyt-card-border) !important; border-radius: 8px; background: var(--zyt-surface); }
|
||||
.el-card__header { padding: 15px 20px; border-bottom-color: var(--zyt-border); font-size: 18px; font-weight: 500; }
|
||||
.el-card__body { padding: 16px 20px; }
|
||||
.profile-summary {
|
||||
display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
|
||||
padding: 16px 20px; margin: 0 0 16px; border-radius: 8px; background: var(--zyt-surface-subtle);
|
||||
}
|
||||
.profile-identity { flex: 1 1 auto; flex-direction: row; justify-content: start; gap: 14px; }
|
||||
.profile-identity .el-avatar { background: var(--zyt-accent-soft); color: var(--zyt-selected-ink, var(--zyt-accent)); flex-shrink: 0; }
|
||||
.profile-identity strong { display: block; color: var(--zyt-ink); font-size: 20px; font-weight: 600; line-height: 1.5; }
|
||||
.profile-balance { flex-basis: auto; align-items: flex-start; min-width: 100px; }
|
||||
.profile-balance > :first-child { color: var(--zyt-text); font-size: 13px; }
|
||||
.profile-balance > :last-child { margin-top: 3px; color: var(--zyt-ink); font-size: 22px; line-height: 1.4; font-variant-numeric: tabular-nums; }
|
||||
.profile-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
|
||||
.profile-fields .el-form-item { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--zyt-border); }
|
||||
.profile-fields .el-form-item__label { justify-content: flex-start; color: var(--zyt-muted); }
|
||||
.profile-fields .el-form-item__content { overflow-wrap: anywhere; color: var(--zyt-ink); font-variant-numeric: tabular-nums; }
|
||||
.profile-linked { margin-top: 12px; }
|
||||
.profile-linked-row { justify-content: space-between; }
|
||||
.profile-links a { color: var(--zyt-selected-ink, var(--zyt-accent)); }
|
||||
@media (max-width: 850px) {
|
||||
.profile-fields { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.el-card__body, .el-card__header { padding: 12px; }
|
||||
.profile-heading { flex-wrap: wrap; }
|
||||
.profile-summary { padding: 12px; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
||||
<div class="consumer-directory">
|
||||
<header v-if="isArt" class="directory-heading">
|
||||
<h1>用户列表</h1>
|
||||
<p>按账号、注册来源或时间查找用户,查看账号资料。</p>
|
||||
</header>
|
||||
<el-card class="!border-none directory-filter" shadow="never">
|
||||
<h2 v-if="isArt">筛选条件</h2>
|
||||
<el-form class="mb-[-16px]" :model="queryParams" :inline="true" @submit.prevent>
|
||||
<el-form-item class="w-[280px]" label="用户信息">
|
||||
<el-input
|
||||
v-model="queryParams.keyword"
|
||||
@@ -10,14 +15,14 @@
|
||||
@keyup.enter="resetPage"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="注册时间">
|
||||
<el-form-item class="directory-dates" label="注册时间">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.create_time_start"
|
||||
v-model:endTime="queryParams.create_time_end"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item class="w-[280px]" label="注册来源">
|
||||
<el-select v-model="queryParams.channel">
|
||||
<el-select v-model="queryParams.channel" placeholder="全部来源" clearable>
|
||||
<el-option
|
||||
v-for="(item, key) in ClientMap"
|
||||
:key="key"
|
||||
@@ -26,10 +31,11 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item class="directory-actions">
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
<el-button @click="resetFilters">重置</el-button>
|
||||
<export-data
|
||||
v-if="!isPreview"
|
||||
class="ml-2.5"
|
||||
:fetch-fun="getUserList"
|
||||
:params="queryParams"
|
||||
@@ -38,61 +44,129 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<el-table size="large" v-loading="pager.loading" :data="pager.lists">
|
||||
<el-table-column label="头像" min-width="100">
|
||||
<el-card class="!border-none mt-4 directory-records" shadow="never">
|
||||
<div v-if="isArt" class="directory-caption">
|
||||
<h2>用户账号</h2><span>共 {{ pager.count }} 个</span>
|
||||
</div>
|
||||
<el-table size="large" v-loading="pager.loading" :data="pager.lists" row-key="id">
|
||||
<el-table-column v-if="isArt" label="用户昵称" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="directory-identity">
|
||||
<el-avatar :src="row.avatar" :size="36">{{ row.nickname?.slice(0, 1) || '用' }}</el-avatar>
|
||||
<div><strong>{{ row.nickname || '—' }}</strong><small>{{ row.sn || '—' }}</small></div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="!isArt" label="头像" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-avatar :src="row.avatar" :size="50" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="昵称" prop="nickname" min-width="100" />
|
||||
<el-table-column label="账号" prop="account" min-width="120" />
|
||||
<el-table-column label="手机号码" prop="mobile" min-width="100" />
|
||||
<el-table-column v-if="!isArt" label="昵称" prop="nickname" min-width="100" />
|
||||
<el-table-column label="账号" prop="account" min-width="125" />
|
||||
<el-table-column label="手机号码" prop="mobile" min-width="128" />
|
||||
<el-table-column label="注册来源" prop="channel" min-width="100" />
|
||||
<el-table-column label="注册时间" prop="create_time" min-width="120" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<el-table-column label="注册时间" prop="create_time" min-width="158" />
|
||||
<el-table-column label="操作" :width="isArt ? 82 : 120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['user.user/detail']" type="primary" link>
|
||||
<router-link
|
||||
:to="{
|
||||
path: getRoutePath('user.user/detail'),
|
||||
query: {
|
||||
id: row.id
|
||||
}
|
||||
}"
|
||||
>
|
||||
详情
|
||||
</router-link>
|
||||
</el-button>
|
||||
<router-link
|
||||
v-perms="['user.user/detail']"
|
||||
class="el-button el-button--primary is-link"
|
||||
:to="{ path: isPreview ? '/members/detail' : getRoutePath('user.user/detail'), query: { id: row.id } }"
|
||||
>详情</router-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="flex justify-end mt-4">
|
||||
<div class="flex justify-end mt-4 directory-pager">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="consumerLists">
|
||||
<script lang="ts">
|
||||
// Only synthetic preview list state survives the round trip to a detail (no localStorage or server writes).
|
||||
let previewReturnState: { query: Record<string, string>; page: number; size: number } | undefined
|
||||
</script>
|
||||
<script lang="ts" setup>
|
||||
import { onBeforeRouteLeave } from 'vue-router'
|
||||
import { getUserList } from '@/api/consumer'
|
||||
import { ClientMap } from '@/enums/appEnums'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { getRoutePath } from '@/router'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
|
||||
defineOptions({ name: 'consumerLists' })
|
||||
const isPreview = import.meta.env.MODE === 'local-preview'
|
||||
const settings = useSettingStore()
|
||||
const isArt = computed(() => settings.adminUi === 'v2')
|
||||
const queryParams = reactive({
|
||||
keyword: '',
|
||||
channel: '',
|
||||
create_time_start: '',
|
||||
create_time_end: ''
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||
fetchFun: getUserList,
|
||||
params: queryParams
|
||||
params: queryParams,
|
||||
latestOnly: true
|
||||
})
|
||||
onActivated(() => {
|
||||
getLists()
|
||||
})
|
||||
|
||||
function resetFilters() {
|
||||
pager.page = 1
|
||||
resetParams()
|
||||
}
|
||||
if (isPreview) {
|
||||
if (previewReturnState) {
|
||||
Object.assign(queryParams, previewReturnState.query)
|
||||
pager.page = previewReturnState.page
|
||||
pager.size = previewReturnState.size
|
||||
previewReturnState = undefined
|
||||
}
|
||||
onBeforeRouteLeave(to => {
|
||||
previewReturnState = to.path === '/members/detail'
|
||||
? { query: { ...queryParams }, page: pager.page, size: pager.size } : undefined
|
||||
})
|
||||
}
|
||||
onActivated(() => { getLists() })
|
||||
getLists()
|
||||
</script>
|
||||
<style lang="scss">
|
||||
html[data-admin-ui='v2'] .consumer-directory {
|
||||
min-width: 0;
|
||||
color: var(--zyt-text);
|
||||
.directory-heading { margin-bottom: 20px; }
|
||||
h1 { margin: 0 0 6px; color: var(--zyt-ink); font-size: clamp(22px, 2vw, 28px); font-weight: 700; line-height: 1.25; }
|
||||
.directory-heading p { margin: 0; font-size: 13px; color: var(--zyt-muted); }
|
||||
h2 { color: var(--zyt-ink); font-size: 18px; font-weight: 500; line-height: 24px; }
|
||||
> .el-card { border: 1px solid var(--zyt-card-border) !important; background: var(--zyt-surface); border-radius: 8px; }
|
||||
> .el-card > .el-card__body { padding: 16px 20px; }
|
||||
.directory-filter h2 { margin: 0 0 14px; }
|
||||
.directory-filter .el-form {
|
||||
display: grid; grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.6fr) minmax(140px, .8fr);
|
||||
gap: 12px 16px; margin: 0;
|
||||
}
|
||||
.directory-filter .el-form-item { display: flex; flex-direction: column; align-items: stretch; margin: 0; min-width: 0; width: auto; }
|
||||
.directory-filter .el-form-item__label { justify-content: flex-start; height: auto; line-height: 18px; padding: 0 0 5px; font-size: 12px; }
|
||||
.directory-filter .el-form-item__content, .directory-filter .el-date-editor { width: 100%; min-width: 0; }
|
||||
.directory-actions { grid-column: 1 / -1; border-top: 1px solid var(--zyt-border); padding-top: 12px; }
|
||||
.directory-caption { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
|
||||
.directory-caption h2 { margin: 0; }
|
||||
.directory-caption span, .directory-identity small { color: var(--zyt-muted); font-size: 12px; }
|
||||
.directory-records { margin-top: 12px; }
|
||||
.directory-records .el-table { --el-table-header-bg-color: var(--zyt-surface); }
|
||||
.directory-identity { display: flex; align-items: center; gap: 12px; }
|
||||
.directory-identity .el-avatar { background: var(--zyt-accent-soft); color: var(--zyt-selected-ink, var(--zyt-accent)); flex-shrink: 0; }
|
||||
.directory-identity strong, .directory-identity small { display: block; line-height: 20px; }
|
||||
.directory-identity strong { color: var(--zyt-ink); font-weight: 500; }
|
||||
.directory-pager .el-pagination { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
|
||||
@media (max-width: 1024px) {
|
||||
.directory-filter .el-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.directory-dates { grid-column: 1 / -1; order: 1; }
|
||||
.directory-actions { order: 2; }
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
> .el-card > .el-card__body { padding: 12px; }
|
||||
.directory-filter .el-form { grid-template-columns: minmax(0, 1fr); }
|
||||
.directory-pager .pagination { min-width: 0; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,356 +1,293 @@
|
||||
<template>
|
||||
<div class="dept-statistics-page">
|
||||
<!-- 筛选区域卡片 -->
|
||||
<el-card class="mb-4" shadow="hover">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">筛选条件</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :inline="true" :model="queryParams" class="filter-form">
|
||||
<main class="dept-statistics-page" :class="{ 'is-art': art }">
|
||||
<header v-if="art" class="report-heading">
|
||||
<h1>部门预约统计</h1>
|
||||
<p>按预约日期统计,部门以挂号医助的所属部门为准。</p>
|
||||
</header>
|
||||
|
||||
<el-card class="report-filter" :shadow="art ? 'never' : 'hover'">
|
||||
<template #header><h2>筛选条件</h2></template>
|
||||
<el-form :model="queryParams" class="filter-form" @submit.prevent="getStatistics">
|
||||
<el-form-item label="部门">
|
||||
<el-select
|
||||
v-model="queryParams.dept_id"
|
||||
placeholder="全部部门"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in deptList"
|
||||
:key="dept.id"
|
||||
:label="dept.name"
|
||||
:value="dept.id"
|
||||
/>
|
||||
<el-select v-model="queryParams.dept_id" placeholder="全部部门" clearable filterable>
|
||||
<el-option v-for="dept in deptList" :key="dept.id" :label="dept.name" :value="dept.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="时间范围">
|
||||
<el-radio-group v-model="queryParams.time_type" @change="handleTimeTypeChange">
|
||||
<el-radio-button label="today">今天</el-radio-button>
|
||||
<el-radio-button label="week">最近7天</el-radio-button>
|
||||
<el-radio-button label="month">最近30天</el-radio-button>
|
||||
<el-radio-button label="custom">自定义</el-radio-button>
|
||||
<el-radio-group v-model="queryParams.time_type" aria-label="时间范围">
|
||||
<el-radio-button v-for="option in periods" :key="option.value" :value="option.value">
|
||||
{{ option.label }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="queryParams.time_type === 'custom'">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 260px"
|
||||
/>
|
||||
<el-form-item v-if="queryParams.time_type === 'custom'" label="预约日期">
|
||||
<el-date-picker v-model="dateRange" type="daterange" range-separator="至"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD"
|
||||
popper-class="dept-stats-date-popper" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getStatistics" :loading="loading">查询</el-button>
|
||||
<div class="filter-actions">
|
||||
<el-button type="primary" native-type="submit" :loading="loading">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 统计数据卡片 -->
|
||||
<el-card v-loading="loading" class="mb-4" shadow="hover">
|
||||
<el-card v-loading="loading" class="report-results" :shadow="art ? 'never' : 'hover'" :aria-busy="loading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">部门统计数据</span>
|
||||
<div class="report-caption">
|
||||
<h2>{{ art ? '部门预约明细' : '部门统计数据' }}</h2>
|
||||
<span v-if="art && statisticsList.length">{{ statisticsList[0].time_range }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="statisticsList.length > 0">
|
||||
<el-table
|
||||
:data="statisticsList"
|
||||
style="width: 100%"
|
||||
:header-cell-style="{ background: '#f5f7fa', color: '#606266', fontWeight: '600' }"
|
||||
>
|
||||
<el-table-column prop="dept_name" label="部门名称" width="120" />
|
||||
|
||||
<!-- 状态明细 -->
|
||||
<el-table-column label="状态明细" min-width="700">
|
||||
<div v-if="loadError" role="alert" class="report-error">
|
||||
<p>部门统计加载失败,请重新查询。</p><el-button @click="getStatistics">重试</el-button>
|
||||
</div>
|
||||
<template v-else-if="statisticsList.length">
|
||||
<template v-if="art || smallScreen">
|
||||
<dl v-if="art" class="report-totals">
|
||||
<div><dt>预约总数</dt><dd data-stat="total">{{ totals.count }}<small>笔</small></dd></div>
|
||||
<div><dt>已完成</dt><dd data-stat="completed">{{ totals.completed }}<small>笔</small></dd></div>
|
||||
<div><dt>整体完成率</dt><dd data-stat="rate">{{ totals.rate }}<small>%</small></dd></div>
|
||||
</dl>
|
||||
<div class="dept-mobile-list">
|
||||
<table class="dept-report-table" aria-label="各部门预约状态统计">
|
||||
<thead><tr>
|
||||
<th scope="col">部门</th>
|
||||
<th v-for="status in statuses" :key="status.key" scope="col">{{ status.label }}</th>
|
||||
<th scope="col">总数</th><th scope="col">完成率</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in statisticsList" :key="row.dept_id">
|
||||
<th scope="row" class="dept-name">
|
||||
{{ row.dept_name }}
|
||||
<router-link v-if="showDetails(row)" :to="detailLocation(row)">查看明细</router-link>
|
||||
</th>
|
||||
<td v-for="status in statuses" :key="status.key" :data-label="status.label">{{ row[status.key] }}</td>
|
||||
<td data-label="总数" class="total-cell">{{ row.total_count }}</td>
|
||||
<td data-label="完成率">{{ row.completion_rate }}%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p v-if="!art" class="period-note">{{ statisticsList[0].time_range }}</p>
|
||||
</template>
|
||||
<el-table v-else :data="statisticsList" row-key="dept_id">
|
||||
<el-table-column prop="dept_name" label="部门名称" width="145">
|
||||
<template #default="{ row }">
|
||||
<div class="status-overview">
|
||||
<div class="status-tags">
|
||||
<el-tag type="info" size="small" class="compact-tag">
|
||||
已挂号: {{ row.registered_count }}
|
||||
</el-tag>
|
||||
<el-tag type="success" size="small" class="compact-tag">
|
||||
已完成: {{ row.completed_count }}
|
||||
</el-tag>
|
||||
<el-tag type="danger" size="small" class="compact-tag">
|
||||
已取消: {{ row.canceled_count }}
|
||||
</el-tag>
|
||||
<el-tag type="warning" size="small" class="compact-tag">
|
||||
已过号: {{ row.expired_count }}
|
||||
</el-tag>
|
||||
<el-tag type="primary" size="small" class="compact-tag">
|
||||
总数量: {{ row.total_count }}
|
||||
</el-tag>
|
||||
<el-tag :type="getCompletionRateType(row.completion_rate)" size="small" class="compact-tag">
|
||||
完成率: {{ row.completion_rate }}%
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="dept-name">{{ row.dept_name }}
|
||||
<router-link v-if="showDetails(row)" :to="detailLocation(row)">查看明细</router-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="time_range" label="统计时间" min-width="200" />
|
||||
<el-table-column label="状态明细" min-width="300">
|
||||
<template #default="{ row }">
|
||||
<div class="status-tags">
|
||||
<el-tag v-for="status in statuses" :key="status.key" :type="status.type" size="small">
|
||||
{{ status.label }}: {{ row[status.key] }}
|
||||
</el-tag>
|
||||
<el-tag size="small">总数量: {{ row.total_count }}</el-tag>
|
||||
<el-tag :type="row.completion_rate >= 80 ? 'success' : row.completion_rate >= 60 ? 'primary' : 'warning'" size="small">
|
||||
完成率: {{ row.completion_rate }}%
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="time_range" label="统计时间" min-width="160" />
|
||||
</el-table>
|
||||
</div>
|
||||
<div v-else class="empty-data">
|
||||
<el-empty description="暂无统计数据" />
|
||||
</div>
|
||||
</template>
|
||||
<el-empty v-else-if="!loading" description="暂无统计数据">
|
||||
<p>所选部门在此日期范围内没有预约。试试其他部门或时间范围。</p>
|
||||
</el-empty>
|
||||
</el-card>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getDeptStatistics, getDeptList } from '@/api/doctor'
|
||||
|
||||
const loading = ref(false)
|
||||
const deptList = ref<any[]>([])
|
||||
const statisticsList = ref<any[]>([])
|
||||
const dateRange = ref<string[]>([])
|
||||
import { getDeptList, getDeptStatistics } from '@/api/doctor'
|
||||
import { useAdminAppearanceStore } from '@/stores/modules/setting'
|
||||
|
||||
const queryParams = reactive({
|
||||
dept_id: '',
|
||||
time_type: 'today',
|
||||
start_date: '',
|
||||
end_date: ''
|
||||
type Department = { id: number; name: string; children?: Department[] }
|
||||
type StatusKey = 'registered_count' | 'completed_count' | 'canceled_count' | 'expired_count'
|
||||
type StatsRow = Record<StatusKey, number> & {
|
||||
dept_id: number; dept_name: string; total_count: number; completion_rate: number
|
||||
time_range: string; start_date?: string; end_date?: string
|
||||
}
|
||||
const statuses = [
|
||||
{ key: 'registered_count', label: '已挂号', type: 'info' },
|
||||
{ key: 'completed_count', label: '已完成', type: 'success' },
|
||||
{ key: 'canceled_count', label: '已取消', type: 'danger' },
|
||||
{ key: 'expired_count', label: '已过号', type: 'warning' }
|
||||
] as const
|
||||
const periods = [
|
||||
{ value: 'today', label: '今天' }, { value: 'week', label: '最近7天' },
|
||||
{ value: 'month', label: '最近30天' }, { value: 'custom', label: '自定义' }
|
||||
]
|
||||
const appearance = useAdminAppearanceStore()
|
||||
const art = computed(() => appearance.mode === 'v2')
|
||||
const smallScreen = useMediaQuery('(max-width: 720px)')
|
||||
const route = useRoute()
|
||||
const showDetails = (row: StatsRow) => import.meta.env.MODE === 'local-preview' &&
|
||||
route.meta.localPreview === true && !!row.start_date && !!row.end_date
|
||||
const detailLocation = (row: StatsRow) => ({
|
||||
path: '/appointments', query: { dept_id: row.dept_id, start_date: row.start_date, end_date: row.end_date }
|
||||
})
|
||||
|
||||
const getDeptLists = async () => {
|
||||
const loading = ref(false)
|
||||
const loadError = ref(false)
|
||||
const deptList = ref<Department[]>([])
|
||||
const statisticsList = ref<StatsRow[]>([])
|
||||
const dateRange = ref<[string, string] | null>(null)
|
||||
const queryParams = reactive({ dept_id: '' as number | '', time_type: 'today' })
|
||||
const totals = computed(() => {
|
||||
const count = statisticsList.value.reduce((n, r) => n + Number(r.total_count), 0)
|
||||
const completed = statisticsList.value.reduce((n, r) => n + Number(r.completed_count), 0)
|
||||
return { count, completed, rate: count ? Number((100 * completed / count).toFixed(2)) : 0 }
|
||||
})
|
||||
async function getDepartments() {
|
||||
function flatten(list: Department[]): Department[] {
|
||||
return list.flatMap(({ id, name, children }) => [{ id, name }, ...flatten(children || [])])
|
||||
}
|
||||
try {
|
||||
const res = await getDeptList()
|
||||
// 将树形结构转换为扁平化列表
|
||||
const flattenDepts = (depts) => {
|
||||
let result = []
|
||||
depts.forEach(dept => {
|
||||
result.push({ id: dept.id, name: dept.name })
|
||||
if (dept.children && dept.children.length > 0) {
|
||||
result = result.concat(flattenDepts(dept.children))
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
deptList.value = flattenDepts(res) || []
|
||||
} catch (error) {
|
||||
console.error('获取部门列表失败:', error)
|
||||
deptList.value = flatten(await getDeptList())
|
||||
} catch {
|
||||
ElMessage.error('部门选项加载失败,仍可查询全部部门')
|
||||
}
|
||||
}
|
||||
|
||||
const getStatistics = async () => {
|
||||
let requestId = 0
|
||||
async function getStatistics() {
|
||||
const params: Record<string, string | number> = { time_type: queryParams.time_type }
|
||||
if (queryParams.dept_id) params.dept_id = queryParams.dept_id
|
||||
if (queryParams.time_type === 'custom') {
|
||||
if (!dateRange.value || dateRange.value.length !== 2) {
|
||||
ElMessage.warning('请选择开始日期和结束日期')
|
||||
return
|
||||
}
|
||||
params.start_date = dateRange.value[0]
|
||||
params.end_date = dateRange.value[1]
|
||||
}
|
||||
const id = ++requestId
|
||||
loading.value = true
|
||||
loadError.value = false
|
||||
try {
|
||||
const params: any = {
|
||||
time_type: queryParams.time_type
|
||||
}
|
||||
|
||||
if (queryParams.dept_id) {
|
||||
params.dept_id = queryParams.dept_id
|
||||
}
|
||||
|
||||
if (queryParams.time_type === 'custom' && dateRange.value && dateRange.value.length === 2) {
|
||||
params.start_date = dateRange.value[0]
|
||||
params.end_date = dateRange.value[1]
|
||||
}
|
||||
|
||||
const res = await getDeptStatistics(params)
|
||||
statisticsList.value = res.lists || []
|
||||
} catch (error: any) {
|
||||
console.error('获取统计数据错误:', error)
|
||||
ElMessage.error(error.msg || '获取统计数据失败')
|
||||
const result = await getDeptStatistics(params)
|
||||
if (id === requestId) statisticsList.value = result.lists || []
|
||||
} catch {
|
||||
if (id === requestId) { statisticsList.value = []; loadError.value = true }
|
||||
} finally {
|
||||
loading.value = false
|
||||
if (id === requestId) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleTimeTypeChange = () => {
|
||||
if (queryParams.time_type !== 'custom') {
|
||||
dateRange.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
function handleReset() {
|
||||
queryParams.dept_id = ''
|
||||
queryParams.time_type = 'today'
|
||||
dateRange.value = []
|
||||
dateRange.value = null
|
||||
getStatistics()
|
||||
}
|
||||
|
||||
// 获取完成率标签类型
|
||||
const getCompletionRateType = (rate: number) => {
|
||||
if (rate >= 80) {
|
||||
return 'success'
|
||||
} else if (rate >= 60) {
|
||||
return 'primary'
|
||||
} else {
|
||||
return 'warning'
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getDeptLists()
|
||||
getStatistics()
|
||||
})
|
||||
onMounted(() => { getDepartments(); getStatistics() })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.dept-statistics-page {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
padding: 20px;
|
||||
background-color: #f5f7fa;
|
||||
min-height: 100vh;
|
||||
background: var(--el-bg-color-page);
|
||||
color: var(--el-text-color-primary);
|
||||
h1, h2, p, dl, dd { margin: 0; }
|
||||
h2 { font-size: 16px; line-height: 1.5; font-weight: 600; }
|
||||
:deep(.el-card) { min-width: 0; }
|
||||
:deep(.el-empty p), .period-note { color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.filter-form, .filter-actions, .status-tags, .report-caption {
|
||||
display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.filter-form {
|
||||
padding: 10px 0;
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
:deep(.el-form-item) { min-width: 0; margin: 0; }
|
||||
:deep(.el-select) { width: 180px; }
|
||||
:deep(.el-date-editor) { width: 256px; max-width: 100%; min-width: 0; }
|
||||
}
|
||||
.filter-actions { gap: 8px; :deep(.el-button + .el-button) { margin-left: 0; } }
|
||||
.status-tags { gap: 6px; }
|
||||
.report-caption { justify-content: space-between; }
|
||||
.report-caption span, .period-note { color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
.report-error { display: flex; align-items: center; gap: 12px; }
|
||||
.dept-name a {
|
||||
display: block; width: fit-content; color: var(--el-color-primary); font-weight: 400; font-size: 13px;
|
||||
text-decoration: underline; text-underline-offset: 3px;
|
||||
}
|
||||
.dept-mobile-list { max-width: 100%; overflow-x: auto; }
|
||||
.dept-report-table {
|
||||
width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;
|
||||
th, td { padding: 14px 12px; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||
thead th { color: var(--el-text-color-regular); background: var(--el-fill-color-light); font-size: 13px; font-weight: 500; white-space: nowrap; }
|
||||
th:first-child { text-align: left; }
|
||||
th:not(:first-child), td { text-align: right; }
|
||||
.dept-name { color: var(--el-text-color-primary); font-weight: 600; }
|
||||
.total-cell { font-weight: 600; color: var(--el-text-color-primary); }
|
||||
tbody tr:last-child > * { border-bottom: 0; }
|
||||
}
|
||||
.is-art {
|
||||
padding: 0; background: var(--zyt-canvas); color: var(--zyt-text);
|
||||
.report-heading h1 { color: var(--zyt-ink); font-size: clamp(22px, 2vw, 28px); line-height: 1.25; font-weight: 700; }
|
||||
.report-heading p { margin-top: 6px; font-size: 13px; color: var(--zyt-muted); }
|
||||
h2 { color: var(--zyt-ink); font-size: 18px; font-weight: 500; }
|
||||
:deep(.el-card__header) { padding: 16px 20px 6px; border-bottom: 0; }
|
||||
:deep(.el-card__body) { padding: 12px 20px 20px; }
|
||||
.filter-form { align-items: end; }
|
||||
.filter-form :deep(.el-form-item) { display: grid; }
|
||||
.filter-form :deep(.el-form-item__label) { justify-content: start; padding: 0; line-height: 22px; height: auto; font-size: 13px; }
|
||||
.report-totals {
|
||||
display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
padding: 10px 0 18px; margin-bottom: 12px; border-bottom: 1px solid var(--zyt-border);
|
||||
div + div { border-left: 1px solid var(--zyt-border); padding-left: clamp(12px, 2vw, 28px); }
|
||||
dt { font-size: 13px; color: var(--zyt-text); }
|
||||
dd { margin-top: 6px; color: var(--zyt-ink); font-weight: 600; font-size: clamp(21px, 2.2vw, 32px); line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
||||
small { font-size: 13px; margin-left: 4px; font-weight: 400; color: var(--zyt-text); }
|
||||
}
|
||||
.dept-report-table tr:hover > td, .dept-report-table tr:hover > .dept-name { background: var(--zyt-surface-subtle); }
|
||||
}
|
||||
|
||||
.status-overview {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.status-section {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
padding-bottom: 4px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.status-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.compact-tag {
|
||||
font-size: 12px !important;
|
||||
padding: 4px 12px !important;
|
||||
margin: 0 !important;
|
||||
border-radius: 12px !important;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
.compact-tag:hover {
|
||||
transform: translateY(-1px) !important;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.empty-data {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 表格样式优化 */
|
||||
:deep(.el-table) {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
transition: box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
:deep(.el-table:hover) {
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
:deep(.el-table th) {
|
||||
background-color: #f5f7fa !important;
|
||||
font-weight: 600 !important;
|
||||
color: #606266 !important;
|
||||
border-bottom: 1px solid #ebeef5 !important;
|
||||
}
|
||||
|
||||
:deep(.el-table tr:hover) {
|
||||
background-color: #f5f7fa !important;
|
||||
}
|
||||
|
||||
:deep(.el-table__cell) {
|
||||
text-align: left !important;
|
||||
vertical-align: top !important;
|
||||
padding: 12px 15px !important;
|
||||
}
|
||||
|
||||
/* 卡片样式优化 */
|
||||
:deep(.el-card) {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1) !important;
|
||||
margin-bottom: 16px !important;
|
||||
transition: box-shadow 0.3s ease;
|
||||
border: none !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-card:hover) {
|
||||
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
:deep(.el-card__header) {
|
||||
background-color: #ffffff !important;
|
||||
border-bottom: 1px solid #ebeef5 !important;
|
||||
padding: 15px 20px !important;
|
||||
}
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 20px !important;
|
||||
background-color: #ffffff !important;
|
||||
}
|
||||
|
||||
/* 按钮样式优化 */
|
||||
:deep(.el-button) {
|
||||
border-radius: 4px !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
:deep(.el-button:hover) {
|
||||
transform: translateY(-1px) !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
/* 选择器样式优化 */
|
||||
:deep(.el-select) {
|
||||
border-radius: 4px !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
:deep(.el-select:hover) {
|
||||
box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2) !important;
|
||||
}
|
||||
|
||||
/* 标签样式优化 */
|
||||
:deep(.el-tag) {
|
||||
border-radius: 4px !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
:deep(.el-tag:hover) {
|
||||
transform: translateY(-1px) !important;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
|
||||
@media (max-width: 720px) {
|
||||
.dept-statistics-page { padding: 0; }
|
||||
.filter-form { display: grid; gap: 10px; }
|
||||
.filter-form :deep(.el-form-item) { display: grid; }
|
||||
.filter-form :deep(.el-form-item__label) { justify-content: start; height: auto; line-height: 24px; }
|
||||
.filter-form :deep(.el-form-item__content) { min-width: 0; }
|
||||
.filter-form :deep(.el-select), .filter-form :deep(.el-date-editor), .filter-form :deep(.el-radio-group) { width: 100%; }
|
||||
.filter-form :deep(.el-radio-group) { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||||
.filter-form :deep(.el-radio-button__inner) { width: 100%; padding-inline: 0; font-size: 13px; }
|
||||
.is-art :deep(.el-card__header) { padding: 14px 14px 2px; }
|
||||
.is-art :deep(.el-card__body) { padding: 10px 14px 14px; }
|
||||
.report-caption { align-items: start; flex-direction: column; gap: 4px; }
|
||||
.dept-report-table {
|
||||
display: block;
|
||||
thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
||||
tbody { display: grid; gap: 14px; }
|
||||
tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
|
||||
tbody tr + tr { border-top: 1px solid var(--el-border-color-lighter); padding-top: 14px; }
|
||||
tbody th, tbody td { padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
|
||||
td::before { display: block; content: attr(data-label); color: var(--el-text-color-secondary); font-size: 12px; font-weight: 400; }
|
||||
.dept-name { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
||||
}
|
||||
.period-note { margin-top: 12px; }
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
// Element Plus teleports the dual-calendar panel outside of the page.
|
||||
@media (max-width: 720px) {
|
||||
.dept-stats-date-popper .el-date-range-picker { width: min(580px, calc(100vw - 28px)); }
|
||||
}
|
||||
@media (max-width: 540px) {
|
||||
.dept-stats-date-popper .el-picker-panel__body {
|
||||
display: flex; flex-direction: column; min-width: 0; overflow-y: auto; max-height: 58vh;
|
||||
}
|
||||
.dept-stats-date-popper .el-date-range-picker__content {
|
||||
width: 100%; padding: 8px 12px; border: 0;
|
||||
&.is-right { border-top: 1px solid var(--el-border-color-lighter); }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,11 +1,90 @@
|
||||
<template>
|
||||
<div class="doctor-roster p-4">
|
||||
<el-card shadow="never">
|
||||
<div class="doctor-roster" :class="{ 'p-4': !isArt }">
|
||||
<section v-if="isArt" class="roster-art" aria-labelledby="roster-title">
|
||||
<header class="roster-head">
|
||||
<div class="roster-heading">
|
||||
<span class="roster-icon" aria-hidden="true"><Calendar /></span>
|
||||
<div>
|
||||
<h1 id="roster-title">医生排班管理</h1>
|
||||
<p>{{ filteredTableData.length }} 位医生<span class="roster-separator">/</span>{{ visibleSegments }} 段排班</p>
|
||||
</div>
|
||||
</div>
|
||||
<el-button v-if="!previewReadonly" type="primary" @click="showBatchDialog">批量排班</el-button>
|
||||
</header>
|
||||
|
||||
<div class="roster-panel">
|
||||
<div class="roster-toolbar">
|
||||
<div class="roster-week">
|
||||
<h2 data-testid="roster-week" aria-live="polite">{{ weekText }}</h2>
|
||||
<div class="roster-switch" aria-label="切换排班周">
|
||||
<button type="button" aria-label="上一周" title="上一周" @click="prevWeek"><ArrowLeft /></button>
|
||||
<button type="button" class="roster-this-week" @click="goToday">本周</button>
|
||||
<button type="button" aria-label="下一周" title="下一周" @click="nextWeek"><ArrowRight /></button>
|
||||
</div>
|
||||
</div>
|
||||
<el-input v-model="searchName" class="roster-filter" data-testid="roster-doctor-filter"
|
||||
placeholder="搜索医生姓名" aria-label="搜索医生姓名" :prefix-icon="Search" clearable />
|
||||
</div>
|
||||
|
||||
<div class="roster-day-nav" aria-label="选择日期">
|
||||
<button v-for="(day, index) in weekDays" :key="day.date" type="button"
|
||||
:aria-label="day.label" :aria-pressed="selectedDay === index" @click="selectedDay = index">
|
||||
<span>{{ day.weekday }}</span><b>{{ day.monthDay }}</b>
|
||||
</button>
|
||||
</div>
|
||||
<div v-loading="loading" class="roster-scroll" :aria-busy="loading">
|
||||
<table class="roster-grid" data-testid="roster-calendar" aria-label="医生周排班">
|
||||
<thead><tr>
|
||||
<th scope="col" class="roster-name-col">医生</th>
|
||||
<th v-for="(day, index) in weekDays" :key="day.date" scope="col"
|
||||
:class="{ 'roster-current': day.isToday, 'roster-selected': index === selectedDay }">
|
||||
<span>{{ day.weekday }}</span>
|
||||
<span class="roster-date">{{ day.monthDay }}</span>
|
||||
<span v-if="day.isToday" class="roster-today">今</span>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="row in filteredTableData" :key="row.doctorId">
|
||||
<th scope="row" class="roster-name-col">
|
||||
<span>{{ row.doctorName }}</span><small v-if="row.departmentName">{{ row.departmentName }}</small>
|
||||
</th>
|
||||
<td v-for="(day, index) in weekDays" :key="day.date"
|
||||
:class="{ 'roster-selected': index === selectedDay, 'roster-current': day.isToday }">
|
||||
<button v-if="getDaySegments(row, day.date).length" type="button" class="roster-cell"
|
||||
:aria-label="row.doctorName + ' ' + day.date + ' 排班详情'" @click="openDayDialog(row, day.date)">
|
||||
<span v-for="seg in getDaySegments(row, day.date)" :key="seg.id" class="roster-shift"
|
||||
:class="'roster-status-' + seg.status" :title="formatSegmentLine(seg)">
|
||||
<strong>{{ seg.start_time.slice(0, 5) }}–{{ seg.end_time.slice(0, 5) }}</strong>
|
||||
<span class="roster-shift-info">
|
||||
<span>{{ seg.status === 1 && seg.shift_type === 'night' ? '夜班' : statusText(seg.status) }}</span>
|
||||
<span v-if="seg.status === 1 && previewReadonly" class="roster-quota">已占 {{ seg.booked_count || 0 }}/{{ capacity(seg) }}</span>
|
||||
<span v-else-if="seg.status === 1 && seg.quota > 0" class="roster-quota">{{ seg.quota }} 号</span>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
<span v-else-if="previewReadonly" class="roster-unplanned">未排班</span>
|
||||
<button v-else class="roster-add" type="button" @click="openDayDialog(row, day.date)"
|
||||
:aria-label="'管理' + row.doctorName + ' ' + day.date + '排班'">+ 排班</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-if="!loading && !filteredTableData.length" class="roster-no-result">
|
||||
{{ searchName ? '没有找到匹配的医生' : '暂无医生' }}
|
||||
<el-button v-if="searchName" type="primary" link @click="searchName = ''">清除筛选</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="roster-guide"><InfoFilled aria-hidden="true" />{{ previewReadonly
|
||||
? '点击已有时段可查看排班详情;未排班表示当天未设置出诊时段。'
|
||||
: '点击日期格管理出诊时段。同一天可设置多段;号源上限为 0 时按间隔自动计算。' }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<el-card v-else shadow="never">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-lg font-medium">医生排班管理</span>
|
||||
<div>
|
||||
<el-button type="success" @click="showBatchDialog">批量排班</el-button>
|
||||
<el-button v-if="!previewReadonly" type="success" @click="showBatchDialog">批量排班</el-button>
|
||||
<el-button @click="prevWeek">上一周</el-button>
|
||||
<el-button @click="nextWeek">下一周</el-button>
|
||||
<el-button type="primary" @click="goToday">本周</el-button>
|
||||
@@ -37,11 +116,12 @@
|
||||
<el-table-column v-for="day in weekDays" :key="day.date" :label="day.label" min-width="168">
|
||||
<template #default="{ row }">
|
||||
<div
|
||||
class="day-cell rounded border border-dashed border-gray-200 p-1 min-h-[56px] cursor-pointer hover:bg-gray-50"
|
||||
class="day-cell rounded border border-dashed border-gray-200 p-1 min-h-[56px]"
|
||||
:class="{ 'cursor-pointer hover:bg-gray-50': !previewReadonly || getDaySegments(row, day.date).length }"
|
||||
@click="openDayDialog(row, day.date)"
|
||||
>
|
||||
<template v-if="getDaySegments(row, day.date).length === 0">
|
||||
<div class="text-xs text-gray-400 text-center py-2">点击管理</div>
|
||||
<div class="text-xs text-gray-400 text-center py-2">{{ previewReadonly ? '未排班' : '点击管理' }}</div>
|
||||
</template>
|
||||
<div v-else class="space-y-1">
|
||||
<div
|
||||
@@ -60,7 +140,7 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 某日排班列表 -->
|
||||
<el-dialog v-model="dayDialogVisible" :title="dayDialogTitle" width="720px" destroy-on-close>
|
||||
<el-dialog v-model="dayDialogVisible" :title="dayDialogTitle" width="min(720px, 94vw)" destroy-on-close>
|
||||
<el-table :data="dayDialogSegments" border size="small" max-height="360">
|
||||
<el-table-column label="时间" width="150">
|
||||
<template #default="{ row }">{{ row.start_time }} - {{ row.end_time }}</template>
|
||||
@@ -74,11 +154,14 @@
|
||||
<el-table-column label="间隔" width="72">
|
||||
<template #default="{ row }">{{ row.slot_minutes || 15 }} 分</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="号源" width="72">
|
||||
<el-table-column v-if="previewReadonly && isArt" label="已占 / 号源" width="100">
|
||||
<template #default="{ row }">{{ row.status === 1 ? (row.booked_count || 0) + ' / ' + capacity(row) : '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else label="号源" width="72">
|
||||
<template #default="{ row }">{{ row.status === 1 ? row.quota || '不限' : '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" prop="remark" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="140" fixed="right">
|
||||
<el-table-column v-if="!previewReadonly" label="操作" width="140" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="openSegmentForm(row)">编辑</el-button>
|
||||
<el-button type="danger" link @click="removeSegment(row)">删除</el-button>
|
||||
@@ -87,12 +170,12 @@
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="dayDialogVisible = false">关闭</el-button>
|
||||
<el-button type="primary" @click="openSegmentForm()">添加时段</el-button>
|
||||
<el-button v-if="!previewReadonly" type="primary" @click="openSegmentForm()">添加时段</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 单段排班表单 -->
|
||||
<el-dialog v-model="segmentDialogVisible" :title="segmentForm.id ? '编辑时段' : '添加时段'" width="520px" destroy-on-close>
|
||||
<el-dialog v-if="!previewReadonly" v-model="segmentDialogVisible" :title="segmentForm.id ? '编辑时段' : '添加时段'" width="520px" destroy-on-close>
|
||||
<el-form :model="segmentForm" label-width="110px">
|
||||
<el-form-item label="接诊时间" required>
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
@@ -151,7 +234,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 批量排班 -->
|
||||
<el-dialog v-model="batchDialogVisible" title="批量排班" width="780px" destroy-on-close>
|
||||
<el-dialog v-if="!previewReadonly" v-model="batchDialogVisible" title="批量排班" width="780px" destroy-on-close>
|
||||
<el-form :model="batchForm" label-width="100px">
|
||||
<el-form-item label="选择医生" required>
|
||||
<el-select v-model="batchForm.doctorIds" multiple placeholder="请选择医生" class="w-full" filterable>
|
||||
@@ -228,6 +311,9 @@
|
||||
|
||||
<script setup lang="ts" name="doctorRoster">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ArrowLeft, ArrowRight, Calendar, InfoFilled, Search } from '@element-plus/icons-vue'
|
||||
import { useAdminAppearanceStore } from '@/stores/modules/setting'
|
||||
import dayjs from 'dayjs'
|
||||
import isoWeek from 'dayjs/plugin/isoWeek'
|
||||
import feedback from '@/utils/feedback'
|
||||
@@ -241,6 +327,7 @@ interface RosterSegment {
|
||||
status: number
|
||||
quota: number
|
||||
max_patients?: number
|
||||
booked_count?: number
|
||||
start_time: string
|
||||
end_time: string
|
||||
shift_type?: string | null
|
||||
@@ -252,12 +339,24 @@ interface RosterSegment {
|
||||
interface DoctorRow {
|
||||
doctorId: number
|
||||
doctorName: string
|
||||
departmentName?: string
|
||||
/** date -> segments */
|
||||
rostersByDate: Record<string, RosterSegment[]>
|
||||
}
|
||||
|
||||
const searchName = ref('')
|
||||
const currentWeekStart = ref(dayjs().startOf('isoWeek'))
|
||||
const previewReadonly = import.meta.env.MODE === 'local-preview'
|
||||
const appearance = useAdminAppearanceStore()
|
||||
const isArt = computed(() => appearance.mode === 'v2')
|
||||
const route = useRoute()
|
||||
// The layout keys views by fullPath, so each incoming appointment link gets its own initial view.
|
||||
const linkedDate = previewReadonly && typeof route.query.date === 'string' ? route.query.date : ''
|
||||
const initialDate = /^\d{4}-\d{2}-\d{2}$/.test(linkedDate) && dayjs(linkedDate).format('YYYY-MM-DD') === linkedDate
|
||||
? dayjs(linkedDate) : dayjs()
|
||||
const linkedDoctorId = previewReadonly ? Number(route.query.doctor_id) : 0
|
||||
const currentWeekStart = ref(initialDate.startOf('isoWeek'))
|
||||
const selectedDay = ref(initialDate.isoWeekday() - 1)
|
||||
const today = dayjs().format('YYYY-MM-DD')
|
||||
const loading = ref(false)
|
||||
|
||||
const dayDialogVisible = ref(false)
|
||||
@@ -314,6 +413,9 @@ const filteredTableData = computed(() => {
|
||||
return tableData.value.filter((r) => r.doctorName.includes(q))
|
||||
})
|
||||
|
||||
const visibleSegments = computed(() => filteredTableData.value.reduce((count, doctor) =>
|
||||
count + weekDays.value.reduce((n, day) => n + getDaySegments(doctor, day.date).length, 0), 0))
|
||||
|
||||
const dayDialogTitle = computed(() => {
|
||||
if (!dayDialogDoctor.value || !dayDialogDate.value) return '当日排班'
|
||||
return `${dayDialogDoctor.value.doctorName} · ${dayDialogDate.value}`
|
||||
@@ -326,6 +428,9 @@ const weekDays = computed(() => {
|
||||
const date = currentWeekStart.value.add(i, 'day')
|
||||
days.push({
|
||||
date: date.format('YYYY-MM-DD'),
|
||||
weekday: labels[i],
|
||||
monthDay: date.format('MM/DD'),
|
||||
isToday: date.format('YYYY-MM-DD') === today,
|
||||
label: `${labels[i]} ${date.format('MM-DD')}`
|
||||
})
|
||||
}
|
||||
@@ -367,6 +472,14 @@ function formatSegmentLine(seg: RosterSegment) {
|
||||
return `${t}${shPart} ${statusText(seg.status)}`
|
||||
}
|
||||
|
||||
// RosterSegmentService generates start times on [start, end), then applies the optional quota.
|
||||
function capacity(seg: RosterSegment): number {
|
||||
const minutes = (time: string) => Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5))
|
||||
const interval = seg.slot_minutes && seg.slot_minutes >= 5 ? Math.min(seg.slot_minutes, 120) : 15
|
||||
const count = Math.max(0, Math.ceil((minutes(seg.end_time) - minutes(seg.start_time)) / interval))
|
||||
return seg.quota > 0 ? Math.min(count, seg.quota) : count
|
||||
}
|
||||
|
||||
function getDaySegments(row: DoctorRow, date: string): RosterSegment[] {
|
||||
return row.rostersByDate[date] || []
|
||||
}
|
||||
@@ -381,6 +494,7 @@ function refreshDayDialogList() {
|
||||
}
|
||||
|
||||
function openDayDialog(row: DoctorRow, date: string) {
|
||||
if (previewReadonly && !getDaySegments(row, date).length) return
|
||||
dayDialogDoctor.value = row
|
||||
dayDialogDate.value = date
|
||||
refreshDayDialogList()
|
||||
@@ -388,6 +502,7 @@ function openDayDialog(row: DoctorRow, date: string) {
|
||||
}
|
||||
|
||||
function openSegmentForm(existing?: RosterSegment) {
|
||||
if (previewReadonly) return
|
||||
if (!dayDialogDoctor.value || !dayDialogDate.value) {
|
||||
feedback.msgWarning('请先选择日期格子')
|
||||
return
|
||||
@@ -425,6 +540,7 @@ function openSegmentForm(existing?: RosterSegment) {
|
||||
}
|
||||
|
||||
async function saveSegment() {
|
||||
if (previewReadonly) return
|
||||
const f = segmentForm.value
|
||||
if (!f.start_time || !f.end_time) {
|
||||
feedback.msgWarning('请填写接诊开始与结束时间')
|
||||
@@ -473,6 +589,7 @@ async function saveSegment() {
|
||||
}
|
||||
|
||||
async function removeSegment(row: RosterSegment) {
|
||||
if (previewReadonly) return
|
||||
try {
|
||||
await ElMessageBox.confirm('确定删除该时段?', '提示', { type: 'warning' })
|
||||
} catch {
|
||||
@@ -495,10 +612,15 @@ const loadDoctors = async () => {
|
||||
page_size: 1000
|
||||
})
|
||||
tableData.value = (res?.lists || []).map((doctor: any) => ({
|
||||
doctorId: doctor.id,
|
||||
doctorId: Number(doctor.id),
|
||||
departmentName: doctor.dept_name || doctor.department || '',
|
||||
doctorName: doctor.name || doctor.account,
|
||||
rostersByDate: {} as Record<string, RosterSegment[]>
|
||||
}))
|
||||
if (linkedDoctorId > 0) {
|
||||
const doctor = tableData.value.find(row => row.doctorId === linkedDoctorId)
|
||||
if (doctor) searchName.value = doctor.doctorName
|
||||
}
|
||||
await loadRosterData()
|
||||
} catch (error) {
|
||||
console.error('加载医生列表失败:', error)
|
||||
@@ -506,7 +628,9 @@ const loadDoctors = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
let rosterRequest = 0
|
||||
const loadRosterData = async () => {
|
||||
const request = ++rosterRequest
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
@@ -514,34 +638,34 @@ const loadRosterData = async () => {
|
||||
end_date: currentWeekStart.value.add(6, 'day').format('YYYY-MM-DD')
|
||||
}
|
||||
const res = await rosterLists(params)
|
||||
const rosters = res?.lists || []
|
||||
|
||||
tableData.value.forEach((doctor) => {
|
||||
doctor.rostersByDate = {}
|
||||
rosters.forEach((roster: any) => {
|
||||
if (roster.doctor_id !== doctor.doctorId) return
|
||||
const d = roster.date
|
||||
if (!doctor.rostersByDate[d]) doctor.rostersByDate[d] = []
|
||||
doctor.rostersByDate[d].push({
|
||||
id: roster.id,
|
||||
status: roster.status,
|
||||
quota: roster.quota || 0,
|
||||
max_patients: roster.max_patients,
|
||||
start_time: roster.start_time || legacyStart(roster.period),
|
||||
end_time: roster.end_time || legacyEnd(roster.period),
|
||||
shift_type: roster.shift_type,
|
||||
slot_minutes: roster.slot_minutes ?? 15,
|
||||
remark: roster.remark,
|
||||
period: roster.period
|
||||
})
|
||||
if (request !== rosterRequest) return
|
||||
const doctors = new Map(tableData.value.map(doctor => [doctor.doctorId, doctor]))
|
||||
for (const doctor of doctors.values()) doctor.rostersByDate = {}
|
||||
for (const roster of res?.lists || []) {
|
||||
const doctor = doctors.get(Number(roster.doctor_id))
|
||||
if (!doctor) continue
|
||||
const segments = (doctor.rostersByDate[roster.date] ||= [])
|
||||
segments.push({
|
||||
id: roster.id,
|
||||
status: Number(roster.status),
|
||||
quota: Number(roster.quota || 0),
|
||||
max_patients: roster.max_patients,
|
||||
booked_count: Number(roster.booked_count || 0),
|
||||
start_time: roster.start_time || legacyStart(roster.period),
|
||||
end_time: roster.end_time || legacyEnd(roster.period),
|
||||
shift_type: roster.shift_type,
|
||||
slot_minutes: roster.slot_minutes ?? 15,
|
||||
remark: roster.remark,
|
||||
period: roster.period
|
||||
})
|
||||
})
|
||||
}
|
||||
refreshDayDialogList()
|
||||
} catch (error) {
|
||||
if (request !== rosterRequest) return
|
||||
console.error('加载排班数据失败:', error)
|
||||
feedback.msgError('加载排班数据失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
if (request === rosterRequest) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,11 +698,13 @@ const nextWeek = () => {
|
||||
}
|
||||
|
||||
const goToday = () => {
|
||||
selectedDay.value = dayjs().isoWeekday() - 1
|
||||
currentWeekStart.value = dayjs().startOf('isoWeek')
|
||||
loadRosterData()
|
||||
}
|
||||
|
||||
const showBatchDialog = () => {
|
||||
if (previewReadonly) return
|
||||
batchForm.value = {
|
||||
doctorIds: [],
|
||||
dateRange: [],
|
||||
@@ -616,6 +742,7 @@ const batchRemoveSegment = (idx: number) => {
|
||||
}
|
||||
|
||||
const handleBatchSave = async () => {
|
||||
if (previewReadonly) return
|
||||
if (batchForm.value.doctorIds.length === 0) {
|
||||
feedback.msgWarning('请选择医生')
|
||||
return
|
||||
@@ -698,4 +825,98 @@ onMounted(() => {
|
||||
.doctor-roster {
|
||||
min-height: 100vh;
|
||||
}
|
||||
/* The Art markup is mounted only for that profile. Status tints mix with the
|
||||
active surface so dark mode and the user's accent stay live. */
|
||||
.roster-art {
|
||||
--r-line: var(--zyt-border);
|
||||
--r-active: var(--zyt-accent, #5d87ff);
|
||||
--r-active-bg: color-mix(in srgb, var(--r-active) 9%, var(--zyt-surface));
|
||||
--r-active-text: color-mix(in srgb, var(--r-active) 52%, var(--zyt-ink));
|
||||
min-width: 0;
|
||||
color: var(--zyt-ink);
|
||||
}
|
||||
.roster-head, .roster-heading, .roster-toolbar, .roster-week, .roster-switch,
|
||||
.roster-guide, .roster-shift-info { display: flex; align-items: center; }
|
||||
.roster-head { justify-content: space-between; gap: 14px; margin: 2px 0 16px; }
|
||||
.roster-heading { gap: 12px; }
|
||||
.roster-icon {
|
||||
display: grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: 12px;
|
||||
color: var(--r-active); background: var(--r-active-bg); border: 1px solid var(--zyt-accent-border);
|
||||
}
|
||||
.roster-icon svg { width: 23px; }
|
||||
.roster-head h1 { margin: 0 0 3px; font-size: 22px; line-height: 1.3; font-weight: 650; }
|
||||
.roster-head p, .roster-guide { margin: 0; font-size: 12px; color: var(--zyt-text); }
|
||||
.roster-separator { padding-inline: 8px; color: var(--art-gray-500); }
|
||||
.roster-panel { background: var(--zyt-surface); border: 1px solid var(--zyt-card-border); border-radius: var(--zyt-radius); overflow: hidden; }
|
||||
.roster-toolbar { justify-content: space-between; flex-wrap: wrap; padding: 15px 18px; gap: 10px; }
|
||||
.roster-week { gap: 15px; flex-wrap: wrap; }
|
||||
.roster-week h2 { margin: 0; font-size: 17px; font-weight: 620; line-height: 1.4; font-variant-numeric: tabular-nums; }
|
||||
.roster-switch { border: 1px solid var(--r-line); border-radius: 7px; }
|
||||
.roster-switch button {
|
||||
display: grid; place-items: center; height: 30px; min-width: 29px; color: var(--zyt-text); border-radius: 6px;
|
||||
}
|
||||
.roster-switch button:hover { background: var(--zyt-surface-subtle); color: var(--r-active-text); }
|
||||
.roster-switch svg { width: 13px; height: 13px; }
|
||||
.roster-switch .roster-this-week { padding: 0 9px; border-radius: 0; border-inline: 1px solid var(--r-line); font-size: 12px; }
|
||||
.roster-filter { width: min(100%, 180px); }
|
||||
.roster-scroll { overflow-x: auto; max-width: 100%; }
|
||||
.roster-grid { width: 100%; min-width: 890px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
|
||||
.roster-grid th, .roster-grid td { border-top: 1px solid var(--r-line); text-align: left; }
|
||||
.roster-grid th + th, .roster-grid td { border-left: 1px solid var(--r-line); }
|
||||
.roster-grid thead th { background: var(--zyt-surface-subtle); padding: 12px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
|
||||
.roster-date { margin-left: 4px; font-size: 11px; font-weight: 450; font-variant-numeric: tabular-nums; color: var(--zyt-text); }
|
||||
.roster-grid thead th.roster-current { box-shadow: inset 0 2px var(--r-active); }
|
||||
.roster-current { background: color-mix(in srgb, var(--r-active) 3%, var(--zyt-surface)); }
|
||||
.roster-today {
|
||||
display: inline-grid; place-items: center; margin-left: 3px; width: 15px; height: 15px; line-height: 1;
|
||||
background: var(--zyt-accent-soft); color: var(--r-active-text); border-radius: 4px; font-size: 10px;
|
||||
}
|
||||
.roster-name-col { position: sticky; left: 0; z-index: 1; width: 116px; background: var(--zyt-surface); }
|
||||
.roster-grid th.roster-name-col { padding: 12px 10px 12px 14px; }
|
||||
.roster-grid tbody th { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
|
||||
.roster-name-col small { display: block; margin-top: 4px; color: var(--zyt-text); font-size: 11px; font-weight: 400; }
|
||||
.roster-grid td { padding: 6px 4px; vertical-align: middle; }
|
||||
.roster-cell { display: grid; gap: 4px; width: 100%; text-align: left; border-radius: 6px; }
|
||||
.roster-shift {
|
||||
--r-shift: var(--r-active);
|
||||
display: block; padding: 5px 4px 5px 7px; border-left: 3px solid var(--r-shift); border-radius: 4px;
|
||||
background: color-mix(in srgb, var(--r-shift) 9%, var(--zyt-surface)); color: var(--zyt-ink);
|
||||
}
|
||||
.roster-cell:hover .roster-shift { background: color-mix(in srgb, var(--r-shift) 16%, var(--zyt-surface)); }
|
||||
.roster-status-2 { --r-shift: #cb7d32; }
|
||||
.roster-status-3 { --r-shift: var(--art-gray-500); }
|
||||
.roster-status-4 { --r-shift: #ab7ec5; }
|
||||
.roster-shift strong { display: block; font-size: 12px; font-weight: 610; line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.roster-shift-info { flex-wrap: wrap; gap: 0 4px; justify-content: space-between; font-size: 11px; line-height: 1.5; color: var(--zyt-text); }
|
||||
.roster-quota { font-variant-numeric: tabular-nums; }
|
||||
.roster-unplanned, .roster-add { display: block; width: 100%; padding: 8px 0; text-align: center; color: var(--zyt-muted); font-size: 11px; }
|
||||
.roster-add:hover { color: var(--r-active-text); background: var(--r-active-bg); border-radius: 5px; }
|
||||
.roster-guide { border-top: 1px solid var(--r-line); padding: 11px 16px; gap: 7px; line-height: 1.55; }
|
||||
.roster-guide svg { width: 14px; height: 14px; flex: none; color: var(--r-active-text); }
|
||||
.roster-no-result { padding: 26px 12px; text-align: center; color: var(--zyt-text); }
|
||||
.roster-day-nav { display: none; }
|
||||
@media (max-width: 760px) {
|
||||
/* One selected date at a time: no panning a seven-column table on a phone. */
|
||||
.roster-day-nav { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; padding: 0 10px 12px; }
|
||||
.roster-day-nav button { padding-block: 5px; min-width: 0; border-radius: 6px; color: var(--zyt-text); font-size: 11px; }
|
||||
.roster-day-nav b { display: block; color: var(--zyt-ink); font-size: 12px; font-weight: 590; }
|
||||
.roster-day-nav button[aria-pressed="true"] { background: var(--r-active-bg); box-shadow: inset 0 0 0 1px var(--zyt-accent-border); }
|
||||
.roster-day-nav button[aria-pressed="true"] b { color: var(--r-active-text); }
|
||||
.roster-grid { min-width: 0; }
|
||||
.roster-grid :is(th,td):not(.roster-name-col, .roster-selected) { display: none; }
|
||||
.roster-grid .roster-name-col { width: 34%; }
|
||||
.roster-grid td { padding: 6px 8px; }
|
||||
.roster-cell { grid-template-columns: repeat(auto-fit, minmax(min(100%,95px), 1fr)); }
|
||||
.roster-shift { padding: 6px; }
|
||||
}
|
||||
@media (max-width: 550px) {
|
||||
.roster-head { margin-bottom: 12px; }
|
||||
.roster-head h1 { font-size: 20px; }
|
||||
.roster-toolbar { padding: 12px; }
|
||||
.roster-week { gap: 8px; width: 100%; justify-content: space-between; }
|
||||
.roster-week h2 { font-size: 14px; }
|
||||
.roster-filter { width: 100%; }
|
||||
.roster-guide { align-items: flex-start; }
|
||||
.roster-guide svg { margin-top: 2px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -872,6 +872,7 @@ const actionsWidth = computed(() => appearance.adminUi === 'v2' &&
|
||||
!['edit', 'split', 'wxQrcode', 'pay', 'refund', 'cancel', 'delete', 'setExempt']
|
||||
.some(action => hasPermission(['order.order/' + action])) ? 82 : 340)
|
||||
|
||||
const previewPatient = import.meta.env.MODE === 'local-preview' ? useRoute().query.patient_keyword : undefined
|
||||
const queryParams = reactive({
|
||||
order_no: '',
|
||||
patient_keyword: '',
|
||||
@@ -1723,6 +1724,8 @@ const loadAssistantOptions = async () => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Apply the preview deep link after usePaging captures the empty reset defaults.
|
||||
if (typeof previewPatient === 'string') queryParams.patient_keyword = previewPatient
|
||||
loadAssistantOptions()
|
||||
getLists()
|
||||
fetchTodayRevenue()
|
||||
|
||||
Reference in New Issue
Block a user