fix(admin): 移除一诊患者和挂号统计的固定装饰绿
This commit is contained in:
@@ -15,15 +15,18 @@ const { outputText } = ts.transpileModule(content, { compilerOptions: { module:
|
||||
const groups = ['performance', 'registrations', 'appointments']
|
||||
|
||||
// Render the real page, replacing its HTTP response and running the mount fetch before SSR.
|
||||
async function rankings(samples) {
|
||||
async function renderStats(samples, palette = null) {
|
||||
const rankings = Object.fromEntries(groups.map((key, i) => [key, samples[i].map((value, j) =>
|
||||
({ admin_id: j + 1, name: '员工' + j, count: 1, value }))]))
|
||||
const stub = { render: () => null }
|
||||
let chartOption
|
||||
const chart = { props: ['option'], render() { chartOption = this.option; return null } }
|
||||
const imports = {
|
||||
vue: { ...vue, onMounted: vue.onServerPrefetch },
|
||||
'@/api/first_visit': { firstVisitRegistrationStatsOverview: async () => ({ rankings }) },
|
||||
'@/hooks/useStatsChartPalette': { useStatsChartPalette: () => vue.shallowRef(palette) },
|
||||
'@element-plus/icons-vue': new Proxy({}, { get: () => stub }),
|
||||
'element-plus': {}, 'vue-echarts': { default: stub }
|
||||
'element-plus': {}, 'vue-echarts': { default: chart }
|
||||
}
|
||||
const mod = { exports: {} }
|
||||
new Function('require', 'module', 'exports', outputText)(id => imports[id] || require(id), mod, mod.exports)
|
||||
@@ -34,12 +37,46 @@ async function rankings(samples) {
|
||||
}
|
||||
app.directive('loading', {})
|
||||
const html = await renderToString(app)
|
||||
return { html, chartOption }
|
||||
}
|
||||
|
||||
async function rankings(samples) {
|
||||
const { html } = await renderStats(samples)
|
||||
const panels = [...html.matchAll(/<article class="panel ranking-panel"[^>]*>([\s\S]*?)<\/article>/g)]
|
||||
assert.equal(panels.length, 3)
|
||||
return panels.map(([, panel]) => [...panel.matchAll(/<div class="ranking-row"[^>]*><b[^>]*>(\d+)<\/b>.*?<i style="width:([^;"]+);?"[^>]*><\/i><\/div><strong[^>]*>([^<]+)<\/strong>/gs)]
|
||||
.map(([, rank, width, label]) => ({ rank: Number(rank), width, label })))
|
||||
}
|
||||
|
||||
test('target chart and external legend share the selected primary and a separate dashed comparison', async () => {
|
||||
const theme = {
|
||||
surface: '#161618', ink: '#eeeeef', muted: '#b2b2c5', accentInk: '#b395ff',
|
||||
accentText: '#bda9f9', border: '#394055', grid: '#252530'
|
||||
}
|
||||
const { html, chartOption } = await renderStats([[], [], []], theme)
|
||||
const [actual, target] = chartOption.series
|
||||
assert.equal(actual.lineStyle.color, theme.accentInk)
|
||||
assert.equal(actual.itemStyle.color, theme.accentInk)
|
||||
assert.equal(actual.areaStyle.color, theme.accentInk)
|
||||
assert.equal(target.lineStyle.color, theme.muted)
|
||||
assert.equal(target.lineStyle.type, 'dashed')
|
||||
assert.equal(target.itemStyle.color, theme.muted)
|
||||
assert.ok(html.includes('--registration-series:' + theme.accentInk))
|
||||
assert.ok(html.includes('--registration-detail:' + theme.muted))
|
||||
assert.equal(chartOption.tooltip.backgroundColor, theme.surface)
|
||||
assert.equal(chartOption.xAxis.axisLabel.color, theme.muted)
|
||||
assert.equal(chartOption.yAxis.splitLine.lineStyle.color, theme.grid)
|
||||
})
|
||||
|
||||
test('classic target chart keeps both original line colors and original tooltip defaults', async () => {
|
||||
const { html, chartOption } = await renderStats([[], [], []])
|
||||
assert.equal(chartOption.series[0].lineStyle.color, '#139a8c')
|
||||
assert.equal(chartOption.series[1].lineStyle.color, '#5f86e8')
|
||||
assert.equal(chartOption.series[0].itemStyle.color, '#ffffff')
|
||||
assert.equal(chartOption.tooltip.backgroundColor, undefined)
|
||||
assert.ok(!html.includes('--registration-series:'))
|
||||
})
|
||||
|
||||
const cases = [
|
||||
[[2, 1, 0], ['100%', '50%', '0%']],
|
||||
[[100, 1, 0], ['100%', '1%', '0%']],
|
||||
|
||||
Reference in New Issue
Block a user