fix(admin): 统一一诊医生看板与获客助手并修正排行口径显示
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="doctor-dashboard" v-loading="loading" element-loading-text="正在汇总医生经营数据">
|
||||
<div class="doctor-dashboard" :style="pageColors" v-loading="loading" element-loading-text="正在汇总医生经营数据">
|
||||
<header class="page-heading">
|
||||
<div class="heading-copy">
|
||||
<span class="heading-mark"><el-icon><DataLine /></el-icon></span>
|
||||
@@ -81,7 +81,7 @@
|
||||
<article class="metric-card metric-card--teal">
|
||||
<div class="metric-icon"><el-icon><Calendar /></el-icon></div>
|
||||
<div>
|
||||
<span>总预约</span>
|
||||
<span>总挂号</span>
|
||||
<strong>{{ formatNumber(dashboard.summary.registration_total) }}</strong>
|
||||
<small>已支付且实收金额大于 0、低于 10 元的订单</small>
|
||||
</div>
|
||||
@@ -282,6 +282,7 @@ import {
|
||||
WarningFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
import vCharts from 'vue-echarts'
|
||||
import { useStatsChartPalette } from '@/hooks/useStatsChartPalette'
|
||||
import {
|
||||
firstVisitDoctorDashboardOverview,
|
||||
type FirstVisitDoctorDashboardParams
|
||||
@@ -333,35 +334,52 @@ const doctorStatusOptions = [
|
||||
const thresholdOptions = [10, 15, 20, 30]
|
||||
const deptTreeProps = { label: 'name', value: 'id', children: 'children' }
|
||||
|
||||
const maxAmount = computed(() => Math.max(0, ...dashboard.rankings.amounts.map((item: any) => Number(item.value) || 0)))
|
||||
const maxAmount = computed(() => dashboard.rankings.amounts.reduce((max, item) => Math.max(max, rankValue(item.value)), 0))
|
||||
const businessRows = computed(() => dashboard.rows.filter((row: any) => hasBusinessData(row)))
|
||||
const zeroDataRows = computed(() => dashboard.rows.filter((row: any) => !hasBusinessData(row)))
|
||||
const visibleDetailRows = computed(() => {
|
||||
if (query.doctor_id || showZeroRows.value) return dashboard.rows
|
||||
return businessRows.value
|
||||
})
|
||||
const trendChartOption = computed(() => ({
|
||||
animationDuration: 450,
|
||||
grid: { left: 20, right: 20, top: 18, bottom: 18, containLabel: true },
|
||||
tooltip: { trigger: 'axis', valueFormatter: (value: number) => formatMoney(value) },
|
||||
xAxis: {
|
||||
type: 'category', boundaryGap: false, data: dashboard.trend.labels,
|
||||
axisLine: { lineStyle: { color: '#dfe5eb' } }, axisTick: { show: false },
|
||||
axisLabel: { color: '#7e8a9b', fontSize: 10, interval: 4 }
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value', splitNumber: 4,
|
||||
axisLabel: { color: '#8793a2', fontSize: 10, formatter: (value: number) => compactMoney(value) },
|
||||
splitLine: { lineStyle: { color: '#eef2f5' } }
|
||||
},
|
||||
series: [{
|
||||
name: '成交金额', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5,
|
||||
data: dashboard.trend.amounts,
|
||||
lineStyle: { color: '#139a8c', width: 3 },
|
||||
itemStyle: { color: '#ffffff', borderColor: '#139a8c', borderWidth: 2 },
|
||||
areaStyle: { color: 'rgba(19,154,140,.08)' }
|
||||
}]
|
||||
}))
|
||||
const palette = useStatsChartPalette()
|
||||
const pageColors = computed(() => palette.value ? {
|
||||
'--doctor-accent-text': palette.value.accentText,
|
||||
'--doctor-detail': palette.value.muted
|
||||
} : undefined)
|
||||
|
||||
const trendChartOption = computed(() => {
|
||||
const skin = palette.value
|
||||
const line = skin?.accentInk ?? '#139a8c'
|
||||
return {
|
||||
animationDuration: 450,
|
||||
grid: { left: 20, right: 20, top: 18, bottom: 18, containLabel: true },
|
||||
tooltip: {
|
||||
trigger: 'axis', valueFormatter: (value: number) => formatMoney(value),
|
||||
...(skin && {
|
||||
confine: true, backgroundColor: skin.surface, borderColor: skin.border,
|
||||
textStyle: { color: skin.ink },
|
||||
axisPointer: { lineStyle: { color: skin.muted, type: 'dashed' } }
|
||||
})
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category', boundaryGap: false, data: dashboard.trend.labels,
|
||||
axisLine: { lineStyle: { color: skin?.border ?? '#dfe5eb' } }, axisTick: { show: false },
|
||||
axisLabel: { color: skin?.muted ?? '#7e8a9b', fontSize: skin ? 12 : 10, interval: 4 }
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value', splitNumber: 4,
|
||||
axisLabel: { color: skin?.muted ?? '#8793a2', fontSize: skin ? 12 : 10, formatter: (value: number) => compactMoney(value) },
|
||||
splitLine: { lineStyle: { color: skin?.grid ?? '#eef2f5' } }
|
||||
},
|
||||
series: [{
|
||||
name: '成交金额', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5,
|
||||
data: dashboard.trend.amounts,
|
||||
lineStyle: { color: line, width: 3 },
|
||||
itemStyle: { color: skin ? line : '#ffffff', borderColor: skin?.surface ?? line, borderWidth: 2 },
|
||||
areaStyle: skin ? { color: line, opacity: 0.10 } : { color: 'rgba(19,154,140,.08)' }
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
async function loadDashboard() {
|
||||
loading.value = true
|
||||
@@ -442,9 +460,14 @@ function compactMoney(value: number) {
|
||||
return `${Math.round(value)}`
|
||||
}
|
||||
|
||||
function rankValue(value: unknown) {
|
||||
if (typeof value !== 'number' && typeof value !== 'string') return 0
|
||||
const amount = Number(value)
|
||||
return Number.isFinite(amount) && amount > 0 ? amount : 0
|
||||
}
|
||||
|
||||
function barWidth(value: unknown, max: number) {
|
||||
if (max <= 0) return '0%'
|
||||
return `${Math.max(3, Math.min(100, Number(value || 0) / max * 100))}%`
|
||||
return max > 0 ? `${Math.min(rankValue(value), max) / max * 100}%` : '0%'
|
||||
}
|
||||
|
||||
function percentageWidth(value: unknown) {
|
||||
@@ -747,4 +770,103 @@ h2 { font-size: 15px; line-height: 1.4; }
|
||||
.alert-row { grid-template-columns: 30px 1fr 80px 65px; padding: 10px; }
|
||||
.alert-data, .alert-row p { grid-column: 2 / -1; }
|
||||
}
|
||||
|
||||
:root[data-admin-ui='v2'] .doctor-dashboard {
|
||||
--ink: var(--zyt-ink);
|
||||
--muted: var(--doctor-detail, var(--zyt-text));
|
||||
--line: var(--zyt-card-border);
|
||||
--canvas: var(--zyt-canvas);
|
||||
--accent: var(--doctor-accent-text, var(--zyt-primary));
|
||||
--negative: #ab3441;
|
||||
--warning: #885214;
|
||||
--positive: #15704b;
|
||||
container: doctors / inline-size;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
|
||||
.page-heading {
|
||||
min-height: 0;
|
||||
padding: 4px 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.heading-mark { color: var(--accent); background: var(--zyt-accent-soft); box-shadow: none; }
|
||||
h1 { font-size: 24px; font-weight: 600; }
|
||||
h2 { font-size: 17px; font-weight: 600; }
|
||||
.heading-copy p, .panel-heading p { font-size: 13px; }
|
||||
.scope-chip { border-color: var(--line); color: var(--zyt-text); background: var(--zyt-surface); }
|
||||
.heading-actions, .filter-strip, .filter-item--time, .panel-heading { flex-wrap: wrap; }
|
||||
.filter-strip, .metric-card, .panel { border-radius: var(--zyt-radius); background: var(--zyt-surface); }
|
||||
.filter-item, .view-switch button, .metric-card span { color: var(--zyt-text); font-size: 13px; }
|
||||
.view-switch { border-color: var(--line); }
|
||||
.view-switch button.active { color: var(--accent); border-bottom-color: var(--accent); }
|
||||
:deep(.el-segmented) {
|
||||
--el-segmented-item-selected-bg-color: var(--zyt-accent-soft);
|
||||
--el-segmented-item-selected-color: var(--ink);
|
||||
}
|
||||
.metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.metric-card > div:last-child { min-width: 0; }
|
||||
.metric-icon { color: var(--zyt-text); background: var(--zyt-surface-subtle); }
|
||||
.metric-card strong { color: var(--ink); font-size: 24px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
|
||||
.metric-card strong, .bar-row > strong, .money-text { font-variant-numeric: tabular-nums; }
|
||||
.metric-card small, .panel-heading > span, .bar-row > b, .threshold-control, .data-note {
|
||||
color: var(--muted); font-size: 12px;
|
||||
}
|
||||
.bar-row { grid-template-columns: 24px minmax(56px, .65fr) minmax(36px, 1fr) auto; }
|
||||
.bar-row > span, .bar-row > strong { font-size: 13px; }
|
||||
.bar-track { background: var(--art-gray-300); }
|
||||
.bar-track i { background: var(--accent); }
|
||||
|
||||
.alert-panel { border-color: var(--line); }
|
||||
.alert-panel.has-alerts, .alert-row { border-color: color-mix(in srgb, var(--negative) 30%, var(--zyt-surface)); }
|
||||
.alert-row { background: color-mix(in srgb, var(--negative) 5%, var(--zyt-surface)); }
|
||||
.alert-heading h2 .el-icon, .alert-rate, .conversion-rate.is-low, .warning-mark { color: var(--negative); }
|
||||
.alert-icon { color: var(--negative); background: var(--zyt-surface); }
|
||||
.alert-doctor small, .alert-data, .alert-row p { color: var(--zyt-text); font-size: 12px; }
|
||||
.severity { font-size: 12px; }
|
||||
.severity.is-high { color: var(--negative); background: color-mix(in srgb, var(--negative) 10%, var(--zyt-surface)); }
|
||||
.severity.is-medium { color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, var(--zyt-surface)); }
|
||||
.alert-empty, .status-pill, .conversion-rate.is-good { color: var(--positive); }
|
||||
.status-pill { background: color-mix(in srgb, var(--positive) 9%, var(--zyt-surface)); }
|
||||
.status-pill.disabled, .zero-doctor-toggle { color: var(--zyt-text); background: var(--zyt-surface-subtle); }
|
||||
.zero-doctor-toggle:hover { color: var(--ink); background: var(--zyt-hover); }
|
||||
.money-text { color: var(--ink); }
|
||||
.conversion-rate.is-neutral { color: var(--muted); }
|
||||
.detail-table {
|
||||
border-color: var(--line);
|
||||
--el-table-header-bg-color: var(--zyt-surface-subtle);
|
||||
--el-table-tr-bg-color: var(--zyt-surface);
|
||||
--el-table-text-color: var(--zyt-text);
|
||||
--el-table-row-hover-bg-color: var(--zyt-hover);
|
||||
--el-table-border-color: var(--zyt-border);
|
||||
}
|
||||
.detail-table :deep(th.el-table__cell) { color: var(--ink); }
|
||||
.detail-table :deep(.is-conversion-warning > td.el-table__cell) { background: color-mix(in srgb, var(--negative) 8%, var(--zyt-surface)) !important; }
|
||||
.detail-table :deep(.is-zero-data > td.el-table__cell) { color: var(--zyt-text); background: var(--zyt-surface-subtle) !important; }
|
||||
|
||||
@container doctors (min-width: 1440px) {
|
||||
.metric-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
||||
}
|
||||
@container doctors (max-width: 760px) {
|
||||
.two-column-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.alert-row { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px; }
|
||||
.alert-data, .alert-row p { grid-column: 2 / -1; }
|
||||
.alert-rate { grid-area: 1 / 3; }
|
||||
.severity { grid-column: 2; justify-self: start; }
|
||||
}
|
||||
@container doctors (max-width: 520px) {
|
||||
.metric-grid { grid-template-columns: minmax(0, 1fr); }
|
||||
.filter-item { flex-wrap: wrap; max-width: 100%; }
|
||||
.filter-item--time :deep(.el-segmented) { max-width: 100%; }
|
||||
.date-range-picker { max-width: 100%; min-width: 0; }
|
||||
.heading-actions, .threshold-control { gap: 6px; }
|
||||
}
|
||||
}
|
||||
:root.dark[data-admin-ui='v2'] .doctor-dashboard {
|
||||
--negative: #ffa4aa;
|
||||
--warning: #f2c187;
|
||||
--positive: #80dcb1;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -250,3 +250,15 @@ onBeforeUnmount(() => emit('busy', false))
|
||||
.tag-success { margin: 8px 0 0; color: #27864c; font-size: 12px; line-height: 1.7; }
|
||||
@media (max-width: 620px) { .tag-select-row { flex-direction: column; }.remark-preview { flex-wrap: wrap; }.automation-form :deep(.el-radio) { margin-right: 14px; }.weekday-select { gap: 0 12px; } }
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
html[data-admin-ui='v2'] .automation-form {
|
||||
.form-section-title { color: var(--zyt-ink); border-color: var(--zyt-card-border); }
|
||||
.schedule-card, .custom-tag-editor { border-color: var(--zyt-card-border); background: var(--zyt-surface-subtle); }
|
||||
.field-help, .time-row > span, .custom-tag-editor label, .switch-help { color: var(--zyt-text); }
|
||||
.warning-help, .time-row > small, .legacy-tags-warning { color: color-mix(in srgb, var(--el-color-warning) 30%, var(--zyt-ink)); }
|
||||
.legacy-tags-warning { border-color: var(--el-color-warning-light-8); background: var(--el-color-warning-light-9); }
|
||||
.inline-error { color: color-mix(in srgb, var(--el-color-danger) 45%, var(--zyt-ink)); }
|
||||
.tag-success { color: color-mix(in srgb, var(--el-color-success) 30%, var(--zyt-ink)); }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1223,3 +1223,33 @@ function openTestLink() {
|
||||
.template-bar { gap: 7px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
// Editor chrome only. The miniature templates, device canvas, code sample and
|
||||
// live widget retain the colors configured for the site visitor.
|
||||
html[data-admin-ui='v2'] .widget-builder {
|
||||
.builder-header, .builder-controls, .install-section {
|
||||
border-color: var(--zyt-card-border);
|
||||
background: var(--zyt-surface);
|
||||
}
|
||||
.builder-icon, .code-title > span { color: var(--zyt-feedback-ink); background: var(--zyt-accent-soft); box-shadow: none; }
|
||||
.builder-intro h3, .control-heading h4, .install-heading h4, .template-copy strong,
|
||||
.code-title strong, .install-tip strong { color: var(--zyt-ink); }
|
||||
.control-section + .control-section, .form-actions { border-color: var(--zyt-card-border); }
|
||||
.builder-intro p, .publish-state small, .control-heading > span, .template-copy small, .template-copy em,
|
||||
.switch-control small, .action-note, .offset-control > span, .install-heading p, .code-title small {
|
||||
color: var(--zyt-text); font-size: 12px;
|
||||
}
|
||||
.control-heading .dirty-state { color: color-mix(in srgb, var(--el-color-warning) 30%, var(--zyt-ink)); }
|
||||
.section-index, .install-tip .el-icon { color: var(--zyt-feedback-ink); }
|
||||
.section-index, .template-copy strong { font-size: 13px; }
|
||||
.template-option { border-color: var(--zyt-card-border); background: var(--zyt-surface); }
|
||||
.template-option:hover { border-color: var(--zyt-accent-border); }
|
||||
.template-option.active { border-color: var(--zyt-primary); box-shadow: none; }
|
||||
.template-option:focus-visible { outline-color: var(--zyt-feedback-ink); }
|
||||
.selected-check { color: var(--zyt-feedback-ink); background: var(--zyt-accent-soft); }
|
||||
.widget-form :deep(.el-form-item__label) { color: var(--zyt-text); font-size: 12px; }
|
||||
.install-tip, .code-card { background: var(--zyt-surface-subtle); }
|
||||
.install-tip { color: var(--zyt-text); font-size: 12px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -244,3 +244,15 @@ onBeforeUnmount(() => {
|
||||
.phone-content { min-height: 330px; max-height: 520px; overflow: auto; background: #ededed; padding: 0 10px 18px; }.preview-time { font-size: 10px; text-align: center; color: #999; padding: 12px 0 18px; }.chat-row { display: flex; gap: 7px; margin-bottom: 12px; align-items: flex-start; }.chat-avatar { width: 27px; height: 27px; background: #6e92ae; color: white; flex-shrink: 0; border-radius: 4px; display: grid; place-items: center; font-size: 11px; }.chat-bubble { background: #fff; padding: 9px 10px; border-radius: 4px; font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; max-width: 172px; }.attachment-preview { width: 172px; }.attachment-preview strong { display: block; font-weight: 500; font-size: 12px; }.attachment-preview p { color: #909399; font-size: 10px; margin: 6px 0; }.attachment-preview small { display: block; font-size: 9px; color: #909399; margin-top: 7px; }.attachment-preview img { width: 100%; max-height: 160px; object-fit: contain; display: block; }.media-placeholder { background: #f2f5f7; height: 85px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #909399; font-size: 10px; }.media-placeholder .el-icon, .file-icon { font-size: 28px; color: #8babc3; }.preview-empty { text-align: center; color: #aaa; font-size: 12px; margin-top: 100px; }.phone-input { display: flex; gap: 10px; padding: 9px; background: #f6f6f6; border-radius: 0 0 14px 14px; align-items: center; color: #909399; }.phone-input__blank { flex: 1; height: 24px; border-radius: 3px; background: white; }.preview-note { margin: 10px 6px 6px; font-size: 11px; color: #909399; line-height: 1.6; }
|
||||
@media (max-width: 850px) { .welcome-editor { grid-template-columns: 1fr; }.welcome-preview { margin: 8px auto 0; } }
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
// The separate phone preview is customer content, not an admin panel.
|
||||
html[data-admin-ui='v2'] .welcome-editor__fields {
|
||||
.text-count, .attachments-heading strong span, .attachment-label, .attachment-label span,
|
||||
.field-tip, .muted { color: var(--zyt-text); }
|
||||
.attachment-empty { color: var(--zyt-text); background: var(--zyt-surface-subtle); border-color: var(--zyt-card-border); }
|
||||
.attachment-card { border-color: var(--zyt-card-border); }
|
||||
.asset-ready { color: color-mix(in srgb, var(--el-color-success) 30%, var(--zyt-ink)); }
|
||||
.text-count.is-error, .upload-error { color: color-mix(in srgb, var(--el-color-danger) 45%, var(--zyt-ink)); }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2006,3 +2006,5 @@ h1, h2, h3, p { margin: 0; }
|
||||
@media (max-width: 1100px) { .heading-actions { flex-wrap: wrap; justify-content: flex-end; }.metric-grid, .customer-metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }.pool-layout { grid-template-columns: 210px minmax(0,1fr); }.pool-toolbar { align-items: flex-start; flex-direction: column; } }
|
||||
@media (max-width: 760px) { .promotion-page { padding: 10px; }.page-header, .section-heading { align-items: flex-start; flex-direction: column; }.section-heading-actions { width: 100%; justify-content: flex-start; }.update-time { display: none; }.metric-grid, .customer-metric-grid, .form-grid, .rule-form-grid, .batch-field-grid, .batch-member-status-grid { grid-template-columns: 1fr; }.tab-nav { overflow-x: auto; }.tab-nav button { min-width: 112px; }.tab-content { padding: 14px; }.pool-layout { height: auto; min-height: 0; grid-template-columns: 1fr; }.pool-sidebar { display: flex; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-gutter: auto; }.pool-select-all { position: static; min-width: 126px; flex: 0 0 126px; margin: 0 6px 0 0; border-right: 1px solid var(--line); border-bottom: 0; }.pool-main { overflow: visible; }.member-table-area { height: 420px; min-height: 320px; flex: none; }.pool-select-row { min-width: 220px; }.pool-item { min-width: 190px; }.callback-list > div { grid-template-columns: 1fr 48px; padding: 8px 0; }.callback-list dt { grid-column: 1 / -1; }.install-pool-select { width: 100%; }.customer-heading-actions { width: 100%; justify-content: flex-end; }.customer-filter-bar :deep(.el-form-item) { width: 100%; margin-right: 0; }.customer-filter-bar :deep(.el-form-item__content), .customer-filter-bar .el-select { width: 100%; }.customer-filter-bar .filter-actions :deep(.el-form-item__content) { justify-content: flex-end; }.customer-pagination { align-items: flex-start; flex-direction: column; }.customer-pagination :deep(.el-pagination) { max-width: 100%; flex-wrap: wrap; justify-content: flex-start; }.access-pool-preview > div { grid-template-columns: 1fr; gap: 3px; } }
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss" src="./promotion-admin-v2.scss"></style>
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// Imported as scoped SFC styles: dialog slots and teleported tree options also
|
||||
// carry this component's scope ID. Don't redefine --teal / --ink on the page:
|
||||
// the JS installer uses those classic variables inside its customer-facing preview.
|
||||
html[data-admin-ui='v2'] {
|
||||
.promotion-page { padding: 0; background: var(--zyt-canvas); }
|
||||
.page-header {
|
||||
min-height: 0;
|
||||
padding: 4px 0 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.heading-copy h1 { color: var(--zyt-ink); font-size: 24px; font-weight: 600; }
|
||||
.heading-copy p { color: var(--zyt-text); font-size: 13px; }
|
||||
.heading-actions { color: var(--zyt-text); }
|
||||
.heading-icon, :is(.metric-card, .customer-metric-card) .metric-icon {
|
||||
color: var(--zyt-feedback-ink);
|
||||
background: var(--zyt-accent-soft);
|
||||
box-shadow: none;
|
||||
}
|
||||
.scope-chip {
|
||||
color: var(--zyt-text);
|
||||
border-color: var(--zyt-card-border);
|
||||
background: var(--zyt-surface);
|
||||
}
|
||||
.metric-card, .customer-metric-card, .workspace-card {
|
||||
border-color: var(--zyt-card-border);
|
||||
border-radius: calc(var(--zyt-radius) + 4px);
|
||||
background: var(--zyt-surface);
|
||||
box-shadow: none;
|
||||
}
|
||||
.metric-card, .customer-metric-card {
|
||||
min-width: 0;
|
||||
small { font-size: 13px; color: var(--zyt-text); }
|
||||
strong { font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--zyt-ink); }
|
||||
p { font-size: 12px; line-height: 1.5; color: var(--zyt-text); white-space: normal; overflow-wrap: anywhere; }
|
||||
}
|
||||
.tab-nav { background: var(--zyt-surface); border-color: var(--zyt-card-border); }
|
||||
.tab-nav button { color: var(--zyt-text); }
|
||||
.tab-nav button.active { border-bottom-color: var(--zyt-primary); color: var(--zyt-feedback-ink); }
|
||||
.section-heading h2, .pool-title-row h3 { color: var(--zyt-ink); font-weight: 600; }
|
||||
.section-heading p, .update-time { color: var(--zyt-text); }
|
||||
.selection-count { color: var(--zyt-feedback-ink); font-size: 12px; }
|
||||
.pool-layout, .pool-sidebar, .pool-select-all, .pool-toolbar { border-color: var(--zyt-card-border); }
|
||||
.pool-sidebar, .pool-select-all { background: var(--zyt-surface-subtle); }
|
||||
.pool-item:hover { background: var(--zyt-hover); }
|
||||
.pool-select-row.active .pool-item {
|
||||
border-color: var(--zyt-accent-border);
|
||||
background: var(--zyt-accent-soft);
|
||||
box-shadow: none;
|
||||
}
|
||||
.pool-item strong, .message-count { color: var(--zyt-ink); }
|
||||
.pool-item > .el-icon { color: var(--zyt-text); }
|
||||
.pool-toolbar, .pool-title-row { flex-wrap: wrap; }
|
||||
.pool-title-row { row-gap: 4px; }
|
||||
.toolbar-actions { justify-content: flex-start; }
|
||||
.pool-select-all > span, .pool-item small, .pool-toolbar p, .member-cell small,
|
||||
.muted, .customer-identifier, .customer-pagination, .message-count.muted {
|
||||
color: var(--zyt-text); font-size: 12px;
|
||||
}
|
||||
.owner-tag, .status-tag, .availability, .message-state { font-size: 12px; }
|
||||
.owner-tag, .status-tag.is-offline, .availability.is-muted, .message-state.is-silent {
|
||||
color: var(--zyt-text); background: var(--art-gray-200);
|
||||
}
|
||||
.status-tag.is-online, .availability.is-ok, .message-state.is-messaged {
|
||||
color: color-mix(in srgb, var(--el-color-success) 30%, var(--zyt-ink));
|
||||
background: var(--el-color-success-light-9);
|
||||
}
|
||||
.status-tag.is-pending, .availability.is-waiting, .message-state.is-unknown {
|
||||
color: color-mix(in srgb, var(--el-color-warning) 30%, var(--zyt-ink));
|
||||
background: var(--el-color-warning-light-9);
|
||||
}
|
||||
.availability.is-error {
|
||||
color: color-mix(in srgb, var(--el-color-danger) 45%, var(--zyt-ink));
|
||||
background: var(--el-color-danger-light-9);
|
||||
}
|
||||
.sync-retry-tip, .uploading-save-tip {
|
||||
color: color-mix(in srgb, var(--el-color-warning) 30%, var(--zyt-ink));
|
||||
font-size: 12px;
|
||||
}
|
||||
.link-table, .customer-table { --el-table-header-bg-color: var(--zyt-surface-subtle); }
|
||||
.link-table :deep(th.el-table__cell), .customer-table :deep(th.el-table__cell) { color: var(--zyt-text); }
|
||||
.customer-filter-bar, .member-sync-results {
|
||||
border-color: var(--zyt-card-border); background: var(--zyt-surface-subtle); color: var(--zyt-text);
|
||||
}
|
||||
.customer-filter-bar :deep(.el-form-item__label) { color: var(--zyt-text); font-size: 12px; }
|
||||
.configuration-panel.is-ready, .configuration-panel.is-pending {
|
||||
color: var(--zyt-ink); border-color: var(--zyt-card-border); background: var(--zyt-surface-subtle);
|
||||
}
|
||||
.is-ready .configuration-state > span {
|
||||
color: color-mix(in srgb, var(--el-color-success) 30%, var(--zyt-ink)); background: var(--el-color-success-light-9);
|
||||
}
|
||||
.is-pending .configuration-state > span, .missing-fields {
|
||||
color: color-mix(in srgb, var(--el-color-warning) 30%, var(--zyt-ink));
|
||||
}
|
||||
.is-pending .configuration-state > span, .missing-fields code { background: var(--el-color-warning-light-9); }
|
||||
.configuration-state p, .callback-list dt, .callback-list dd { color: var(--zyt-text); font-size: 12px; }
|
||||
.callback-list, .callback-list > div { border-color: var(--zyt-card-border); }
|
||||
|
||||
// Batch, access and member configuration (not the welcome-message mockup).
|
||||
.member-tree-option.is-department .member-tree-option__label,
|
||||
.batch-config-section > h3, .access-pool-preview span { color: var(--zyt-ink); }
|
||||
.member-tree-option__count, .member-tree-option__detail, .form-tip, .batch-section-tip,
|
||||
.access-pool-preview small, .access-pool-preview p, .batch-pool-summary small {
|
||||
font-size: 12px; color: var(--zyt-text);
|
||||
}
|
||||
.access-pool-preview, .batch-pool-summary, .batch-field.is-disabled {
|
||||
color: var(--zyt-text); border-color: var(--zyt-card-border); background: var(--zyt-surface-subtle);
|
||||
}
|
||||
.batch-field.is-disabled { opacity: 1; }
|
||||
.batch-pool-summary span {
|
||||
font-size: 12px; color: var(--zyt-text); background: var(--art-gray-200);
|
||||
}
|
||||
.batch-config-section { border-color: var(--zyt-card-border); background: var(--zyt-surface); }
|
||||
.access-pool-preview > div, .batch-field { border-color: var(--zyt-card-border); }
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.heading-actions { justify-content: flex-start; }
|
||||
.metric-card, .customer-metric-card { min-height: 0; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const test = require('node:test')
|
||||
const { parse, compileScript } = require('@vue/compiler-sfc')
|
||||
const ts = require('typescript')
|
||||
const vue = require('vue')
|
||||
const { renderToString } = require('vue/server-renderer')
|
||||
|
||||
const filename = path.join(__dirname, '../src/views/first_visit/doctor_dashboard/index.vue')
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
assert.deepEqual(errors, [])
|
||||
const compiled = compileScript(descriptor, { id: 'doctor-dashboard', inlineTemplate: true, templateOptions: { ssr: true } })
|
||||
function compile(content) {
|
||||
return ts.transpileModule(content, { compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022
|
||||
} }).outputText
|
||||
}
|
||||
const outputText = compile(compiled.content)
|
||||
function loadPage(code, imports) {
|
||||
const mod = { exports: {} }
|
||||
new Function('require', 'module', 'exports', code)(id => imports[id] || require(id), mod, mod.exports)
|
||||
return mod.exports.default
|
||||
}
|
||||
|
||||
const light = { surface: '#ffffff', ink: '#323251', border: '#e2e8ee', muted: '#62718b', grid: '#e6eaeb', accentInk: '#5d87ff', accentText: '#4569bf' }
|
||||
const dark = { surface: '#161618', ink: '#e3e3e8', border: '#383840', muted: '#9999a9', grid: '#323238', accentInk: '#ba9aff', accentText: '#d0c3ff' }
|
||||
async function renderDashboard(values, palette = null) {
|
||||
const skin = vue.shallowRef(palette)
|
||||
const stub = { render: () => null }
|
||||
let option
|
||||
const Chart = { props: ['option'], render() { option = this.option; return null } }
|
||||
const imports = {
|
||||
vue: { ...vue, onMounted: vue.onServerPrefetch },
|
||||
'@/api/first_visit': { firstVisitDoctorDashboardOverview: async () => ({
|
||||
summary: { registration_total: 18, appointment_total: 12 },
|
||||
rankings: { amounts: values.map((value, i) => ({ doctor_id: i + 1, name: '医生' + i, value })), conversion: [] },
|
||||
trend: { labels: ['12-01', '12-02'], amounts: [0, 10000] }
|
||||
}) },
|
||||
'@/hooks/useStatsChartPalette': { useStatsChartPalette: () => skin },
|
||||
'@element-plus/icons-vue': new Proxy({}, { get: () => stub }),
|
||||
'element-plus': {}, 'vue-echarts': { default: Chart }
|
||||
}
|
||||
const app = vue.createSSRApp(loadPage(outputText, imports))
|
||||
for (const [, tag] of descriptor.template.content.matchAll(/<(el-[\w-]+)/g)) {
|
||||
if (!app.component(tag)) app.component(tag, stub)
|
||||
}
|
||||
app.directive('loading', {})
|
||||
const html = await renderToString(app)
|
||||
return { html, option }
|
||||
}
|
||||
|
||||
test('挂号和预约在各自的指标下显示接口原值', async () => {
|
||||
const { html } = await renderDashboard([])
|
||||
const cards = [...html.matchAll(/<article class="metric-card[^"]*"[^>]*>(.*?)<\/article>/gs)]
|
||||
.map(([, body]) => body.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' '))
|
||||
assert.equal(cards.length, 6)
|
||||
assert.match(cards[0], /总挂号 18 /)
|
||||
assert.match(cards[5], /预约完成率 .*总预约 12/)
|
||||
})
|
||||
|
||||
for (const [values, widths] of [
|
||||
[[10000, 100, 0], ['100%', '1%', '0%']],
|
||||
[[0, 0], ['0%', '0%']],
|
||||
[['10', 0.025, -1, 'invalid'], ['100%', '0.25%', '0%', '0%']]
|
||||
]) {
|
||||
test('金额排行按真实比例并保留顺序:' + values.join('/'), async () => {
|
||||
const { html } = await renderDashboard(values)
|
||||
const rows = [...html.matchAll(/<div class="bar-row"[^>]*><b[^>]*>(\d+)<\/b>.*?style="width:([^;"]+).*?<strong[^>]*>([^<]+)<\/strong>/gs)]
|
||||
assert.deepEqual(rows.map(([,rank,width]) => [Number(rank), width]), widths.map((w,i) => [i+1, w]))
|
||||
if (values[0] === 10000) assert.deepEqual(rows.map(r => r[3]), ['¥10,000.00', '¥100.00', '¥0.00'])
|
||||
})
|
||||
}
|
||||
|
||||
for (const [name, skin] of [['浅色', light], ['暗色自选主色', dark]]) {
|
||||
test(name + '趋势的实际序列、坐标和 tooltip 使用主题,业务数值不变', async () => {
|
||||
const { option } = await renderDashboard([], skin)
|
||||
const [amount] = option.series
|
||||
assert.equal(amount.name, '成交金额')
|
||||
assert.deepEqual([...amount.data], [0, 10000])
|
||||
assert.equal(amount.lineStyle.color, skin.accentInk)
|
||||
assert.equal(amount.itemStyle.color, skin.accentInk)
|
||||
assert.equal(amount.areaStyle.color, skin.accentInk)
|
||||
assert.equal(option.xAxis.axisLabel.color, skin.muted)
|
||||
assert.equal(option.yAxis.splitLine.lineStyle.color, skin.grid)
|
||||
assert.equal(option.tooltip.textStyle.color, skin.ink)
|
||||
assert.equal(option.tooltip.backgroundColor, skin.surface)
|
||||
})
|
||||
}
|
||||
|
||||
test('经典版保留既有趋势和提示框外观', async () => {
|
||||
const { option } = await renderDashboard([])
|
||||
assert.equal(option.series[0].lineStyle.color, '#139a8c')
|
||||
assert.equal(option.series[0].itemStyle.color, '#ffffff')
|
||||
assert.equal(option.tooltip.backgroundColor, undefined)
|
||||
})
|
||||
|
||||
// Exercise the compiled page's computed option on one ECharts instance, not a remount per color.
|
||||
test('原地切色后 ECharts 实际绘制新色,切回经典色也能还原', () => {
|
||||
const echarts = require('echarts')
|
||||
const skin = vue.shallowRef(light)
|
||||
const page = loadPage(compile(compileScript(descriptor, { id: 'doctor-dashboard' }).content), {
|
||||
vue: { ...vue, onMounted() {} }, '@/api/first_visit': {}, 'vue-echarts': {},
|
||||
'element-plus': {}, '@element-plus/icons-vue': {},
|
||||
'@/hooks/useStatsChartPalette': { useStatsChartPalette: () => skin }
|
||||
})
|
||||
const { dashboard, trendChartOption } = page.setup({}, { expose() {} })
|
||||
dashboard.trend.labels = ['12-01', '12-02']
|
||||
dashboard.trend.amounts = [25, 100]
|
||||
const plot = echarts.init(null, null, { ssr: true, renderer: 'svg', width: 500, height: 200 })
|
||||
try {
|
||||
for (const current of [light, dark, null]) {
|
||||
skin.value = current
|
||||
plot.setOption({ ...trendChartOption.value, animation: false }, { notMerge: true })
|
||||
const color = current?.accentInk ?? '#139a8c'
|
||||
assert.equal(plot.getOption().series[0].lineStyle.color, color)
|
||||
assert.ok(plot.renderToSVGString().includes('stroke="' + color + '"'))
|
||||
}
|
||||
} finally { plot.dispose() }
|
||||
})
|
||||
@@ -0,0 +1,132 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require('node:test')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const postcss = require('postcss')
|
||||
const sass = require('sass')
|
||||
const { parseDOM } = require('htmlparser2')
|
||||
const { selectAll, selectOne, compile } = require('css-select')
|
||||
const { parse, compileStyle } = require('@vue/compiler-sfc')
|
||||
|
||||
const src = path.join(__dirname, '../src')
|
||||
const base = path.join(src, 'views/first_visit/wecom_promotion')
|
||||
const scope = 'data-v-c02'
|
||||
|
||||
// Use Vue's actual scope rewriting and template classes. No browser or live data.
|
||||
function component(name) {
|
||||
const filename = path.join(base, name)
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
assert.deepEqual(errors, [])
|
||||
const rules = []
|
||||
for (const block of descriptor.styles.slice(1)) {
|
||||
const file = block.src ? path.resolve(base, block.src) : filename
|
||||
const source = block.src ? fs.readFileSync(file, 'utf8') : block.content
|
||||
const compiled = compileStyle({ filename: file, source, scoped: block.scoped, id: scope, preprocessLang: block.lang })
|
||||
assert.deepEqual(compiled.errors, [])
|
||||
postcss.parse(compiled.code).walkRules(rule => {
|
||||
assert.ok(rule.selectors.every(selector => selector.startsWith('html[data-admin-ui=v2] ')), rule.selector)
|
||||
rules.push({ rule, matches: compile(rule.selector.replaceAll(':focus-visible', '[data-focus-visible]')) })
|
||||
})
|
||||
}
|
||||
const dom = parseDOM('<html data-admin-ui="v2"><body>' + descriptor.template.content + '</body></html>')
|
||||
selectAll('body *', dom).forEach(el => { el.attribs[scope] = '' })
|
||||
return { dom, rules }
|
||||
}
|
||||
const page = component('index.vue')
|
||||
|
||||
function properties(rules, node) {
|
||||
const values = {}
|
||||
for (const { rule, matches } of rules) {
|
||||
if (matches(node)) {
|
||||
rule.walkDecls(d => { values[d.prop] = d.value })
|
||||
}
|
||||
}
|
||||
return values
|
||||
}
|
||||
const theme = postcss.parse(sass.compile(path.join(src, 'styles/admin-v2.scss')).css)
|
||||
function themeColors(dark) {
|
||||
const vars = {}
|
||||
for (const selector of [':root[data-admin-ui=v2]', ...(dark ? [':root[data-admin-ui=v2].dark'] : [])]) {
|
||||
theme.nodes.find(n => n.selector === selector).walkDecls(d => { vars[d.prop] = d.value })
|
||||
}
|
||||
function rgb(value) {
|
||||
const ref = /^var\((--[\w-]+)\)$/.exec(value)
|
||||
if (ref) return rgb(vars[ref[1]])
|
||||
if (value.startsWith('rgb(')) return value.match(/[\d.]+/g).map(Number)
|
||||
const mix = /^color-mix\(in srgb, (var\([^)]+\)) (\d+)%, (var\([^)]+\))\)$/.exec(value)
|
||||
if (mix) {
|
||||
const a = rgb(mix[1]), b = rgb(mix[3]), weight = Number(mix[2]) / 100
|
||||
return a.map((v, i) => v * weight + b[i] * (1 - weight))
|
||||
}
|
||||
assert.match(value, /^#(?:[a-f\d]{3}|[a-f\d]{6})$/i)
|
||||
const hex = value.slice(1)
|
||||
return (hex.length === 3 ? [...hex].map(c => c + c) : hex.match(/../g)).map(c => parseInt(c, 16))
|
||||
}
|
||||
return rgb
|
||||
}
|
||||
function contrast(a, b) {
|
||||
const luma = rgb => rgb.reduce((sum, byte, i) => {
|
||||
const c = byte / 255
|
||||
return sum + [0.2126, 0.7152, 0.0722][i] * (c <= 0.04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4)
|
||||
}, 0)
|
||||
const [high, low] = [luma(a), luma(b)].sort((x, y) => y - x)
|
||||
return (high + .05) / (low + .05)
|
||||
}
|
||||
|
||||
test('both sets of four counts share a neutral card and a legible hint; the active tab follows the primary action', () => {
|
||||
const { dom, rules } = page
|
||||
const cards = selectAll('.metric-card, .customer-metric-card', dom)
|
||||
assert.equal(cards.length, 8)
|
||||
for (const card of cards) {
|
||||
const node = properties(rules, card), hint = properties(rules, selectOne('p', card))
|
||||
const icon = properties(rules, selectOne('.metric-icon', card))
|
||||
assert.equal(node.background, 'var(--zyt-surface)')
|
||||
assert.equal(node['border-color'], 'var(--zyt-card-border)')
|
||||
assert.equal(node['box-shadow'], 'none')
|
||||
assert.equal(icon.background, 'var(--zyt-accent-soft)')
|
||||
assert.ok(parseFloat(hint['font-size']) >= 12)
|
||||
for (const rgb of [themeColors(false), themeColors(true)]) {
|
||||
assert.ok(contrast(rgb(hint.color), rgb(node.background)) >= 4.5)
|
||||
}
|
||||
}
|
||||
const tab = selectOne('.tab-nav button', dom)
|
||||
tab.attribs.class = 'active'
|
||||
assert.equal(properties(rules, tab)['border-bottom-color'], 'var(--zyt-primary)')
|
||||
assert.ok(selectOne('.section-heading-actions el-button[type="primary"]', dom))
|
||||
})
|
||||
|
||||
test('running, offline, waiting and error text keep distinct, legible color pairs in both themes', () => {
|
||||
const { dom, rules } = page
|
||||
const states = []
|
||||
for (const className of ['status-tag is-online', 'status-tag is-offline', 'availability is-waiting', 'availability is-error']) {
|
||||
const el = selectOne('.pool-title-row span', dom)
|
||||
el.attribs.class = className
|
||||
const { color, background } = properties(rules, el)
|
||||
states.push(background)
|
||||
for (const rgb of [themeColors(false), themeColors(true)]) {
|
||||
assert.ok(contrast(rgb(color), rgb(background)) >= 4.5, className)
|
||||
}
|
||||
}
|
||||
assert.equal(new Set(states).size, states.length)
|
||||
})
|
||||
|
||||
test('classic is unchanged and V2 editor styles do not reach the customer previews, template swatches or copied code', () => {
|
||||
const classicPage = component('index.vue')
|
||||
selectOne('html', classicPage.dom).attribs['data-admin-ui'] = 'legacy'
|
||||
for (const node of selectAll('body *', classicPage.dom)) assert.deepEqual(properties(classicPage.rules, node), {})
|
||||
for (const [name, preview] of [
|
||||
['components/WecomFloatingWidgetBuilder.vue', '.preview-canvas, .template-swatch, .code-card pre'],
|
||||
['components/WelcomeMessageEditor.vue', '.welcome-preview'],
|
||||
['components/PromotionAutomationForm.vue', '.remark-preview']
|
||||
]) {
|
||||
const { dom, rules } = component(name)
|
||||
assert.ok(rules.length, name)
|
||||
const roots = selectAll(preview, dom)
|
||||
assert.ok(roots.length, name)
|
||||
for (const node of roots.flatMap(n => [n, ...selectAll('*', n)])) {
|
||||
assert.deepEqual(properties(rules, node), {}, name + ': ' + node.attribs.class)
|
||||
}
|
||||
selectOne('html', dom).attribs['data-admin-ui'] = 'legacy'
|
||||
for (const node of selectAll('body *', dom)) assert.deepEqual(properties(rules, node), {})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user