feat(admin): 升级后台主题并增加本机只读预览
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<template><span class="preview-identity" title="仅使用本机生成的演示数据,不连接业务后台"><i aria-hidden="true"></i>本地只读<span>预览</span></span></template>
|
||||
<style scoped>.preview-identity{display:inline-flex;align-items:center;gap:3px;font-size:12px;color:var(--el-text-color-regular);white-space:nowrap}.preview-identity i{width:7px;height:7px;background:#1b916b;border-radius:50%;margin-right:4px}@media(max-width:520px){.preview-identity span{display:none}}</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
# 甄养堂管理后台:本地主题预览
|
||||
|
||||
从本分支的真实工作台、订单列表和导航构建。独立 HTML、只读预览身份与合成数据替代登录、通知轮询和生产账户操作。只允许两条预览页面路由;不读业务数据库,无代理,不执行生产发布脚本或同步发布目录。构建复用本项目已安装的前端依赖,不需要后端或数据库凭据。
|
||||
|
||||
在 admin 目录执行:
|
||||
|
||||
```sh
|
||||
node local-preview/build.mjs && node local-preview/server.mjs 5178
|
||||
```
|
||||
|
||||
打开 `http://127.0.0.1:5178/admin/workbench` 或 `http://127.0.0.1:5178/admin/order`。初次默认新版,顶栏切换可比较经典版。订单数据是虚构的,可筛选、翻页、看详情,不支持写入。停止前台服务按 Ctrl+C。改代码后重新构建即可,刷新页面获取新版本。
|
||||
|
||||
独立构建输出仅在本 worktree 的 `admin/node_modules/.zyt-ui-preview/dist`。本地服务器只绑定 IPv4 回环,校验 Host / Origin;只提供构建静态资源和显式模拟的查询端点(唯一允许的 POST 是查看订单详情)。未识别的请求不会转发。浏览器 CSP 限制接口、静态资源和图片加载。常规生产入口不使用预览路由或合成数据。
|
||||
|
||||
本机若用 macOS 会话任务启动本分支的预览,可用 `launchctl list local.zyt.theme-preview.bfc2` 查看、`launchctl remove local.zyt.theme-preview.bfc2` 停止;停止预览不影响其他应用。未安装开机启动项。
|
||||
|
||||
验证:`node --test local-preview/fixtures.test.mjs` 检查模拟数据;服务运行后 `node local-preview/verify-http.mjs` 复核写入、代理、跨域等均被拒绝。可选的 `browser_smoke.py` 使用 Python Playwright 和本地 Chromium,只允许本机请求。
|
||||
@@ -0,0 +1,12 @@
|
||||
<template><el-config-provider :locale="zhCn"><router-view /></el-config-provider></template>
|
||||
<script setup lang="ts">
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import { useDark, useWindowSize } from '@vueuse/core'
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import { ScreenEnum } from '@/enums/appEnums'
|
||||
const app = useAppStore(), settings = useSettingStore(), dark = useDark()
|
||||
const { width } = useWindowSize()
|
||||
watch(dark, v => settings.setTheme(v), { immediate: true })
|
||||
watch(width, w => { app.setMobile(w <= ScreenEnum.SM); app.toggleCollapsed(w < ScreenEnum.MD) }, { immediate: true })
|
||||
</script>
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Browser acceptance for the loopback-only theme preview; never allow a remote URL."""
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
from playwright.sync_api import sync_playwright, expect
|
||||
|
||||
args = argparse.ArgumentParser()
|
||||
args.add_argument('--screens', type=Path, required=True)
|
||||
args.add_argument('--chrome', help='Path to an installed Chromium/Chrome executable')
|
||||
a = args.parse_args(); a.screens.mkdir(exist_ok=True, parents=True)
|
||||
origin = 'http://127.0.0.1:5178'
|
||||
errors, external, failed = [], [], []
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(executable_path=a.chrome, args=['--disable-background-networking','--no-proxy-server','--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1'])
|
||||
ctx = browser.new_context(viewport={'width':1440, 'height':960}, color_scheme='light', service_workers='block')
|
||||
def only_local(route):
|
||||
if route.request.url.startswith(origin+'/'):
|
||||
route.continue_()
|
||||
else:
|
||||
external.append(route.request.url); route.abort()
|
||||
ctx.route('**/*',only_local)
|
||||
page = ctx.new_page()
|
||||
page.on('pageerror', lambda e: errors.append(str(e)))
|
||||
page.on('response', lambda r: failed.append([r.status,r.url]) if r.status >= 400 else None)
|
||||
page.goto(origin+'/admin/workbench', wait_until='networkidle'); expect(page.get_by_role('heading', name='数据工作台')).to_be_visible()
|
||||
expect(page.locator('canvas').first).to_be_visible(); assert page.locator('canvas').count() >= 3
|
||||
root = page.locator('html'); switch = page.locator('[data-admin-ui-toggle]'); expect(root).to_have_attribute('data-admin-ui','v2')
|
||||
page.screenshot(path=str(a.screens/'workbench.png')); switch.click(); expect(root).to_have_attribute('data-admin-ui','legacy')
|
||||
page.screenshot(path=str(a.screens/'classic-workbench.png')); switch.click()
|
||||
page.get_by_role('menuitem',name='订单列表').click(); expect(page.locator('.zyt-order-records tr.el-table__row')).to_have_count(15)
|
||||
expect(page.get_by_text('共 258 条').first).to_be_visible(); assert page.get_by_role('button',name='创建支付单').count()==0 or not page.get_by_role('button',name='创建支付单').first.is_visible()
|
||||
rows=page.locator('.zyt-order-records tr.el-table__row'); first=rows.first.locator('td.zyt-order-id').inner_text().strip(); assert first.startswith('DEMO-')
|
||||
page.screenshot(path=str(a.screens/'orders.png'))
|
||||
page.locator('.el-pagination .btn-next').first.click(); expect(rows.first.locator('td.zyt-order-id')).not_to_have_text(first)
|
||||
field=page.get_by_placeholder('请输入订单号'); field.fill(first); page.get_by_role('button',name='查询',exact=True).click(); expect(rows).to_have_count(1)
|
||||
switch.click(); expect(root).to_have_attribute('data-admin-ui','legacy'); expect(field).to_have_value(first); expect(rows).to_have_count(1)
|
||||
switch.click(); expect(root).to_have_attribute('data-admin-ui','v2'); expect(field).to_have_value(first)
|
||||
page.get_by_role('button',name='详情',exact=True).first.click(); dlg=page.get_by_role('dialog',name='订单详情'); expect(dlg).to_be_visible(); expect(dlg).to_contain_text(first); page.keyboard.press('Escape'); expect(dlg).not_to_be_visible()
|
||||
page.get_by_role('button',name='重置',exact=True).click(); expect(rows).to_have_count(15)
|
||||
page.emulate_media(color_scheme='dark'); expect(root).to_have_class(re.compile('dark')); page.screenshot(path=str(a.screens/'orders-dark.png'))
|
||||
page.set_viewport_size({'width':390,'height':844}); page.emulate_media(color_scheme='light'); expect(page.get_by_role('heading',name='订单管理')).to_be_visible()
|
||||
assert page.evaluate('document.documentElement.scrollWidth <= innerWidth + 1'), 'page-level horizontal overflow'
|
||||
expect(switch).to_be_visible(); page.screenshot(path=str(a.screens/'orders-mobile.png'))
|
||||
browser.close()
|
||||
assert not errors and not external and not failed, (errors, external, failed)
|
||||
print(json.dumps({'PASS':['real_workbench_charts','menu_navigation','pagination','filter','switch_preserves_order','read_only_detail','wide_dark_mobile','no_page_overflow'], 'browser_errors':errors,'external_requests':external,'unexpected_http_errors':failed},ensure_ascii=False))
|
||||
@@ -0,0 +1,24 @@
|
||||
// Dedicated build: no inherited Vite config, deployment script, production HTML, .env, or public directory.
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import path from 'node:path'
|
||||
import { mkdir } from 'node:fs/promises'
|
||||
import { build } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
|
||||
const here = path.dirname(fileURLToPath(import.meta.url)), root = path.dirname(here)
|
||||
process.chdir(root)
|
||||
export const outDir = path.join(root,'node_modules/.zyt-ui-preview/dist')
|
||||
await mkdir(outDir, {recursive:true})
|
||||
await build({ root, configFile:false, envFile:false, envPrefix:'ZYT_LOCAL_NO_EXPOSE_', publicDir:false, base:'/admin/',
|
||||
cacheDir:path.join(root,'node_modules/.zyt-ui-preview/cache'),
|
||||
define:{'import.meta.env.VITE_APP_BASE_URL':JSON.stringify('')},
|
||||
resolve:{alias:[{find:/^@\/router$/,replacement:path.join(here,'router.ts')},{find:/^\.\/user-drop-down\.vue$/,replacement:path.join(here,'PreviewIdentity.vue')},{find:'@',replacement:path.join(root,'src')}]},
|
||||
plugins:[vue(),vueJsx(),createSvgIconsPlugin({iconDirs:[path.join(root,'src/assets/icons')],symbolId:'local-icon-[dir]-[name]'}),AutoImport({imports:['vue','vue-router'],resolvers:[ElementPlusResolver({importStyle:false})],dts:false}),Components({dirs:[path.join(root,'src/components')],directoryAsNamespace:true,dts:false}),vueSetupExtend()],
|
||||
build:{outDir,emptyOutDir:true,sourcemap:false,reportCompressedSize:false,rollupOptions:{input:path.join(here,'index.html')}},
|
||||
css:{preprocessorOptions:{scss:{api:'modern-compiler'}}}
|
||||
})
|
||||
@@ -0,0 +1,201 @@
|
||||
// Local Vite preview only. All records are generated here; no accounts, DBs or upstream APIs.
|
||||
const departments = ['一组', '二组', '三组'].map((n, i) => ({ dept_id: i + 1, dept_name: '演示运营' + n }))
|
||||
const assistants = ['宁禾', '云初', '林川', '叶青', '许安'].map((n, i) => ({
|
||||
id: 101 + i, name: n + '(演示)', dept_id: departments[i % departments.length].dept_id
|
||||
}))
|
||||
const types = ['退款统计', '挂号费', '问诊费', '药品费用', '首付费用', '尾款费用', '其他费用', '全部费用', '驼奶费用']
|
||||
const amounts = [29, 99, 238, 300, 580, 68, 798, 199]
|
||||
// Never use dialable numbers or real patient data in the preview.
|
||||
const patients = Array.from({ length: 20 }, (_, i) => ({
|
||||
id: 501 + i, patient_name: '演示患者' + pad(i + 1), phone: '000****' + String(1000 + i)
|
||||
}))
|
||||
|
||||
function pad(n) { return String(n).padStart(2, '0') }
|
||||
function dateLabel(offset = 0, now = new Date()) {
|
||||
const d = new Date(now)
|
||||
d.setDate(d.getDate() - offset)
|
||||
return [d.getFullYear(), pad(d.getMonth() + 1), pad(d.getDate())].join('-')
|
||||
}
|
||||
|
||||
function makeOrders(now) {
|
||||
const rows = []
|
||||
const states = [2, 1, 5, 2, 4, 3, 2, 2, 1, 2, 3, 2, 5, 2, 4, 2, 2]
|
||||
const channels = ['normal', 'wechat_work', 'normal', 'express_cod', 'fubei']
|
||||
for (let day = 0; day < 30; day++) {
|
||||
const date = dateLabel(day, now)
|
||||
const count = day ? 5 + day % 7 : 28
|
||||
// Spread today's orders over *elapsed* time, not later this afternoon.
|
||||
const latestMinute = day ? 17 * 60 : now.getHours() * 60 + now.getMinutes()
|
||||
for (let slot = 0; slot < count; slot++) {
|
||||
const i = rows.length
|
||||
const minute = Math.max(0, latestMinute - slot * 13)
|
||||
const time = date + ' ' + pad(Math.floor(minute / 60)) + ':' + pad(minute % 60) + ':00'
|
||||
const type = i % 8 + 1
|
||||
const status = states[i % states.length]
|
||||
const creator = assistants[(i + Math.floor(i / 8)) % assistants.length]
|
||||
const patient = i % 6 === 1 ? null : patients[i % patients.length]
|
||||
const channel = status === 5 ? 'fubei' : channels[i % channels.length]
|
||||
rows.push({
|
||||
id: 10001 + i, order_no: 'DEMO-' + date.replaceAll('-', '') + '-' + String(i + 1).padStart(4, '0'),
|
||||
creator_id: creator.id, creator, patient_id: patient?.id || 0, patient,
|
||||
amount: (amounts[type - 1] + i % 3).toFixed(2),
|
||||
status, order_type: type, create_type: channel, is_exempt: 0,
|
||||
payment_method: channel === 'normal' ? (i % 2 ? 'alipay' : 'wechat') : channel,
|
||||
create_time: time, payment_time: [2, 4].includes(status) ? time : null,
|
||||
remark: '本地合成的支付单,用于预览界面。',
|
||||
prescription_orders: patient && i % 3 === 0 ? [{ id: 20001 + i, order_no: 'DEMO-RX-' + (301 + i) }] : []
|
||||
})
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
function positiveInt(raw, fallback, maximum) {
|
||||
const n = Number(raw)
|
||||
return Number.isSafeInteger(n) && n > 0 ? Math.min(n, maximum) : fallback
|
||||
}
|
||||
|
||||
function paged(rows, q) {
|
||||
const page = positiveInt(q.page_no, 1, Number.MAX_SAFE_INTEGER)
|
||||
const size = positiveInt(q.page_size, 15, 100)
|
||||
return { count: rows.length, lists: rows.slice((page - 1) * size, page * size), extend: {} }
|
||||
}
|
||||
|
||||
function matchesPatient(p, keyword) {
|
||||
return !keyword || (p && (p.patient_name.includes(keyword) || p.phone.includes(keyword)))
|
||||
}
|
||||
|
||||
function filterOrders(rows, q) {
|
||||
const end = endOfFilter(q.create_time_end)
|
||||
return rows.filter(r =>
|
||||
(!q.order_no || r.order_no.toLowerCase().includes(String(q.order_no).trim().toLowerCase())) &&
|
||||
matchesPatient(r.patient, String(q.patient_keyword ?? '').trim()) &&
|
||||
(!q.assistant_id || r.creator_id === Number(q.assistant_id)) &&
|
||||
(!q.order_type || r.order_type === Number(q.order_type)) &&
|
||||
(!q.status || r.status === Number(q.status)) &&
|
||||
(!q.patient_association || (r.patient ? 'associated' : 'pending') === q.patient_association) &&
|
||||
(!q.create_time_start || r.create_time >= q.create_time_start) &&
|
||||
(!end || r.create_time <= end)
|
||||
)
|
||||
}
|
||||
function endOfFilter(s) {
|
||||
return s && s.length === 10 ? s + ' 23:59:59' : s
|
||||
}
|
||||
function sumMoney(rows) {
|
||||
return (rows.reduce((sum, r) => sum + Math.round(Number(r.amount) * 100), 0) / 100).toFixed(2)
|
||||
}
|
||||
function rankOrders(rows) {
|
||||
return assistants.map(a => {
|
||||
const own = rows.filter(r => r.creator_id === a.id)
|
||||
return { ...a, count: own.length, amount: sumMoney(own) }
|
||||
}).filter(a => a.count).sort((a, b) => b.count - a.count || Number(b.amount) - Number(a.amount))
|
||||
}
|
||||
function chart(ranking, name) {
|
||||
return { xAxis: ranking.map(a => a.name), series: [{ name, data: ranking.map(a => a.count) }] }
|
||||
}
|
||||
|
||||
function orderStats(rows, q, now) {
|
||||
const today = dateLabel(0, now)
|
||||
const start = dateLabel(Math.min(30, Math.max(0, Number(q.days ?? 0) || 0)), now)
|
||||
const type = Number(q.order_type ?? -1)
|
||||
const selected = rows.filter(r => r.create_time >= start &&
|
||||
(type === 0 ? r.status === 4 : r.status === 2 && (type === -1 || r.order_type === type)))
|
||||
const current = selected.filter(r => r.create_time.startsWith(today))
|
||||
const ranking = rankOrders(selected)
|
||||
return {
|
||||
order_type_name: type === -1 ? '全部(已支付)' : types[type], date_range: [start, today],
|
||||
today_total: current.length, today_amount: sumMoney(current), today_ranking: rankOrders(current),
|
||||
ranking, chart: chart(ranking, '单数'),
|
||||
departments: departments.map(d => {
|
||||
const own = selected.filter(r => r.creator.dept_id === d.dept_id)
|
||||
return { ...d, total: own.length, amount: sumMoney(own), members: rankOrders(own) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function diagnosisStats(q, now) {
|
||||
const days = Math.min(30, Math.max(0, Math.trunc(Number(q.days ?? 0) || 0)))
|
||||
const rank = (daysBack) => assistants.map((a, i) => {
|
||||
let count = 0
|
||||
for (let day = 0; day <= daysBack; day++) count += 2 + (2 * i + day) % 7
|
||||
return { ...a, count }
|
||||
}).sort((a, b) => b.count - a.count)
|
||||
const today = rank(0), ranking = rank(days)
|
||||
return {
|
||||
date_range: [dateLabel(days, now), dateLabel(0, now)], today_ranking: today,
|
||||
today_total: today.reduce((n, a) => n + a.count, 0), ranking, chart: chart(ranking, '诊单数'),
|
||||
departments: departments.map(d => {
|
||||
const members = ranking.filter(a => a.dept_id === d.dept_id)
|
||||
return { ...d, total: members.reduce((n, a) => n + a.count, 0), assistants: members }
|
||||
})
|
||||
}
|
||||
}
|
||||
function workbench(rows, now) {
|
||||
// The actual Vue component reverses dates (but NOT values) on receipt.
|
||||
const date = Array.from({ length: 7 }, (_, i) => dateLabel(i, now))
|
||||
const sale = [...date].reverse().map(d => Number(
|
||||
(Number(sumMoney(rows.filter(r => r.status === 2 && r.payment_time.startsWith(d)))) / 10000).toFixed(2)
|
||||
))
|
||||
return { menu: [], today: {}, version: {}, support: {},
|
||||
visitor: { date, list: [{ data: [68, 83, 79, 105, 90, 120, 111] }] },
|
||||
sale: { date: [...date], list: [{ data: sale }] } }
|
||||
}
|
||||
|
||||
function logs(rows) {
|
||||
return rows.map(r => ({
|
||||
order_id: r.id, admin_id: r.creator_id, admin_name: r.creator.name, action_label: '创建支付单',
|
||||
summary: '生成本地演示记录', create_time_text: r.create_time
|
||||
}))
|
||||
}
|
||||
|
||||
// Keep timestamps stable while browsing, and reseed the sample automatically on a new local day.
|
||||
let sampleClock
|
||||
function snapshotTime() {
|
||||
const live = new Date()
|
||||
if (!sampleClock || dateLabel(0, sampleClock) !== dateLabel(0, live)) sampleClock = live
|
||||
return sampleClock
|
||||
}
|
||||
|
||||
/** Closed allowlist; null means the transport must reject, never proxy. */
|
||||
export function resolveFixture(pathname, params = {}) {
|
||||
const q = params instanceof URLSearchParams ? Object.fromEntries(params) : params || {}
|
||||
const now = snapshotTime()
|
||||
const ok = data => ({ code: 1, data, msg: '', show: 0 })
|
||||
switch (pathname) {
|
||||
case '/adminapi/workbench/index': return ok(workbench(makeOrders(now), now))
|
||||
case '/adminapi/tcm.diagnosis/assistantDiagnosisStats': return ok(diagnosisStats(q, now))
|
||||
case '/adminapi/order.order/orderStats': return ok(orderStats(makeOrders(now), q, now))
|
||||
case '/adminapi/order.order/lists': return ok(paged(filterOrders(makeOrders(now), q), q))
|
||||
case '/adminapi/order.order/todayRevenue': {
|
||||
const paid = makeOrders(now).filter(r => r.status === 2 && r.payment_time.startsWith(dateLabel(0, now)))
|
||||
return ok({ count: paid.length, amount: sumMoney(paid) })
|
||||
}
|
||||
case '/adminapi/tcm.diagnosis/getAssistants': return ok(assistants.map(a => ({
|
||||
id: a.id, name: a.name, dept_ids: [a.dept_id], dept_names: departments[a.dept_id - 1].dept_name
|
||||
})))
|
||||
case '/adminapi/tcm.diagnosis/searchPatient':
|
||||
return ok(paged(patients.filter(p => matchesPatient(p, String(q.keyword ?? '').trim())), q))
|
||||
// The shared export widget asks for counts even when its button is hidden.
|
||||
// Only answer the metadata probe. Never generate/download an export (mode 2).
|
||||
case '/adminapi/order.order/export': {
|
||||
if (String(q.export) !== '1') return null
|
||||
const count = filterOrders(makeOrders(now), q).length
|
||||
const size = positiveInt(q.page_size, 15, 100)
|
||||
return ok({ count, sum_page: Math.ceil(count / size), page_size: size, max_page: 0, all_max_size: 0 })
|
||||
}
|
||||
case '/adminapi/order.order/detail': {
|
||||
const row = makeOrders(now).find(r => r.id === Number(q.id))
|
||||
return row ? ok(row) : { code: 0, data: null, show: 1, msg: '演示订单不存在' }
|
||||
}
|
||||
case '/adminapi/order.order/actionLogs':
|
||||
return ok(paged(logs(makeOrders(now).filter(r => r.id === Number(q.order_id))), q))
|
||||
case '/adminapi/order.order/actionLogStats': {
|
||||
const start = q.start_time || dateLabel(6, now), end = endOfFilter(q.end_time || dateLabel(0, now))
|
||||
const records = logs(makeOrders(now)).filter(l => l.create_time_text >= start && l.create_time_text <= end)
|
||||
return ok({ start_time: start, end_time: end, list: assistants.map(a => ({
|
||||
admin_name: a.name, cnt: records.filter(r => r.admin_id === a.id).length
|
||||
})).filter(a => a.cnt).sort((a, b) => b.cnt - a.cnt).slice(0, positiveInt(q.limit, 50, 100)) })
|
||||
}
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { resolveFixture } from './fixtures.mjs'
|
||||
|
||||
const read = (path, query) => {
|
||||
const result = resolveFixture('/adminapi/' + path, query)
|
||||
assert.equal(result.code, 1)
|
||||
assert.deepEqual([result.msg, result.show], ['', 0])
|
||||
return result.data
|
||||
}
|
||||
const orders = q => read('order.order/lists', q)
|
||||
|
||||
test('分页、每种状态、订单号、患者与医助过滤使用同一数据集', () => {
|
||||
const first = orders({}), second = orders(new URLSearchParams('page_no=2&page_size=15'))
|
||||
assert.ok(first.count > 15)
|
||||
assert.equal(first.lists.length, 15)
|
||||
assert.equal(second.count, first.count)
|
||||
assert.ok(!first.lists.some(r => second.lists.some(other => other.id === r.id)))
|
||||
assert.deepEqual(orders({ order_no: 'NO-MATCH' }).lists, [])
|
||||
for (const status of [1, 2, 3, 4, 5]) {
|
||||
const { lists } = orders({ status: String(status) })
|
||||
assert.ok(lists.length && lists.every(r => r.status === status))
|
||||
}
|
||||
const r = first.lists[0]
|
||||
assert.deepEqual(orders({ order_no: r.order_no.toLowerCase(), patient_keyword: r.patient.phone,
|
||||
order_type: r.order_type, assistant_id: r.creator.id, status: r.status, create_time_start: r.create_time,
|
||||
create_time_end: r.create_time }).lists, [r])
|
||||
assert.equal(orders({ create_time_end: '2000-01-01' }).count, 0)
|
||||
assert.equal(orders({ patient_association: 'pending' }).count + orders({ patient_association: 'associated' }).count, first.count)
|
||||
assert.ok(orders({ patient_association: 'pending' }).lists.every(r => !r.patient))
|
||||
assert.ok(read('tcm.diagnosis/getAssistants').some(a => a.id === r.creator_id))
|
||||
assert.ok(read('tcm.diagnosis/searchPatient', { keyword: r.patient.patient_name }).lists.some(p => p.id === r.patient_id))
|
||||
})
|
||||
|
||||
test('订单详情和日志只读取演示数据,统计按日期返回', () => {
|
||||
const sample = orders({}).lists[0]
|
||||
assert.deepEqual(read('order.order/detail', { id: sample.id }), sample)
|
||||
assert.equal(resolveFixture('/adminapi/order.order/detail', { id: -1 }).code, 0)
|
||||
const records = read('order.order/actionLogs', { order_id: sample.id })
|
||||
assert.ok(records.count && records.lists.every(l => l.order_id === sample.id))
|
||||
assert.ok(read('order.order/actionLogStats').list.length)
|
||||
assert.deepEqual(read('order.order/actionLogStats', { start_time: '1999-01-01', end_time: '1999-01-07' }).list, [])
|
||||
})
|
||||
|
||||
test('工作台图表均有数据;今日收益、类型、周期和排行榜可核对', () => {
|
||||
const revenue = read('order.order/todayRevenue')
|
||||
const today = read('order.order/orderStats', { order_type: -1, days: 0 })
|
||||
assert.deepEqual([revenue.count, revenue.amount], [today.today_total, today.today_amount])
|
||||
assert.ok(revenue.count && Number(revenue.amount) > 0)
|
||||
const count = rs => rs.reduce((n, a) => n + a.count, 0)
|
||||
assert.equal(count(today.ranking), revenue.count)
|
||||
const week = read('order.order/orderStats', { order_type: -1, days: 7 })
|
||||
assert.ok(count(week.ranking) > revenue.count)
|
||||
assert.ok(week.chart.xAxis.length && week.departments.every(d => d.total > 0))
|
||||
for (let type = 0; type <= 8; type++) {
|
||||
const result = read('order.order/orderStats', { order_type: type, days: 30 })
|
||||
assert.ok(result.order_type_name && result.ranking.length)
|
||||
}
|
||||
const diagnosis = read('tcm.diagnosis/assistantDiagnosisStats', { days: 14 })
|
||||
assert.equal(diagnosis.today_total, count(diagnosis.today_ranking))
|
||||
assert.ok(diagnosis.chart.xAxis.length && count(diagnosis.ranking) > diagnosis.today_total)
|
||||
const wb = read('workbench/index')
|
||||
for (const series of [wb.visitor, wb.sale]) {
|
||||
assert.equal(series.date.length, series.list[0].data.length)
|
||||
assert.ok(series.list[0].data.every(n => n > 0))
|
||||
}
|
||||
})
|
||||
|
||||
test('未列入白名单的路径一律不生成响应(包括会写入的 GET)', () => {
|
||||
for (const p of ['order.order/create', 'order.order/delete', 'order.order/edit', 'order.order/syncWechatWorkBills',
|
||||
'order.order/syncWechatWorkBillsDebug', 'order.order/export', 'order.order/pay', 'unknown']) {
|
||||
assert.equal(resolveFixture('/adminapi/' + p), null)
|
||||
}
|
||||
assert.equal(resolveFixture('/api/workbench/index'), null)
|
||||
})
|
||||
|
||||
test('隐藏导出控件只获得合成条数,不生成导出文件', () => {
|
||||
assert.equal(read('order.order/export', { export: '1' }).count, orders({}).count)
|
||||
assert.equal(resolveFixture('/adminapi/order.order/export', { export: '2' }), null)
|
||||
})
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="zh-CN" data-admin-ui="v2"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>甄养堂 · 本地主题预览</title><link rel="icon" href="data:,"></head><body><div id="app"></div><script type="module" src="./main.ts"></script></body></html>
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'virtual:svg-icons-register'
|
||||
import 'element-plus/dist/index.css'
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css'
|
||||
import '@/styles/index.scss'
|
||||
import '@/install/plugins/echart'
|
||||
import { createApp } from 'vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import installIcons from '@/install/plugins/element'
|
||||
import perms from '@/install/directives/perms'
|
||||
import store from '@/stores'
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import useTabsStore from '@/stores/modules/multipleTabs'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import Root from './Root.vue'
|
||||
import router, { pages } from './router'
|
||||
import logo from './preview-mark.svg'
|
||||
const app = createApp(Root)
|
||||
app.use(store); app.use(ElementPlus); installIcons(app); app.directive('perms', perms)
|
||||
useUserStore().$patch({ token: '', userInfo: { name: '本地预览', role_ids: [] }, perms: ['order.order/lists','order.order/detail'], routes: pages.map(({ path, name, meta }) => ({ path, name, meta })) as any })
|
||||
useAppStore().$patch({ configFetchAttempted: true, config: { web_name: '甄养堂', web_logo: logo } })
|
||||
useSettingStore().$patch({ showLogo: true })
|
||||
useTabsStore().setRouteName('preview-workbench')
|
||||
app.use(router); router.isReady().then(() => app.mount('#app'))
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><rect x="1" y="1" width="38" height="38" rx="11" fill="#13765e"/><path d="M10 26c0-11 6-17 20-17 0 13-6 20-17 19m0-2 13-13m-8 8v-5m2 3h5" fill="none" stroke="#f5fffa" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9"/></svg>
|
||||
|
After Width: | Height: | Size: 301 B |
@@ -0,0 +1,15 @@
|
||||
// Only the two real business pages under review. Do not load auth, chat, or other production routes.
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Layout from '@/layout/default/index.vue'
|
||||
export const pages = [
|
||||
{ path: '/workbench', name: 'preview-workbench', component: () => import('@/views/workbench/index.vue'), meta: { title: '数据工作台', icon: 'el-icon-DataAnalysis', keepAlive: true } },
|
||||
{ path: '/order', name: 'preview-order', component: () => import('@/views/order/index.vue'), meta: { title: '订单列表', icon: 'el-icon-Tickets', keepAlive: true } }
|
||||
]
|
||||
const router = createRouter({ history: createWebHistory('/admin/'), routes: [
|
||||
{ path: '/', component: Layout, redirect: '/workbench', children: pages },
|
||||
{ path: '/:other(.*)*', redirect: '/workbench' }
|
||||
] })
|
||||
// Satisfy the shared auth/store imports without registering any real routes or permission lookups.
|
||||
export const filterAsyncRoutes = () => []
|
||||
export const resetRouter = () => undefined
|
||||
export default router
|
||||
@@ -0,0 +1,40 @@
|
||||
// A loopback static/fixture server. No proxy, database driver, transport client or environment credentials.
|
||||
import http from 'node:http'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import path from 'node:path'
|
||||
import { resolveFixture } from './fixtures.mjs'
|
||||
const dist = fileURLToPath(new URL('../node_modules/.zyt-ui-preview/dist/', import.meta.url))
|
||||
const port = Number(process.argv[2] ?? 5178), host = '127.0.0.1'
|
||||
const origin = `http://${host}:${port}`
|
||||
const csp = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data: blob:; font-src 'self' data:; media-src 'none'; frame-src 'none'; worker-src 'none'; form-action 'none'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
|
||||
const types = {'.js':'application/javascript','.css':'text/css','.svg':'image/svg+xml','.woff2':'font/woff2','.woff':'font/woff','.png':'image/png','.jpg':'image/jpeg','.webp':'image/webp','.gif':'image/gif','.ttf':'font/ttf'}
|
||||
const routes = new Set(['/','/admin','/admin/','/admin/workbench','/admin/order'])
|
||||
async function serve(req,res) {
|
||||
res.setHeader('Content-Security-Policy',csp); res.setHeader('Cache-Control','no-store'); res.setHeader('X-Content-Type-Options','nosniff'); res.setHeader('Referrer-Policy','no-referrer')
|
||||
const send=(status,type,body)=>{ res.writeHead(status,{'Content-Type':type}); res.end(req.method==='HEAD' ? undefined : body) }
|
||||
const json=(status,obj)=>send(status,'application/json; charset=utf-8',JSON.stringify(obj))
|
||||
const deny=(status)=>json(status,{code:0,show:1,msg:'本地只读预览:此操作未开放',data:null})
|
||||
if(req.headers.host !== `${host}:${port}` || (req.headers.origin && req.headers.origin !== origin) || req.headers['sec-fetch-site']==='cross-site') return deny(403)
|
||||
if(!req.url?.startsWith('/') || req.url.startsWith('//')) return deny(400)
|
||||
const {pathname,searchParams}=new URL(req.url,origin)
|
||||
if(pathname.startsWith('/adminapi/')) {
|
||||
let params=Object.fromEntries(searchParams)
|
||||
if(pathname==='/adminapi/order.order/detail') {
|
||||
if(req.method!=='POST') return deny(405)
|
||||
if(!req.headers['content-type']?.startsWith('application/json')) return deny(415)
|
||||
let raw=''; for await(const chunk of req){ raw+=chunk; if(raw.length>4096) return deny(413) }
|
||||
try { params=JSON.parse(raw); if(!params || typeof params!=='object' || Array.isArray(params)) return deny(400) } catch { return deny(400) }
|
||||
} else if(req.method!=='GET') return deny(405)
|
||||
const result=resolveFixture(pathname,params); return result ? json(200,result) : deny(403)
|
||||
}
|
||||
if(!['GET','HEAD'].includes(req.method)) return deny(405)
|
||||
if(routes.has(pathname)) return send(200,'text/html; charset=utf-8',await readFile(path.join(dist,'local-preview/index.html')))
|
||||
const asset=pathname.match(/^\/admin\/assets\/([a-zA-Z0-9_.-]+)$/)
|
||||
if(asset && types[path.extname(asset[1])]) {
|
||||
try { return send(200,types[path.extname(asset[1])],await readFile(path.join(dist,'assets',asset[1]))) } catch { return deny(404) }
|
||||
}
|
||||
return deny(404)
|
||||
}
|
||||
await readFile(path.join(dist,'local-preview/index.html'))
|
||||
http.createServer((req,res)=>serve(req,res).catch(()=>{if(!res.headersSent)res.writeHead(500); res.end()})).listen(port,host,()=>console.log(`本地只读预览:${origin}/admin/workbench(合成数据,无转发)`))
|
||||
@@ -0,0 +1,22 @@
|
||||
// Run the real Pinia settings module against an isolated in-memory document/cache.
|
||||
const fs = require('node:fs'), path = require('node:path'), assert = require('node:assert/strict')
|
||||
const ts = require('typescript'), { createPinia, setActivePinia } = require('pinia')
|
||||
const root = path.resolve(process.argv[2] || path.join(__dirname,'..')), cache = new Map()
|
||||
const load = (file, imports = {}) => {
|
||||
const module = {exports:{}}
|
||||
const js = ts.transpileModule(fs.readFileSync(path.join(root,file),'utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022,esModuleInterop:true}}).outputText
|
||||
new Function('require','exports','module',js)(id => Object.hasOwn(imports,id) ? imports[id] : require(id), module.exports, module)
|
||||
return module.exports
|
||||
}
|
||||
const config = load('src/config/setting.ts')
|
||||
function enter(preview) {
|
||||
global.document = {documentElement:{dataset:preview?{adminUi:'v2'}:{}}}
|
||||
setActivePinia(createPinia())
|
||||
return load('src/stores/modules/setting.ts',{'@/config/setting':config,'@/enums/cacheEnums':{SETTING_KEY:'setting'},'@/utils/cache':{get:k=>cache.get(k),set:(k,v)=>cache.set(k,v),remove:k=>cache.delete(k)},'@/utils/theme':{setTheme(){}}}).default()
|
||||
}
|
||||
let store=enter(false)
|
||||
if(typeof store.toggleAdminUi!=='function') { assert.equal(store.adminUi,undefined); console.log('classic-only'); }
|
||||
else {
|
||||
assert.equal(store.adminUi,'legacy'); store.toggleAdminUi(); assert.equal(document.documentElement.dataset.adminUi,'v2'); assert.equal(enter(false).adminUi,'v2')
|
||||
store=enter(true); assert.equal(store.adminUi,'v2'); store.toggleAdminUi(); assert.equal(document.documentElement.dataset.adminUi,'legacy'); assert.equal(enter(false).adminUi,'v2'); console.log('classic/new switch; preview preference isolated')
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Check the running local preview only; do not follow redirects, and do not use credentials.
|
||||
import assert from 'node:assert/strict'
|
||||
const origin='http://127.0.0.1:5178'
|
||||
async function check(method,p,status,opts={}) {
|
||||
const r=await fetch(origin+p,{...opts,method,redirect:'error'}); assert.equal(r.status,status,`${method} ${p}`); console.log(`${method} ${p} -> ${r.status}`); return r
|
||||
}
|
||||
const page=await check('GET','/admin/workbench',200); assert.match(page.headers.get('content-security-policy'),/connect-src 'self';/)
|
||||
const rows=await (await check('GET','/adminapi/order.order/lists',200)).json(); assert.ok(rows.data.lists[0].order_no.startsWith('DEMO-'))
|
||||
await check('POST','/adminapi/order.order/detail',200,{headers:{'content-type':'application/json'},body:JSON.stringify({id:rows.data.lists[0].id})})
|
||||
await check('POST','/adminapi/order.order/pay',405)
|
||||
await check('GET','/adminapi/order.order/syncWechatWorkBills',403)
|
||||
await check('GET','/adminapi/order.order/export?export=2',403)
|
||||
await check('GET','/api-proxy/adminapi/order.order/lists',404)
|
||||
await check('GET','/adminapi/order.order/lists',403,{headers:{origin:'http://different-origin.invalid'}})
|
||||
await check('GET','/.env',404)
|
||||
+3
-1
@@ -6,13 +6,15 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
|
||||
import { ScreenEnum } from './enums/appEnums'
|
||||
import useAppStore from './stores/modules/app'
|
||||
import useSettingStore from './stores/modules/setting'
|
||||
import useSettingStore, { useAdminAppearanceStore } from './stores/modules/setting'
|
||||
import useUserStore from './stores/modules/user'
|
||||
import ChatNotifyToast from './components/chat-notify-toast/index.vue'
|
||||
import RevisitDueToast from './components/revisit-due-toast/index.vue'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const settingStore = useSettingStore()
|
||||
// Resolve the saved appearance before the first route (including login) renders.
|
||||
useAdminAppearanceStore()
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
|
||||
|
||||
@@ -21,7 +21,22 @@
|
||||
<breadcrumb />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
class="admin-ui-toggle"
|
||||
type="button"
|
||||
data-admin-ui-toggle
|
||||
aria-label="新版界面"
|
||||
:aria-pressed="settingStore.adminUi === 'v2'"
|
||||
:title="settingStore.adminUi === 'v2' ? '切回旧版界面' : '切换至新版界面'"
|
||||
@click="settingStore.toggleAdminUi()"
|
||||
>
|
||||
<svg aria-hidden="true" viewBox="0 0 16 16" fill="none" width="15" height="15">
|
||||
<rect x="2" y="3" width="12" height="10" rx="2" stroke="currentColor" stroke-width="1.4" />
|
||||
<path d="M6 3v10m2-7h4" stroke="currentColor" stroke-width="1.4" />
|
||||
</svg>
|
||||
{{ settingStore.adminUi === 'v2' ? '切回旧版' : '体验新版' }}
|
||||
</button>
|
||||
<div class="navbar-item" v-if="!isMobile">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
@@ -80,4 +95,23 @@ const { isFullscreen } = useFullscreen()
|
||||
@apply h-full flex justify-center items-center hover:bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-ui-toggle {
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin-inline: 4px;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--el-color-primary);
|
||||
border: 1px solid var(--el-color-primary-light-7);
|
||||
background: var(--el-color-primary-light-9);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
&:hover { border-color: var(--el-color-primary); }
|
||||
&:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<main class="main-wrap h-full bg-page">
|
||||
<el-scrollbar>
|
||||
<div class="px-2 py-4">
|
||||
<div class="admin-content px-2 py-4">
|
||||
<router-view v-if="isRouteShow" v-slot="{ Component, route }">
|
||||
<keep-alive :include="includeList" :max="20">
|
||||
<component :is="Component" :key="route.fullPath" />
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
<template>
|
||||
<div class="side" :style="sideStyle">
|
||||
<div class="side" :class="{ 'side--dark': sideTheme === 'dark' }" :style="sideStyle">
|
||||
<side-logo v-if="settingStore.showLogo" :show-title="!isCollapsed" :theme="sideTheme" />
|
||||
<div v-else-if="settingStore.adminUi === 'v2'" class="admin-nav-heading" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" width="24" height="24">
|
||||
<path d="M4 6.5h10M4 12h16M4 17.5h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
<circle cx="19" cy="6.5" r="2" fill="currentColor"/>
|
||||
</svg>
|
||||
<span v-if="!isCollapsed">工作导航</span>
|
||||
</div>
|
||||
<side-menu
|
||||
:routes="routes"
|
||||
:is-collapsed="isCollapsed"
|
||||
@@ -14,6 +21,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import defaultSetting from '@/config/setting'
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
@@ -39,11 +47,16 @@ const routes = computed(() => userStore.routes)
|
||||
const sideStyle = computed(() => {
|
||||
return sideTheme.value == 'dark'
|
||||
? {
|
||||
'--side-dark-color': settingStore.sideDarkColor
|
||||
'--side-dark-color':
|
||||
settingStore.adminUi === 'v2' && settingStore.sideDarkColor === defaultSetting.sideDarkColor
|
||||
? 'var(--zyt-sidebar-dark)'
|
||||
: settingStore.sideDarkColor
|
||||
}
|
||||
: ''
|
||||
})
|
||||
const menuProp = computed(() => {
|
||||
// In v2 the root tokens also style the collapsed menu's teleported popup.
|
||||
if (settingStore.adminUi === 'v2') return {}
|
||||
return {
|
||||
backgroundColor: sideTheme.value == 'dark' ? settingStore.sideDarkColor : '',
|
||||
textColor: sideTheme.value == 'dark' ? 'var(--el-color-white)' : '',
|
||||
|
||||
@@ -11,6 +11,31 @@ import { setTheme } from '@/utils/theme'
|
||||
|
||||
const storageSetting = cache.get(SETTING_KEY)
|
||||
|
||||
type AdminUi = 'legacy' | 'v2'
|
||||
const APPEARANCE_KEY = 'admin_ui'
|
||||
|
||||
// A preview can seed <html data-admin-ui="v2"> before the first store is created.
|
||||
// Its switch is local to that document; it never overwrites the normal entry's preference.
|
||||
function initialAppearance() {
|
||||
const root = document.documentElement
|
||||
const preview = root.dataset.adminUi === 'v2'
|
||||
const mode: AdminUi = preview || cache.get(APPEARANCE_KEY) === 'v2' ? 'v2' : 'legacy'
|
||||
root.dataset.adminUi = mode
|
||||
return { preview, mode }
|
||||
}
|
||||
|
||||
// Keep the new preference separate from the existing, versioned settings object.
|
||||
export const useAdminAppearanceStore = defineStore('adminAppearance', {
|
||||
state: initialAppearance,
|
||||
actions: {
|
||||
select(mode: AdminUi) {
|
||||
this.mode = mode
|
||||
document.documentElement.dataset.adminUi = mode
|
||||
if (!this.preview) cache.set(APPEARANCE_KEY, mode)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function applySettingSchemaMigrations(
|
||||
state: Record<string, any>,
|
||||
storedVersion: number
|
||||
@@ -49,7 +74,15 @@ export const useSettingStore = defineStore({
|
||||
state._settingSchemaVersion = SETTING_SCHEMA_VERSION
|
||||
return state
|
||||
},
|
||||
getters: {
|
||||
adminUi(): AdminUi {
|
||||
return useAdminAppearanceStore().mode
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
toggleAdminUi() {
|
||||
useAdminAppearanceStore().select(this.adminUi === 'v2' ? 'legacy' : 'v2')
|
||||
},
|
||||
// 设置布局设置
|
||||
setSetting(data: Record<string, any>) {
|
||||
const { key, value } = data
|
||||
@@ -64,6 +97,14 @@ export const useSettingStore = defineStore({
|
||||
},
|
||||
// 设置主题色
|
||||
setTheme(isDark: boolean) {
|
||||
// An explicitly chosen accent is shared; the legacy default stays blue,
|
||||
// while the v2 default is jade. Neither switch rewrites the color picker.
|
||||
const rootStyle = document.documentElement.style
|
||||
if (this.theme && this.theme !== defaultSetting.theme) {
|
||||
rootStyle.setProperty('--zyt-user-primary', this.theme)
|
||||
} else {
|
||||
rootStyle.removeProperty('--zyt-user-primary')
|
||||
}
|
||||
setTheme(
|
||||
{
|
||||
primary: this.theme,
|
||||
@@ -83,6 +124,7 @@ export const useSettingStore = defineStore({
|
||||
}
|
||||
this._settingSchemaVersion = SETTING_SCHEMA_VERSION
|
||||
cache.remove(SETTING_KEY)
|
||||
useAdminAppearanceStore().select('legacy')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
// Only the new appearance opts into these rules. Root scope also reaches
|
||||
// Element Plus dialogs, selectors and collapsed menus teleported to <body>.
|
||||
:root[data-admin-ui='v2'] {
|
||||
--zyt-canvas: #f3f6f6;
|
||||
--zyt-surface: #fff;
|
||||
--zyt-surface-subtle: #f6f8f8;
|
||||
--zyt-ink: #1c3037;
|
||||
--zyt-text: #3f555d;
|
||||
--zyt-muted: #60747b;
|
||||
--zyt-border: #dce5e5;
|
||||
--zyt-primary: var(--zyt-user-primary, #146e60);
|
||||
--zyt-accent: var(--zyt-primary);
|
||||
--zyt-accent-soft: #e5f3ef;
|
||||
--zyt-accent-border: #b9dcd2;
|
||||
--zyt-sidebar-dark: #193339;
|
||||
--zyt-radius: 12px;
|
||||
--zyt-shadow: 0 2px 5px rgba(28, 52, 57, .045);
|
||||
|
||||
--el-color-primary: var(--zyt-accent);
|
||||
--el-color-primary-light-3: #398c7d;
|
||||
--el-color-primary-light-5: #77b1a4;
|
||||
--el-color-primary-light-7: #a8cec3;
|
||||
--el-color-primary-light-8: var(--zyt-accent-border);
|
||||
--el-color-primary-light-9: var(--zyt-accent-soft);
|
||||
--el-color-primary-dark-2: #0e594d;
|
||||
--el-bg-color: var(--zyt-surface);
|
||||
--el-bg-color-page: var(--zyt-canvas);
|
||||
--el-bg-color-overlay: var(--zyt-surface);
|
||||
--el-fill-color-blank: var(--zyt-surface);
|
||||
--el-fill-color-light: var(--zyt-surface-subtle);
|
||||
--el-fill-color-lighter: var(--zyt-surface-subtle);
|
||||
--el-text-color-primary: var(--zyt-ink);
|
||||
--el-text-color-regular: var(--zyt-text);
|
||||
--el-text-color-secondary: var(--zyt-muted);
|
||||
--el-border-color: var(--zyt-border);
|
||||
--el-border-color-light: var(--zyt-border);
|
||||
--el-border-color-lighter: var(--zyt-border);
|
||||
--el-border-radius-base: 7px;
|
||||
--el-box-shadow-lighter: var(--zyt-shadow);
|
||||
--table-header-bg-color: var(--zyt-surface-subtle);
|
||||
--navbar-height: 54px;
|
||||
--el-menu-item-height: 40px;
|
||||
--el-menu-sub-item-height: 36px;
|
||||
--el-menu-level-padding: 15px;
|
||||
|
||||
&.dark {
|
||||
--zyt-canvas: #142126;
|
||||
--zyt-surface: #1d2d32;
|
||||
--zyt-surface-subtle: #24363b;
|
||||
--zyt-ink: #e2eeee;
|
||||
--zyt-text: #c5d4d7;
|
||||
--zyt-muted: #a4b8bd;
|
||||
--zyt-border: #3b5055;
|
||||
--zyt-primary: var(--zyt-user-primary, #63bcaa);
|
||||
--zyt-accent-soft: #24453f;
|
||||
--zyt-accent-border: #3a6159;
|
||||
--zyt-sidebar-dark: #15292e;
|
||||
--zyt-shadow: 0 2px 5px rgba(0, 0, 0, .16);
|
||||
--el-color-primary-light-3: #509e8e;
|
||||
--el-color-primary-light-5: #478777;
|
||||
--el-color-primary-light-7: #396457;
|
||||
--el-color-primary-dark-2: #8acdbf;
|
||||
}
|
||||
|
||||
@supports (color: color-mix(in srgb, red, blue)) {
|
||||
&, &.dark {
|
||||
--zyt-accent-soft: color-mix(in srgb, var(--zyt-primary) 10%, var(--zyt-surface));
|
||||
--zyt-accent-border: color-mix(in srgb, var(--zyt-primary) 25%, var(--zyt-surface));
|
||||
--el-color-primary-light-3: color-mix(in srgb, var(--zyt-primary) 83%, var(--zyt-surface));
|
||||
--el-color-primary-light-5: color-mix(in srgb, var(--zyt-primary) 56%, var(--zyt-surface));
|
||||
--el-color-primary-light-7: color-mix(in srgb, var(--zyt-primary) 35%, var(--zyt-surface));
|
||||
--el-color-primary-dark-2: color-mix(in srgb, var(--zyt-primary) 78%, var(--zyt-ink));
|
||||
}
|
||||
}
|
||||
|
||||
&.dark .el-button--primary:not(.is-plain, .is-text, .is-link, .is-disabled) {
|
||||
--el-button-text-color: var(--zyt-on-primary, #112823);
|
||||
--el-button-active-text-color: var(--zyt-on-primary, #112823);
|
||||
--el-button-hover-text-color: var(--zyt-on-primary, #112823);
|
||||
}
|
||||
|
||||
.layout-default { background: var(--zyt-canvas); }
|
||||
.app-header {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
border-bottom: 1px solid var(--zyt-border);
|
||||
background: var(--zyt-surface);
|
||||
}
|
||||
.navbar { padding-inline: clamp(8px, 1.25vw, 22px); }
|
||||
.navbar .navbar-item {
|
||||
border-radius: 7px;
|
||||
color: var(--zyt-text);
|
||||
}
|
||||
.app-header .app-breadcrumb .el-breadcrumb__item .el-breadcrumb__inner,
|
||||
.app-header .app-breadcrumb .el-breadcrumb__separator { color: var(--zyt-muted); }
|
||||
.app-header .app-breadcrumb .el-breadcrumb__item:last-child .el-breadcrumb__inner {
|
||||
color: var(--zyt-ink);
|
||||
font-weight: 600;
|
||||
}
|
||||
.app-header .app-tabs {
|
||||
padding-block: 4px;
|
||||
border-color: var(--zyt-border);
|
||||
.el-tabs { height: 30px; --el-tabs-header-height: 30px; }
|
||||
.el-tabs__item {
|
||||
height: 30px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
&.is-active { background: var(--zyt-accent-soft); color: var(--zyt-primary); font-weight: 600; }
|
||||
&.is-active::after { display: none; }
|
||||
}
|
||||
}
|
||||
|
||||
.admin-content { padding: clamp(12px, 1.45vw, 24px); }
|
||||
.admin-nav-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: var(--navbar-height);
|
||||
padding: 0 18px;
|
||||
white-space: nowrap;
|
||||
color: var(--zyt-ink);
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
svg { color: var(--zyt-accent); }
|
||||
}
|
||||
.side .logo, .side .admin-nav-heading { border-bottom: 1px solid var(--zyt-border); }
|
||||
.side--dark {
|
||||
border-right-color: var(--side-dark-color);
|
||||
.admin-nav-heading, .logo { color: #f0f7f5; border-bottom-color: rgba(255,255,255,.12); }
|
||||
.admin-nav-heading svg { color: #86ceba; }
|
||||
}
|
||||
.side .menu { padding-block: 8px; }
|
||||
.side .menu, .el-menu--popup-container {
|
||||
--zyt-nav-bg: var(--zyt-surface);
|
||||
--zyt-nav-text: var(--zyt-text);
|
||||
--zyt-nav-hover: var(--zyt-surface-subtle);
|
||||
--zyt-nav-active: var(--zyt-accent-soft);
|
||||
--zyt-nav-selected: var(--zyt-accent);
|
||||
&.theme-dark {
|
||||
--zyt-nav-bg: var(--side-dark-color, var(--zyt-sidebar-dark));
|
||||
--zyt-nav-text: #cbdedc;
|
||||
--zyt-nav-hover: rgba(255,255,255,.09);
|
||||
--zyt-nav-active: #2b514e;
|
||||
--zyt-nav-selected: #d2faea;
|
||||
}
|
||||
.el-menu {
|
||||
--el-menu-bg-color: var(--zyt-nav-bg);
|
||||
--el-menu-text-color: var(--zyt-nav-text);
|
||||
--el-menu-hover-text-color: var(--zyt-nav-selected);
|
||||
--el-menu-hover-bg-color: var(--zyt-nav-hover);
|
||||
--el-menu-active-color: var(--zyt-nav-selected);
|
||||
}
|
||||
.el-menu-item, .el-sub-menu__title {
|
||||
margin: 2px 5px;
|
||||
border-radius: 7px;
|
||||
font-size: 13px;
|
||||
&:hover { background: var(--zyt-nav-hover); color: var(--zyt-nav-selected); }
|
||||
}
|
||||
.el-menu .el-menu-item.is-active,
|
||||
.el-menu.el-menu--collapse .el-sub-menu.is-active > .el-sub-menu__title {
|
||||
border-right: none;
|
||||
background: var(--zyt-nav-active);
|
||||
color: var(--zyt-nav-selected);
|
||||
font-weight: 650;
|
||||
}
|
||||
}
|
||||
|
||||
.el-card {
|
||||
--el-card-border-radius: var(--zyt-radius);
|
||||
--el-card-border-color: var(--zyt-border);
|
||||
&.is-always-shadow { box-shadow: var(--zyt-shadow); }
|
||||
}
|
||||
.el-table {
|
||||
--el-table-header-text-color: var(--zyt-text);
|
||||
--el-table-header-bg-color: var(--zyt-surface-subtle);
|
||||
--el-table-row-hover-bg-color: var(--zyt-surface-subtle);
|
||||
font-variant-numeric: tabular-nums;
|
||||
thead th { font-weight: 600; font-size: 13px; }
|
||||
}
|
||||
.el-overlay-dialog .el-dialog, .el-message-box {
|
||||
border-radius: var(--zyt-radius);
|
||||
border: 1px solid var(--zyt-border);
|
||||
}
|
||||
.el-dialog__title, .el-drawer__title { font-weight: 650; }
|
||||
.el-tag { border-radius: 5px; }
|
||||
.el-pagination { --el-pagination-button-bg-color: var(--zyt-surface-subtle); }
|
||||
:focus-visible:is(button, a, [role='button']) {
|
||||
outline: 2px solid var(--zyt-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.admin-content { padding: 10px; }
|
||||
.navbar { padding-inline: 4px; }
|
||||
}
|
||||
}
|
||||
@@ -3,3 +3,4 @@
|
||||
@import 'var.css';
|
||||
@import 'tailwind.css';
|
||||
@import 'public.scss';
|
||||
@import 'admin-v2.scss';
|
||||
|
||||
+108
-11
@@ -1,7 +1,12 @@
|
||||
<!-- 订单列表 -->
|
||||
<template>
|
||||
<div class="order-list">
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<header class="zyt-order-heading" hidden>
|
||||
<h1>订单管理</h1>
|
||||
<p>查询支付订单,跟进患者关联与收款状态。</p>
|
||||
</header>
|
||||
<el-card class="!border-none zyt-order-filter" shadow="never">
|
||||
<h2 class="zyt-order-title" hidden>筛选条件</h2>
|
||||
<!-- 搜索表单 -->
|
||||
<el-form class="ls-form" :model="queryParams" inline>
|
||||
<el-form-item class="w-[280px]" label="订单号">
|
||||
@@ -64,14 +69,14 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="创建时间">
|
||||
<el-form-item class="zyt-order-date" label="创建时间">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.create_time_start"
|
||||
v-model:endTime="queryParams.create_time_end"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-form-item class="zyt-order-tools">
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
<el-button
|
||||
@@ -109,14 +114,14 @@
|
||||
</el-card>
|
||||
|
||||
<!-- Tab 筛选 + 今日收益 -->
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<el-card class="!border-none mt-4 zyt-order-association" shadow="never">
|
||||
<div class="flex items-center justify-between mb-4 zyt-order-association-row">
|
||||
<el-tabs v-model="patientAssociationTab" @tab-change="handleTabChange">
|
||||
<el-tab-pane label="全部" name="" />
|
||||
<el-tab-pane label="待关联" name="pending" />
|
||||
<el-tab-pane label="已关联" name="associated" />
|
||||
</el-tabs>
|
||||
<div class="flex items-center gap-4 text-sm">
|
||||
<div 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>
|
||||
@@ -125,7 +130,11 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<el-card class="!border-none mt-4 zyt-order-records" shadow="never">
|
||||
<div class="zyt-order-record-heading" hidden>
|
||||
<h2>订单明细</h2>
|
||||
<span>共 {{ pager.count }} 条</span>
|
||||
</div>
|
||||
<div v-perms="['order.order/zhipai']" class="mb-3 flex items-center gap-3">
|
||||
<el-button type="primary" :disabled="!selectedOrderIds.length" @click="openAssignDialog">
|
||||
将创建人指给医助
|
||||
@@ -143,7 +152,7 @@
|
||||
@selection-change="handleOrderSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="48" />
|
||||
<el-table-column label="订单号" prop="order_no" min-width="150" />
|
||||
<el-table-column label="订单号" prop="order_no" class-name="zyt-order-id" min-width="150" />
|
||||
|
||||
<el-table-column label="处方业务订单号" min-width="210">
|
||||
<template #default="{ row }">
|
||||
@@ -179,7 +188,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="金额" width="100">
|
||||
<el-table-column label="金额" class-name="zyt-order-amount" width="100">
|
||||
<template #default="{ row }">
|
||||
<span class="text-red-500 font-semibold">¥{{ row.amount }}</span>
|
||||
</template>
|
||||
@@ -212,7 +221,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="340" fixed="right">
|
||||
<el-table-column 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']"
|
||||
@@ -294,7 +303,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="flex justify-end mt-4">
|
||||
<div class="flex justify-end mt-4 zyt-order-pager">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
@@ -828,6 +837,7 @@
|
||||
import { computed } from 'vue'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { hasPermission } from '@/utils/perm'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import {
|
||||
orderLists,
|
||||
orderDetail,
|
||||
@@ -856,6 +866,12 @@ import { generateOrderQrcode } from '@/api/tcm'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
|
||||
// A viewer with only the detail action does not need the full 340px sticky column.
|
||||
const appearance = useSettingStore()
|
||||
const actionsWidth = computed(() => appearance.adminUi === 'v2' &&
|
||||
!['edit', 'split', 'wxQrcode', 'pay', 'refund', 'cancel', 'delete', 'setExempt']
|
||||
.some(action => hasPermission(['order.order/' + action])) ? 82 : 340)
|
||||
|
||||
const queryParams = reactive({
|
||||
order_no: '',
|
||||
patient_keyword: '',
|
||||
@@ -1718,3 +1734,84 @@ onMounted(() => {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
html[data-admin-ui="v2"] .order-list {
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
background: var(--zyt-canvas);
|
||||
color: var(--zyt-text);
|
||||
.zyt-order-heading { display: block; margin-bottom: 20px; }
|
||||
.zyt-order-heading h1 {
|
||||
margin: 0 0 6px; color: var(--zyt-ink); font-size: clamp(22px, 2vw, 28px);
|
||||
font-weight: 700; line-height: 1.25;
|
||||
}
|
||||
.zyt-order-heading p { margin: 0; font-size: 13px; color: var(--zyt-muted); }
|
||||
> .el-card { border-radius: var(--zyt-radius); background: var(--zyt-surface); box-shadow: var(--zyt-shadow); }
|
||||
> .el-card > .el-card__body { padding: 16px 20px; }
|
||||
.zyt-order-title, .zyt-order-record-heading h2 {
|
||||
margin: 0; color: var(--zyt-ink); font-size: 16px; line-height: 24px; font-weight: 600;
|
||||
}
|
||||
.zyt-order-title { display: block; margin-bottom: 14px; }
|
||||
.zyt-order-record-heading {
|
||||
display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
|
||||
span { font-size: 12px; color: var(--zyt-muted); font-variant-numeric: tabular-nums; }
|
||||
}
|
||||
.zyt-order-filter .ls-form {
|
||||
display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
|
||||
align-items: end; gap: 12px 16px;
|
||||
}
|
||||
.zyt-order-filter .el-form-item {
|
||||
display: flex; flex-direction: column; align-items: stretch; width: auto; min-width: 0; margin: 0;
|
||||
}
|
||||
.zyt-order-filter .el-form-item__label {
|
||||
justify-content: start; height: auto; padding: 0 0 5px; line-height: 18px;
|
||||
font-size: 12px; color: var(--zyt-text);
|
||||
}
|
||||
.zyt-order-filter .el-form-item__content,
|
||||
.zyt-order-filter .el-date-editor { width: 100%; min-width: 0; }
|
||||
.zyt-order-tools {
|
||||
grid-column: 1 / -1; border-top: 1px solid var(--zyt-border); padding-top: 12px;
|
||||
> .el-form-item__content { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
> .el-form-item__content > * { margin: 0; }
|
||||
}
|
||||
> .zyt-order-association > .el-card__body { padding-block: 8px; }
|
||||
.zyt-order-association-row { flex-wrap: wrap; gap: 4px 16px; margin: 0; }
|
||||
.zyt-order-association .el-tabs__header { margin: 0; }
|
||||
.zyt-order-association .el-tabs__nav-wrap::after { display: none; }
|
||||
.zyt-order-revenue {
|
||||
flex-wrap: wrap; gap: 5px; padding: 4px 10px; border-radius: 7px;
|
||||
background: var(--zyt-accent-soft); font-variant-numeric: tabular-nums;
|
||||
.text-red-500 { color: var(--zyt-primary); }
|
||||
.text-gray-400, .text-gray-500 { color: var(--zyt-text); }
|
||||
}
|
||||
.zyt-order-records .el-table {
|
||||
--el-table-header-bg-color: var(--zyt-surface-subtle);
|
||||
--el-table-header-text-color: var(--zyt-text);
|
||||
--el-table-border-color: var(--zyt-border);
|
||||
--el-table-row-hover-bg-color: var(--zyt-accent-soft);
|
||||
.el-table__cell { padding-block: 9px; }
|
||||
th.el-table__cell { font-size: 12px; font-weight: 600; }
|
||||
.zyt-order-id .cell, .zyt-order-amount .cell { font-variant-numeric: tabular-nums; }
|
||||
td.zyt-order-id { color: var(--zyt-ink); }
|
||||
.zyt-order-amount span { color: var(--zyt-primary); }
|
||||
td.zyt-order-ops .cell { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
|
||||
td.zyt-order-ops .el-button { margin: 0; padding-block: 3px; }
|
||||
.text-gray-400 { color: var(--zyt-muted); }
|
||||
}
|
||||
.zyt-order-pager { max-width: 100%; overflow-x: auto; }
|
||||
.zyt-order-pager .pagination { min-width: 0; }
|
||||
.zyt-order-pager .el-pagination { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }
|
||||
@media (min-width: 1024px) {
|
||||
.zyt-order-date { grid-column: span 2; }
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.zyt-order-heading { margin-bottom: 14px; }
|
||||
> .el-card > .el-card__body { padding: 12px; }
|
||||
.zyt-order-association .el-tabs { max-width: 100%; }
|
||||
// A fixed 340px actions column would obscure the scrollable data on phones.
|
||||
.zyt-order-records .el-table .zyt-order-ops { position: static !important; box-shadow: none; }
|
||||
.zyt-order-records .el-table .zyt-order-ops::before { display: none; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -44,3 +44,7 @@
|
||||
| [上游用户列表示例](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/views/system/user/index.vue#L6-L40)按搜索区、表格工具栏、表格、弹窗排列;[ArtTable](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/components/core/tables/art-table/index.vue#L1-L92)仍使用 Element Plus 表格与分页,但另外依赖它自己的表格设置和高度计算。 | 复制区域排列,不替换现有表格、不搬请求或分页逻辑。以订单列表为准,用同一筛选条件验证新旧两版的结果、总数、固定操作列及按钮权限。 |
|
||||
|
||||
**从试点推到全后台:** 先留存工作台与订单列表的旧版截图和操作基线,交付同数据、同窗口的新旧预览;方向认可后,按「查询列表 → 编辑表单/详情 → 统计报表」复用同一套样式。最后单列登录页、聊天/诊疗、打印等特殊界面,检查覆盖范围而不是一键套用。登录页可改外观,但仍用原登录流程;打印只验证不受屏幕主题影响。常用模块推广的估时不等于全站逐页验收,剩余模块按试点后盘点的差异另估。
|
||||
|
||||
## 实施记录 · 2026-12-01(试点)
|
||||
|
||||
上述首轮已在本分支实现:正式入口保留经典外观作为初始值,顶栏可选择新版;本地隔离预览默认打开新版,工作台与订单页使用真实 Vue 组件。试点没有更换业务框架或接入正式后端。[启动与停止方法](../../admin/local-preview/README.md)。后续模块仍为计划,不在本次验收结论内。
|
||||
|
||||
Reference in New Issue
Block a user