feat(admin): 增加本人正式账号的独立只读预览入口
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user