feat(admin): 升级后台主题并增加本机只读预览

This commit is contained in:
2026-12-01 16:32:03 +08:00
parent c48df2464e
commit 9024e4b287
24 changed files with 1056 additions and 38 deletions
+150 -22
View File
@@ -39,7 +39,7 @@
<el-option label="最近7天" :value="7" />
<el-option label="最近30天" :value="30" />
</el-select>
<el-button :icon="Refresh" circle @click="loadOrderStats" />
<el-button aria-label="刷新订单统计" :icon="Refresh" circle @click="loadOrderStats" />
</div>
</div>
<div class="wb-section-body">
@@ -87,6 +87,7 @@
class="wb-chart"
style="height: 300px"
:option="orderDeptCountPieOption"
:theme="chartTheme"
:autoresize="true"
/>
<el-empty v-else class="wb-chart-empty" description="暂无数据" />
@@ -104,6 +105,7 @@
class="wb-chart"
style="height: 300px"
:option="orderChartOption"
:theme="chartTheme"
:autoresize="true"
/>
<el-empty v-else class="wb-chart-empty" description="暂无图表数据" />
@@ -122,6 +124,7 @@
class="wb-chart"
style="height: 300px"
:option="orderDeptAmountPieOption"
:theme="chartTheme"
:autoresize="true"
/>
<el-empty v-else class="wb-chart-empty" description="暂无数据" />
@@ -205,7 +208,7 @@
<el-option label="最近14天" :value="14" />
<el-option label="最近30天" :value="30" />
</el-select>
<el-button :icon="Refresh" circle @click="loadAssistantStats" />
<el-button aria-label="刷新诊单统计" :icon="Refresh" circle @click="loadAssistantStats" />
</div>
</div>
<div class="wb-section-body">
@@ -249,6 +252,7 @@
class="wb-chart"
style="height: 340px"
:option="assistantChartOption"
:theme="chartTheme"
:autoresize="true"
/>
<el-empty v-else class="wb-chart-empty" description="暂无图表数据" />
@@ -265,6 +269,7 @@
class="wb-chart"
style="height: 340px"
:option="assistantDeptPieOption"
:theme="chartTheme"
:autoresize="true"
/>
<el-empty v-else class="wb-chart-empty" description="暂无部门数据" />
@@ -332,6 +337,7 @@
class="wb-chart"
style="height: 320px"
:option="workbenchData.visitorOption"
:theme="chartTheme"
:autoresize="true"
/>
</div>
@@ -347,6 +353,7 @@
class="wb-chart"
style="height: 320px"
:option="workbenchData.saleOption"
:theme="chartTheme"
:autoresize="true"
/>
</div>
@@ -359,6 +366,7 @@
<script lang="ts" setup name="workbench">
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useMutationObserver } from '@vueuse/core'
import vCharts from 'vue-echarts'
import { DataAnalysis, Histogram, Refresh, TrendCharts } from '@element-plus/icons-vue'
@@ -374,6 +382,40 @@ const saleChart = useComponentRef(vCharts)
const visitorChart = useComponentRef(vCharts)
const assistantChart = useComponentRef(vCharts)
// ECharts paints on canvas, so resolve the active shell colors before passing them in.
const root = document.documentElement
function readChartSkin() {
if (root.dataset.adminUi !== 'v2') return null
const css = getComputedStyle(root)
const token = (key: string, fallback: string) => css.getPropertyValue('--zyt-' + key).trim() || fallback
return {
primary: token('primary', '#15775e'),
text: token('muted', '#667b71'),
surface: token('surface', '#ffffff'),
border: token('border', '#dce6e1'),
dark: root.classList.contains('dark')
}
}
const skin = ref(readChartSkin())
useMutationObserver(root, () => { skin.value = readChartSkin() }, {
attributes: true, attributeFilter: ['data-admin-ui', 'class']
})
const chartPrimary = computed(() => skin.value?.primary ?? settingStore.theme)
const chartTheme = computed(() => {
const s = skin.value
if (!s) return undefined
const axis = {
axisLabel: { color: s.text }, nameTextStyle: { color: s.text },
axisLine: { lineStyle: { color: s.border } }, splitLine: { lineStyle: { color: s.border } }
}
return {
darkMode: s.dark, backgroundColor: 'transparent',
textStyle: { color: s.text }, legend: { textStyle: { color: s.text } },
categoryAxis: axis, valueAxis: axis,
tooltip: { backgroundColor: s.surface, borderColor: s.border, textStyle: { color: s.text } }
}
})
const jadePieColors = ['#168364', '#5987b0', '#d09b50', '#8779ad', '#58aa9a', '#bd7787', '#96994c', '#617282']
const pieColors = ['#5b7cfa', '#36cfc9', '#ffc53d', '#ff7a45', '#b37feb', '#597ef7', '#73d13d', '#ff85c0']
function parseAmount(v: unknown): number {
@@ -407,7 +449,7 @@ const assistantDeptPieOption = computed(() => {
.filter((d: any) => Number(d.total) > 0)
.map((d: any) => ({ name: d.dept_name || '—', value: Number(d.total) }))
return {
color: pieColors,
color: skin.value ? jadePieColors : pieColors,
tooltip: { trigger: 'item', formatter: '{b}<br/>{c} 单 ({d}%)' },
legend: { type: 'scroll', bottom: 0, textStyle: { fontSize: 11 } },
series: [
@@ -417,7 +459,7 @@ const assistantDeptPieOption = computed(() => {
radius: ['46%', '72%'],
center: ['50%', '46%'],
avoidLabelOverlap: true,
itemStyle: { borderRadius: 6, borderColor: '#fff', borderWidth: 2 },
itemStyle: { borderRadius: 6, borderColor: skin.value?.surface ?? '#fff', borderWidth: 2 },
label: { formatter: '{b}\n{c}' },
data
}
@@ -426,7 +468,7 @@ const assistantDeptPieOption = computed(() => {
})
const assistantChartOption = computed(() => {
const theme = settingStore.theme
const theme = chartPrimary.value
const barSeries = (assistantStats.chart.series || []).map((s: any) => ({
...s,
name: s.name || '诊单数',
@@ -455,12 +497,12 @@ const assistantChartOption = computed(() => {
type: 'category',
data: assistantStats.chart.xAxis || [],
axisLabel: { rotate: 28, fontSize: 11 },
axisLine: { lineStyle: { color: '#e4e7ec' } }
axisLine: { lineStyle: { color: skin.value?.border ?? '#e4e7ec' } }
},
yAxis: {
type: 'value',
name: '诊单数',
splitLine: { lineStyle: { type: 'dashed', color: '#eef0f4' } }
splitLine: { lineStyle: { type: 'dashed', color: skin.value?.border ?? '#eef0f4' } }
},
tooltip: { trigger: 'axis' },
grid: { left: '2%', right: '2%', bottom: '12%', top: 48, containLabel: true },
@@ -518,7 +560,7 @@ const orderDeptCountPieOption = computed(() => {
.filter((d: any) => Number(d.total) > 0)
.map((d: any) => ({ name: d.dept_name || '—', value: Number(d.total) }))
return {
color: pieColors,
color: skin.value ? jadePieColors : pieColors,
tooltip: { trigger: 'item', formatter: '{b}<br/>{c} 单 ({d}%)' },
legend: { type: 'scroll', bottom: 0, textStyle: { fontSize: 11 } },
series: [
@@ -527,7 +569,7 @@ const orderDeptCountPieOption = computed(() => {
type: 'pie',
radius: ['44%', '70%'],
center: ['50%', '46%'],
itemStyle: { borderRadius: 6, borderColor: '#fff', borderWidth: 2 },
itemStyle: { borderRadius: 6, borderColor: skin.value?.surface ?? '#fff', borderWidth: 2 },
label: { formatter: '{b}\n{c}' },
data
}
@@ -540,7 +582,7 @@ const orderDeptAmountPieOption = computed(() => {
.map((d: any) => ({ name: d.dept_name || '—', value: parseAmount(d.amount) }))
.filter((d) => d.value > 0)
return {
color: pieColors,
color: skin.value ? jadePieColors : pieColors,
tooltip: {
trigger: 'item',
formatter: (p: any) => {
@@ -555,7 +597,7 @@ const orderDeptAmountPieOption = computed(() => {
type: 'pie',
radius: ['44%', '70%'],
center: ['50%', '46%'],
itemStyle: { borderRadius: 6, borderColor: '#fff', borderWidth: 2 },
itemStyle: { borderRadius: 6, borderColor: skin.value?.surface ?? '#fff', borderWidth: 2 },
label: { formatter: (p: any) => `${p.name}\n¥${Number(p.value).toFixed(0)}` },
data
}
@@ -582,7 +624,7 @@ function formatDate(d: Date) {
}
const orderChartOption = computed(() => {
const theme = settingStore.theme
const theme = chartPrimary.value
const barSeries = (orderStatsData.chart?.series || []).map((s: any) => ({
...s,
name: s.name || '单数',
@@ -611,12 +653,12 @@ const orderChartOption = computed(() => {
type: 'category',
data: orderStatsData.chart?.xAxis || [],
axisLabel: { rotate: 28, fontSize: 11 },
axisLine: { lineStyle: { color: '#e4e7ec' } }
axisLine: { lineStyle: { color: skin.value?.border ?? '#e4e7ec' } }
},
yAxis: {
type: 'value',
name: '单数',
splitLine: { lineStyle: { type: 'dashed', color: '#eef0f4' } }
splitLine: { lineStyle: { type: 'dashed', color: skin.value?.border ?? '#eef0f4' } }
},
tooltip: { trigger: 'axis' },
grid: { left: '2%', right: '2%', bottom: '12%', top: 48, containLabel: true },
@@ -660,7 +702,7 @@ const refreshAll = () => {
}
watch(
() => settingStore.theme,
chartPrimary,
() => {
updateColor()
}
@@ -690,8 +732,8 @@ const workbenchData: any = reactive({
data: [],
type: 'line',
smooth: true,
color: settingStore.theme,
lineStyle: { color: settingStore.theme, width: 2 },
color: chartPrimary.value,
lineStyle: { color: chartPrimary.value, width: 2 },
areaStyle: {
color: {
type: 'linear',
@@ -700,8 +742,8 @@ const workbenchData: any = reactive({
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: settingStore.theme },
{ offset: 1, color: settingStore.theme }
{ offset: 0, color: chartPrimary.value },
{ offset: 1, color: chartPrimary.value }
]
},
opacity: 0.12
@@ -731,8 +773,8 @@ const workbenchData: any = reactive({
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: calcColor(settingStore.theme, 0.65) },
{ offset: 1, color: settingStore.theme }
{ offset: 0, color: calcColor(chartPrimary.value, 0.65) },
{ offset: 1, color: chartPrimary.value }
]
}
}
@@ -793,7 +835,7 @@ const getData = () => {
}
const updateColor = () => {
const t = settingStore.theme
const t = chartPrimary.value
workbenchData.visitorOption.series[0].color = t
workbenchData.visitorOption.series[0].lineStyle.color = t
workbenchData.visitorOption.series[0].areaStyle.color.colorStops = [
@@ -1243,3 +1285,89 @@ onMounted(() => {
background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}
</style>
<style lang="scss">
html[data-admin-ui="v2"] .workbench-page {
min-width: 0;
padding: 0;
background: var(--zyt-canvas);
color: var(--zyt-text);
.wb-hero {
padding: 0;
margin: 0 0 20px;
border: 0;
border-radius: 0;
background: none;
box-shadow: none;
}
.wb-hero-title { color: var(--zyt-ink); font-size: clamp(22px, 2vw, 28px); letter-spacing: 0; }
.wb-hero-desc { color: var(--zyt-muted); font-size: 13px; }
.wb-refresh-btn { box-shadow: none; border-radius: 8px; }
.wb-section {
margin-bottom: 16px;
border: 1px solid var(--zyt-border);
border-image: none;
border-radius: var(--zyt-radius);
background: var(--zyt-surface);
box-shadow: var(--zyt-shadow);
backdrop-filter: none;
}
.wb-section-head {
padding: 14px 20px;
background: none;
border-color: var(--zyt-border);
}
.wb-section-title { gap: 10px; }
.wb-section-icon {
width: 36px; height: 36px; border-radius: 10px; font-size: 19px;
color: var(--zyt-primary); background: var(--zyt-accent-soft); box-shadow: none;
}
.wb-section-name, .wb-chart-title, .wb-dept-title, .wb-ranking-name,
.wb-dept-card-head, .wb-dept-num, .wb-ranking-money { color: var(--zyt-ink); }
.wb-section-name { font-size: 16px; }
.wb-section-sub, .wb-chart-hint, .wb-rank-strip-label, .wb-rank-empty, .wb-kpi-hint,
.wb-dept-total, .wb-dept-num small, .wb-dept-empty, .wb-ranking-meta,
.wb-rank-chip--dense small { color: var(--zyt-muted); }
.wb-toolbar { gap: 8px; }
.wb-section-body { padding: 16px 20px 20px; }
.wb-kpi-row, .wb-chart-row, .wb-trend-body > .el-row { row-gap: 12px; }
.wb-kpi, .wb-rank-strip {
min-height: 100px; padding: 15px 18px; border-radius: 10px;
background: var(--zyt-surface-subtle); border: 1px solid var(--zyt-border);
}
.wb-kpi { display: flex; flex-direction: column; justify-content: center; }
.wb-kpi-label { color: var(--zyt-text); }
.wb-kpi-value { color: var(--zyt-ink); font-weight: 650; overflow-wrap: anywhere; }
.wb-kpi--amber { background: var(--zyt-accent-soft); }
.wb-kpi--amber .wb-kpi-value { color: var(--zyt-primary); }
.wb-rank-chip {
color: var(--zyt-text); border-color: var(--zyt-border); background: var(--zyt-surface); box-shadow: none;
em, strong { color: var(--zyt-primary); }
}
.wb-chart-card {
border: 1px solid var(--zyt-border); border-radius: 10px;
padding: 12px 14px 6px; background: var(--zyt-surface);
}
.wb-chart-card-head { align-items: center; gap: 8px; margin-bottom: 8px; }
.wb-chart-title { font-size: 14px; }
.wb-dept-block { border-color: var(--zyt-border); }
.wb-dept-card, .wb-ranking-item {
background: var(--zyt-surface-subtle); border-color: var(--zyt-border); box-shadow: none;
border-radius: 8px;
}
.wb-ranking-item { margin-bottom: 5px; padding: 7px 10px; }
.wb-ranking-rank { background: var(--zyt-accent-soft); color: var(--zyt-primary); }
.wb-dept-row { color: var(--zyt-text); border-color: var(--zyt-border); }
@media (max-width: 640px) {
.wb-hero { gap: 10px; margin-bottom: 14px; }
.wb-section-head, .wb-section-body { padding: 12px; }
.wb-toolbar { width: 100%; }
.wb-toolbar .wb-select { min-width: 0; flex: 1; }
.wb-toolbar .wb-select--wide { flex: 1.5; }
.wb-kpi, .wb-rank-strip { min-height: 75px; padding: 12px 14px; }
.wb-chart-card { padding-inline: 9px; }
.wb-chart { max-height: 270px; }
.wb-chart-empty { min-height: 180px; }
}
}
</style>