feat(admin): 增加本人正式账号的独立只读预览入口

This commit is contained in:
2026-12-01 17:43:21 +08:00
parent ff55e1568e
commit d96152da09
22 changed files with 997 additions and 77 deletions
+21 -4
View File
@@ -3,7 +3,8 @@
<div class="flex-1 flex items-center justify-center">
<div class="login-card flex rounded-md overflow-hidden">
<div class="flex-1 h-full hidden md:inline-block">
<image-contain :src="config.login_image" :width="400" height="100%" />
<div v-if="liveReadonly" class="live-login-note"><strong>正式数据 · 只读预览</strong><p>这是本机运行的甄养堂管理后台。账号密码由浏览器直接通过 HTTPS 提交到正式后台,本机服务只提供页面文件。</p><code>admin.zhenyangtang.com.cn</code><p>仅支持已开通的账号密码登录。企业微信、统一登录、首次改密和账号绑定请在正式站点完成。</p><a href="https://admin.zhenyangtang.com.cn/admin/" target="_blank" rel="noopener noreferrer">打开正式后台 ↗</a></div>
<image-contain v-else :src="config.login_image" :width="400" height="100%" />
</div>
<div
class="login-form bg-body flex flex-col justify-center px-10 py-10 md:w-[420px] w-[380px] flex-none mx-auto"
@@ -29,6 +30,7 @@
<!-- 账号密码登录 -->
<template v-if="loginMode === 'account'">
<p v-if="liveReadonly" class="live-login-destination">正式账号登录 · 仅查询<br><span>密码直发 admin.zhenyangtang.com.cn,不经本机代理。</span></p>
<el-form ref="formRef" :model="formData" size="large" :rules="rules">
<el-form-item prop="account">
<el-input
@@ -63,7 +65,7 @@
v-model="formData.password"
show-password
placeholder="请输入密码"
@keyup.enter="handleLogin"
@keyup.enter="liveReadonly ? lockLogin() : handleLogin()"
>
<template #prepend>
<icon name="el-icon-Lock" size="16" />
@@ -71,7 +73,7 @@
</el-input>
</el-form-item>
</el-form>
<div class="mb-5">
<div v-if="!liveReadonly" class="mb-5">
<el-checkbox v-model="remAccount" label="记住账号"></el-checkbox>
</div>
<el-button type="primary" size="large" :loading="isLock" @click="lockLogin">
@@ -131,6 +133,7 @@ import useUserStore from '@/stores/modules/user'
import cache from '@/utils/cache'
import { getIamConfig, getWorkWechatConfig } from '@/api/user'
const liveReadonly = import.meta.env.MODE === 'live-readonly'
const passwordRef = shallowRef<InputInstance>()
const formRef = shallowRef<FormInstance>()
const appStore = useAppStore()
@@ -227,11 +230,20 @@ const handleEnter = () => {
if (!formData.password) {
return passwordRef.value?.focus()
}
handleLogin()
if (liveReadonly) void lockLogin()
else handleLogin()
}
const handleLogin = async () => {
await formRef.value?.validate()
if (liveReadonly) {
try {
await userStore.login({account: formData.account.trim(), password: formData.password})
await router.replace('/')
} catch (e) { ElMessage.error(e instanceof Error ? e.message : '登录未完成') }
finally { formData.password = '' }
return
}
const result: any = await userStore.login(formData)
const account = formData.account.trim()
const others = rememberedAccounts.value.filter((saved) => saved !== account)
@@ -337,6 +349,7 @@ function selectRememberedAccount(account: string) {
}
onMounted(async () => {
if (liveReadonly) return
// 恢复记住账号
const value = cache.get(ACCOUNT_KEY)
const saved: unknown[] = Array.isArray(value?.accounts) ? value.accounts : value?.remember ? [value.account] : []
@@ -501,3 +514,7 @@ onMounted(async () => {
}
}
</style>
<style scoped>
.live-login-note{width:330px;min-height:100%;padding:44px 32px;display:flex;flex-direction:column;justify-content:center;gap:17px;background:var(--el-color-primary-light-9);color:var(--el-text-color-regular);font-size:14px;line-height:1.75}.live-login-note strong{font-size:22px;color:var(--el-text-color-primary)}.live-login-note code,.live-login-note a{color:var(--el-color-primary)}.live-login-destination{font-size:14px;margin:0 0 18px}.live-login-destination span{font-size:12px;color:var(--el-text-color-secondary)}
</style>
+20 -12
View File
@@ -5,14 +5,14 @@
<h1>用户详情</h1>
<p>查看注册资料、账户余额与最近登录时间。</p>
</div>
<el-button @click="goBack">{{ isPreview ? '返回用户列表' : '返回' }}</el-button>
<el-button @click="goBack">{{ isLocalView ? '返回用户列表' : '返回' }}</el-button>
</header>
<el-card v-else class="!border-none" shadow="never">
<el-page-header content="用户详情" @back="goBack" />
</el-card>
<el-card v-if="loadFailed" class="!border-none" shadow="never">
<el-empty description="未能读取该用户的资料">
<el-button @click="goBack">{{ isPreview ? '返回用户列表' : '返回' }}</el-button>
<el-button @click="goBack">{{ isLocalView ? '返回用户列表' : '返回' }}</el-button>
</el-empty>
</el-card>
<el-card v-else v-loading="loading" class="mt-4 !border-none profile-card" header="基本资料" shadow="never">
@@ -33,7 +33,7 @@
<div class="mt-2 flex items-center">
¥{{ formData.user_money }}
<el-button
v-if="!isPreview"
v-if="!isLocalView"
v-perms="['user.user/adjustMoney']"
type="primary"
link
@@ -51,7 +51,7 @@
<el-form-item label="账号:">
{{ formData.account }}
<popover-input
v-if="!isPreview"
v-if="!isLocalView"
class="ml-[10px]"
@confirm="handleEdit($event, 'account')"
:limit="32"
@@ -65,7 +65,7 @@
<el-form-item label="真实姓名:">
{{ formData.real_name || '-' }}
<popover-input
v-if="!isPreview"
v-if="!isLocalView"
class="ml-[10px]"
@confirm="handleEdit($event, 'real_name')"
:limit="32"
@@ -79,7 +79,7 @@
<el-form-item label="性别:">
{{ formData.sex }}
<popover-input
v-if="!isPreview"
v-if="!isLocalView"
class="ml-[10px]"
type="select"
:options="[
@@ -107,7 +107,7 @@
<el-form-item label="联系电话:">
{{ formData.mobile || '-' }}
<popover-input
v-if="!isPreview"
v-if="!isLocalView"
class="ml-[10px]"
type="number"
@confirm="handleEdit($event, 'mobile')"
@@ -135,7 +135,7 @@
</div>
</el-card>
<account-adjust
v-if="!isPreview"
v-if="!isLocalView"
v-model:show="adjustState.show"
:value="adjustState.value"
@confirm="handleConfirmAdjust"
@@ -149,10 +149,13 @@ 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 { hasPermission } from '@/utils/perm'
import AccountAdjust from '../components/account-adjust.vue'
const isPreview = import.meta.env.MODE === 'local-preview'
const isLiveReadonly = import.meta.env.MODE === 'live-readonly'
const isLocalView = isPreview || isLiveReadonly
const settings = useSettingStore()
const isArt = computed(() => settings.adminUi === 'v2')
const route = useRoute()
@@ -161,7 +164,7 @@ 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')
if (isLocalView && window.history.state?.back !== '/members') return router.replace('/members')
router.back()
}
const formData = reactive({
@@ -185,6 +188,11 @@ const adjustState = reactive({
const formRef = shallowRef<FormInstance>()
const getDetails = async () => {
if (isLiveReadonly && (!hasPermission(['user.user/detail']) || typeof route.query.id !== 'string' ||
!/^[1-9]\d{0,14}$/.test(route.query.id))) {
loadFailed.value = true
return
}
loading.value = true
loadFailed.value = false
try {
@@ -201,7 +209,7 @@ const getDetails = async () => {
}
const handleEdit = async (value: string, field: string) => {
if (isPreview || isEmpty(value)) return
if (isLocalView || isEmpty(value)) return
await userEdit({
id: route.query.id,
field,
@@ -211,12 +219,12 @@ const handleEdit = async (value: string, field: string) => {
}
const handleAdjust = (value: string) => {
if (isPreview) return
if (isLocalView) return
adjustState.show = true
adjustState.value = value
}
const handleConfirmAdjust = async (value: any) => {
if (isPreview) return
if (isLocalView) return
await adjustMoney({ user_id: route.query.id, ...value })
adjustState.show = false
getDetails()
+7 -3
View File
@@ -35,7 +35,7 @@
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetFilters">重置</el-button>
<export-data
v-if="!isPreview"
v-if="!isLocalView"
class="ml-2.5"
:fetch-fun="getUserList"
:params="queryParams"
@@ -67,12 +67,12 @@
<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="158" />
<el-table-column label="操作" :width="isArt ? 82 : 120" fixed="right">
<el-table-column v-if="canViewDetail" label="操作" :width="isArt ? 82 : 120" fixed="right">
<template #default="{ row }">
<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 } }"
:to="{ path: isLocalView ? '/members/detail' : getRoutePath('user.user/detail'), query: { id: row.id } }"
>详情</router-link>
</template>
</el-table-column>
@@ -93,10 +93,14 @@ import { getUserList } from '@/api/consumer'
import { ClientMap } from '@/enums/appEnums'
import { usePaging } from '@/hooks/usePaging'
import { getRoutePath } from '@/router'
import { hasPermission } from '@/utils/perm'
import useSettingStore from '@/stores/modules/setting'
defineOptions({ name: 'consumerLists' })
const isPreview = import.meta.env.MODE === 'local-preview'
const isLiveReadonly = import.meta.env.MODE === 'live-readonly'
const isLocalView = isPreview || isLiveReadonly
const canViewDetail = computed(() => !isLiveReadonly || hasPermission(['user.user/detail']))
const settings = useSettingStore()
const isArt = computed(() => settings.adminUi === 'v2')
const queryParams = reactive({
+55 -27
View File
@@ -1,5 +1,6 @@
<template>
<div class="doctor-roster" :class="{ 'p-4': !isArt }">
<el-alert v-if="isLiveReadonly && rosterError" :title="rosterError" type="error" :closable="false" />
<section v-if="isArt" class="roster-art" aria-labelledby="roster-title">
<header class="roster-head">
<div class="roster-heading">
@@ -9,7 +10,7 @@
<p>{{ filteredTableData.length }} 位医生<span class="roster-separator">/</span>{{ visibleSegments }} 段排班</p>
</div>
</div>
<el-button v-if="!previewReadonly" type="primary" @click="showBatchDialog">批量排班</el-button>
<el-button v-if="!isReadOnly" type="primary" @click="showBatchDialog">批量排班</el-button>
</header>
<div class="roster-panel">
@@ -22,7 +23,10 @@
<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"
<el-select v-if="isLiveReadonly" v-model="activeDoctorId" class="roster-filter" placeholder="选择医生" aria-label="选择医生" filterable @change="loadRosterData">
<el-option v-for="doctor in tableData" :key="doctor.doctorId" :label="doctor.doctorName" :value="doctor.doctorId" />
</el-select>
<el-input v-else v-model="searchName" class="roster-filter" data-testid="roster-doctor-filter"
placeholder="搜索医生姓名" aria-label="搜索医生姓名" :prefix-icon="Search" clearable />
</div>
@@ -57,24 +61,24 @@
<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-if="seg.status === 1 && isPreview" 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>
<span v-else-if="isReadOnly" 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">
<div v-if="!loading && !rosterError && !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
<p class="roster-guide"><InfoFilled aria-hidden="true" />{{ isReadOnly
? '点击已有时段可查看排班详情;未排班表示当天未设置出诊时段。'
: '点击日期格管理出诊时段。同一天可设置多段;号源上限为 0 时按间隔自动计算。' }}</p>
</div>
@@ -84,7 +88,7 @@
<div class="flex justify-between items-center">
<span class="text-lg font-medium">医生排班管理</span>
<div>
<el-button v-if="!previewReadonly" type="success" @click="showBatchDialog">批量排班</el-button>
<el-button v-if="!isReadOnly" 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>
@@ -95,7 +99,10 @@
<div class="mb-4">
<el-form inline>
<el-form-item label="医生">
<el-input v-model="searchName" placeholder="请输入医生姓名" clearable style="width: 200px" />
<el-select v-if="isLiveReadonly" v-model="activeDoctorId" class="roster-filter" placeholder="选择医生" aria-label="选择医生" filterable @change="loadRosterData">
<el-option v-for="doctor in tableData" :key="doctor.doctorId" :label="doctor.doctorName" :value="doctor.doctorId" />
</el-select>
<el-input v-else v-model="searchName" placeholder="请输入医生姓名" clearable style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="loadData">查询</el-button>
@@ -117,11 +124,11 @@
<template #default="{ row }">
<div
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 }"
:class="{ 'cursor-pointer hover:bg-gray-50': !isReadOnly || 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">{{ previewReadonly ? '未排班' : '点击管理' }}</div>
<div class="text-xs text-gray-400 text-center py-2">{{ isReadOnly ? '未排班' : '点击管理' }}</div>
</template>
<div v-else class="space-y-1">
<div
@@ -154,14 +161,14 @@
<el-table-column label="间隔" width="72">
<template #default="{ row }">{{ row.slot_minutes || 15 }} 分</template>
</el-table-column>
<el-table-column v-if="previewReadonly && isArt" label="已占 / 号源" width="100">
<el-table-column v-if="isPreview && 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 v-if="!previewReadonly" label="操作" width="140" fixed="right">
<el-table-column v-if="!isReadOnly" 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>
@@ -170,12 +177,12 @@
</el-table>
<template #footer>
<el-button @click="dayDialogVisible = false">关闭</el-button>
<el-button v-if="!previewReadonly" type="primary" @click="openSegmentForm()">添加时段</el-button>
<el-button v-if="!isReadOnly" type="primary" @click="openSegmentForm()">添加时段</el-button>
</template>
</el-dialog>
<!-- 单段排班表单 -->
<el-dialog v-if="!previewReadonly" v-model="segmentDialogVisible" :title="segmentForm.id ? '编辑时段' : '添加时段'" width="520px" destroy-on-close>
<el-dialog v-if="!isReadOnly" 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">
@@ -234,7 +241,7 @@
</el-dialog>
<!-- 批量排班 -->
<el-dialog v-if="!previewReadonly" v-model="batchDialogVisible" title="批量排班" width="780px" destroy-on-close>
<el-dialog v-if="!isReadOnly" 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>
@@ -345,15 +352,19 @@ interface DoctorRow {
}
const searchName = ref('')
const previewReadonly = import.meta.env.MODE === 'local-preview'
const isPreview = import.meta.env.MODE === 'local-preview'
const isLiveReadonly = import.meta.env.MODE === 'live-readonly'
const isReadOnly = isPreview || isLiveReadonly
const activeDoctorId = ref<number>()
const rosterError = ref('')
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 linkedDate = isPreview && 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 linkedDoctorId = isPreview ? 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')
@@ -408,6 +419,9 @@ const batchForm = ref({
const tableData = ref<DoctorRow[]>([])
const filteredTableData = computed(() => {
if (isLiveReadonly) {
return rosterError.value || loading.value ? [] : tableData.value.filter(row => row.doctorId === activeDoctorId.value)
}
const q = searchName.value.trim()
if (!q) return tableData.value
return tableData.value.filter((r) => r.doctorName.includes(q))
@@ -494,7 +508,7 @@ function refreshDayDialogList() {
}
function openDayDialog(row: DoctorRow, date: string) {
if (previewReadonly && !getDaySegments(row, date).length) return
if (isReadOnly && !getDaySegments(row, date).length) return
dayDialogDoctor.value = row
dayDialogDate.value = date
refreshDayDialogList()
@@ -502,7 +516,7 @@ function openDayDialog(row: DoctorRow, date: string) {
}
function openSegmentForm(existing?: RosterSegment) {
if (previewReadonly) return
if (isReadOnly) return
if (!dayDialogDoctor.value || !dayDialogDate.value) {
feedback.msgWarning('请先选择日期格子')
return
@@ -540,7 +554,7 @@ function openSegmentForm(existing?: RosterSegment) {
}
async function saveSegment() {
if (previewReadonly) return
if (isReadOnly) return
const f = segmentForm.value
if (!f.start_time || !f.end_time) {
feedback.msgWarning('请填写接诊开始与结束时间')
@@ -589,7 +603,7 @@ async function saveSegment() {
}
async function removeSegment(row: RosterSegment) {
if (previewReadonly) return
if (isReadOnly) return
try {
await ElMessageBox.confirm('确定删除该时段?', '提示', { type: 'warning' })
} catch {
@@ -609,7 +623,8 @@ const loadDoctors = async () => {
try {
const res = await doctorLists({
page_no: 1,
page_size: 1000
page_size: isLiveReadonly ? 100 : 1000,
...(isLiveReadonly ? { apply_data_scope: 1 } : {})
})
tableData.value = (res?.lists || []).map((doctor: any) => ({
doctorId: Number(doctor.id),
@@ -617,12 +632,17 @@ const loadDoctors = async () => {
doctorName: doctor.name || doctor.account,
rostersByDate: {} as Record<string, RosterSegment[]>
}))
if (isLiveReadonly) {
tableData.value = tableData.value.filter(row => Number.isSafeInteger(row.doctorId) && row.doctorId > 0)
activeDoctorId.value = tableData.value[0]?.doctorId
}
if (linkedDoctorId > 0) {
const doctor = tableData.value.find(row => row.doctorId === linkedDoctorId)
if (doctor) searchName.value = doctor.doctorName
}
await loadRosterData()
} catch (error) {
if (isLiveReadonly) rosterError.value = '未能读取当前账号可查看的医生名单'
console.error('加载医生列表失败:', error)
feedback.msgError('加载医生列表失败')
}
@@ -631,15 +651,22 @@ const loadDoctors = async () => {
let rosterRequest = 0
const loadRosterData = async () => {
const request = ++rosterRequest
const activeDoctor = isLiveReadonly ? tableData.value.find(row => row.doctorId === activeDoctorId.value) : undefined
if (isLiveReadonly) {
dayDialogVisible.value = false
if (!activeDoctor) { loading.value = false; return }
rosterError.value = ''
}
loading.value = true
try {
const params = {
start_date: currentWeekStart.value.format('YYYY-MM-DD'),
end_date: currentWeekStart.value.add(6, 'day').format('YYYY-MM-DD')
end_date: currentWeekStart.value.add(6, 'day').format('YYYY-MM-DD'),
...(activeDoctor ? { doctor_id: activeDoctor.doctorId } : {})
}
const res = await rosterLists(params)
if (request !== rosterRequest) return
const doctors = new Map(tableData.value.map(doctor => [doctor.doctorId, doctor]))
const doctors = new Map((activeDoctor ? [activeDoctor] : 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))
@@ -662,6 +689,7 @@ const loadRosterData = async () => {
refreshDayDialogList()
} catch (error) {
if (request !== rosterRequest) return
if (isLiveReadonly) rosterError.value = '未能读取所选医生本周的排班'
console.error('加载排班数据失败:', error)
feedback.msgError('加载排班数据失败')
} finally {
@@ -704,7 +732,7 @@ const goToday = () => {
}
const showBatchDialog = () => {
if (previewReadonly) return
if (isReadOnly) return
batchForm.value = {
doctorIds: [],
dateRange: [],
@@ -742,7 +770,7 @@ const batchRemoveSegment = (idx: number) => {
}
const handleBatchSave = async () => {
if (previewReadonly) return
if (isReadOnly) return
if (batchForm.value.doctorIds.length === 0) {
feedback.msgWarning('请选择医生')
return
+48 -17
View File
@@ -27,7 +27,7 @@
/>
</el-form-item>
<el-form-item class="w-[280px]" label="医助">
<el-form-item v-if="canReadAssistants" class="w-[280px]" label="医助">
<el-select
v-model="queryParams.assistant_id"
placeholder="全部医助"
@@ -80,12 +80,14 @@
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
<el-button
v-if="!isLiveReadonly"
v-perms="['order.order/lists']"
@click="statsDialogVisible = true"
>
操作统计
</el-button>
<export-data
v-if="!isLiveReadonly"
v-perms="['order.order/export']"
class="ml-2.5"
:fetch-fun="orderExport"
@@ -93,6 +95,7 @@
:page-size="pager.size"
/>
<el-button
v-if="!isLiveReadonly"
v-perms="['order.order/create']"
:type="appearance.adminUi === 'v2' ? 'default' : 'success'"
class="ml-2.5"
@@ -101,6 +104,7 @@
+ 创建支付单
</el-button>
<el-button
v-if="!isLiveReadonly"
v-perms="['order.order/alltongbu']"
:type="appearance.adminUi === 'v2' ? 'default' : 'warning'"
class="ml-2.5"
@@ -121,10 +125,11 @@
<el-tab-pane label="待关联" name="pending" />
<el-tab-pane label="已关联" name="associated" />
</el-tabs>
<div class="flex items-center gap-4 text-sm zyt-order-revenue">
<div v-if="canReadRevenue" class="flex items-center gap-4 text-sm zyt-order-revenue">
<span class="text-gray-500">今日收益:</span>
<span class="text-red-500 font-semibold text-lg">¥{{ todayRevenue.amount }}</span>
<span class="text-gray-400">({{ todayRevenue.count }} 笔)</span>
<span v-if="!isLiveReadonly || revenueReady" class="text-red-500 font-semibold text-lg">¥{{ todayRevenue.amount }}</span>
<span v-else>—</span>
<span v-if="!isLiveReadonly || revenueReady" class="text-gray-400">({{ todayRevenue.count }} 笔)</span>
</div>
</div>
</el-card>
@@ -135,7 +140,7 @@
<h2>订单明细</h2>
<span>共 {{ pager.count }} 条</span>
</div>
<div v-perms="['order.order/zhipai']" class="mb-3 flex items-center gap-3">
<div v-if="!isLiveReadonly" v-perms="['order.order/zhipai']" class="mb-3 flex items-center gap-3">
<el-button type="primary" :disabled="!selectedOrderIds.length" @click="openAssignDialog">
将创建人指给医助
</el-button>
@@ -151,7 +156,7 @@
size="large"
@selection-change="handleOrderSelectionChange"
>
<el-table-column type="selection" width="48" />
<el-table-column v-if="!isLiveReadonly" type="selection" width="48" />
<el-table-column label="订单号" prop="order_no" class-name="zyt-order-id" min-width="150" />
<el-table-column label="处方业务订单号" min-width="210">
@@ -221,7 +226,7 @@
</template>
</el-table-column>
<el-table-column label="操作" class-name="zyt-order-ops" label-class-name="zyt-order-ops" :width="actionsWidth" fixed="right">
<el-table-column v-if="!isLiveReadonly" label="操作" class-name="zyt-order-ops" label-class-name="zyt-order-ops" :width="actionsWidth" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['order.order/detail']"
@@ -309,7 +314,7 @@
</el-card>
<!-- 详情弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="detailVisible"
title="订单详情"
width="820px"
@@ -396,7 +401,7 @@
</el-dialog>
<!-- 按人操作统计(时间范围内) -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="statsDialogVisible"
title="支付单操作统计"
width="520px"
@@ -425,7 +430,7 @@
</el-table>
</el-dialog>
<el-dialog v-model="assignDialogVisible" title="变更创建人(医助)" width="440px" destroy-on-close>
<el-dialog v-if="!isLiveReadonly" v-model="assignDialogVisible" title="变更创建人(医助)" width="440px" destroy-on-close>
<p class="text-sm text-gray-600 mb-3">
将 {{ selectedOrderIds.length }} 条支付单的「创建人」改为所选医助,并写入各单操作日志。
</p>
@@ -451,7 +456,7 @@
</el-dialog>
<!-- 支付弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="payDialogVisible"
title="订单支付"
width="500px"
@@ -513,7 +518,7 @@
</el-dialog>
<!-- 创建订单弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="createDialogVisible"
title="创建订单"
width="600px"
@@ -635,7 +640,7 @@
</template>
</el-dialog>
<!-- 同步企业微信收款弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="syncDialogVisible"
title="同步企业微信对外收款"
width="420px"
@@ -668,7 +673,7 @@
</template>
</el-dialog>
<!-- 编辑订单弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="editOrderDialogVisible"
title="编辑订单"
width="480px"
@@ -737,7 +742,7 @@
<el-button type="primary" :loading="editOrderLoading" @click="submitEditOrder">保存</el-button>
</template>
</el-dialog>
<el-dialog v-model="splitDialogVisible" title="拆分订单" width="620px" destroy-on-close @closed="splitSource = null">
<el-dialog v-if="!isLiveReadonly" v-model="splitDialogVisible" title="拆分订单" width="620px" destroy-on-close @closed="splitSource = null">
<template v-if="splitSource">
<p class="text-sm text-gray-600 mb-3">
原订单号 <span class="font-mono">{{ splitSource.order_no }}</span>,金额
@@ -799,7 +804,7 @@
</template>
</el-dialog>
<!-- 小程序码弹窗 -->
<el-dialog
<el-dialog v-if="!isLiveReadonly"
v-model="qrcodeDialogVisible"
title="支付小程序码"
width="400px"
@@ -868,6 +873,9 @@ import feedback from '@/utils/feedback'
// A viewer with only the detail action does not need the full 340px sticky column.
const appearance = useSettingStore()
const isLiveReadonly = import.meta.env.MODE === 'live-readonly'
const canReadAssistants = computed(() => !isLiveReadonly || hasPermission(['tcm.diagnosis/getAssistants']))
const canReadRevenue = computed(() => !isLiveReadonly || hasPermission(['order.order/todayRevenue']))
const actionsWidth = computed(() => appearance.adminUi === 'v2' &&
!['edit', 'split', 'wxQrcode', 'pay', 'refund', 'cancel', 'delete', 'setExempt']
.some(action => hasPermission(['order.order/' + action])) ? 82 : 340)
@@ -899,6 +907,7 @@ const assignForm = reactive({
const patientAssociationTab = ref<'' | 'pending' | 'associated'>('')
const todayRevenue = ref({ amount: '0.00', count: 0 })
const revenueReady = ref(false)
const { pager, getLists, resetPage, resetParams } = usePaging({
fetchFun: orderLists,
@@ -919,6 +928,7 @@ const openAssignDialog = () => {
}
const submitBatchAssign = async () => {
if (isLiveReadonly) return
if (assignForm.assistant_id == null) {
feedback.msgWarning('请选择医助')
return
@@ -954,10 +964,14 @@ const handleTabChange = (name: string | number) => {
// 获取今日收益
const fetchTodayRevenue = async () => {
if (!canReadRevenue.value) return
try {
const res: any = await orderTodayRevenue()
todayRevenue.value = res?.data || res || { amount: '0.00', count: 0 }
const result = res?.data || res
revenueReady.value = result?.amount != null && result?.count != null
todayRevenue.value = result || { amount: '0.00', count: 0 }
} catch (e) {
revenueReady.value = false
todayRevenue.value = { amount: '0.00', count: 0 }
}
}
@@ -984,6 +998,7 @@ const statsDateRange = ref<[string, string] | null>(null)
const statsRangeText = ref('')
const loadOrderActionLogs = async () => {
if (isLiveReadonly) return
if (!currentOrderIdForLog.value) {
return
}
@@ -1015,6 +1030,7 @@ const onStatsDialogOpen = () => {
}
const fetchActionLogStats = async () => {
if (isLiveReadonly) return
statsLoading.value = true
try {
const params: { start_time?: string; end_time?: string } = {}
@@ -1109,6 +1125,7 @@ const editOrderRules = {
// 搜索患者
const searchPatients = async (query: string) => {
if (isLiveReadonly) return
if (!query) {
patientList.value = []
return
@@ -1182,6 +1199,7 @@ const handleSyncWechatWork = () => {
}
const handleSyncDebug = async () => {
if (isLiveReadonly) return
const range = syncDateRange.value
if (!range || range.length !== 2) {
feedback.msgError('请先选择时间范围')
@@ -1212,6 +1230,7 @@ const handleSyncDebug = async () => {
}
const submitSyncWechatWork = async () => {
if (isLiveReadonly) return
const range = syncDateRange.value
if (!range || range.length !== 2) {
feedback.msgError('请选择时间范围')
@@ -1239,6 +1258,7 @@ const submitSyncWechatWork = async () => {
// 提交创建订单
const submitCreateOrder = async () => {
if (isLiveReadonly) return
try {
await createFormRef.value?.validate()
@@ -1413,6 +1433,7 @@ const handleEditOrder = (row: any) => {
}
const searchPatientsForEdit = async (query: string) => {
if (isLiveReadonly) return
if (!query) {
editPatientList.value = []
return
@@ -1429,6 +1450,7 @@ const searchPatientsForEdit = async (query: string) => {
}
const submitEditOrder = async () => {
if (isLiveReadonly) return
if (!editOrderForm.value) return
try {
await editOrderFormRef.value?.validate()
@@ -1499,6 +1521,7 @@ const splitSumMatches = computed(() => {
})
const submitSplitOrder = async () => {
if (isLiveReadonly) return
if (!splitSource.value || !splitSumMatches.value) return
splitLoading.value = true
try {
@@ -1520,6 +1543,7 @@ const submitSplitOrder = async () => {
// 查看详情
const handleDetail = async (row: any) => {
if (isLiveReadonly) return
try {
const res = await orderDetail({ id: row.id })
detailData.value = res
@@ -1550,6 +1574,7 @@ const handlePay = (row: any) => {
// 确认支付
const confirmPay = async () => {
if (isLiveReadonly) return
try {
// 付呗待审核:直接标记已支付
if (payForm.value.fubeiPendingAudit) {
@@ -1632,6 +1657,7 @@ const confirmPay = async () => {
// 取消订单
const handleCancel = async (row: any) => {
if (isLiveReadonly) return
try {
await feedback.confirm('确定要取消该订单吗?')
await orderCancel({ id: row.id })
@@ -1644,6 +1670,7 @@ const handleCancel = async (row: any) => {
// 退款订单
const handleRefund = async (row: any) => {
if (isLiveReadonly) return
try {
await feedback.confirm('确定要退款该订单吗?')
await orderRefund({ id: row.id })
@@ -1656,6 +1683,7 @@ const handleRefund = async (row: any) => {
// 删除订单
const handleDelete = async (row: any) => {
if (isLiveReadonly) return
try {
await feedback.confirm('确定要删除该订单吗?此操作不可恢复')
await orderDelete({ id: row.id })
@@ -1667,6 +1695,7 @@ const handleDelete = async (row: any) => {
}
const handleToggleExempt = async (row: any) => {
if (isLiveReadonly) return
const newVal: 0 | 1 = row.is_exempt === 1 ? 0 : 1
const actionText = newVal === 1 ? '设为豁免' : '取消豁免'
try {
@@ -1686,6 +1715,7 @@ const qrcodeUrl = ref('')
const qrcodeOrderNo = ref('')
const handleOrderQrcode = async (row: any) => {
if (isLiveReadonly) return
if (!row.order_no) {
feedback.msgWarning('订单号不存在')
return
@@ -1715,6 +1745,7 @@ const handleOrderQrcodeRefresh = () => {
}
const loadAssistantOptions = async () => {
if (!canReadAssistants.value) return
try {
const list = await getAssistants()
assistantOptions.value = Array.isArray(list) ? list : []
+43 -14
View File
@@ -3,7 +3,7 @@
<header class="wb-hero">
<div class="wb-hero-text">
<h1 class="wb-hero-title">数据工作台</h1>
<p class="wb-hero-desc">医助诊单、订单营收与运营趋势一屏掌握</p>
<p class="wb-hero-desc">{{ isLiveReadonly ? '查看订单与诊单统计,仅展示接口返回的实际数据。' : '医助诊单、订单营收与运营趋势一屏掌握' }}</p>
</div>
<el-button type="primary" :icon="Refresh" round class="wb-refresh-btn" @click="refreshAll">
刷新全部
@@ -18,7 +18,7 @@
</span>
<div>
<div class="wb-section-name">订单统计</div>
<div class="wb-section-sub">{{ orderStatsDateRangeText }} · {{ orderStatsData.order_type_name || '—' }}</div>
<div v-if="!isLiveReadonly || orderReadState === 'ready'" class="wb-section-sub">{{ orderStatsDateRangeText }} · {{ orderStatsData.order_type_name || '—' }}</div>
</div>
</div>
<div class="wb-toolbar">
@@ -42,7 +42,10 @@
<el-button aria-label="刷新订单统计" :icon="Refresh" circle @click="loadOrderStats" />
</div>
</div>
<div class="wb-section-body">
<div v-if="isLiveReadonly && orderReadState !== 'ready'" class="wb-section-body" role="status">
{{ orderReadState === 'error' ? '订单统计读取失败,请重新刷新。' : '正在读取订单统计…' }}
</div>
<div v-else class="wb-section-body">
<el-row :gutter="16" class="wb-kpi-row">
<el-col :xs="24" :sm="8">
<div class="wb-kpi wb-kpi--violet">
@@ -97,7 +100,7 @@
<div class="wb-chart-card">
<div class="wb-chart-card-head">
<span class="wb-chart-title">开单人 · 单数排行</span>
<span class="wb-chart-hint">柱状 + 趋势</span>
<span class="wb-chart-hint">{{ isLiveReadonly ? '按开单人排名' : '柱状 + 趋势' }}</span>
</div>
<v-charts
v-if="orderStatsData.chart?.xAxis?.length"
@@ -196,7 +199,7 @@
</span>
<div>
<div class="wb-section-name">医助理诊单统计</div>
<div class="wb-section-sub">
<div v-if="!isLiveReadonly || diagnosisReadState === 'ready'" class="wb-section-sub">
{{ assistantStats.date_range?.[0] }} 至 {{ assistantStats.date_range?.[1] }}
</div>
</div>
@@ -211,7 +214,10 @@
<el-button aria-label="刷新诊单统计" :icon="Refresh" circle @click="loadAssistantStats" />
</div>
</div>
<div class="wb-section-body">
<div v-if="isLiveReadonly && diagnosisReadState !== 'ready'" class="wb-section-body" role="status">
{{ diagnosisReadState === 'error' ? '诊单统计读取失败,请重新刷新。' : '正在读取诊单统计…' }}
</div>
<div v-else class="wb-section-body">
<el-row :gutter="16" class="wb-kpi-row">
<el-col :xs="24" :sm="8" :lg="6">
<div class="wb-kpi wb-kpi--blue">
@@ -244,7 +250,7 @@
<div class="wb-chart-card">
<div class="wb-chart-card-head">
<span class="wb-chart-title">诊单量分布</span>
<span class="wb-chart-hint">柱状 + 趋势线</span>
<span class="wb-chart-hint">{{ isLiveReadonly ? '按医助排名' : '柱状 + 趋势线' }}</span>
</div>
<v-charts
v-if="assistantStats.chart.xAxis?.length"
@@ -313,7 +319,7 @@
<!-- 访问 & 销售趋势 -->
<section class="wb-section wb-section--trend">
<section v-if="!isLiveReadonly" class="wb-section wb-section--trend">
<div class="wb-section-head">
<div class="wb-section-title">
<span class="wb-section-icon wb-section-icon--teal">
@@ -377,6 +383,12 @@ import useSettingStore from '@/stores/modules/setting'
import { useComponentRef } from '@/utils/getExposeType'
import { calcColor } from '@/utils/util'
const isLiveReadonly = import.meta.env.MODE === 'live-readonly'
type ReadState = 'loading' | 'ready' | 'error'
const orderReadState = ref<ReadState>('loading')
const diagnosisReadState = ref<ReadState>('loading')
let orderRequest = 0
let diagnosisRequest = 0
const settingStore = useSettingStore()
const saleChart = useComponentRef(vCharts)
const visitorChart = useComponentRef(vCharts)
@@ -498,7 +510,7 @@ const assistantChartOption = computed(() => {
const lineData = (barSeries[0] as any)?.data || []
return {
color: [theme, trend],
legend: { data: ['诊单数', '趋势'], top: 4 },
legend: { data: isLiveReadonly ? ['诊单数'] : ['诊单数', '趋势'], top: 4 },
xAxis: {
type: 'category',
data: assistantStats.chart.xAxis || [],
@@ -512,7 +524,7 @@ const assistantChartOption = computed(() => {
},
tooltip: { trigger: 'axis' },
grid: { left: '2%', right: '2%', bottom: '12%', top: 48, containLabel: true },
series: [
series: isLiveReadonly ? barSeries : [
...barSeries,
{
name: '趋势',
@@ -529,8 +541,15 @@ const assistantChartOption = computed(() => {
})
const loadAssistantStats = () => {
const request = ++diagnosisRequest
if (isLiveReadonly) diagnosisReadState.value = 'loading'
assistantDiagnosisStats({ days: assistantStats.days })
.then((res: any) => {
if (isLiveReadonly) {
if (request !== diagnosisRequest) return
if (res?.today_total == null) throw new Error('缺少诊单统计')
diagnosisReadState.value = 'ready'
}
assistantStats.date_range = res.date_range
assistantStats.today_total = res.today_total ?? 0
assistantStats.today_ranking = res.today_ranking || []
@@ -538,7 +557,7 @@ const loadAssistantStats = () => {
assistantStats.ranking = res.ranking || []
assistantStats.chart = res.chart || { xAxis: [], series: [] }
})
.catch(() => {})
.catch(() => { if (isLiveReadonly && request === diagnosisRequest) diagnosisReadState.value = 'error' })
}
const orderStatsType = ref(-1)
@@ -614,6 +633,7 @@ const orderDeptAmountPieOption = computed(() => {
const orderStatsDateRangeText = computed(() => {
const arr = orderStatsData.date_range
if (arr?.length >= 2) return `${arr[0]} 至 ${arr[1]}`
if (isLiveReadonly) return '—'
const days = orderStatsDays.value
const end = new Date()
const start = new Date()
@@ -655,7 +675,7 @@ const orderChartOption = computed(() => {
const lineData = (barSeries[0] as any)?.data || []
return {
color: [theme, trend],
legend: { data: ['单数', '趋势'], top: 4 },
legend: { data: isLiveReadonly ? ['单数'] : ['单数', '趋势'], top: 4 },
xAxis: {
type: 'category',
data: orderStatsData.chart?.xAxis || [],
@@ -669,7 +689,7 @@ const orderChartOption = computed(() => {
},
tooltip: { trigger: 'axis' },
grid: { left: '2%', right: '2%', bottom: '12%', top: 48, containLabel: true },
series: [
series: isLiveReadonly ? barSeries : [
...barSeries,
{
name: '趋势',
@@ -686,8 +706,15 @@ const orderChartOption = computed(() => {
})
const loadOrderStats = () => {
const request = ++orderRequest
if (isLiveReadonly) orderReadState.value = 'loading'
orderStats({ order_type: orderStatsType.value, days: orderStatsDays.value })
.then((res: any) => {
if (isLiveReadonly) {
if (request !== orderRequest) return
if (res?.today_total == null || res?.today_amount == null) throw new Error('缺少订单统计')
orderReadState.value = 'ready'
}
Object.assign(orderStatsData, {
order_type_name: res.order_type_name ?? '',
date_range: res.date_range || [],
@@ -699,7 +726,7 @@ const loadOrderStats = () => {
chart: res.chart || { xAxis: [], series: [] }
})
})
.catch(() => {})
.catch(() => { if (isLiveReadonly && request === orderRequest) orderReadState.value = 'error' })
}
const refreshAll = () => {
@@ -804,6 +831,8 @@ const workbenchData: any = reactive({
})
const getData = () => {
// WorkbenchLogic::visitor() and sale() generate random series, not operational figures.
if (isLiveReadonly) return
getWorkbench()
.then((res: any) => {
workbenchData.version = res.version