Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e7c74a00
authored
Nov 20, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.0' of
http://192.168.3.233:8090/ujia/uj-admin
into v1.0.0
2 parents
63cd7519
e0240807
Pipeline
#581
for
e7c74a00
failed
in 0 seconds
Changes
81
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
81 changed files
with
3665 additions
and
1388 deletions
apps/web/shell/package.json
apps/web/shell/src/MicroApp.tsx
apps/web/shell/src/layouts/BasicLayout.tsx
apps/web/shell/src/layouts/SideNav.tsx
apps/web/shell/src/main.tsx
apps/web/shell/src/pages/Profile/index.tsx
apps/web/shell/src/subapp-lifecycle.ts
apps/web/subapps/finance/package.json
apps/web/subapps/points/package.json
apps/web/subapps/points/src/pages/OrderList/components/OrderDetailDrawer.tsx
apps/web/subapps/points/src/pages/WithdrawManage/components/ApprovalDetailDrawer.tsx
apps/web/subapps/points/src/pages/WithdrawManage/components/CustomTagDrawer.tsx
apps/web/subapps/store/package.json
apps/web/subapps/store/src/features/store/StoreDetailDrawer.tsx
apps/web/subapps/store/src/pages/TemplateImport/index.tsx
apps/web/subapps/system/package.json
apps/web/subapps/system/src/api/modules/menu.ts
apps/web/subapps/usedcar/package.json
apps/web/subapps/usedcar/src/api/core/client.ts
apps/web/subapps/usedcar/src/main.tsx
apps/web/subapps/usedcar/src/pages/Assessment/AssessmentDetail.tsx
apps/web/subapps/usedcar/src/pages/Assessment/EvaluatePage.tsx
apps/web/subapps/usedcar/src/pages/Assessment/assessment.css
apps/web/subapps/usedcar/src/pages/Condition/ConditionDetail.tsx
apps/web/subapps/usedcar/src/pages/Condition/condition.css
apps/web/subapps/usedcar/src/pages/Condition/conditionConfig.ts
apps/web/subapps/usedcar/src/pages/Condition/index.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/GroupCodeEditor.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/LiveCodesTab.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigTab.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/customerGroup.css
apps/web/subapps/usedcar/src/pages/CustomerGroup/index.tsx
apps/web/subapps/usedcar/src/pages/Delivery/DeliveryDetail.tsx
apps/web/subapps/usedcar/src/pages/Delivery/delivery.css
apps/web/subapps/usedcar/src/pages/Delivery/index.tsx
apps/web/subapps/usedcar/src/pages/Handover/HandoverDetailModal.tsx → apps/web/subapps/usedcar/src/pages/Handover/HandoverDetailDrawer.tsx
apps/web/subapps/usedcar/src/pages/Handover/index.tsx
apps/web/subapps/usedcar/src/pages/Leads/LeadDetail.tsx
apps/web/subapps/usedcar/src/pages/Leads/leads.css
apps/web/subapps/usedcar/src/pages/Ledger/FinancialLedger.tsx
apps/web/subapps/usedcar/src/pages/Ledger/VehicleLedger.tsx
apps/web/subapps/usedcar/src/pages/Ledger/index.tsx
apps/web/subapps/usedcar/src/pages/Operation/ContractDetail.tsx
apps/web/subapps/usedcar/src/pages/Operation/ContractEdit.tsx
apps/web/subapps/usedcar/src/pages/Operation/components/ContractTab.tsx
apps/web/subapps/usedcar/src/pages/Operation/components/SunshineDetailDrawer.tsx
apps/web/subapps/usedcar/src/pages/Operation/components/SunshineTab.tsx
apps/web/subapps/usedcar/src/pages/Operation/contractDetail.css
apps/web/subapps/usedcar/src/pages/Operation/index.tsx
apps/web/subapps/usedcar/src/pages/Reports/index.tsx
apps/web/subapps/usedcar/src/pages/Vehicles/VehicleDetail.tsx
apps/web/subapps/usedcar/src/pages/Vehicles/vehicles.css
apps/web/subapps/usedcar/src/styles/detail.css
docs/PORT_CONVERSION.md
packages/api-core/src/core/facade.ts
packages/api-core/test/facade.test.mjs
packages/api-core/test/strategy.test.mjs
packages/biz/src/components/BrandLoader.tsx
packages/biz/src/components/SearchForm/index.tsx
packages/biz/src/components/formSchema.ts
packages/biz/src/components/index.ts
packages/contracts/src/download-center.ts
packages/download-center/src/DownloadCenterButton.tsx
packages/download-center/src/DownloadCenterProvider.tsx
packages/download-center/src/TaskPreviewModal.tsx
packages/download-center/src/deliver.ts
packages/download-center/src/engine.ts
packages/download-center/src/handlers/asyncExport.ts
packages/download-center/src/handlers/simple.ts
packages/download-center/src/handlers/stream.ts
packages/download-center/src/index.ts
packages/download-center/src/store.ts
packages/download-center/src/types.ts
packages/platform-core/src/access/backend/adapter.ts
packages/platform-core/src/api/modules/menu.ts
packages/platform-sdk/src/compat/access/backend/adapter.ts
packages/platform-sdk/src/compat/api/modules/menu.ts
packages/platform-sdk/src/downloadCenter.ts
packages/ui/src/styles/ui.css
scripts/audit-module.mjs
scripts/finance-menu-migration.sql
apps/web/shell/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-shell"
,
"name"
:
"@uj/web-shell"
,
"version"
:
"0.0.1
1
"
,
"version"
:
"0.0.1
5
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/shell/src/MicroApp.tsx
View file @
e7c74a0
...
@@ -7,7 +7,7 @@ import { busEvents } from '@uj/contracts';
...
@@ -7,7 +7,7 @@ import { busEvents } from '@uj/contracts';
import { entryOf } from './subapps';
import { entryOf } from './subapps';
import { forgetReady, isReady, markReady } from './subapp-handshake';
import { forgetReady, isReady, markReady } from './subapp-handshake';
import { createSubAppProps } from './subapp-props';
import { createSubAppProps } from './subapp-props';
import { logoutEverything } from './subapp-lifecycle';
import { logoutEverything
, reportSessionExpired
} from './subapp-lifecycle';
import { destroyAppLocked, restartAppLocked, startAppLocked } from './wujie-lifecycle';
import { destroyAppLocked, restartAppLocked, startAppLocked } from './wujie-lifecycle';
/**
/**
...
@@ -183,7 +183,7 @@ export function MicroApp({ shortName, route }: { shortName: string; route: strin
...
@@ -183,7 +183,7 @@ export function MicroApp({ shortName, route }: { shortName: string; route: strin
bus.$emit(events.navigate, subPath);
bus.$emit(events.navigate, subPath);
};
};
const onNavigateHost = (...args: unknown[]) => navigate(String(args[0] ?? '/'));
const onNavigateHost = (...args: unknown[]) => navigate(String(args[0] ?? '/'));
const onLogoutHost = () => void
logoutEverything(navigate
);
const onLogoutHost = () => void
reportSessionExpired().then(() => logoutEverything(navigate)
);
bus.$on(events.ready, onReady);
bus.$on(events.ready, onReady);
bus.$on(events.navigateHost, onNavigateHost);
bus.$on(events.navigateHost, onNavigateHost);
...
...
apps/web/shell/src/layouts/BasicLayout.tsx
View file @
e7c74a0
...
@@ -10,7 +10,7 @@ import { menu as menuApi, cancelRequests } from '@/api';
...
@@ -10,7 +10,7 @@ import { menu as menuApi, cancelRequests } from '@/api';
import { logoutEverything } from '../subapp-lifecycle';
import { logoutEverything } from '../subapp-lifecycle';
import { DownloadCenterButton } from '@uj/download-center';
import { DownloadCenterButton } from '@uj/download-center';
import { Logo } from '@/components/Logo';
import { Logo } from '@/components/Logo';
import {
Skeleton } from '@uj/ui
';
import {
BrandLoading } from '@uj/biz
';
import menuJson from '@/config/menu.json';
import menuJson from '@/config/menu.json';
import { roleLabels } from '@/access';
import { roleLabels } from '@/access';
import SideNav from './SideNav';
import SideNav from './SideNav';
...
@@ -92,10 +92,11 @@ function BackGlyph() {
...
@@ -92,10 +92,11 @@ function BackGlyph() {
export default function BasicLayout() {
export default function BasicLayout() {
const navigate = useNavigate();
const navigate = useNavigate();
const location = useLocation();
const location = useLocation();
const {
can, role, roleCodes, point
s } = useAccess();
const {
role, roleCode
s } = useAccess();
const { collapsed, toggleCollapsed, currentUser, loggedIn } = useAppStore();
const { collapsed, toggleCollapsed, currentUser, loggedIn } = useAppStore();
// 后端菜单树:登录后拉取;接口失败则回落 menu.json 兜底(remoteGroups 保持 null)
// 后端菜单树:登录后拉取;接口失败则回落 menu.json 兜底(remoteGroups 保持 null)
// /current 已按当前登录角色装配好菜单,可见性以它为准,前端不再用 permCodes 二次过滤。
const [remoteGroups, setRemoteGroups] = useState<MenuGroupDef[] | null>(null);
const [remoteGroups, setRemoteGroups] = useState<MenuGroupDef[] | null>(null);
useEffect(() => {
useEffect(() => {
if (!loggedIn) return;
if (!loggedIn) return;
...
@@ -103,7 +104,7 @@ export default function BasicLayout() {
...
@@ -103,7 +104,7 @@ export default function BasicLayout() {
menuApi
menuApi
.tree()
.tree()
.then((tree) => {
.then((tree) => {
if (alive) setRemoteGroups(buildMenus(tree,
points,
PATH_BY_RESOURCE));
if (alive) setRemoteGroups(buildMenus(tree, PATH_BY_RESOURCE));
})
})
.catch(() => {
.catch(() => {
// 接口未就绪/令牌失效:不阻断,走本地兜底菜单
// 接口未就绪/令牌失效:不阻断,走本地兜底菜单
...
@@ -112,7 +113,7 @@ export default function BasicLayout() {
...
@@ -112,7 +113,7 @@ export default function BasicLayout() {
return () => {
return () => {
alive = false;
alive = false;
};
};
}, [loggedIn
, points
]);
}, [loggedIn]);
// 后端树为空(接口未就绪或该账号无任何菜单)时走兜底,避免侧边栏整组消失。
// 后端树为空(接口未就绪或该账号无任何菜单)时走兜底,避免侧边栏整组消失。
// useMemo 固定引用:下面的 openKeys 校准 effect 依赖 groups,若每次渲染都生成新数组会导致 effect 反复执行。
// useMemo 固定引用:下面的 openKeys 校准 effect 依赖 groups,若每次渲染都生成新数组会导致 effect 反复执行。
...
@@ -121,15 +122,13 @@ export default function BasicLayout() {
...
@@ -121,15 +122,13 @@ export default function BasicLayout() {
[remoteGroups],
[remoteGroups],
);
);
// 交给自绘 SideNav 的分组:权限过滤后剔除空组,避免出现点不开的空章节。
// 交给自绘 SideNav 的分组:只剔除空组,避免出现点不开的空章节。
// 菜单显隐完全以 /system/menu/tree/current 为准——后端已按角色装配好,前端不再拿登录
// 返回的 permCodes 做二次过滤(两个接口口径不一致时会静默丢菜单、整组连标题都不渲染)。
// 这里只做过滤,不再把数据翻译成 antd Menu items —— 渲染结构由 SideNav 负责。
// 这里只做过滤,不再把数据翻译成 antd Menu items —— 渲染结构由 SideNav 负责。
// can 来自 AccessProvider 的 useMemo value,引用稳定,故 useMemo 能真正固定住引用。
const visibleGroups: MenuGroupDef[] = useMemo(
const visibleGroups: MenuGroupDef[] = useMemo(
() =>
() => groups.filter((g) => g.children.length > 0),
groups
[groups],
.map((g) => ({ ...g, children: g.children.filter((m) => !m.resource || can(m.resource)) }))
.filter((g) => g.children.length > 0),
[groups, can],
);
);
const flat = groups.flatMap((g) => g.children);
const flat = groups.flatMap((g) => g.children);
...
@@ -361,7 +360,7 @@ export default function BasicLayout() {
...
@@ -361,7 +360,7 @@ export default function BasicLayout() {
flexDirection: 'column',
flexDirection: 'column',
}}
}}
>
>
<Suspense fallback={<
Skeleton variant="default"
/>}>
<Suspense fallback={<
BrandLoading
/>}>
<Outlet />
<Outlet />
</Suspense>
</Suspense>
</Content>
</Content>
...
...
apps/web/shell/src/layouts/SideNav.tsx
View file @
e7c74a0
...
@@ -46,8 +46,9 @@ import type { MenuGroupDef } from '@/access';
...
@@ -46,8 +46,9 @@ import type { MenuGroupDef } from '@/access';
* BasicLayout 里「原先 group 标题永远展开才换成 SubMenu」的修复回退掉。
* BasicLayout 里「原先 group 标题永远展开才换成 SubMenu」的修复回退掉。
*
*
* 因此只换渲染层:数据仍是后端菜单树经 buildMenus 得到的 MenuGroupDef[],
* 因此只换渲染层:数据仍是后端菜单树经 buildMenus 得到的 MenuGroupDef[],
*
权限过滤
/ selectedKey 最长前缀 / openKeys 受控校准 / 切页时的
*
空组剔除
/ selectedKey 最长前缀 / openKeys 受控校准 / 切页时的
* PAGE_LEAVE_EVENT + cancelRequests + navigate 全部留在 BasicLayout,本组件不碰。
* PAGE_LEAVE_EVENT + cancelRequests + navigate 全部留在 BasicLayout,本组件不碰。
* 菜单显隐以 /system/menu/tree/current 为准,本组件不做任何权限判断。
*
*
* 二级菜单刻意不渲染 m.icon:12 个不同线性图标在 34px 行里会形成锯齿边,
* 二级菜单刻意不渲染 m.icon:12 个不同线性图标在 34px 行里会形成锯齿边,
* 且 iconMap 是白名单,后端新增页面漏登记就会静默回落。二级改用导轨上的统一节点,
* 且 iconMap 是白名单,后端新增页面漏登记就会静默回落。二级改用导轨上的统一节点,
...
...
apps/web/shell/src/main.tsx
View file @
e7c74a0
...
@@ -14,14 +14,18 @@ import { DownloadCenterProvider } from '@uj/download-center';
...
@@ -14,14 +14,18 @@ import { DownloadCenterProvider } from '@uj/download-center';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import type { RemoteRequestFn } from '@uj/contracts';
import type { RemoteRequestFn } from '@uj/contracts';
import { loadRuntimeManifest } from './runtime-manifest';
import { loadRuntimeManifest } from './runtime-manifest';
import { reportSessionExpired } from './subapp-lifecycle';
import '@uj/design-tokens/tokens.css';
import '@uj/design-tokens/tokens.css';
import './index.css';
import './index.css';
import './theme/design.css';
import './theme/design.css';
import './theme/mfe.css';
import './theme/mfe.css';
// 401 / 10002 的统一处理出口。必须在任何请求发出(含下面的 initSign)之前注册:
// 401 / 10002 的统一处理出口。必须在任何请求发出(含下面的 initSign)之前注册:
// logout 会双清 uj_token 与 session 并把 loggedIn 置 false,RequireAuth 随即重定向。
// 先弹「登录已失效」提示并短暂延时,再 logout 双清 uj_token 与 session,
setUnauthorizedHandler(() => useAppStore.getState().logout());
// RequireAuth 随即重定向;不提示直接跳会让用户莫名其妙。
setUnauthorizedHandler(() => {
void reportSessionExpired().then(() => useAppStore.getState().logout());
});
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
installGlobalUnhandledRejectionHandler();
...
...
apps/web/shell/src/pages/Profile/index.tsx
View file @
e7c74a0
...
@@ -5,7 +5,8 @@ import { useEffect, useState, type ReactNode } from 'react';
...
@@ -5,7 +5,8 @@ import { useEffect, useState, type ReactNode } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { App, Avatar, Tag } from 'antd';
import { App, Avatar, Tag } from 'antd';
import { UserOutlined } from '@ant-design/icons';
import { UserOutlined } from '@ant-design/icons';
import { UCard, UForm, UInput, UButton, UAlert, UText, Skeleton } from '@uj/ui';
import { UCard, UForm, UInput, UButton, UAlert, UText } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import { auth, type UserInfo } from '@/api';
import { auth, type UserInfo } from '@/api';
import { useAppStore } from '@/store/useAppStore';
import { useAppStore } from '@/store/useAppStore';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
...
@@ -66,7 +67,7 @@ export default function Profile() {
...
@@ -66,7 +67,7 @@ export default function Profile() {
}
}
};
};
if (loading) return <
Skeleton variant="detail"
/>;
if (loading) return <
BrandLoading
/>;
if (!info) return <UCard>{<UText type="secondary">暂无账号信息</UText>}</UCard>;
if (!info) return <UCard>{<UText type="secondary">暂无账号信息</UText>}</UCard>;
const codes = info.roleCodes?.length ? info.roleCodes : roleCodes;
const codes = info.roleCodes?.length ? info.roleCodes : roleCodes;
...
...
apps/web/shell/src/subapp-lifecycle.ts
View file @
e7c74a0
import
{
bus
}
from
'wujie'
;
import
{
bus
}
from
'wujie'
;
import
{
message
}
from
'antd'
;
import
{
busEvents
}
from
'@uj/contracts'
;
import
{
busEvents
}
from
'@uj/contracts'
;
import
{
collectRouteDefs
}
from
'./dynamic-subapps'
;
import
{
collectRouteDefs
}
from
'./dynamic-subapps'
;
import
{
forgetReady
,
isReady
}
from
'./subapp-handshake'
;
import
{
forgetReady
,
isReady
}
from
'./subapp-handshake'
;
...
@@ -7,6 +8,31 @@ import { stopDownloadCenter } from '@uj/download-center';
...
@@ -7,6 +8,31 @@ import { stopDownloadCenter } from '@uj/download-center';
import
{
useAppStore
}
from
'@/store/useAppStore'
;
import
{
useAppStore
}
from
'@/store/useAppStore'
;
import
{
auth
,
menu
as
menuApi
}
from
'@/api'
;
import
{
auth
,
menu
as
menuApi
}
from
'@/api'
;
const
SESSION_NOTICE
=
'登录状态已失效,即将返回登录页,请重新登录'
;
let
lastNoticeAt
=
0
;
let
noticeWait
:
Promise
<
void
>
|
null
=
null
;
/**
* 会话失效的统一提示。
*
* 静默登出会让用户莫名其妙地回到登录页,所以先弹提示并把登出延后 1.5s。
* 同一时刻常有多条请求一起命中登出码,3s 窗口内只提示一次、共用同一个等待 Promise;
* 静态 antd message 不依赖 AntApp 上下文——setUnauthorizedHandler 在 React 挂载前就注册了。
*/
export
function
reportSessionExpired
():
Promise
<
void
>
{
const
now
=
Date
.
now
();
if
(
noticeWait
&&
now
-
lastNoticeAt
<
3000
)
return
noticeWait
;
lastNoticeAt
=
now
;
message
.
warning
(
SESSION_NOTICE
,
3
);
noticeWait
=
new
Promise
<
void
>
((
resolve
)
=>
{
window
.
setTimeout
(
resolve
,
1500
);
});
return
noticeWait
;
}
/** 并发会话失效 / 用户连点退出只做一次完整收尾。 */
let
loggingOut
=
false
;
/**
/**
* 统一登出:主壳与所有 wujie 子应用必须一起收尾。
* 统一登出:主壳与所有 wujie 子应用必须一起收尾。
*
*
...
@@ -20,30 +46,37 @@ import { auth, menu as menuApi } from '@/api';
...
@@ -20,30 +46,37 @@ import { auth, menu as menuApi } from '@/api';
* 子应用绝不自己 clearToken():令牌与会话的真源在主壳,两边各自清会留下半吊子状态。
* 子应用绝不自己 clearToken():令牌与会话的真源在主壳,两边各自清会留下半吊子状态。
*/
*/
export
async
function
logoutEverything
(
navigate
:
(
path
:
string
)
=>
void
):
Promise
<
void
>
{
export
async
function
logoutEverything
(
navigate
:
(
path
:
string
)
=>
void
):
Promise
<
void
>
{
// 必须在销毁子应用之前中止在途下载:ROP 通道的 postRop 闭包在子应用 iframe 里,
// 并发会话失效 / 用户连点退出只做一次完整收尾,避免重复 auth.logout 与重复导航。
// 销毁后失效,正在轮询的任务会失败并被误报「导出失败」。先落 canceled 再销毁。
if
(
loggingOut
)
return
;
stopDownloadCenter
({
markCanceled
:
true
});
loggingOut
=
true
;
try
{
try
{
await
auth
.
logout
();
// 必须在销毁子应用之前中止在途下载:ROP 通道的 postRop 闭包在子应用 iframe 里,
}
catch
{
// 销毁后失效,正在轮询的任务会失败并被误报「导出失败」。先落 canceled 再销毁。
/* 忽略:本地令牌清除即可 */
stopDownloadCenter
({
markCanceled
:
true
});
}
useAppStore
.
getState
().
logout
();
try
{
menuApi
.
clearCache
();
await
auth
.
logout
();
auth
.
clearCache
();
}
catch
{
/* 忽略:本地令牌清除即可 */
// 用「构建期 ∪ 运行时清单」的完整集合:只遍历 SUBAPPS 会漏掉 manifest
}
// 动态注册的子应用,它们收不到 logout 且沙箱不被销毁,重新登录时会复用
// 带着上一个账号数据的 alive iframe(串号)。
// warn:false 避免登出时重复打印清单冲突告警(建路由时已打过)。
for
(
const
s
of
collectRouteDefs
({
warn
:
false
}))
{
if
(
isReady
(
s
.
shortName
))
bus
.
$emit
(
busEvents
(
s
.
shortName
).
logout
);
forgetReady
(
s
.
shortName
);
// 不阻塞登出导航:销毁是异步的,子应用尚未启动时失败可忽略。
void
destroyAppLocked
(
s
.
shortName
).
catch
(()
=>
{});
}
navigate
(
'/login'
);
useAppStore
.
getState
().
logout
();
menuApi
.
clearCache
();
auth
.
clearCache
();
// 用「构建期 ∪ 运行时清单」的完整集合:只遍历 SUBAPPS 会漏掉 manifest
// 动态注册的子应用,它们收不到 logout 且沙箱不被销毁,重新登录时会复用
// 带着上一个账号数据的 alive iframe(串号)。
// warn:false 避免登出时重复打印清单冲突告警(建路由时已打过)。
for
(
const
s
of
collectRouteDefs
({
warn
:
false
}))
{
if
(
isReady
(
s
.
shortName
))
bus
.
$emit
(
busEvents
(
s
.
shortName
).
logout
);
forgetReady
(
s
.
shortName
);
// 不阻塞登出导航:销毁是异步的,子应用尚未启动时失败可忽略。
void
destroyAppLocked
(
s
.
shortName
).
catch
(()
=>
{});
}
navigate
(
'/login'
);
}
finally
{
loggingOut
=
false
;
}
}
}
apps/web/subapps/finance/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-finance"
,
"name"
:
"@uj/web-finance"
,
"version"
:
"0.0.
5
"
,
"version"
:
"0.0.
7
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/subapps/points/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-points"
,
"name"
:
"@uj/web-points"
,
"version"
:
"0.0.
6
"
,
"version"
:
"0.0.
8
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/subapps/points/src/pages/OrderList/components/OrderDetailDrawer.tsx
View file @
e7c74a0
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { Skeleton, UAlert, UButton, UDrawer, UTitle } from '@uj/ui';
import { UAlert, UButton, UDrawer, UTitle } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import { pointsApi, type WriteOffOrderDetail } from '@/api';
import { pointsApi, type WriteOffOrderDetail } from '@/api';
import { SETTLE_STATUS, optionLabel } from '@/features/shared/dictionaries';
import { SETTLE_STATUS, optionLabel } from '@/features/shared/dictionaries';
import { numberOr, textOr } from '@/features/shared/format';
import { numberOr, textOr } from '@/features/shared/format';
...
@@ -57,7 +58,7 @@ export function OrderDetailDrawer({ open, id, onClose }: OrderDetailDrawerProps)
...
@@ -57,7 +58,7 @@ export function OrderDetailDrawer({ open, id, onClose }: OrderDetailDrawerProps)
}
}
/>
/>
) : detail.isPending ? (
) : detail.isPending ? (
<
Skeleton variant="detail"
/>
<
BrandLoading
/>
) : (
) : (
<>
<>
{/* 抽屉面板本身就是容器,不再套带描边的卡片,避免双重边框。 */}
{/* 抽屉面板本身就是容器,不再套带描边的卡片,避免双重边框。 */}
...
...
apps/web/subapps/points/src/pages/WithdrawManage/components/ApprovalDetailDrawer.tsx
View file @
e7c74a0
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { Skeleton, UTimeline, UText, UDrawer, UTitle } from '@uj/ui';
import { UTimeline, UText, UDrawer, UTitle } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import { withdrawApi, type ApprovalLogItem } from '@/api';
import { withdrawApi, type ApprovalLogItem } from '@/api';
import { APPROVAL_OPERATION, APPROVAL_STATUS, statusMeta } from '@/features/shared/dictionaries';
import { APPROVAL_OPERATION, APPROVAL_STATUS, statusMeta } from '@/features/shared/dictionaries';
import { dateTimeOr, numberOr, textOr } from '@/features/shared/format';
import { dateTimeOr, numberOr, textOr } from '@/features/shared/format';
...
@@ -81,7 +82,7 @@ export function ApprovalDetailDrawer({ open, id, onClose }: ApprovalDetailDrawer
...
@@ -81,7 +82,7 @@ export function ApprovalDetailDrawer({ open, id, onClose }: ApprovalDetailDrawer
return (
return (
<UDrawer title="详细信息" open={open} width={900} onClose={onClose}>
<UDrawer title="详细信息" open={open} width={900} onClose={onClose}>
{detail.isPending ? (
{detail.isPending ? (
<
Skeleton variant="detail"
/>
<
BrandLoading
/>
) : (
) : (
<div className="uj-points-detail">
<div className="uj-points-detail">
<UTitle level={5}>订单信息</UTitle>
<UTitle level={5}>订单信息</UTitle>
...
...
apps/web/subapps/points/src/pages/WithdrawManage/components/CustomTagDrawer.tsx
View file @
e7c74a0
import { useState } from 'react';
import { useState } from 'react';
import { useMutation } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';
import { Skeleton, UButton, UDrawer, UText, useUMessage } from '@uj/ui';
import { UButton, UDrawer, UText, useUMessage } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import { ConfirmModal } from '@/components';
import { ConfirmModal } from '@/components';
import { withdrawApi, type TagNode } from '@/api';
import { withdrawApi, type TagNode } from '@/api';
import { errorMessage } from '@/features/shared/format';
import { errorMessage } from '@/features/shared/format';
...
@@ -94,7 +95,7 @@ export function CustomTagDrawer({ open, onClose }: CustomTagDrawerProps) {
...
@@ -94,7 +95,7 @@ export function CustomTagDrawer({ open, onClose }: CustomTagDrawerProps) {
<>
<>
<UDrawer title="自定义标签" width={680} open={open} onClose={onClose}>
<UDrawer title="自定义标签" width={680} open={open} onClose={onClose}>
{tags.isLoading ? (
{tags.isLoading ? (
<
Skeleton
/>
<
BrandLoading
/>
) : (
) : (
<div className="uj-points-tag-panel">
<div className="uj-points-tag-panel">
<div className="uj-points-tag-root">
<div className="uj-points-tag-root">
...
...
apps/web/subapps/store/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-store"
,
"name"
:
"@uj/web-store"
,
"version"
:
"0.0.
6
"
,
"version"
:
"0.0.
8
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/subapps/store/src/features/store/StoreDetailDrawer.tsx
View file @
e7c74a0
import type { ReactNode } from 'react';
import type { ReactNode } from 'react';
import type { TableColumnsType } from 'antd';
import type { TableColumnsType } from 'antd';
import { Skeleton, UAlert, UButton, UDrawer, UResult, UTable, UTabs, UTag, UText, tabLabel } from '@uj/ui';
import { UAlert, UButton, UDrawer, UResult, UTable, UTabs, UTag, UText, tabLabel } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import type { StoreListingDetail, StoreListingItem } from '@/api';
import type { StoreListingDetail, StoreListingItem } from '@/api';
import type { StoreDictionaries } from './dictionaries';
import type { StoreDictionaries } from './dictionaries';
import { dictionaryLabel, formatPolicyValue } from './formatters';
import { dictionaryLabel, formatPolicyValue } from './formatters';
...
@@ -213,7 +214,7 @@ export function StoreDetailDrawer({
...
@@ -213,7 +214,7 @@ export function StoreDetailDrawer({
footer={footer}
footer={footer}
>
>
{loading ? (
{loading ? (
<
Skeleton variant="detail"
/>
<
BrandLoading
/>
) : error ? (
) : error ? (
<UResult
<UResult
status="error"
status="error"
...
...
apps/web/subapps/store/src/pages/TemplateImport/index.tsx
View file @
e7c74a0
import { useState } from 'react';
import { useState } from 'react';
import { Skeleton, useUApp } from '@uj/ui';
import { useUApp } from '@uj/ui';
import { BrandLoading } from '@uj/biz';
import { PageHeader } from './components/PageHeader';
import { PageHeader } from './components/PageHeader';
import { NoticeSection } from './components/NoticeSection';
import { NoticeSection } from './components/NoticeSection';
import { StepsBar } from './components/StepsBar';
import { StepsBar } from './components/StepsBar';
...
@@ -116,7 +117,7 @@ export default function TemplateImport() {
...
@@ -116,7 +117,7 @@ export default function TemplateImport() {
}
}
};
};
if (loading) return <
Skeleton
/>;
if (loading) return <
BrandLoading
/>;
return (
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
...
...
apps/web/subapps/system/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-system"
,
"name"
:
"@uj/web-system"
,
"version"
:
"0.0.
6
"
,
"version"
:
"0.0.
8
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/subapps/system/src/api/modules/menu.ts
View file @
e7c74a0
...
@@ -29,21 +29,15 @@ export interface MenuNode {
...
@@ -29,21 +29,15 @@ export interface MenuNode {
class
Menu
extends
ApiClient
{
class
Menu
extends
ApiClient
{
/**
/**
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
*
* 需要它仅因为开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,
* 需要它的两个真实原因:
* 导致同一棵树双发请求。菜单可见性以 /current 为准、不依赖权限点,故不需要按 points 重算。
* 1) 开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,直接双发请求;
* 2) 权限点 points 会变化(AccessProvider 挂载后异步 auth.info() 返回再 applyLogin 一次),
* BasicLayout 的 effect 依赖 points,points 一变就会重跑。
*
* 缓存的是「网络请求」,不是「菜单结果」:调用方仍用当前 points 重新 buildMenus,
* 所以权限点更新后菜单过滤依旧准确,只是不会重复请求。
*/
*/
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
/**
/**
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 后端已按当前登录用户的角色装配并返回,前端
仍与登录下发的 permCodes 取交集后再渲染
* 后端已按当前登录用户的角色装配并返回,前端
原样渲染,不再与登录下发的 permCodes 取交集。
*
(双保险:即便后端未按角色过滤,也不会有越权菜单被渲染出来)
。
*
菜单显隐的唯一真源就是这棵树;越权菜单由后端装配时拦截,不在前端二次过滤
。
*/
*/
tree
():
Promise
<
MenuNode
[]
>
{
tree
():
Promise
<
MenuNode
[]
>
{
if
(
!
this
.
treePromise
)
{
if
(
!
this
.
treePromise
)
{
...
...
apps/web/subapps/usedcar/package.json
View file @
e7c74a0
{
{
"name"
:
"@uj/web-usedcar"
,
"name"
:
"@uj/web-usedcar"
,
"version"
:
"0.0.
7
"
,
"version"
:
"0.0.
11
"
,
"private"
:
true
,
"private"
:
true
,
"type"
:
"module"
,
"type"
:
"module"
,
"scripts"
:
{
"scripts"
:
{
...
...
apps/web/subapps/usedcar/src/api/core/client.ts
View file @
e7c74a0
...
@@ -209,7 +209,7 @@ function hostOptions(): Pick<
...
@@ -209,7 +209,7 @@ function hostOptions(): Pick<
},
},
errorHandler: (error) => { throw error.cause ?? error; },
errorHandler: (error) => { throw error.cause ?? error; },
/**
/**
* 登录态失效统一出口(GSC / ROP 信封的登出码:20 缺会话、21 登录过期)。
* 登录态失效统一出口(GSC / ROP 信封的登出码:20 缺会话、21 登录过期
、22 sessionId不存在
)。
*
*
* 门面在命中 logoutCodes 时先回调这里,再按 throwOnError 抛错。原先本域没有装配该回调,
* 门面在命中 logoutCodes 时先回调这里,再按 throwOnError 抛错。原先本域没有装配该回调,
* 于是 code=21 只被抛成一个普通 RequestError,React Query 落到 isError 分支,
* 于是 code=21 只被抛成一个普通 RequestError,React Query 落到 isError 分支,
...
@@ -236,7 +236,15 @@ function callConfig(options: UsedcarCallOptions, rop: boolean, defaultTimeout: n
...
@@ -236,7 +236,15 @@ function callConfig(options: UsedcarCallOptions, rop: boolean, defaultTimeout: n
return {
return {
timeout: typeof options.timeout === 'number' ? options.timeout : defaultTimeout,
timeout: typeof options.timeout === 'number' ? options.timeout : defaultTimeout,
...(rop ? {} : { returnAll: options.returnAll }),
...(rop ? {} : { returnAll: options.returnAll }),
...(options.response ? { response: options.response } : {}),
// GSC / ROP 信封的会话失效码:20 缺会话、21 登录过期、22 sessionId不存在。
// 不声明时 api-core 门面走兜底 [20,21],网关实测的 22 只会 toast + throw,
// 页面 React Query 落到 isError,表现为「线索列表加载失败」而停在原页。
// 声明后与 hostOptions().onLoginRequired 闭环:compat store 广播 logout-host →
// 主壳 logoutEverything 双清并 navigate('/login')。消费方显式传 logoutCodes 时优先。
response: {
logoutCodes: [20, 21, 22],
...(options.response ?? {}),
},
...(Object.keys(headers).length ? { headers } : {}),
...(Object.keys(headers).length ? { headers } : {}),
};
};
}
}
...
...
apps/web/subapps/usedcar/src/main.tsx
View file @
e7c74a0
...
@@ -5,6 +5,7 @@ import { App } from './App';
...
@@ -5,6 +5,7 @@ import { App } from './App';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import '@uj/design-tokens/tokens.css';
import '@uj/design-tokens/tokens.css';
import './index.css';
import './index.css';
import './styles/detail.css';
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
installGlobalUnhandledRejectionHandler();
...
...
apps/web/subapps/usedcar/src/pages/Assessment/AssessmentDetail.tsx
View file @
e7c74a0
import type { ReactNode } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UEmpty, UResult } from '@uj/ui';
import { UAlert, UButton, UCard, U
Descriptions, U
Empty, UResult } from '@uj/ui';
import { downloadCenter } from '@uj/platform-sdk';
import { downloadCenter } from '@uj/platform-sdk';
import {
CombiForm, PageShell, type FieldSchema
} from '@/components';
import {
PageShell
} from '@/components';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { assessmentApi, type AssessmentDetail as Detail } from '@/api';
import { assessmentApi, type AssessmentDetail as Detail } from '@/api';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import type { PageParams } from '@/routes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import { DYNAMIC_EVENT_CONFIG, PRICE_DETAIL_FIELDS, readOnlyValues, VEHICLE_ASSET_GROUPS, VEHICLE_DETAIL_FIELDS } from './detailConfig';
import {
DYNAMIC_EVENT_CONFIG,
PRICE_DETAIL_FIELDS,
readOnlyValues,
VEHICLE_ASSET_GROUPS,
VEHICLE_DETAIL_FIELDS,
} from './detailConfig';
import './assessment.css';
import './assessment.css';
const display = (value: unknown) =>
const display = (value: unknown) =>
...
@@ -48,74 +55,140 @@ export default function AssessmentDetail({ params }: { params: PageParams }) {
...
@@ -48,74 +55,140 @@ export default function AssessmentDetail({ params }: { params: PageParams }) {
const checks = Array.isArray(data.priceHistoryListDTO)
const checks = Array.isArray(data.priceHistoryListDTO)
? data.priceHistoryListDTO.filter((item) => Number(item.opType) === 40)
? data.priceHistoryListDTO.filter((item) => Number(item.opType) === 40)
: [];
: [];
const model = [data.carBrand, data.carSeriesName, data.carTypeName].filter(Boolean).join(' ');
const events = history.data ?? [];
return (
return (
<PageShell title="评估单详情" description="查看车辆资料、总部估价、核价意见和评估动态。">
<PageShell title="评估单详情" description="查看车辆资料、总部估价、核价意见和评估动态。">
{detail.isError ? <UAlert type="error" showIcon title="评估单详情加载失败" description={errorDetail(detail.error)} /> : null}
{detail.isError ? (
<div className="uc-assess-detail">
<UAlert
<UCard>
type="error"
<h3>车辆信息</h3>
showIcon
<ReadOnlyForm items={readOnlyValues(VEHICLE_DETAIL_FIELDS, data)} />
title="评估单详情加载失败"
</UCard>
description={errorDetail(detail.error)}
<UCard>
/>
<h3>车辆资料</h3>
) : null}
<div className="uc-assess-files">
<UCard className="uc-detail-card" loading={detail.isPending}>
{VEHICLE_ASSET_GROUPS.map((group) => {
<div className="uc-detail-dossier">
const urls = files(data[group.key]);
<div className="uc-detail-dossier__identity">
return <span key={group.key}>
<div className="uc-detail-dossier__name">
{group.label}:
{model || '-'}
{Array.isArray(urls) && urls.length
{data.licensePlate ? (
? urls.map((url, index) => (
<span className="uc-detail-dossier__chip">{String(data.licensePlate)}</span>
<UButton
) : null}
key={String(url)}
</div>
type="link"
<div className="uc-detail-dossier__code">评估单编号:{display(data.evalOrderNo)}</div>
size="small"
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 评估管理 / 车辆资料',
label: `${String(group.label)} · 文件 ${index + 1}`,
url: String(url),
silent: true,
dedupeKey: `usedcar-assess-file-${String(url)}`,
})
}
>
文件 {index + 1}{' '}
</UButton>
))
: '-'}
</span>;
})}
</div>
</div>
</UCard>
<div className="uc-detail-dossier__meta">
<PriceCard title="总部定价师估价与意见" data={pricing} fallback={data} />
<MetaItem label="评估单状态">{display(data.status)}</MetaItem>
<PriceCard title="核价与意见" data={checks} />
<MetaItem label="门店">{display(data.sellerMerchantName)}</MetaItem>
<UCard>
<MetaItem label="下单时间">{display(data.evalOrderTime)}</MetaItem>
<h3>评估动态</h3>
</div>
{history.isError ? (
</div>
<UAlert type="error" showIcon title="评估动态加载失败" description={errorDetail(history.error)} />
</UCard>
) : history.data?.length ? (
<div className="uc-detail-split">
<div className="uc-assess-history">
<div className="uc-detail-split__main">
{history.data.map((item, index) => {
<UCard className="uc-detail-card" loading={detail.isPending}>
const config = DYNAMIC_EVENT_CONFIG[String(item.opType)];
<CardHead title="车辆信息" />
return <div
<div className="uc-detail-card__body">
className="uc-assess-history__item"
<ReadOnlyForm items={readOnlyValues(VEHICLE_DETAIL_FIELDS, data)} />
key={`${String(item.quoteTime ?? '')}-${index}`}
</div>
>
</UCard>
<div className="uc-assess-history__head">
<PriceCard
<b>
title="总部定价师估价与意见"
{config?.title ?? '评估动态'}:{display(item.createdBy)}
data={pricing}
</b>
fallback={data}
<span>{display(item.quoteTime)}</span>
loading={detail.isPending}
</div>
/>
{config?.fields.map((field) => <p key={field.key}>{field.label}:{display(item[field.key])}{field.suffix ? ` ${field.suffix}` : ''}</p>)}
<PriceCard title="核价与意见" data={checks} loading={detail.isPending} />
</div>;
</div>
})}
<div className="uc-detail-split__rail">
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="车辆资料" />
<div className="uc-detail-card__body">
<div className="uc-detail-files">
{VEHICLE_ASSET_GROUPS.map((group) => {
const urls = files(data[group.key]);
return (
<div className="uc-detail-files__row" key={group.key}>
<span className="uc-detail-files__label">{group.label}</span>
<span className="uc-detail-files__value">
{urls.length
? urls.map((url, index) => (
<UButton
key={String(url)}
type="link"
size="small"
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 评估管理 / 车辆资料',
label: `${String(group.label)} · 文件 ${index + 1}`,
url: String(url),
silent: true,
dedupeKey: `usedcar-assess-file-${String(url)}`,
})
}
>
文件 {index + 1}
</UButton>
))
: '-'}
</span>
</div>
);
})}
</div>
</div>
</div>
) : (
</UCard>
<UEmpty description="暂无评估动态" />
<UCard className="uc-detail-card" loading={history.isPending}>
)}
<CardHead title="评估动态" aux={events.length ? `共 ${events.length} 条` : undefined} />
</UCard>
<div className="uc-detail-card__body">
{history.isError ? (
<UAlert
type="error"
showIcon
title="评估动态加载失败"
description={errorDetail(history.error)}
/>
) : events.length ? (
<div className="uc-detail-timeline">
{events.map((item, index) => {
const config = DYNAMIC_EVENT_CONFIG[String(item.opType)];
return (
<div
className="uc-detail-timeline__item"
key={`${String(item.quoteTime ?? '')}-${index}`}
>
<span className="uc-detail-timeline__marker" />
<div>
<div className="uc-detail-timeline__head">
<span className="uc-detail-timeline__title">
{config?.title ?? '评估动态'}:{display(item.createdBy)}
</span>
<span className="uc-detail-timeline__time">
{display(item.quoteTime)}
</span>
</div>
<div className="uc-detail-timeline__body">
{config?.fields.map((field) => (
<div key={field.key}>
<span className="uc-detail-timeline__label">{field.label}:</span>
{display(item[field.key])}
{field.suffix ? ` ${field.suffix}` : ''}
</div>
))}
</div>
</div>
</div>
);
})}
</div>
) : (
<UEmpty description="暂无评估动态" />
)}
</div>
</UCard>
</div>
</div>
</div>
</PageShell>
</PageShell>
);
);
...
@@ -124,31 +197,59 @@ function PriceCard({
...
@@ -124,31 +197,59 @@ function PriceCard({
title,
title,
data,
data,
fallback,
fallback,
loading,
}: {
}: {
title: string;
title: string;
data: Array<Record<string, unknown>>;
data: Array<Record<string, unknown>>;
fallback?: Detail;
fallback?: Detail;
loading?: boolean;
}) {
}) {
const items = data.length ? data : fallback ? [fallback] : [];
const items = data.length ? data : fallback ? [fallback] : [];
return (
return (
<UCard>
<UCard className="uc-detail-card" loading={loading}>
<h3>{title}</h3>
<CardHead title={title} aux={items.length > 1 ? `共 ${items.length} 轮` : undefined} />
{items.length ? (
<div className="uc-detail-card__body">
items.map((item, index) => (
{items.length ? (
<ReadOnlyForm key={index} items={readOnlyValues(PRICE_DETAIL_FIELDS, item)} />
items.map((item, index) => (
))
<div className="uc-detail-block" key={index}>
) : (
<ReadOnlyForm items={readOnlyValues(PRICE_DETAIL_FIELDS, item)} />
<UEmpty description="暂无信息" />
</div>
)}
))
) : (
<UEmpty description="暂无信息" />
)}
</div>
</UCard>
</UCard>
);
);
}
}
function ReadOnlyForm({ items }: { items: Array<[string, string, boolean?]> }) {
function ReadOnlyForm({ items }: { items: Array<[string, string, boolean?]> }) {
const values = Object.fromEntries(items.map(([label, value]) => [label, value]));
return (
const fields: FieldSchema<Record<string, string>>[] = items.map(([label]) => ({
<UDescriptions
name: label,
className="uc-detail-descriptions"
label,
column={{ xs: 1, sm: 2 }}
type: 'input',
styles={{ label: { width: 112, whiteSpace: 'nowrap' } }}
}));
items={items.map(([label, value, wide]) => ({
return <CombiForm mode="detail" fields={fields} initialValues={values} />;
key: label,
label,
children: value,
span: wide ? 2 : 1,
}))}
/>
);
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
}
apps/web/subapps/usedcar/src/pages/Assessment/EvaluatePage.tsx
View file @
e7c74a0
...
@@ -5,10 +5,10 @@ import {
...
@@ -5,10 +5,10 @@ import {
UButton,
UButton,
UCard,
UCard,
UDescriptions,
UDescriptions,
UEmpty,
UForm,
UForm,
UModal,
UModal,
UResult,
UResult,
UText,
useUMessage,
useUMessage,
} from '@uj/ui';
} from '@uj/ui';
import { CombiForm, PageShell, type FieldSchema } from '@/components';
import { CombiForm, PageShell, type FieldSchema } from '@/components';
...
@@ -18,7 +18,7 @@ import { UC } from '@/permissions/codes';
...
@@ -18,7 +18,7 @@ import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import type { PageParams } from '@/routes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import { goTo } from '../Leads/navigate';
import { goTo } from '../Leads/navigate';
import { readOnlyValues, VEHICLE_DETAIL_FIELDS } from './detailConfig';
import {
DYNAMIC_EVENT_CONFIG,
readOnlyValues, VEHICLE_DETAIL_FIELDS } from './detailConfig';
import './assessment.css';
import './assessment.css';
/**
/**
...
@@ -35,6 +35,16 @@ type RejectValues = { rejectReason: string; rejectSuggestion: string };
...
@@ -35,6 +35,16 @@ type RejectValues = { rejectReason: string; rejectSuggestion: string };
const display = (value: unknown) =>
const display = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
value === undefined || value === null || value === '' ? '-' : String(value);
/** 动态字段文案:与详情页 DYNAMIC_EVENT_CONFIG 同一套语义,这里按实际下发字段取值。 */
const EVENT_FIELD_LABEL: Record<string, string> = {
evalPrice: '评估价',
evalOpinion: '评估意见',
checkPrice: '核价',
checkOpinion: '核价意见',
rejectReason: '驳回原因',
rejectSuggestion: '驳回意见',
};
const integerRule = (label: string) => [
const integerRule = (label: string) => [
{ required: true, message: `请输入${label}` },
{ required: true, message: `请输入${label}` },
{
{
...
@@ -174,62 +184,91 @@ export default function EvaluatePage({ params }: { params: PageParams }) {
...
@@ -174,62 +184,91 @@ export default function EvaluatePage({ params }: { params: PageParams }) {
<PageShell
<PageShell
title={isCheck ? '评估核价' : '车辆评估'}
title={isCheck ? '评估核价' : '车辆评估'}
description={isCheck ? '录入核价与核价意见,或驳回该评估单。' : '录入评估价与评估意见,或驳回该评估单。'}
description={isCheck ? '录入核价与核价意见,或驳回该评估单。' : '录入评估价与评估意见,或驳回该评估单。'}
actions={<UButton onClick={() => goTo('assessment')}>返回列表</UButton>}
>
>
{detail.isError ? (
{detail.isError ? (
<UAlert type="error" showIcon title="评估单加载失败" description={errorDetail(detail.error)} />
<UAlert type="error" showIcon title="评估单加载失败" description={errorDetail(detail.error)} />
) : null}
) : null}
<div className="uc-assess-detail">
<div className="uc-detail-stack">
<UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<h3>车辆信息</h3>
<CardHead title="车辆信息" />
<UDescriptions
<div className="uc-detail-card__body">
column={2}
<UDescriptions
size="small"
className="uc-detail-descriptions"
items={readOnlyValues(VEHICLE_DETAIL_FIELDS, data as AssessmentDetail).map(
column={{ xs: 1, sm: 2 }}
([label, value]) => ({ key: label, label, children: display(value) }),
styles={{ label: { width: 112, whiteSpace: 'nowrap' } }}
)}
items={readOnlyValues(VEHICLE_DETAIL_FIELDS, data as AssessmentDetail).map(
/>
([label, value, wide]) => ({
key: label,
label,
children: display(value),
span: wide ? 2 : 1,
}),
)}
/>
</div>
</UCard>
</UCard>
<UCard>
<UCard className="uc-detail-card">
<h3>{isCheck ? '核价与意见' : '总部定价师估价与意见'}</h3>
<CardHead title={isCheck ? '核价与意见' : '总部定价师估价与意见'} />
<CombiForm mode="form" form={form} fields={fields} layout="vertical" onSubmit={onSave} />
<div className="uc-detail-card__body">
<CombiForm mode="form" form={form} fields={fields} layout="vertical" onSubmit={onSave} />
</div>
</UCard>
</UCard>
<UCard>
<UCard
className="uc-detail-card" loading={history.isPending}
>
<
h3>评估动态</h3>
<
CardHead
{history.data?.length ? (
title="评估动态"
<div className="uc-assess-dynamics">
aux={history.data?.length ? `共 ${history.data.length} 条` : undefined}
{history.data.map((item, index) => (
/>
<div key={index} className="uc-assess-dynamic
">
<div className="uc-detail-card__body
">
<UText type="secondary">
{history.data?.length ? (
{display(item.opType)} · {display(item.createdDate)} · {display(item.createdBy)}
<div className="uc-detail-timeline">
</UText>
{history.data.map((item, index) => (
<div>
<div
key={index} className="uc-detail-timeline__item"
>
{Object.entries(item)
<span className="uc-detail-timeline__marker" />
.filter(([key, value]) =
>
<div
>
['evalPrice', 'evalOpinion', 'checkPrice', 'checkOpinion', 'rejectReason', 'rejectSuggestion'].includes(key) &&
<div className="uc-detail-timeline__head">
value !== undefined &&
<span className="uc-detail-timeline__title">
value !== '',
{DYNAMIC_EVENT_CONFIG[String(item.opType)]?.title ?? '评估动态'}:
)
{display(item.createdBy)}
.map(([key, value]) => (
</span>
<span
key={key} style={{ marginRight: 16 }}
>
<span
className="uc-detail-timeline__time"
>
{
key}:{String(valu
e)}
{
display(item.createdDat
e)}
</span>
</span>
))}
</div>
<div className="uc-detail-timeline__body">
{Object.entries(item)
.filter(
([key, value]) =>
key in EVENT_FIELD_LABEL && value !== undefined && value !== '',
)
.map(([key, value]) => (
<div key={key}>
<span className="uc-detail-timeline__label">
{EVENT_FIELD_LABEL[key]}:
</span>
{String(value)}
</div>
))}
</div>
</div>
</div>
</div>
</div>
))}
))}
</div>
</div>
) : (
) : (
<UEmpty description="暂无评估动态" />
<UText type="secondary">暂无评估动态</UText>
)}
)}
</div>
</UCard>
</UCard>
</div>
</div>
<div
style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', padding: '12px 0' }}
>
<div
className="uc-assess-actions"
>
<UButton type="primary" loading={submit.isPending} onClick={() => form.submit()}>
<UButton type="primary" loading={submit.isPending} onClick={() => form.submit()}>
保存
保存
</UButton>
</UButton>
<UButton onClick={() => setRejectOpen(true)}>驳回</UButton>
<UButton type="default" onClick={() => setRejectOpen(true)}>
<UButton onClick={() => goTo('assessment')}>关闭</UButton>
驳回
</UButton>
<UButton type="default" onClick={() => goTo('assessment')}>
关闭
</UButton>
</div>
</div>
<UModal
<UModal
open={rejectOpen}
open={rejectOpen}
...
@@ -249,3 +288,11 @@ export default function EvaluatePage({ params }: { params: PageParams }) {
...
@@ -249,3 +288,11 @@ export default function EvaluatePage({ params }: { params: PageParams }) {
</PageShell>
</PageShell>
);
);
}
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
apps/web/subapps/usedcar/src/pages/Assessment/assessment.css
View file @
e7c74a0
...
@@ -7,54 +7,9 @@
...
@@ -7,54 +7,9 @@
border-radius
:
4px
;
border-radius
:
4px
;
background
:
var
(
--uj-surface-3
);
background
:
var
(
--uj-surface-3
);
}
}
.uc-assess-detail
{
.uc-assess-actions
{
display
:
grid
;
gap
:
16px
;
}
.uc-assess-detail
h3
{
margin
:
0
0
14px
;
font-size
:
15px
;
}
.uc-assess-history
{
display
:
grid
;
gap
:
12px
;
}
.uc-assess-history__item
{
border-left
:
2px
solid
var
(
--uj-primary
);
padding-left
:
14px
;
}
.uc-assess-history__head
{
display
:
flex
;
justify-content
:
space-between
;
margin-bottom
:
6px
;
}
.uc-assess-files
{
display
:
flex
;
display
:
flex
;
flex-wrap
:
wrap
;
justify-content
:
flex-end
;
gap
:
8px
;
gap
:
8px
;
}
padding
:
12px
0
;
.uc-assess-files
a
{
color
:
var
(
--uj-primary
);
}
.uc-assess-readonly-form__grid
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
column-gap
:
24px
;
}
.uc-assess-readonly-form
.ant-form-item
{
margin-bottom
:
12px
;
}
.uc-assess-readonly-form
.ant-form-item-label
{
min-width
:
132px
;
}
.uc-assess-readonly-form__wide
{
grid-column
:
span
2
;
}
@media
(
max-width
:
760px
)
{
.uc-assess-readonly-form__grid
{
grid-template-columns
:
1
fr
;
}
.uc-assess-readonly-form__wide
{
grid-column
:
auto
;
}
}
}
apps/web/subapps/usedcar/src/pages/Condition/ConditionDetail.tsx
View file @
e7c74a0
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useState
, type ReactNode
} from 'react';
import dayjs from 'dayjs';
import dayjs from 'dayjs';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import {
import {
CaretRightOutlined,
CheckCircleFilled,
DownOutlined,
ExclamationCircleFilled,
PictureOutlined,
SearchOutlined,
} from '@ant-design/icons';
import {
UAlert,
UAlert,
UButton,
UButton,
UCard,
UCheckbox,
UCheckbox,
UDatePicker,
UDatePicker,
UEmpty,
UForm,
UForm,
UImage,
UImage,
UInput,
UInput,
...
@@ -15,14 +25,23 @@ import {
...
@@ -15,14 +25,23 @@ import {
useUMessage,
useUMessage,
} from '@uj/ui';
} from '@uj/ui';
import { CombiForm } from '@/components';
import { CombiForm } from '@/components';
import { PageShell } from '@/components';
import { PageShell
, type FieldOption
} from '@/components';
import { carConditionApi, commonApi } from '@/api';
import { carConditionApi, commonApi } from '@/api';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import type { PageParams } from '@/routes';
import type { PageParams } from '@/routes';
import { goTo } from '../Leads/navigate';
import {
import { BASE_FIELDS, colorLabel, PRICE_FIELDS, type ConditionValues } from './conditionConfig';
AI_REPORT_STATUS,
BASE_FIELDS,
CONDITION_STATUS,
colorLabel,
labelOf,
PRICE_FIELDS,
statusTone,
type ConditionValues,
} from './conditionConfig';
import './condition.css';
type Row = Record<string, unknown> & {
type Row = Record<string, unknown> & {
id: string | number;
id: string | number;
...
@@ -184,6 +203,11 @@ function districtOptions(value: unknown) {
...
@@ -184,6 +203,11 @@ function districtOptions(value: unknown) {
value: String(item.code ?? ''),
value: String(item.code ?? ''),
}));
}));
}
}
/** 单选 onChange 的 option 在 antd 类型里是「单项 | 数组」,这里只取单项的字符串 label。 */
function optionLabel(option: unknown): string | undefined {
const single = (Array.isArray(option) ? option[0] : option) as { label?: unknown } | undefined;
return typeof single?.label === 'string' ? single.label : undefined;
}
export default function ConditionDetail({ params }: { params: PageParams }) {
export default function ConditionDetail({ params }: { params: PageParams }) {
const { canPoint } = useAccess();
const { canPoint } = useAccess();
...
@@ -252,6 +276,8 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -252,6 +276,8 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
enabled: Boolean(seriesId),
enabled: Boolean(seriesId),
});
});
const photos = useMemo(() => (data ? sourcePhotos(data) : []), [data]);
const photos = useMemo(() => (data ? sourcePhotos(data) : []), [data]);
const photoFilled = photos.filter((photo) => photo.url).length;
const requiredReady = photos.length >= 8 && photos.slice(0, 8).every((photo) => photo.url);
useEffect(() => {
useEffect(() => {
if (!detail.data) return;
if (!detail.data) return;
const normalized = unwrap(detail.data) as Detail;
const normalized = unwrap(detail.data) as Detail;
...
@@ -469,7 +495,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -469,7 +495,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
if (field.name === 'vin') return <UInput onBlur={() => void checkVin()} />;
if (field.name === 'vin') return <UInput onBlur={() => void checkVin()} />;
if (field.name === 'brandModel')
if (field.name === 'brandModel')
return (
return (
<div className="uc-condition-
detail__
compound">
<div className="uc-condition-compound">
<USelect
<USelect
value={brandId as string}
value={brandId as string}
options={brandRows.map((item) => ({ value: String(item.id), label: text(item.name) }))}
options={brandRows.map((item) => ({ value: String(item.id), label: text(item.name) }))}
...
@@ -555,14 +581,14 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -555,14 +581,14 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
: undefined;
: undefined;
if (region)
if (region)
return (
return (
<div className="uc-condition-
detail__
compound">
<div className="uc-condition-compound">
<USelect
<USelect
value={form.getFieldValue(region.provinceName) as string}
value={form.getFieldValue(region.provinceName) as string}
options={districtOptions(provinces.data)}
options={districtOptions(provinces.data)}
placeholder="请选择省"
placeholder="请选择省"
onChange={(value, option) =>
onChange={(value, option) =>
form.setFieldsValue({
form.setFieldsValue({
[region.provinceName]: option
?.label
,
[region.provinceName]: option
Label(option)
,
[region.provinceId]: value,
[region.provinceId]: value,
[region.cityName]: undefined,
[region.cityName]: undefined,
[region.cityId]: undefined,
[region.cityId]: undefined,
...
@@ -574,7 +600,10 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -574,7 +600,10 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
options={districtOptions(region.cities)}
options={districtOptions(region.cities)}
placeholder="请选择市"
placeholder="请选择市"
onChange={(value, option) =>
onChange={(value, option) =>
form.setFieldsValue({ [region.cityName]: option?.label, [region.cityId]: value })
form.setFieldsValue({
[region.cityName]: optionLabel(option),
[region.cityId]: value,
})
}
}
/>
/>
</div>
</div>
...
@@ -589,7 +618,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -589,7 +618,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
label: text(item.staffName ?? item.userName ?? item.name),
label: text(item.staffName ?? item.userName ?? item.name),
}))}
}))}
onChange={(value, option) =>
onChange={(value, option) =>
form.setFieldsValue({ sellerUserId: value, sellerName: option
?.label
})
form.setFieldsValue({ sellerUserId: value, sellerName: option
Label(option)
})
}
}
/>
/>
);
);
...
@@ -608,7 +637,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -608,7 +637,7 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
);
);
form.setFieldsValue({
form.setFieldsValue({
conversionUserId: value,
conversionUserId: value,
conversionName: option
?.label
,
conversionName: option
Label(option)
,
conversionMerchantId: staff?.yqMerchantId,
conversionMerchantId: staff?.yqMerchantId,
conversionMerchantName: staff?.yqMerchantName,
conversionMerchantName: staff?.yqMerchantName,
});
});
...
@@ -625,174 +654,235 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -625,174 +654,235 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
if (!record)
if (!record)
return <UResult status="404" title="未找到车况信息" subTitle="详情地址缺少车况单编号。" />;
return <UResult status="404" title="未找到车况信息" subTitle="详情地址缺少车况单编号。" />;
return (
return (
<PageShell>
<PageShell
<div className="uc-condition-detail">
title="车况信息详情"
<header className="uc-condition-detail__header">
description="核对一线回传的车况描述与照片,完善评估单基础信息,生成评估单或 AI 收车报告。"
<div>
actions={
<div className="uc-condition-detail__header-left">
<UButton
<h1 className="uc-condition-detail__title">车况信息详情</h1>
type="primary"
disabled={Number(data?.status) === 1}
loading={creatingAssessment}
onClick={() => void createAssessment()}
>
一键生成评估单
</UButton>
}
>
{detail.isError ? (
<UAlert
type="error"
showIcon
title="车况详情加载失败"
description={errorDetail(detail.error)}
/>
) : null}
<UCard className="uc-detail-card" loading={detail.isPending}>
<div className="uc-detail-dossier">
<div className="uc-detail-dossier__identity">
<div className="uc-detail-dossier__name">
{text(data?.brandModel)}
{data?.licensePlate ? (
<span className="uc-detail-dossier__chip">{String(data.licensePlate)}</span>
) : null}
</div>
<div className="uc-detail-dossier__code">编号:{text(data?.carConditionCode)}</div>
</div>
<div className="uc-detail-dossier__meta">
<MetaItem label="来源">
<span className="uc-condition-source">
<span className="uc-condition-source">
来源:
{SOURCE_LABEL[String(data?.source ?? '')] ?? text(data?.sourceName ?? data?.source)}
{SOURCE_LABEL[String(data?.source ?? '')] ?? text(data?.sourceName ?? data?.source)}
</span>
</span>
</div>
</MetaItem>
{data?.carConditionCode && (
<MetaItem label="车况单状态">
<div className="uc-condition-detail__meta">
{statusValue(data?.status, CONDITION_STATUS, '1')}
编号:{text(data?.carConditionCode)}
</MetaItem>
</div>
<MetaItem label="收车报告状态">
)}
{statusValue(data?.aiReportStatus, AI_REPORT_STATUS, '2', '3')}
</div>
</MetaItem>
<div>
<MetaItem label="提交时间">{text(data?.entryTime)}</MetaItem>
<UButton type="default" onClick={() => goTo('condition')}>
返回列表
</UButton>
<UButton
type="primary"
disabled={Number(data?.status) === 1}
loading={creatingAssessment}
onClick={() => void createAssessment()}
>
一键生成评估单
</UButton>
</div>
</div>
</header>
</div>
{detail.isError ? (
</UCard>
<UAlert
<div className="uc-condition-detail">
type="error"
<aside className="uc-condition-detail__rail">
showIcon
<UCard className="uc-detail-card" loading={detail.isPending}>
title="车况详情加载失败"
<CardHead title="一线回传车况描述" />
description={errorDetail(detail.error)}
<div className="uc-detail-card__body">
/>
{data?.conditionDescription ? (
) : null}
<div className="uc-condition-desc">{String(data.conditionDescription)}</div>
<div className="uc-condition-detail__body">
) : (
<aside className="uc-condition-detail__left">
<UEmpty description="暂无车况描述" />
<section className="uc-condition-detail__block">
)}
<h2 className="uc-condition-detail__block-title">一线回传车况描述</h2>
</div>
<div className="uc-condition-detail__description">
</UCard>
{text(data?.conditionDescription)}
<UCard className="uc-detail-card" loading={detail.isPending}>
</div>
<CardHead
</section>
title="一线回传照片"
<section className="uc-condition-detail__block">
aux={photos.length ? `已回传 ${photoFilled}/${photos.length}` : undefined}
<h2 className="uc-condition-detail__block-title">一线回传照片</h2>
/>
<div className="uc-condition-detail__photos">
<div className="uc-detail-card__body">
{photos.length
<div className="uc-condition-photos">
? photos.map((photo) => (
{photos.map((photo) => (
<figure className="uc-condition-detail__photo" key={photo.url}>
<figure className="uc-condition-photo" key={photo.subtype}>
{photo.video ? (
<div className="uc-condition-photo__media">
<button
{photo.video ? (
type="button"
<button
className="uc-condition-detail__video-button"
type="button"
onClick={() => setVideoUrl(photo.url)}
className="uc-condition-photo__video"
>
onClick={() => setVideoUrl(photo.url)}
<video className="uc-condition-detail__video" muted src={photo.url} />
>
<span>播放视频</span>
<video muted preload="metadata" src={photo.url} />
</button>
<span className="uc-condition-photo__play">
) : (
<CaretRightOutlined />
<UImage
</span>
src={photo.url}
</button>
width="100%"
) : photo.url ? (
height={110}
<UImage
styles={{
src={photo.url}
image: { width: '100%', height: '110px', objectFit: 'cover' },
width="100%"
}}
styles={{
/>
image: { width: '100%', height: '100%', objectFit: 'cover' },
)}
}}
<figcaption>{photo.caption}</figcaption>
/>
</figure>
) : (
))
<div className="uc-condition-photo__empty">
: '暂无照片'}
<PictureOutlined />
<span>未回传</span>
</div>
)}
</div>
<figcaption>
{photo.caption}
{photo.subtype === 41 ? (
<span className="uc-condition-photo__optional">选传</span>
) : null}
</figcaption>
</figure>
))}
</div>
</div>
</section>
{photos.length ? (
</aside>
requiredReady ? (
<main className="uc-condition-detail__right">
<div className="uc-condition-photos__note uc-condition-photos__note--ok">
<section>
<CheckCircleFilled />
<div className="uc-condition-detail__section-head">
必传照片已齐,可生成评估单。
<div>
</div>
<h2 className="uc-condition-detail__section-title uc-inline">完善评估单基础信息</h2>
) : (
<UButton className="uc-inline" type="link" loading={updatingBase} onClick={() => void updateBase()}>
<div className="uc-condition-photos__note uc-condition-photos__note--warn">
<ExclamationCircleFilled />
生成评估单需补齐前 8 张必传照片。
</div>
)
) : null}
</div>
</UCard>
</aside>
<main className="uc-condition-detail__workspace">
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead
title="完善评估单基础信息"
actions={
<>
<UButton
size="small"
type="default"
loading={updatingBase}
onClick={() => void updateBase()}
>
更新
更新
</UButton>
</UButton>
</div>
<UButton
<span>
size="small"
<UButton type="link" onClick={() => setBaseOpen((open) => !open)}>
type="text"
onClick={() => setBaseOpen((open) => !open)}
icon={
<DownOutlined
className={
baseOpen
? 'uc-condition-chevron'
: 'uc-condition-chevron uc-condition-chevron--closed'
}
/>
}
>
{baseOpen ? '收起' : '展开'}
{baseOpen ? '收起' : '展开'}
</UButton>
</UButton>
</span>
</>
</div>
}
{baseOpen ? (
/>
<>
{baseOpen ? (
<div className="uc-condition-detail__model-reference">
<div className="uc-detail-card__body">
车型参考:{text(data?.brandModel)}
<div className="uc-condition-reference">
</div>
<span className="uc-condition-reference__label">车型参考</span>
<span className="uc-condition-reference__value">{text(data?.brandModel)}</span>
</div>
<div className="uc-condition-form">
<CombiForm
<CombiForm
mode="form"
mode="form"
form={form}
form={form}
fields={BASE_FIELDS}
fields={BASE_FIELDS}
layout="horizontal"
layout="horizontal"
labelWidth={150}
labelWidth={180}
sectionContentStyle={{
display: 'grid',
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
columnGap: 24,
}}
renderControl={renderBaseControl}
renderControl={renderBaseControl}
/>
/>
</>
</div>
) : null}
</div>
</section>
) : null}
<section>
</UCard>
<h2 className="uc-condition-detail__section-title">
<UCard className="uc-detail-card" loading={detail.isPending}>
补充核心压价策略(终极融合引擎)
<CardHead title="补充核心压价策略(终极融合引擎)" />
</h2>
<div className="uc-detail-card__body">
<CombiForm
<div className="uc-condition-form">
mode="form"
<CombiForm
form={form}
mode="form"
fields={PRICE_FIELDS}
form={form}
layout="horizontal"
fields={PRICE_FIELDS}
labelWidth={150}
layout="horizontal"
sectionContentStyle={{
labelWidth={180}
display: 'grid',
/>
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
</div>
columnGap: 24,
<div className="uc-condition-third">
}}
<div className="uc-condition-third__head">
/>
<UCheckbox
<div className="uc-condition-detail__third">
checked={thirdReport}
<UCheckbox
onChange={(event) => {
checked={thirdReport}
if (thirdReportPresent !== true) {
onChange={(event) => {
message.warning('未查询到事故报告,请先查询事故报告。');
if (thirdReportPresent !== true) {
setThirdReport(false);
message.warning('未查询到事故报告,请先查询事故报告。');
return;
setThirdReport(false);
}
return;
setThirdReport(event.target.checked);
}
}}
setThirdReport(event.target.checked);
>
}}
附加条件:融合高阶第三方出险报告
>
</UCheckbox>
附加条件:融合高阶第三方出险报告
<UButton
</UCheckbox>
size="small"
<UButton
type="default"
type="link"
icon={<SearchOutlined />}
loading={checkingThirdReport}
loading={checkingThirdReport}
onClick={() => void checkThirdPartyReport()}
onClick={() => void checkThirdPartyReport()}
>
>
查询事故报告
查询事故报告
</UButton>
</UButton>
<div>
</div>
<div className="uc-condition-third__desc">
勾选后,系统会校验车架号历史报告,并将严重碰撞和维保记录合并到 AI 收车报告中。
勾选后,系统会校验车架号历史报告,并将严重碰撞和维保记录合并到 AI 收车报告中。
</div>
</div>
{thirdReportPresent === false ? (
{thirdReportPresent === false ? (
<div className="uc-condition-detail__third-warning">
<div className="uc-condition-third__status uc-condition-third__status--warn">
<ExclamationCircleFilled />
未查询到事故报告,请先使用“查询事故报告”。
未查询到事故报告,请先使用“查询事故报告”。
</div>
</div>
) : null}
) : null}
{thirdReportPresent === true && thirdReport ? (
{thirdReportPresent === true && thirdReport ? (
<div className="uc-condition-detail__third-success">
<div className="uc-condition-third__status uc-condition-third__status--ok">
<CheckCircleFilled />
校验通过:已匹配到历史理赔记录,将随表单合并生成。
校验通过:已匹配到历史理赔记录,将随表单合并生成。
</div>
</div>
) : null}
) : null}
</div>
</div>
</
section
>
</
div
>
<
footer className="uc-condition-detail__footer
">
<
div className="uc-detail-card__foot
">
<UButton
<UButton
type="primary"
type="primary"
loading={creatingReport}
loading={creatingReport}
...
@@ -800,9 +890,9 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -800,9 +890,9 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
>
>
生成AI收车报告
生成AI收车报告
</UButton>
</UButton>
</
footer
>
</
div
>
</
main
>
</
UCard
>
</
div
>
</
main
>
</div>
</div>
<UModal
<UModal
open={Boolean(videoUrl)}
open={Boolean(videoUrl)}
...
@@ -811,9 +901,37 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
...
@@ -811,9 +901,37 @@ export default function ConditionDetail({ params }: { params: PageParams }) {
onCancel={() => setVideoUrl('')}
onCancel={() => setVideoUrl('')}
>
>
{videoUrl ? (
{videoUrl ? (
<video className="uc-condition-
detail__
video-preview" controls autoPlay src={videoUrl} />
<video className="uc-condition-video-preview" controls autoPlay src={videoUrl} />
) : null}
) : null}
</UModal>
</UModal>
</PageShell>
</PageShell>
);
);
}
}
function statusValue(value: unknown, options: FieldOption[], success: string, failed?: string) {
if (value === undefined || value === null || value === '') return '-';
return (
<span className={`uc-detail-status uc-detail-status--${statusTone(value, success, failed)}`}>
{labelOf(options, value)}
</span>
);
}
function CardHead({ title, aux, actions }: { title: string; aux?: string; actions?: ReactNode }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
{actions ? <div className="uc-detail-card__actions">{actions}</div> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
apps/web/subapps/usedcar/src/pages/Condition/condition.css
View file @
e7c74a0
.uc-condition-status
{
/* 车况页私有样式。卡片解剖/档案条/状态点等通用部分在 src/styles/detail.css。 */
display
:
inline-flex
;
align-items
:
center
;
gap
:
8px
;
color
:
var
(
--uj-text-2
);
}
.uc-inline
{
display
:
inline-block
;
}
.uc-condition-status
::before
{
content
:
''
;
width
:
6px
;
height
:
6px
;
border-radius
:
50%
;
background
:
var
(
--uj-text-4
);
}
.uc-condition-status--success
::before
{
background
:
var
(
--uj-primary
);
}
.uc-condition-status--pending
::before
{
background
:
var
(
--uj-text-4
);
}
.uc-condition-status--progress
::before
{
background
:
var
(
--uj-warning
);
}
.uc-condition-status--failed
::before
{
background
:
var
(
--uj-error
);
}
.uc-condition-drawer
.ant-drawer-body
{
padding
:
0
;
background
:
var
(
--uj-bg
);
}
.uc-condition-detail
{
.uc-condition-detail
{
min-height
:
100%
;
}
.uc-condition-detail__header
{
display
:
flex
;
justify-content
:
space-between
;
gap
:
16px
;
padding
:
16px
20px
;
background
:
var
(
--uj-surface
);
border-bottom
:
1px
solid
var
(
--uj-border
);
}
.uc-condition-detail__header-left
{
display
:
flex
;
align-items
:
center
;
flex-wrap
:
wrap
;
gap
:
10px
12px
;
}
.uc-condition-detail__title
{
margin
:
0
;
color
:
var
(
--uj-text-1
);
font-size
:
20px
;
}
.uc-condition-source
{
display
:
inline-flex
;
align-items
:
center
;
height
:
24px
;
padding
:
0
10px
;
font-size
:
12px
;
font-weight
:
normal
;
color
:
#5584f2
;
background
:
#ecf5ff
;
border
:
1px
solid
#d9ecff
;
border-radius
:
4px
;
line-height
:
1
;
white-space
:
nowrap
;
}
.uc-condition-detail__meta
{
margin-top
:
8px
;
color
:
var
(
--uj-text-3
);
}
.uc-condition-detail__body
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
minmax
(
280px
,
32%
)
minmax
(
0
,
1
fr
);
grid-template-columns
:
minmax
(
300px
,
340px
)
minmax
(
0
,
1
fr
);
gap
:
var
(
--uj-space-module
);
align-items
:
start
;
align-items
:
start
;
background
:
var
(
--uj-surface
);
}
.uc-condition-detail__left
{
padding
:
16px
;
border-right
:
1px
solid
var
(
--uj-border
);
}
}
.uc-condition-detail__right
{
.uc-condition-detail__rail
,
.uc-condition-detail__workspace
{
display
:
grid
;
gap
:
var
(
--uj-space-module
);
min-width
:
0
;
min-width
:
0
;
}
}
.uc-condition-detail__block
{
margin-bottom
:
20px
;
.uc-condition-chevron
{
transition
:
transform
0.2s
var
(
--uj-ease-out
);
}
}
.uc-condition-detail__block-title
,
.uc-condition-chevron--closed
{
.uc-condition-detail__section-title
{
transform
:
rotate
(
-90deg
);
margin
:
0
0
12px
;
color
:
var
(
--uj-text-1
);
font-size
:
16px
;
font-weight
:
600
;
}
}
.uc-condition-detail__section-head
{
display
:
flex
;
.uc-condition-source
{
display
:
inline-flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
1px
8px
;
gap
:
12px
;
color
:
var
(
--uj-info
);
}
font-size
:
var
(
--uj-font-xs
);
.uc-condition-detail__section-head
.uc-condition-detail__section-title
{
margin-bottom
:
12px
;
}
.uc-condition-detail__model-reference
{
margin
:
0
0
12px
;
padding
:
10px
14px
;
color
:
var
(
--uj-warning
);
background
:
var
(
--uj-warning-soft
);
border
:
1px
solid
var
(
--uj-warning-border
);
border-radius
:
4px
;
}
.uc-condition-detail__description
{
white-space
:
pre-wrap
;
line-height
:
1.6
;
line-height
:
1.6
;
white-space
:
nowrap
;
background
:
var
(
--uj-info-soft
);
border
:
1px
solid
var
(
--uj-info-border
);
border-radius
:
var
(
--uj-radius-sm
);
}
/* ---- 左栏:车况描述 + 回传照片 ---- */
.uc-condition-desc
{
color
:
var
(
--uj-text-2
);
color
:
var
(
--uj-text-2
);
font-size
:
var
(
--uj-font-md
);
line-height
:
1.7
;
white-space
:
pre-wrap
;
overflow-wrap
:
anywhere
;
}
}
.uc-condition-
detail__
photos
{
.uc-condition-photos
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
120px
,
1
fr
));
gap
:
1
6
px
;
gap
:
1
2
px
;
}
}
.uc-condition-
detail__
photo
{
.uc-condition-photo
{
margin
:
0
;
margin
:
0
;
min-width
:
0
;
min-width
:
0
;
overflow
:
hidden
;
}
}
.uc-condition-detail__photo
.ant-image
{
.uc-condition-photo__media
{
display
:
block
;
position
:
relative
;
width
:
100%
;
aspect-ratio
:
4
/
3
;
height
:
110px
;
overflow
:
hidden
;
overflow
:
hidden
;
background
:
var
(
--uj-surface-2
);
border
:
1px
solid
var
(
--uj-border
);
border
:
1px
solid
var
(
--uj-border
);
border-radius
:
6px
;
border-radius
:
var
(
--uj-radius-md
)
;
background
:
var
(
--uj-bg
)
;
transition
:
border-color
0.2s
;
}
}
.uc-condition-detail__photo
.ant-image
img
,
.uc-condition-photo
:hover
.uc-condition-photo__media
{
.uc-condition-detail__video
{
border-color
:
var
(
--uj-border-strong
);
}
.uc-condition-photo__media
.ant-image
{
display
:
block
;
width
:
100%
;
width
:
100%
;
height
:
110px
;
height
:
100%
;
object-fit
:
cover
;
}
}
.uc-condition-detail__photo
figcaption
{
.uc-condition-photo__media
.ant-image
img
{
margin-top
:
6px
;
transition
:
transform
0.25s
var
(
--uj-ease-out
);
color
:
var
(
--uj-text-3
);
font-size
:
12px
;
}
}
.uc-condition-detail__video-button
{
.uc-condition-photo
:hover
.ant-image
img
{
position
:
relative
;
transform
:
scale
(
1.04
);
}
.uc-condition-photo__empty
{
position
:
absolute
;
inset
:
0
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
gap
:
4px
;
color
:
var
(
--uj-text-4
);
font-size
:
var
(
--uj-font-xs
);
}
.uc-condition-photo__empty
.anticon
{
font-size
:
20px
;
}
.uc-condition-photo__video
{
position
:
absolute
;
inset
:
0
;
display
:
block
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
padding
:
0
;
padding
:
0
;
border
:
0
;
border
:
0
;
background
:
transparent
;
background
:
transparent
;
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.uc-condition-detail__video-button
span
{
.uc-condition-photo__video
video
{
display
:
block
;
width
:
100%
;
height
:
100%
;
object-fit
:
cover
;
}
.uc-condition-photo__video
::after
{
content
:
''
;
position
:
absolute
;
position
:
absolute
;
inset
:
0
;
inset
:
0
;
background
:
linear-gradient
(
180deg
,
rgba
(
11
,
20
,
55
,
0
)
55%
,
rgba
(
11
,
20
,
55
,
0.45
)
100%
);
pointer-events
:
none
;
}
.uc-condition-photo__play
{
position
:
absolute
;
top
:
50%
;
left
:
50%
;
z-index
:
1
;
display
:
grid
;
display
:
grid
;
place-items
:
center
;
place-items
:
center
;
color
:
var
(
--uj-on-primary
);
width
:
32px
;
background
:
color-mix
(
in
srgb
,
var
(
--uj-brand-1
)
45%
,
transparent
);
height
:
32px
;
color
:
var
(
--uj-primary
);
font-size
:
14px
;
background
:
rgba
(
255
,
255
,
255
,
0.92
);
border-radius
:
50%
;
box-shadow
:
var
(
--uj-shadow-raise
);
translate
:
-50%
-50%
;
transition
:
transform
0.2s
var
(
--uj-ease-out
);
}
}
.uc-condition-detail__video-preview
{
.uc-condition-photo__video
:hover
.uc-condition-photo__play
{
display
:
block
;
transform
:
scale
(
1.1
);
width
:
100%
;
}
max-height
:
70vh
;
.uc-condition-photo
figcaption
{
background
:
var
(
--uj-brand-1
);
display
:
flex
;
align-items
:
baseline
;
gap
:
4px
;
margin-top
:
6px
;
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
line-height
:
1.5
;
}
.uc-condition-photo__optional
{
color
:
var
(
--uj-text-4
);
}
.uc-condition-photo__optional
::before
{
content
:
'·'
;
margin-right
:
4px
;
}
.uc-condition-photos__note
{
display
:
flex
;
align-items
:
center
;
gap
:
6px
;
margin-top
:
12px
;
font-size
:
var
(
--uj-font-xs
);
line-height
:
1.6
;
}
.uc-condition-photos__note--warn
{
color
:
var
(
--uj-warning
);
}
.uc-condition-photos__note--ok
{
color
:
var
(
--uj-success
);
}
/* ---- 右栏:表单 ---- */
/* 车型参考是只读信息带:淡底无边框,不与卡片外框抢线。 */
.uc-condition-reference
{
display
:
flex
;
align-items
:
baseline
;
gap
:
8px
;
margin-bottom
:
16px
;
padding
:
8px
12px
;
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.6
;
background
:
var
(
--uj-surface-2
);
border-radius
:
var
(
--uj-radius-md
);
}
}
.uc-condition-detail__right
section
{
.uc-condition-reference__label
{
padding
:
16px
20px
;
flex
:
none
;
border-bottom
:
6px
solid
var
(
--uj-bg
);
color
:
var
(
--uj-text-3
);
}
.uc-condition-reference__value
{
color
:
var
(
--uj-text-1
);
overflow-wrap
:
anywhere
;
}
}
.uc-condition-detail__form
{
/* CombiForm 的分区容器是裸 div,栅格落在这里才能被媒体查询接管(内联样式压不过)。 */
.uc-condition-form
>
form
>
section
>
div
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
0
24px
;
column-gap
:
24px
;
}
}
.uc-condition-detail__compound
{
.uc-condition-form
.ant-form-item
{
margin-bottom
:
16px
;
}
.uc-condition-form
.ant-form-item-label
>
label
{
color
:
var
(
--uj-text-2
);
}
.uc-condition-compound
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
8px
;
gap
:
8px
;
width
:
100%
;
width
:
100%
;
}
}
.uc-condition-detail__third
{
padding
:
14px
16px
;
/* ---- 第三方出险报告:软面板无边框,状态行用语义色 ---- */
color
:
var
(
--uj-text-2
);
.uc-condition-third
{
padding
:
12px
16px
;
background
:
var
(
--uj-primary-soft
);
background
:
var
(
--uj-primary-soft
);
border-radius
:
6px
;
border-radius
:
var
(
--uj-radius-lg
)
;
}
}
.uc-condition-detail__third-warning
{
.uc-condition-third__head
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
center
;
gap
:
8px
12px
;
}
.uc-condition-third__head
.ant-checkbox-wrapper
{
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-md
);
}
.uc-condition-third__head
.ant-btn
{
margin-left
:
auto
;
}
.uc-condition-third__desc
{
margin-top
:
8px
;
margin-top
:
8px
;
color
:
var
(
--uj-warning
);
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
line-height
:
1.7
;
}
}
.uc-condition-detail__third-success
{
.uc-condition-third__status
{
display
:
flex
;
align-items
:
center
;
gap
:
6px
;
margin-top
:
8px
;
margin-top
:
8px
;
font-size
:
var
(
--uj-font-xs
);
line-height
:
1.6
;
}
.uc-condition-third__status--warn
{
color
:
var
(
--uj-warning
);
}
.uc-condition-third__status--ok
{
color
:
var
(
--uj-success
);
color
:
var
(
--uj-success
);
}
}
.uc-condition-detail__footer
{
display
:
flex
;
.uc-condition-video-preview
{
justify-content
:
center
;
display
:
block
;
padding
:
24px
;
width
:
100%
;
background
:
var
(
--uj-surface
);
max-height
:
70vh
;
background
:
var
(
--uj-brand-1
);
border-radius
:
var
(
--uj-radius-md
);
}
}
@media
(
max-width
:
900px
)
{
.uc-condition-detail__body
{
@media
(
max-width
:
1100px
)
{
.uc-condition-detail
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
.uc-condition-detail__left
{
}
border-right
:
0
;
@media
(
max-width
:
700px
)
{
border-bottom
:
1px
solid
var
(
--uj-border
);
.uc-condition-form
>
form
>
section
>
div
{
}
.uc-condition-detail__form
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
/* itemStyle/labelCol 是内联样式,单列与竖排标签只能在这里压回去。 */
.uc-condition-form
.ant-form-item
{
flex-direction
:
column
;
grid-column
:
auto
!important
;
}
.uc-condition-form
.ant-form-item-label
{
flex
:
none
!important
;
max-width
:
100%
;
padding
:
0
0
4px
;
text-align
:
left
;
}
.uc-condition-form
.ant-form-item-label
>
label
{
height
:
auto
;
}
.uc-condition-form
.ant-form-item-label
>
label
::after
{
content
:
none
;
}
}
}
apps/web/subapps/usedcar/src/pages/Condition/conditionConfig.ts
View file @
e7c74a0
...
@@ -40,6 +40,10 @@ const requiredInput = (label: string) => [
...
@@ -40,6 +40,10 @@ const requiredInput = (label: string) => [
{
required
:
true
,
whitespace
:
true
,
message
:
`请填写
${
label
}
`
},
{
required
:
true
,
whitespace
:
true
,
message
:
`请填写
${
label
}
`
},
];
];
/**
* 字段顺序即两列栅格的落位顺序:相邻两项语义成对(标识/地区/日期/价格/颜色/评价/人员/证件),
* 单格字段共 30 个恰好排满 15 行,不留半空行;跨两列的长文本统一收在末尾。
*/
export
const
BASE_FIELDS
:
FieldSchema
<
ConditionValues
>
[]
=
[
export
const
BASE_FIELDS
:
FieldSchema
<
ConditionValues
>
[]
=
[
{
{
name
:
'licensePlate'
,
name
:
'licensePlate'
,
...
@@ -48,14 +52,6 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -48,14 +52,6 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
rules
:
requiredInput
(
'车牌号'
),
rules
:
requiredInput
(
'车牌号'
),
inputProps
:
{
maxLength
:
10
},
inputProps
:
{
maxLength
:
10
},
},
},
{
name
:
'registrationDate'
,
label
:
'上牌时间'
,
type
:
'date'
,
rules
:
required
(
'上牌时间'
)
},
{
name
:
'brandModel'
,
label
:
'车型'
,
type
:
'input'
,
rules
:
requiredInput
(
'车型'
),
inputProps
:
{
maxLength
:
100
},
},
{
{
name
:
'vin'
,
name
:
'vin'
,
label
:
'车架号'
,
label
:
'车架号'
,
...
@@ -70,6 +66,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -70,6 +66,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
.
replace
(
/
[^
A-HJ-NPR-Z0-9
]
/g
,
''
)
.
replace
(
/
[^
A-HJ-NPR-Z0-9
]
/g
,
''
)
.
slice
(
0
,
17
),
.
slice
(
0
,
17
),
},
},
{
name
:
'brandModel'
,
label
:
'车型'
,
type
:
'input'
,
rules
:
requiredInput
(
'车型'
),
inputProps
:
{
maxLength
:
100
},
},
{
name
:
'engineNumber'
,
label
:
'发动机号'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
20
}
},
{
name
:
'engineNumber'
,
label
:
'发动机号'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
20
}
},
{
{
name
:
'registrationCityName'
,
name
:
'registrationCityName'
,
...
@@ -85,6 +88,8 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -85,6 +88,8 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
rules
:
requiredInput
(
'车辆所在地'
),
rules
:
requiredInput
(
'车辆所在地'
),
inputProps
:
{
maxLength
:
100
},
inputProps
:
{
maxLength
:
100
},
},
},
{
name
:
'registrationDate'
,
label
:
'上牌时间'
,
type
:
'date'
,
rules
:
required
(
'上牌时间'
)
},
{
name
:
'productionDate'
,
label
:
'生产日期'
,
type
:
'date'
,
rules
:
required
(
'生产日期'
)
},
{
{
name
:
'displayMileage'
,
name
:
'displayMileage'
,
label
:
'表显里程'
,
label
:
'表显里程'
,
...
@@ -93,6 +98,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -93,6 +98,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
inputProps
:
{
maxLength
:
6
},
inputProps
:
{
maxLength
:
6
},
},
},
{
{
name
:
'guidePrice'
,
label
:
'指导价(元)'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d
+
(\.\d{1,2})?
$/
,
message
:
'请输入有效指导价'
}],
inputProps
:
{
maxLength
:
10
},
},
{
name
:
'vehicleCategory'
,
name
:
'vehicleCategory'
,
label
:
'车辆类别'
,
label
:
'车辆类别'
,
type
:
'select'
,
type
:
'select'
,
...
@@ -103,19 +115,32 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -103,19 +115,32 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
rules
:
required
(
'车辆类别'
),
rules
:
required
(
'车辆类别'
),
},
},
{
{
name
:
'usageType'
,
label
:
'使用性质'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'非营运'
},
{
value
:
2
,
label
:
'营运'
},
{
value
:
3
,
label
:
'营转非'
},
],
rules
:
required
(
'使用性质'
),
},
{
name
:
'emissionStandard'
,
name
:
'emissionStandard'
,
label
:
'排放标准'
,
label
:
'排放标准'
,
type
:
'select'
,
type
:
'select'
,
options
:
[
3
,
4
,
5
,
6
].
map
((
value
)
=>
({
value
,
label
:
`国
${
value
}
`
})),
options
:
[
3
,
4
,
5
,
6
].
map
((
value
)
=>
({
value
,
label
:
`国
${
value
}
`
})),
rules
:
required
(
'排放标准'
),
rules
:
required
(
'排放标准'
),
},
},
{
name
:
'productionDate'
,
label
:
'生产日期'
,
type
:
'date'
,
rules
:
required
(
'生产日期'
)
},
{
{
name
:
'guidePrice'
,
name
:
'ownerType'
,
label
:
'指导价(元)'
,
label
:
'所有人性质'
,
type
:
'input'
,
type
:
'select'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d
+
(\.\d{1,2})?
$/
,
message
:
'请输入有效指导价'
}],
options
:
[
inputProps
:
{
maxLength
:
10
},
{
value
:
1
,
label
:
'个人'
},
{
value
:
2
,
label
:
'单位'
},
],
rules
:
required
(
'所有人性质'
),
},
},
{
{
name
:
'sunroof'
,
name
:
'sunroof'
,
...
@@ -129,6 +154,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -129,6 +154,13 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
rules
:
required
(
'天窗'
),
rules
:
required
(
'天窗'
),
},
},
{
{
name
:
'overallRating'
,
label
:
'综合评价'
,
type
:
'select'
,
options
:
[
'优'
,
'良'
,
'中'
,
'差'
].
map
((
label
,
index
)
=>
({
value
:
index
+
1
,
label
})),
rules
:
required
(
'综合评价'
),
},
{
name
:
'interiorColor'
,
name
:
'interiorColor'
,
label
:
'内饰颜色'
,
label
:
'内饰颜色'
,
type
:
'select'
,
type
:
'select'
,
...
@@ -142,6 +174,20 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -142,6 +174,20 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
options
:
COLORS
,
options
:
COLORS
,
rules
:
required
(
'外观颜色'
),
rules
:
required
(
'外观颜色'
),
},
},
{
name
:
'hasAccident'
,
label
:
'是否事故车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否事故车'
),
},
{
name
:
'buyNewCar'
,
label
:
'是否购买新车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否购买新车'
),
},
{
name
:
'sellerMerchantName'
,
label
:
'门店'
,
type
:
'input'
,
disabled
:
true
},
{
name
:
'sellerMerchantName'
,
label
:
'门店'
,
type
:
'input'
,
disabled
:
true
},
{
name
:
'sellerName'
,
label
:
'销售顾问'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
{
name
:
'sellerName'
,
label
:
'销售顾问'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
{
name
:
'conversionName'
,
label
:
'驻店人员'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
{
name
:
'conversionName'
,
label
:
'驻店人员'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
50
}
},
...
@@ -164,13 +210,6 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -164,13 +210,6 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
.
slice
(
0
,
11
),
.
slice
(
0
,
11
),
},
},
{
{
name
:
'previousOwnerAddress'
,
label
:
'原车主住址'
,
type
:
'textarea'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
textareaProps
:
{
maxLength
:
200
,
rows
:
2
,
showCount
:
true
},
},
{
name
:
'keyCount'
,
name
:
'keyCount'
,
label
:
'钥匙数量'
,
label
:
'钥匙数量'
,
type
:
'input'
,
type
:
'input'
,
...
@@ -188,46 +227,11 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -188,46 +227,11 @@ export const BASE_FIELDS: FieldSchema<ConditionValues>[] = [
{
name
:
'annualInspectionExpiry'
,
label
:
'年审到期日'
,
type
:
'date'
},
{
name
:
'annualInspectionExpiry'
,
label
:
'年审到期日'
,
type
:
'date'
},
{
name
:
'commercialInsuranceExpiry'
,
label
:
'商业险到期'
,
type
:
'date'
},
{
name
:
'commercialInsuranceExpiry'
,
label
:
'商业险到期'
,
type
:
'date'
},
{
{
name
:
'usageType'
,
name
:
'previousOwnerAddress'
,
label
:
'使用性质'
,
label
:
'原车主住址'
,
type
:
'select'
,
type
:
'textarea'
,
options
:
[
itemStyle
:
{
gridColumn
:
'span 2'
},
{
value
:
1
,
label
:
'非营运'
},
textareaProps
:
{
maxLength
:
200
,
rows
:
2
,
showCount
:
true
},
{
value
:
2
,
label
:
'营运'
},
{
value
:
3
,
label
:
'营转非'
},
],
rules
:
required
(
'使用性质'
),
},
{
name
:
'ownerType'
,
label
:
'所有人性质'
,
type
:
'select'
,
options
:
[
{
value
:
1
,
label
:
'个人'
},
{
value
:
2
,
label
:
'单位'
},
],
rules
:
required
(
'所有人性质'
),
},
{
name
:
'overallRating'
,
label
:
'综合评价'
,
type
:
'select'
,
options
:
[
'优'
,
'良'
,
'中'
,
'差'
].
map
((
label
,
index
)
=>
({
value
:
index
+
1
,
label
})),
rules
:
required
(
'综合评价'
),
},
{
name
:
'hasAccident'
,
label
:
'是否事故车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否事故车'
),
},
{
name
:
'buyNewCar'
,
label
:
'是否购买新车'
,
type
:
'select'
,
options
:
YES_NO
,
rules
:
required
(
'是否购买新车'
),
},
},
{
{
name
:
'conditionDescription'
,
name
:
'conditionDescription'
,
...
@@ -274,6 +278,14 @@ export const PRICE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -274,6 +278,14 @@ export const PRICE_FIELDS: FieldSchema<ConditionValues>[] = [
type
:
'input'
,
type
:
'input'
,
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,9}
$/
,
message
:
'请输入有效车辆公里数'
}],
rules
:
[{
required
:
true
,
pattern
:
/^
\d{1,9}
$/
,
message
:
'请输入有效车辆公里数'
}],
},
},
{
name
:
'prepCost'
,
label
:
'整备成本预估(元)'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
9
}
},
{
name
:
'marketRisk'
,
label
:
'市场与行情风险'
,
type
:
'input'
,
itemStyle
:
{
gridColumn
:
'span 2'
},
inputProps
:
{
maxLength
:
100
},
},
{
{
name
:
'reportConditionDescription'
,
name
:
'reportConditionDescription'
,
label
:
'车况描述(瑕疵/维保详述)'
,
label
:
'车况描述(瑕疵/维保详述)'
,
...
@@ -298,9 +310,15 @@ export const PRICE_FIELDS: FieldSchema<ConditionValues>[] = [
...
@@ -298,9 +310,15 @@ export const PRICE_FIELDS: FieldSchema<ConditionValues>[] = [
rules
:
requiredInput
(
'历史与状态'
),
rules
:
requiredInput
(
'历史与状态'
),
textareaProps
:
{
maxLength
:
100
,
rows
:
3
,
showCount
:
true
},
textareaProps
:
{
maxLength
:
100
,
rows
:
3
,
showCount
:
true
},
},
},
{
name
:
'prepCost'
,
label
:
'整备成本预估(元)'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
9
}
},
{
name
:
'marketRisk'
,
label
:
'市场与行情风险'
,
type
:
'input'
,
inputProps
:
{
maxLength
:
100
}
},
];
];
export
const
labelOf
=
(
options
:
FieldOption
[],
value
:
unknown
)
=>
export
const
labelOf
=
(
options
:
FieldOption
[],
value
:
unknown
)
=>
options
.
find
((
item
)
=>
String
(
item
.
value
)
===
String
(
value
))?.
label
??
'-'
;
options
.
find
((
item
)
=>
String
(
item
.
value
)
===
String
(
value
))?.
label
??
'-'
;
/** 状态点色调:列表与详情档案条共用同一套判定,避免两处各写一份漂移。 */
export
const
statusTone
=
(
value
:
unknown
,
success
:
string
,
failed
?:
string
)
=>
{
if
(
String
(
value
)
===
success
)
return
'success'
;
if
(
failed
!==
undefined
&&
String
(
value
)
===
failed
)
return
'failed'
;
if
(
String
(
value
)
===
'0'
)
return
'pending'
;
return
'progress'
;
};
apps/web/subapps/usedcar/src/pages/Condition/index.tsx
View file @
e7c74a0
import { useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UResult, useUMessage } from '@uj/ui';
import { UAlert, UButton, UCard, UResult, useUMessage } from '@uj/ui';
import { openExternal } from '@uj/platform-sdk';
import {
import {
DataTable,
DataTable,
PageShell,
PageShell,
...
@@ -15,7 +16,7 @@ import { UC } from '@/permissions/codes';
...
@@ -15,7 +16,7 @@ import { UC } from '@/permissions/codes';
import { loadUsedcarRemoteConfig } from '../../api/core/config-center';
import { loadUsedcarRemoteConfig } from '../../api/core/config-center';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import { goTo } from '../Leads/navigate';
import { goTo } from '../Leads/navigate';
import { AI_REPORT_STATUS, CONDITION_STATUS, labelOf } from './conditionConfig';
import { AI_REPORT_STATUS, CONDITION_STATUS, labelOf
, statusTone
} from './conditionConfig';
import './condition.css';
import './condition.css';
type Filters = Record<string, unknown> & {
type Filters = Record<string, unknown> & {
...
@@ -34,12 +35,6 @@ type Row = Record<string, unknown> & {
...
@@ -34,12 +35,6 @@ type Row = Record<string, unknown> & {
type PageResult = { records: Row[]; total: number };
type PageResult = { records: Row[]; total: number };
const text = (value: unknown) =>
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
value === undefined || value === null || value === '' ? '-' : String(value);
const statusTone = (value: unknown, success: string, failed?: string) => {
if (String(value) === success) return 'success';
if (failed !== undefined && String(value) === failed) return 'failed';
if (String(value) === '0') return 'pending';
return 'progress';
};
export default function Condition() {
export default function Condition() {
const { canPoint } = useAccess();
const { canPoint } = useAccess();
...
@@ -113,7 +108,7 @@ export default function Condition() {
...
@@ -113,7 +108,7 @@ export default function Condition() {
dataIndex: 'status',
dataIndex: 'status',
width: 130,
width: 130,
render: (value: unknown) => (
render: (value: unknown) => (
<span className={`uc-
condition-status uc-condition
-status--${statusTone(value, '1')}`}>
<span className={`uc-
detail-status uc-detail
-status--${statusTone(value, '1')}`}>
{labelOf(CONDITION_STATUS, value)}
{labelOf(CONDITION_STATUS, value)}
</span>
</span>
),
),
...
@@ -123,7 +118,7 @@ export default function Condition() {
...
@@ -123,7 +118,7 @@ export default function Condition() {
dataIndex: 'aiReportStatus',
dataIndex: 'aiReportStatus',
width: 130,
width: 130,
render: (value: unknown) => (
render: (value: unknown) => (
<span className={`uc-
condition-status uc-condition
-status--${statusTone(value, '2', '3')}`}>
<span className={`uc-
detail-status uc-detail
-status--${statusTone(value, '2', '3')}`}>
{labelOf(AI_REPORT_STATUS, value)}
{labelOf(AI_REPORT_STATUS, value)}
</span>
</span>
),
),
...
@@ -140,10 +135,8 @@ export default function Condition() {
...
@@ -140,10 +135,8 @@ export default function Condition() {
return;
return;
}
}
const join = baseUrl.includes('?') ? '&' : '?';
const join = baseUrl.includes('?') ? '&' : '?';
window.open
(
openExternal
(
`${baseUrl}${join}source=1&carConditionCode=${encodeURIComponent(String(row.carConditionCode ?? ''))}`,
`${baseUrl}${join}source=1&carConditionCode=${encodeURIComponent(String(row.carConditionCode ?? ''))}`,
'_blank',
'noopener,noreferrer',
);
);
} catch (error) {
} catch (error) {
message.error(errorDetail(error));
message.error(errorDetail(error));
...
@@ -190,9 +183,10 @@ export default function Condition() {
...
@@ -190,9 +183,10 @@ export default function Condition() {
}
}
/>
/>
) : null}
) : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Row>
<DataTable<Row>
rowKey="id"
rowKey="id"
fillHeight
columns={columns}
columns={columns}
dataSource={list.data?.records ?? []}
dataSource={list.data?.records ?? []}
loading={list.isPending || list.isFetching}
loading={list.isPending || list.isFetching}
...
...
apps/web/subapps/usedcar/src/pages/CustomerGroup/GroupCodeEditor.tsx
View file @
e7c74a0
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useState
, type ReactNode
} from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UForm, UInput, UModal, UResult, useUMessage } from '@uj/ui';
import {
UAlert,
UButton,
UCard,
UEmpty,
UForm,
UInput,
UModal,
UResult,
useUMessage,
} from '@uj/ui';
import { CombiForm, DataTable, PageShell, type FieldSchema } from '@/components';
import { CombiForm, DataTable, PageShell, type FieldSchema } from '@/components';
import { getLiveCodeDetail, liveCodeApi } from '@/api';
import { getLiveCodeDetail, liveCodeApi } from '@/api';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import { goTo } from '../Leads/navigate';
import { goTo } from '../Leads/navigate';
import './customerGroup.css';
type Group = Record<string, unknown> & {
type Group = Record<string, unknown> & {
groupChatId: string;
groupChatId: string;
...
@@ -217,58 +228,78 @@ export default function GroupCodeEditor({ params }: Props) {
...
@@ -217,58 +228,78 @@ export default function GroupCodeEditor({ params }: Props) {
if (!(editing ? canPoint(UC.GROUP_UPDATE) : canPoint(UC.GROUP_CREATE)))
if (!(editing ? canPoint(UC.GROUP_UPDATE) : canPoint(UC.GROUP_CREATE)))
return <UResult status="403" title="无操作群活码的权限" subTitle="请联系管理员开通权限。" />;
return <UResult status="403" title="无操作群活码的权限" subTitle="请联系管理员开通权限。" />;
return (
return (
<PageShell
<PageShell title={editing ? '修改群活码' : '创建群活码'}>
title={editing ? '修改群活码' : '创建群活码'}
<div className="uc-detail-stack">
extra={<UButton onClick={() => goTo('customer-group')}>返回</UButton>}
<UCard className="uc-detail-card">
>
<CardHead title="基础信息" />
<UCard title="基础信息" size="small">
<div className="uc-detail-card__body">
<CombiForm
<div className="uc-group-form">
mode="form"
<CombiForm
form={form}
mode="form"
fields={fields}
form={form}
layout="horizontal"
fields={fields}
labelWidth={140}
layout="horizontal"
sectionContentStyle={{ display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '0 24px' }}
labelWidth={140}
onSubmit={(values) => void save(values)}
sectionContentStyle={{
/>
display: 'grid',
</UCard>
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
<UCard
gap: '0 24px',
title="群池配置"
}}
size="small"
onSubmit={(values) => void save(values)}
style={{ marginTop: 16 }}
/>
extra={
</div>
<UButton type="primary" onClick={() => setPickerOpen(true)}>
</div>
从企微后台添加群聊
</UCard>
<UCard className="uc-detail-card">
<CardHead
title="群池配置"
aux={`已关联 ${groups.length} 个群`}
actions={
<UButton type="primary" onClick={() => setPickerOpen(true)}>
从企微后台添加群聊
</UButton>
}
/>
<div className="uc-detail-card__body">
<p className="uc-group-tip">
支持最多选择1000个群聊,系统将按列表顺序自动分配状态为“空闲”的群。序号即分配顺序。
</p>
{groups.length ? (
<div className="uc-group-pool">
{groups.map((item, index) => (
<span key={item.groupChatId} className="uc-group-chip">
<span className="uc-group-chip__index">{index + 1}</span>
<span className="uc-group-chip__name" title={item.groupChatName}>
{item.groupChatName}
</span>
{!item.disabled ? (
<button
type="button"
className="uc-group-chip__remove"
aria-label={`移除${item.groupChatName}`}
onClick={() =>
setGroups((old) =>
old.filter((row) => row.groupChatId !== item.groupChatId),
)
}
>
×
</button>
) : null}
</span>
))}
</div>
) : (
<UEmpty description="尚未关联群聊" />
)}
</div>
</UCard>
<div className="uc-group-actions">
<UButton onClick={() => goTo('customer-group')}>取消</UButton>
<UButton type="primary" loading={saving} onClick={() => form.submit()}>
保存
</UButton>
</UButton>
}
>
<p>已关联 {groups.length} 个群</p>
<p className="uj-page-tip">
支持最多选择1000个群聊,系统将按列表顺序自动分配状态为“空闲”的群。
</p>
<div className="uj-group-tags">
{groups.map((item) => (
<span key={item.groupChatId} className="uj-group-tag">
{item.groupChatName}
{!item.disabled ? (
<button
type="button"
onClick={() =>
setGroups((old) => old.filter((row) => row.groupChatId !== item.groupChatId))
}
>
×
</button>
) : null}
</span>
))}
</div>
</div>
</UCard>
<div className="uj-page-footer-actions">
<UButton onClick={() => goTo('customer-group')}>取消</UButton>
<UButton type="primary" loading={saving} onClick={() => form.submit()}>
保存
</UButton>
</div>
</div>
<GroupPicker
<GroupPicker
open={pickerOpen}
open={pickerOpen}
...
@@ -283,3 +314,12 @@ export default function GroupCodeEditor({ params }: Props) {
...
@@ -283,3 +314,12 @@ export default function GroupCodeEditor({ params }: Props) {
</PageShell>
</PageShell>
);
);
}
}
function CardHead({ title, aux, actions }: { title: string; aux?: string; actions?: ReactNode }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
{actions ? <div className="uc-detail-card__actions">{actions}</div> : null}
</div>
);
}
apps/web/subapps/usedcar/src/pages/CustomerGroup/LiveCodesTab.tsx
View file @
e7c74a0
...
@@ -68,6 +68,9 @@ export default function LiveCodesTab() {
...
@@ -68,6 +68,9 @@ export default function LiveCodesTab() {
source: 'usedcar',
source: 'usedcar',
sourceLabel: '二手车管理 / 一客一群',
sourceLabel: '二手车管理 / 一客一群',
label: `${text(row.liveName)}二维码`,
label: `${text(row.liveName)}二维码`,
// 直链末端是预签名路径(qrcode_xxx_static_时间戳.png),不带可读文件名。
// 这里给业务文件名,下载中心和浏览器保存对话框才显示用户认识的名字。
fileName: `${text(row.liveName)}二维码.png`,
url: row.defaultQrCodeUrl,
url: row.defaultQrCodeUrl,
silent: true,
silent: true,
}),
}),
...
@@ -120,9 +123,10 @@ export default function LiveCodesTab() {
...
@@ -120,9 +123,10 @@ export default function LiveCodesTab() {
}
}
/>
/>
) : null}
) : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Row>
<DataTable<Row>
rowKey="id"
rowKey="id"
fillHeight
columns={columns}
columns={columns}
dataSource={query.data?.records ?? []}
dataSource={query.data?.records ?? []}
loading={query.isPending || query.isFetching}
loading={query.isPending || query.isFetching}
...
...
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigTab.tsx
View file @
e7c74a0
...
@@ -102,9 +102,10 @@ export default function StoreConfigTab() {
...
@@ -102,9 +102,10 @@ export default function StoreConfigTab() {
}
}
/>
/>
) : null}
) : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Row>
<DataTable<Row>
rowKey="id"
rowKey="id"
fillHeight
columns={[
columns={[
{ title: '4S店名称', dataIndex: 'storeName', width: 260, line: 1, render: text },
{ title: '4S店名称', dataIndex: 'storeName', width: 260, line: 1, render: text },
{
{
...
...
apps/web/subapps/usedcar/src/pages/CustomerGroup/customerGroup.css
View file @
e7c74a0
...
@@ -9,41 +9,92 @@
...
@@ -9,41 +9,92 @@
max-width
:
360px
;
max-width
:
360px
;
}
}
.uj-group-tags
{
/* 群活码编辑页:表单限宽避免输入框拉通整屏,群池用带序号的徽章网格表达分配顺序。 */
display
:
flex
;
.uc-group-form
{
flex-wrap
:
wrap
;
max-width
:
960px
;
}
.uc-group-tip
{
margin
:
0
0
12px
;
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
}
.uc-group-pool
{
display
:
grid
;
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
240px
,
1
fr
));
gap
:
8px
;
gap
:
8px
;
min-height
:
32px
;
}
}
.u
j-group-tag
{
.u
c-group-chip
{
display
:
inline-
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
gap
:
8px
;
gap
:
8px
;
max-width
:
320px
;
min-width
:
0
;
padding
:
4px
8px
;
padding
:
6px
10px
;
border-radius
:
var
(
--uj-radius-md
);
background
:
var
(
--uj-surface-2
);
transition
:
background
0.15s
var
(
--uj-ease-out
);
}
.uc-group-chip
:hover
{
background
:
var
(
--uj-surface-3
);
}
.uc-group-chip__index
{
flex
:
none
;
display
:
inline-grid
;
place-items
:
center
;
width
:
20px
;
height
:
20px
;
border-radius
:
50%
;
background
:
var
(
--uj-surface
);
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-variant-numeric
:
var
(
--uj-num
);
}
.uc-group-chip__name
{
flex
:
1
;
min-width
:
0
;
overflow
:
hidden
;
overflow
:
hidden
;
border
:
1px
solid
var
(
--ant-color-border
);
color
:
var
(
--uj-text-1
);
border-radius
:
4px
;
font-size
:
var
(
--uj-font-sm
);
color
:
var
(
--ant-color-text
);
white-space
:
nowrap
;
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
text-overflow
:
ellipsis
;
}
}
.u
j-group-tag
button
{
.u
c-group-chip__remove
{
flex
:
none
;
flex
:
none
;
width
:
16px
;
height
:
16px
;
padding
:
0
;
padding
:
0
;
border
:
0
;
border
:
0
;
border-radius
:
50%
;
background
:
transparent
;
background
:
transparent
;
color
:
inherit
;
color
:
var
(
--uj-text-4
)
;
cursor
:
pointer
;
cursor
:
pointer
;
font-size
:
1
8
px
;
font-size
:
1
4
px
;
line-height
:
1
;
line-height
:
1
;
transition
:
color
0.15s
var
(
--uj-ease-out
),
background
0.15s
var
(
--uj-ease-out
);
}
.uc-group-chip__remove
:hover
{
color
:
var
(
--uj-error
);
background
:
var
(
--uj-surface
);
}
}
.u
j-page-footer
-actions
{
.u
c-group
-actions
{
display
:
flex
;
display
:
flex
;
justify-content
:
flex-end
;
justify-content
:
flex-end
;
gap
:
12px
;
gap
:
8px
;
margin-top
:
16px
;
padding
:
12px
0
;
}
@media
(
max-width
:
700px
)
{
.uc-group-pool
{
grid-template-columns
:
1
fr
;
}
}
}
apps/web/subapps/usedcar/src/pages/CustomerGroup/index.tsx
View file @
e7c74a0
...
@@ -13,11 +13,12 @@ export default function CustomerGroup() {
...
@@ -13,11 +13,12 @@ export default function CustomerGroup() {
if (!canPoint(UC.GROUP_VIEW))
if (!canPoint(UC.GROUP_VIEW))
return <UResult status="403" title="无访问一客一群的权限" subTitle="请联系管理员开通访问权限。" />;
return <UResult status="403" title="无访问一客一群的权限" subTitle="请联系管理员开通访问权限。" />;
return (
return (
<PageShell title="一客一群">
<PageShell
fill
title="一客一群">
<UTabs activeKey={tab} onChange={setTab} items={[
<UTabs activeKey={tab} onChange={setTab} items={[
{ key: 'group', label: '一客一群'
, children: <LiveCodesTab />
},
{ key: 'group', label: '一客一群' },
{ key: 'dealer', label: '4S店配置'
, children: <StoreConfigTab />
},
{ key: 'dealer', label: '4S店配置' },
]} />
]} />
{tab === 'group' ? <LiveCodesTab /> : <StoreConfigTab />}
</PageShell>
</PageShell>
);
);
}
}
apps/web/subapps/usedcar/src/pages/Delivery/DeliveryDetail.tsx
View file @
e7c74a0
import type { ReactNode } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, U
Button, UCard
, UImage, UResult } from '@uj/ui';
import { UAlert, U
Card, UEmpty
, UImage, UResult } from '@uj/ui';
import { CombiForm, PageShell, type FieldSchema } from '@/components';
import { CombiForm, PageShell, type FieldSchema } from '@/components';
import { deliveryOrderApi } from '@/api';
import { deliveryOrderApi } from '@/api';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import type { PageParams } from '@/routes';
import { goTo } from '../Leads/navigate';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import './delivery.css';
import './delivery.css';
type Detail = Record<string, unknown> & { id: string; confirmImages?: string };
type Detail = Record<string, unknown> & { id: string; confirmImages?: string };
...
@@ -85,36 +85,28 @@ const DETAIL_SECTIONS: Array<{ title: string; fields: FieldSchema<Record<string,
...
@@ -85,36 +85,28 @@ const DETAIL_SECTIONS: Array<{ title: string; fields: FieldSchema<Record<string,
['custodianPhone', '车辆保管人联系方式'],
['custodianPhone', '车辆保管人联系方式'],
]),
]),
},
},
{
title: '交付图片',
fields: [
{
name: 'confirmImages',
label: '交付图片',
type: 'input',
render: (v) => {
const images = String(v ?? '')
.split(/,\s*(?=https?:\/\/)/)
.filter(Boolean);
return images.length ? (
<div className="uc-delivery-images">
{images.map((url) => (
<UImage key={url} src={url} width={90} height={90} />
))}
</div>
) : (
'-'
);
},
},
],
},
];
];
const LOG_FIELDS = make([
/** 交付图片独立成卡:逗号分隔的 URL 串解析规则与原配置一致。 */
['operationName', '操作类型'],
function DeliveryImages({ value }: { value: unknown }) {
['opUserName', '操作人'],
const images = String(value ?? '')
['createdDate', '操作时间'],
.split(/,\s*(?=https?:\/\/)/)
]);
.filter(Boolean);
if (!images.length) return <UEmpty description="暂无交付图片" />;
return (
<div className="uc-delivery-images">
{images.map((url) => (
<UImage
key={url}
src={url}
width="100%"
height={112}
className="uc-delivery-image"
styles={{ image: { objectFit: 'cover' } }}
/>
))}
</div>
);
}
const OPERATION_NAME_MAP: Record<string, string> = {
const OPERATION_NAME_MAP: Record<string, string> = {
1: '创建交付工单',
1: '创建交付工单',
2: '确认客户到店',
2: '确认客户到店',
...
@@ -141,6 +133,8 @@ export default function DeliveryDetail({ params }: { params: PageParams }) {
...
@@ -141,6 +133,8 @@ export default function DeliveryDetail({ params }: { params: PageParams }) {
<UResult status="403" title="无查看交付单详情的权限" subTitle="请联系管理员开通对应权限。" />
<UResult status="403" title="无查看交付单详情的权限" subTitle="请联系管理员开通对应权限。" />
);
);
const data = query.data ?? { id: params.id };
const data = query.data ?? { id: params.id };
const logRows = logs.data ?? [];
const sectionOf = (title: string) => DETAIL_SECTIONS.find((item) => item.title === title);
return (
return (
<PageShell title="交付单详情">
<PageShell title="交付单详情">
{query.isError ? (
{query.isError ? (
...
@@ -151,39 +145,147 @@ export default function DeliveryDetail({ params }: { params: PageParams }) {
...
@@ -151,39 +145,147 @@ export default function DeliveryDetail({ params }: { params: PageParams }) {
description={errorDetail(query.error)}
description={errorDetail(query.error)}
/>
/>
) : null}
) : null}
<div className="uc-delivery-detail">
<UCard className="uc-detail-card" loading={query.isPending}>
{DETAIL_SECTIONS.map((section) => (
<div className="uc-detail-dossier">
<UCard key={section.title} title={section.title}>
<div className="uc-detail-dossier__identity">
<CombiForm
<div className="uc-detail-dossier__name">
mode="detail"
{text(data.vehicleTitle)}
detailColumns={2}
{data.licensePlate ? (
labelWidth={128}
<span className="uc-detail-dossier__chip">{String(data.licensePlate)}</span>
fields={section.fields}
) : null}
initialValues={data}
</div>
/>
<div className="uc-detail-dossier__code">交付单编号:{text(data.deliveryOrderId)}</div>
</div>
<div className="uc-detail-dossier__meta">
<MetaItem label="交付单状态">{status(data.orderStatus)}</MetaItem>
<MetaItem label="交付方式">{delivery(data.deliveryType)}</MetaItem>
<MetaItem label="创建时间">{text(data.createdDate)}</MetaItem>
</div>
</div>
</UCard>
<div className="uc-detail-split">
<div className="uc-detail-split__main">
{['车辆信息', '交易信息', '交付与物流信息'].map((title) => {
const section = sectionOf(title);
return section ? (
<SectionCard
key={title}
title={title}
fields={section.fields}
data={data}
loading={query.isPending}
/>
) : null;
})}
<UCard className="uc-detail-card" loading={query.isPending}>
<CardHead title="交付图片" />
<div className="uc-detail-card__body">
<DeliveryImages value={data.confirmImages} />
</div>
</UCard>
</UCard>
))}
</div>
{logs.data?.length ? (
<div className="uc-detail-split__rail">
<UCard title="操作日志">
{['交付单信息', '拍卖信息', '交付联系信息'].map((title) => {
{logs.data.map((item) => (
const section = sectionOf(title);
<CombiForm
return section ? (
key={item.id}
<SectionCard
mode="detail"
key={title}
detailColumns={2}
title={title}
labelWidth={128}
fields={section.fields}
initialValues={{
data={data}
...item,
loading={query.isPending}
operationName: OPERATION_NAME_MAP[String(item.opType)] ?? '-',
columns={1}
}}
fields={LOG_FIELDS}
/>
/>
))}
) : null;
})}
<UCard className="uc-detail-card" loading={logs.isPending}>
<CardHead
title="操作日志"
aux={logRows.length ? `共 ${logRows.length} 条` : undefined}
/>
<div className="uc-detail-card__body">
{logs.isError ? (
<UAlert
type="error"
showIcon
title="操作日志加载失败"
description={errorDetail(logs.error)}
/>
) : logRows.length ? (
<div className="uc-detail-timeline">
{logRows.map((item) => (
<div className="uc-detail-timeline__item" key={item.id}>
<span className="uc-detail-timeline__marker" />
<div>
<div className="uc-detail-timeline__head">
<span className="uc-detail-timeline__title">
{OPERATION_NAME_MAP[String(item.opType)] ?? '-'}
</span>
<span className="uc-detail-timeline__time">{text(item.createdDate)}</span>
</div>
<div className="uc-detail-timeline__body">
<div>
<span className="uc-detail-timeline__label">操作人:</span>
{text(item.opUserName)}
</div>
</div>
</div>
</div>
))}
</div>
) : (
<UEmpty description="暂无操作日志" />
)}
</div>
</UCard>
</UCard>
) : null}
</div>
</div>
<div className="uc-delivery-detail-actions">
<UButton onClick={() => goTo('delivery')}>返回</UButton>
</div>
</div>
</PageShell>
</PageShell>
);
);
}
}
function SectionCard({
title,
fields,
data,
loading,
columns = 2,
}: {
title: string;
fields: FieldSchema<Record<string, unknown>>[];
data: Record<string, unknown>;
loading?: boolean;
columns?: 1 | 2;
}) {
return (
<UCard className="uc-detail-card" loading={loading}>
<CardHead title={title} />
<div className="uc-detail-card__body">
<div className="uc-detail-descriptions">
<CombiForm
mode="detail"
detailColumns={columns}
labelWidth={columns === 1 ? 140 : 128}
fields={fields}
initialValues={data}
/>
</div>
</div>
</UCard>
);
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
apps/web/subapps/usedcar/src/pages/Delivery/delivery.css
View file @
e7c74a0
.uc-delivery-detail
{
/* 交付单详情私有样式。卡片/档案条/时间线等通用部分在 src/styles/detail.css。 */
.uc-delivery-images
{
display
:
grid
;
display
:
grid
;
gap
:
16px
;
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
112px
,
1
fr
));
gap
:
12px
;
}
}
.uc-delivery-
detail
.ant-descriptions-view
>
tabl
e
{
.uc-delivery-
image.ant-imag
e
{
width
:
100%
;
width
:
100%
;
table-layout
:
fixed
;
overflow
:
hidden
;
border
:
1px
solid
var
(
--uj-border
);
border-radius
:
var
(
--uj-radius-md
);
transition
:
border-color
0.2s
;
}
}
.uc-delivery-detail
.ant-descriptions-item-label
{
.uc-delivery-image.ant-image
:hover
{
width
:
128px
;
border-color
:
var
(
--uj-border-strong
);
min-width
:
128px
;
white-space
:
nowrap
;
}
}
.uc-delivery-images
{
.uc-delivery-image.ant-image
.ant-image-img
{
display
:
flex
;
transition
:
transform
0.25s
var
(
--uj-ease-out
);
flex-wrap
:
wrap
;
gap
:
12px
;
align-items
:
center
;
}
}
.uc-delivery-detail-actions
{
.uc-delivery-image.ant-image
:hover
.ant-image-img
{
display
:
flex
;
transform
:
scale
(
1.04
);
justify-content
:
center
;
margin-top
:
16px
;
}
}
apps/web/subapps/usedcar/src/pages/Delivery/index.tsx
View file @
e7c74a0
...
@@ -110,11 +110,13 @@ export default function Delivery() {
...
@@ -110,11 +110,13 @@ export default function Delivery() {
.slice(0, 20)
.slice(0, 20)
: undefined,
: undefined,
}));
}));
// 常显字段固定 4 个(车牌/车架/车源/车型),与评估管理一致:筛选卡在常见宽度下 4 列,
// 一排正好放满;第 5 个常显字段会被挤到第二行。姓名/电话这类「下拉类型 + 关键词」组合
// 控件较宽,统一收进「更多筛选」,避免收起时换行、展开时与另一个同形控件看起来重复。
fields.splice(4, 0, {
fields.splice(4, 0, {
name: 'personKeyword',
name: 'personKeyword',
label: '',
label: '
姓名
',
type: 'input',
type: 'input',
essential: true,
placeholder: '请输入交付专员姓名',
placeholder: '请输入交付专员姓名',
selector: {
selector: {
name: 'personType',
name: 'personType',
...
@@ -128,7 +130,7 @@ export default function Delivery() {
...
@@ -128,7 +130,7 @@ export default function Delivery() {
});
});
fields.splice(5, 0, {
fields.splice(5, 0, {
name: 'phoneKeyword',
name: 'phoneKeyword',
label: '',
label: '
电话
',
type: 'input',
type: 'input',
placeholder: '请输入交付专员电话',
placeholder: '请输入交付专员电话',
selector: {
selector: {
...
...
apps/web/subapps/usedcar/src/pages/Handover/HandoverDetail
Modal
.tsx
→
apps/web/subapps/usedcar/src/pages/Handover/HandoverDetail
Drawer
.tsx
View file @
e7c74a0
import { useState } from 'react';
import { useState
, type ReactNode
} from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, U
Image, UModal
} from '@uj/ui';
import { UAlert, UButton, U
Card, UDrawer, UImage
} from '@uj/ui';
import {
CombiForm, DataTable, type DataTableColumn, type FieldSchema
} from '@/components';
import {
DataTable, type DataTableColumn
} from '@/components';
import { staffHandoverApi } from '@/api';
import { staffHandoverApi } from '@/api';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import './handover.css';
import './handover.css';
type Row = Record<string, unknown> & { id: string | number };
type Row = Record<string, unknown> & { id: string | number };
const text = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
const text = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
const detailFields = (items: Array<[string, string]>): FieldSchema<Record<string, unknown>>[] =>
export default function HandoverDetailDrawer({
items.map(([name, label]) => ({ name, label, type: 'input', render: text }));
export default function HandoverDetailModal({
record,
record,
onClose,
onClose,
}: {
}: {
...
@@ -26,6 +24,7 @@ export default function HandoverDetailModal({
...
@@ -26,6 +24,7 @@ export default function HandoverDetailModal({
enabled: Boolean(record),
enabled: Boolean(record),
});
});
const data = q.data ?? {};
const data = q.data ?? {};
const assets = (data.details as Record<string, unknown>[]) ?? [];
const columns = [
const columns = [
['评估单号', 'evalOrderNo'],
['评估单号', 'evalOrderNo'],
['门店', 'sellerMerchantName'],
['门店', 'sellerMerchantName'],
...
@@ -66,29 +65,47 @@ export default function HandoverDetailModal({
...
@@ -66,29 +65,47 @@ export default function HandoverDetailModal({
},
},
);
);
return (
return (
<UModal open={Boolean(record)} title="详情" width={1080} footer={null} onCancel={onClose}>
<UDrawer
<CombiForm
open={Boolean(record)}
mode="detail"
title="交接详情"
detailColumns={3}
size={1000}
labelWidth={128}
onClose={onClose}
fields={detailFields([
styles={{
['handoverBatchNo', '交接批次号'],
body: {
['handoverTime', '操作时间'],
padding: 16,
['createdBy', '操作人'],
background: 'var(--uj-bg)',
])}
display: 'flex',
initialValues={data}
flexDirection: 'column',
/>
gap: 'var(--uj-space-module)',
<h3>待交接资产列表</h3>
},
}}
>
{q.isError ? (
{q.isError ? (
<UAlert type="error" showIcon title="详情加载失败" description={errorDetail(q.error)} />
<UAlert type="error" showIcon title="详情加载失败" description={errorDetail(q.error)} />
) : (
) : null}
<DataTable<Record<string, unknown>>
<UCard className="uc-detail-card" loading={q.isPending}>
rowKey="evalOrderNo"
<div className="uc-detail-dossier">
columns={columns}
<div className="uc-detail-dossier__identity">
dataSource={(data.details as Record<string, unknown>[]) ?? []}
<div className="uc-detail-dossier__name">交接批次 {text(data.handoverBatchNo)}</div>
pagination={false}
</div>
/>
<div className="uc-detail-dossier__meta">
)}
<MetaItem label="操作时间">{text(data.handoverTime)}</MetaItem>
<MetaItem label="操作人">{text(data.createdBy)}</MetaItem>
</div>
</div>
</UCard>
<UCard className="uc-detail-card">
<CardHead title="待交接资产" aux={`共 ${assets.length} 项`} />
<div className="uc-detail-card__body">
<DataTable<Record<string, unknown>>
rowKey="evalOrderNo"
columns={columns}
dataSource={assets}
loading={q.isPending || q.isFetching}
pagination={false}
/>
</div>
</UCard>
{previewUrl ? (
{previewUrl ? (
<div className="uc-handover-image-viewer" onClick={() => setPreviewUrls([])}>
<div className="uc-handover-image-viewer" onClick={() => setPreviewUrls([])}>
<div
<div
...
@@ -125,6 +142,22 @@ export default function HandoverDetailModal({
...
@@ -125,6 +142,22 @@ export default function HandoverDetailModal({
</div>
</div>
</div>
</div>
) : null}
) : null}
</UModal>
</UDrawer>
);
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
);
}
}
apps/web/subapps/usedcar/src/pages/Handover/index.tsx
View file @
e7c74a0
...
@@ -13,7 +13,7 @@ import { staffHandoverApi } from '@/api';
...
@@ -13,7 +13,7 @@ import { staffHandoverApi } from '@/api';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import HandoverDetail
Modal from './HandoverDetailModal
';
import HandoverDetail
Drawer from './HandoverDetailDrawer
';
import CreateHandoverModal from './CreateHandoverModal';
import CreateHandoverModal from './CreateHandoverModal';
type Filters = Record<string, unknown> & { name?: string; dateValue?: [Dayjs, Dayjs] };
type Filters = Record<string, unknown> & { name?: string; dateValue?: [Dayjs, Dayjs] };
type Row = Record<string, unknown> & { id: string | number };
type Row = Record<string, unknown> & { id: string | number };
...
@@ -129,7 +129,7 @@ export default function Handover() {
...
@@ -129,7 +129,7 @@ export default function Handover() {
}}
}}
/>
/>
</UCard>
</UCard>
<HandoverDetail
Modal
record={detail} onClose={() => setDetail(undefined)} />
<HandoverDetail
Drawer
record={detail} onClose={() => setDetail(undefined)} />
<CreateHandoverModal
<CreateHandoverModal
open={create}
open={create}
onClose={() => setCreate(false)}
onClose={() => setCreate(false)}
...
...
apps/web/subapps/usedcar/src/pages/Leads/LeadDetail.tsx
View file @
e7c74a0
import type { ReactNode } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UDescriptions, UEmpty, UResult, UTable, UTag } from '@uj/ui';
import { UAlert, UButton, UCard, UDescriptions, UEmpty, UResult, UTable, UTag } from '@uj/ui';
import { PageShell } from '@/components';
import { PageShell } from '@/components';
...
@@ -8,26 +9,103 @@ import type { PageParams } from '@/routes';
...
@@ -8,26 +9,103 @@ import type { PageParams } from '@/routes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import './leads.css';
import './leads.css';
const levelDescription: Record<string, string> = { O: '客情回复,确认交车时间', H: '1日内跟进', A: '2日内跟进', B: '5天内跟进', C: '10天跟进', D: '20天跟进' };
const levelDescription: Record<string, string> = {
const followStyle: Record<number, string> = { 1: '电话', 2: '微信', 3: '到店', 4: '上门', 5: '短信', 6: '其他' };
O: '客情回复,确认交车时间',
const followResult: Record<number, string> = { 1: '邀约验车', 2: '客户考虑中', 3: '不卖旧车', 4: '还在考虑收购价', 5: '还没定新车', 6: '成功收车', 7: '其他' };
H: '1日内跟进',
A: '2日内跟进',
B: '5天内跟进',
C: '10天跟进',
D: '20天跟进',
};
const followStyle: Record<number, string> = {
1: '电话',
2: '微信',
3: '到店',
4: '上门',
5: '短信',
6: '其他',
};
const followResult: Record<number, string> = {
1: '邀约验车',
2: '客户考虑中',
3: '不卖旧车',
4: '还在考虑收购价',
5: '还没定新车',
6: '成功收车',
7: '其他',
};
const displacement: Record<number, string> = { 1: '收车置换', 2: '不收车置换', 3: '未确定' };
const displacement: Record<number, string> = { 1: '收车置换', 2: '不收车置换', 3: '未确定' };
const detection: Record<number, string> = { 1: '到店', 2: '远程', 3: '第三方', 4: '上门' };
const detection: Record<number, string> = { 1: '到店', 2: '远程', 3: '第三方', 4: '上门' };
const failReason: Record<number, string> = { 1: '客户自行处理', 2: '家人不同意', 3: '客户决定增购', 4: '旧车已处置', 5: '其他' };
const failReason: Record<number, string> = {
const operationType: Record<number, string> = { 1: '创建线索', 2: '新增跟进', 3: '状态变更', 4: '意向等级变更' };
1: '客户自行处理',
const statusText: Record<string, string> = { '1': '待跟进', '2': '跟进中', '3': '暂败', '4': '成功收车' };
2: '家人不同意',
3: '客户决定增购',
4: '旧车已处置',
5: '其他',
};
const operationType: Record<number, string> = {
1: '创建线索',
2: '新增跟进',
3: '状态变更',
4: '意向等级变更',
};
const statusText: Record<string, string> = {
'1': '待跟进',
'2': '跟进中',
'3': '暂败',
'4': '成功收车',
};
function display(value: unknown): string { return value === undefined || value === null || value === '' ? '-' : String(value); }
function display(value: unknown): string {
function model(detail: LeadDetail): string { return [detail.carBrand, detail.carChildsBrandName, detail.carSeriesName, detail.carTypeName].filter(Boolean).join('-') || '-'; }
return value === undefined || value === null || value === '' ? '-' : String(value);
}
function model(detail: LeadDetail): string {
return (
[detail.carBrand, detail.carChildsBrandName, detail.carSeriesName, detail.carTypeName]
.filter(Boolean)
.join('-') || '-'
);
}
function FollowItem({ item }: { item: FollowRecord }) {
function FollowItem({ item }: { item: FollowRecord }) {
const result = Number(item.followResult);
const result = Number(item.followResult);
const rows: Array<[string, unknown]> = [
const rows: Array<[string, unknown, boolean?]> = [
['跟进人', item.followUserName], ['跟进方式', followStyle[Number(item.followStyle)]], ['跟进结果', followResult[result]],
['跟进人', item.followUserName],
...(result === 1 ? [['置换类型', displacement[Number(item.displacementType)]], ['检测方式', detection[Number(item.detectionMode)]]] as Array<[string, unknown]> : []),
['跟进方式', followStyle[Number(item.followStyle)]],
...(result === 3 ? [['暂败原因', failReason[Number(item.failReason)]]] as Array<[string, unknown]> : []),
['跟进结果', followResult[result]],
['意向等级', item.customerIntentLevelChange], ['下一次跟进时间', item.nextFollowTime], ['跟进内容', item.followRemark],
...(result === 1
? ([
['置换类型', displacement[Number(item.displacementType)]],
['检测方式', detection[Number(item.detectionMode)]],
] as Array<[string, unknown]>)
: []),
...(result === 3
? ([['暂败原因', failReason[Number(item.failReason)]]] as Array<[string, unknown]>)
: []),
['意向等级', item.customerIntentLevelChange],
['下一次跟进时间', item.nextFollowTime],
['跟进内容', item.followRemark, true],
];
];
return <div className="uc-lead-follow__item"><div className="uc-lead-follow__head"><b>{Number(item.followRecordType) === 2 ? '24小时内跟进线索' : '跟进线索'}</b><span>{display(item.createdDate)}</span></div><div className="uc-lead-follow__body">{rows.map(([label, value]) => <span key={label}>{label}:<b>{display(value)}</b></span>)}</div></div>;
return (
<div className="uc-detail-timeline__item">
<span className="uc-detail-timeline__marker" />
<div>
<div className="uc-detail-timeline__head">
<span className="uc-detail-timeline__title">
{Number(item.followRecordType) === 2 ? '24小时内跟进线索' : '跟进线索'}
</span>
<span className="uc-detail-timeline__time">{display(item.createdDate)}</span>
</div>
<div className="uc-lead-follow__body">
{rows.map(([label, value, wide]) => (
<span key={label} className={wide ? 'uc-lead-follow__wide' : undefined}>
<span className="uc-detail-timeline__label">{label}:</span>
{display(value)}
</span>
))}
</div>
</div>
</div>
);
}
}
/** 线索详情为独立路由页面:/usedcar/leads/:id。 */
/** 线索详情为独立路由页面:/usedcar/leads/:id。 */
...
@@ -35,30 +113,220 @@ export default function LeadDetail({ params }: { params: PageParams }) {
...
@@ -35,30 +113,220 @@ export default function LeadDetail({ params }: { params: PageParams }) {
const { canPoint } = useAccess();
const { canPoint } = useAccess();
const allowed = canPoint(UC.LEAD_DETAIL);
const allowed = canPoint(UC.LEAD_DETAIL);
const id = params.id;
const id = params.id;
const detail = useQuery({ queryKey: ['usedcar', 'lead', id], queryFn: () => leadsApi.detail(id), enabled: allowed && Boolean(id) });
const detail = useQuery({
const follows = useQuery({ queryKey: ['usedcar', 'lead', id, 'follows'], queryFn: () => leadsApi.followRecords(id), enabled: allowed && Boolean(id) });
queryKey: ['usedcar', 'lead', id],
const logs = useQuery({ queryKey: ['usedcar', 'lead', id, 'logs'], queryFn: () => leadsApi.operationLogs(id), enabled: allowed && Boolean(id) });
queryFn: () => leadsApi.detail(id),
if (!allowed) return <UResult status="403" title="无查看线索详情的权限" subTitle="请联系管理员开通“查看详情”权限。" />;
enabled: allowed && Boolean(id),
});
const follows = useQuery({
queryKey: ['usedcar', 'lead', id, 'follows'],
queryFn: () => leadsApi.followRecords(id),
enabled: allowed && Boolean(id),
});
const logs = useQuery({
queryKey: ['usedcar', 'lead', id, 'logs'],
queryFn: () => leadsApi.operationLogs(id),
enabled: allowed && Boolean(id),
});
if (!allowed)
return (
<UResult
status="403"
title="无查看线索详情的权限"
subTitle="请联系管理员开通“查看详情”权限。"
/>
);
if (!id) return <UResult status="404" title="未找到线索" subTitle="详情地址缺少线索编号。" />;
if (!id) return <UResult status="404" title="未找到线索" subTitle="详情地址缺少线索编号。" />;
const data: LeadDetail = detail.data ?? { id };
const data: LeadDetail = detail.data ?? { id };
const status = String(data.cluesStatus ?? '');
const status = String(data.cluesStatus ?? '');
const followStatus = Number(data.followTimeStatus);
const followStatus = Number(data.followTimeStatus);
return <PageShell title="线索详情" description="查看线索基础信息、跟进记录和操作日志。">
const level = String(data.customerIntentLevel ?? '');
{detail.isError ? <UAlert type="error" showIcon title="线索详情加载失败" description={errorDetail(detail.error)} action={<UButton type="link" onClick={() => void detail.refetch()}>重试</UButton>} /> : null}
const gradeTone = ['o', 'h', 'a', 'b', 'c'].includes(level.toLowerCase())
<div className="uc-lead-detail">
? level.toLowerCase()
<div className="uc-lead-detail__top">
: 'none';
<UCard><h3 className="uc-lead-detail__title">基础信息 {status ? <UTag color={status === '2' ? 'green' : status === '3' ? 'red' : status === '4' ? 'purple' : 'blue'}>{statusText[status]}</UTag> : null} {followStatus ? <UTag color={followStatus === 1 ? 'orange' : 'red'}>{followStatus === 1 ? '临期' : '已超期'}</UTag> : null}</h3>
const followRows = follows.data ?? [];
<UDescriptions column={2} size="small">
return (
<UDescriptions.Item label="线索 ID">{display(data.cluesNo)}</UDescriptions.Item><UDescriptions.Item label="录入时间">{display(data.enterTime)}</UDescriptions.Item>
<PageShell title="线索详情" description="查看线索基础信息、跟进记录和操作日志。">
<UDescriptions.Item label="线索门店">{display(data.sellerMerchantName)}</UDescriptions.Item><UDescriptions.Item label="推荐销售顾问">{display(data.sellerName)}</UDescriptions.Item>
{detail.isError ? (
<UDescriptions.Item label="车主姓名">{display(data.carOwnerName)}</UDescriptions.Item><UDescriptions.Item label="车主电话">{display(data.carOwnerPhone)}</UDescriptions.Item>
<UAlert
<UDescriptions.Item label="评估品牌车型" span={2}>{model(data)}</UDescriptions.Item><UDescriptions.Item label="最近跟进时间">{display(data.latestFollowTime)}</UDescriptions.Item><UDescriptions.Item label="下一次跟进时间">{display(data.nextFollowTime)}</UDescriptions.Item>
type="error"
</UDescriptions>
showIcon
</UCard>
title="线索详情加载失败"
<div><UCard><h3 className="uc-lead-detail__title">客户意向等级</h3><p><strong>{display(data.customerIntentLevel)}级</strong>{' '}{levelDescription[String(data.customerIntentLevel)] ?? '-'}</p><p>下一次跟进时间:{display(data.nextFollowTime)}</p></UCard><UCard style={{ marginTop: 16 }}><h3 className="uc-lead-detail__title">备注说明</h3><p>{display(data.remark === undefined ? '暂无备注' : data.remark)}</p></UCard></div>
description={errorDetail(detail.error)}
action={
<UButton type="link" onClick={() => void detail.refetch()}>
重试
</UButton>
}
/>
) : null}
<UCard className="uc-detail-card" loading={detail.isPending}>
<div className="uc-detail-dossier">
<div className="uc-detail-dossier__identity">
<div className="uc-detail-dossier__name">
{model(data)}
{level ? <span className="uc-detail-dossier__chip">{level}级</span> : null}
</div>
<div className="uc-detail-dossier__code">线索 ID:{display(data.cluesNo)}</div>
</div>
<div className="uc-detail-dossier__meta">
{status ? (
<MetaItem label="线索状态">
<UTag
color={
status === '2'
? 'green'
: status === '3'
? 'red'
: status === '4'
? 'purple'
: 'blue'
}
>
{statusText[status]}
</UTag>
</MetaItem>
) : null}
{followStatus ? (
<MetaItem label="跟进时效">
<UTag color={followStatus === 1 ? 'orange' : 'red'}>
{followStatus === 1 ? '临期' : '已超期'}
</UTag>
</MetaItem>
) : null}
<MetaItem label="线索门店">{display(data.sellerMerchantName)}</MetaItem>
<MetaItem label="录入时间">{display(data.enterTime)}</MetaItem>
</div>
</div>
</UCard>
<div className="uc-detail-split">
<div className="uc-detail-split__main">
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="基础信息" />
<div className="uc-detail-card__body">
<UDescriptions
className="uc-detail-descriptions"
column={{ xs: 1, sm: 2 }}
styles={{ label: { width: 112, whiteSpace: 'nowrap' } }}
items={[
{
key: 'merchant',
label: '线索门店',
children: display(data.sellerMerchantName),
},
{ key: 'seller', label: '推荐销售顾问', children: display(data.sellerName) },
{ key: 'owner', label: '车主姓名', children: display(data.carOwnerName) },
{ key: 'phone', label: '车主电话', children: display(data.carOwnerPhone) },
{ key: 'model', label: '评估品牌车型', span: 2, children: model(data) },
{
key: 'latest',
label: '最近跟进时间',
children: display(data.latestFollowTime),
},
{ key: 'next', label: '下一次跟进时间', children: display(data.nextFollowTime) },
]}
/>
</div>
</UCard>
<UCard className="uc-detail-card" loading={follows.isPending}>
<CardHead
title="跟进记录"
aux={followRows.length ? `共 ${followRows.length} 条 · 时间倒序` : undefined}
/>
<div className="uc-detail-card__body">
{follows.isError ? (
<UAlert
type="error"
showIcon
title="跟进记录加载失败"
description={errorDetail(follows.error)}
/>
) : followRows.length ? (
<div className="uc-detail-timeline">
{followRows.map((item, index) => (
<FollowItem item={item} key={`${item.createdDate ?? ''}-${index}`} />
))}
</div>
) : (
<UEmpty description="暂无跟进记录" />
)}
</div>
</UCard>
<UCard className="uc-detail-card" loading={logs.isPending}>
<CardHead title="操作日志" />
<div className="uc-detail-card__body">
{logs.isError ? (
<UAlert
type="error"
showIcon
title="操作日志加载失败"
description={errorDetail(logs.error)}
/>
) : (
<UTable<OperationLog>
rowKey={(_, index) => String(index)}
pagination={false}
dataSource={logs.data ?? []}
columns={[
{ title: '操作时间', dataIndex: 'opTime', render: display },
{ title: '操作人', dataIndex: 'opUserName', render: display },
{
title: '操作类型',
dataIndex: 'opType',
render: (value) => operationType[Number(value)] ?? '-',
},
{ title: '操作内容', dataIndex: 'opContent', render: display },
]}
/>
)}
</div>
</UCard>
</div>
<div className="uc-detail-split__rail">
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="客户意向等级" />
<div className="uc-detail-card__body">
<div className="uc-lead-grade">
<span className={`uc-lead-grade__badge uc-lead-grade__badge--${gradeTone}`}>
{level || '-'}
</span>
<div className="uc-lead-grade__text">
<div className="uc-lead-grade__desc">{levelDescription[level] ?? '-'}</div>
<div className="uc-lead-grade__next">
下一次跟进时间:{display(data.nextFollowTime)}
</div>
</div>
</div>
</div>
</UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="备注说明" />
<div className="uc-detail-card__body">
<p className="uc-lead-remark">
{data.remark === undefined || data.remark === null || data.remark === ''
? '暂无备注'
: String(data.remark)}
</p>
</div>
</UCard>
</div>
</div>
</div>
<UCard><h3 className="uc-lead-detail__title">跟进记录(共 {follows.data?.length ?? 0} 条,时间倒序)</h3>{follows.isError ? <UAlert type="error" showIcon title="跟进记录加载失败" description={errorDetail(follows.error)} /> : follows.data?.length ? <div className="uc-lead-follow">{follows.data.map((item, index) => <FollowItem item={item} key={`${item.createdDate ?? ''}-${index}`} />)}</div> : <UEmpty description="暂无跟进记录" />}</UCard>
</PageShell>
<UCard><h3 className="uc-lead-detail__title">操作日志</h3>{logs.isError ? <UAlert type="error" showIcon title="操作日志加载失败" description={errorDetail(logs.error)} /> : <UTable<OperationLog> rowKey={(_, index) => String(index)} pagination={false} dataSource={logs.data ?? []} columns={[{ title: '操作时间', dataIndex: 'opTime', render: display }, { title: '操作人', dataIndex: 'opUserName', render: display }, { title: '操作类型', dataIndex: 'opType', render: (value) => operationType[Number(value)] ?? '-' }, { title: '操作内容', dataIndex: 'opContent', render: display }]} />}</UCard>
);
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
</div>
</PageShell>
;
)
;
}
}
apps/web/subapps/usedcar/src/pages/Leads/leads.css
View file @
e7c74a0
.uc-lead-reminder
{
margin
:
0
0
12px
;
color
:
var
(
--uj-warning
);
}
.uc-lead-reminder
{
.uc-lead-reminder
strong
{
color
:
var
(
--uj-error
);
font-weight
:
500
;
}
margin
:
0
0
12px
;
.uc-lead-level
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
7px
;
}
color
:
var
(
--uj-warning
);
.uc-lead-level
b
{
display
:
inline-grid
;
place-items
:
center
;
width
:
22px
;
height
:
22px
;
border-radius
:
50%
;
color
:
var
(
--uj-on-primary
);
background
:
var
(
--uj-lead-none
);
}
}
.uc-lead-level--o
b
{
background
:
var
(
--uj-lead-o
);
}
.uc-lead-level--h
b
{
background
:
var
(
--uj-lead-h
);
}
.uc-lead-level--a
b
{
background
:
var
(
--uj-lead-a
);
}
.uc-lead-level--b
b
{
background
:
var
(
--uj-lead-b
);
}
.uc-lead-level--c
b
{
background
:
var
(
--uj-lead-c
);
}
.uc-lead-reminder
strong
{
.uc-lead-detail
{
display
:
grid
;
gap
:
16px
;
}
.uc-lead-detail__top
{
display
:
grid
;
grid-template-columns
:
minmax
(
0
,
1
fr
)
300px
;
gap
:
16px
;
}
.uc-lead-detail__title
{
margin
:
0
0
14px
;
font-size
:
15px
;
}
.uc-lead-detail__empty
{
padding
:
28px
;
text-align
:
center
;
color
:
var
(
--uj-text-3
);
}
.uc-lead-follow
{
display
:
grid
;
gap
:
12px
;
}
.uc-lead-follow__item
{
border-left
:
2px
solid
var
(
--uj-primary
);
padding-left
:
14px
;
}
.uc-lead-follow__head
{
display
:
flex
;
justify-content
:
space-between
;
margin-bottom
:
8px
;
}
.uc-lead-follow__body
{
background
:
var
(
--uj-surface-3
);
padding
:
12px
;
border-radius
:
6px
;
display
:
grid
;
gap
:
6px
;
}
.uc-lead-follow__body
span
{
color
:
var
(
--uj-text-2
);
}
.uc-lead-follow__body
b
{
color
:
var
(
--uj-text-1
);
font-weight
:
400
;
}
color
:
var
(
--uj-error
);
@media
(
max-width
:
900px
)
{
.uc-lead-detail__top
{
grid-template-columns
:
1
fr
;
}
}
font-weight
:
500
;
}
.uc-lead-level
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
7px
;
}
.uc-lead-level
b
{
display
:
inline-grid
;
place-items
:
center
;
width
:
22px
;
height
:
22px
;
border-radius
:
50%
;
color
:
var
(
--uj-on-primary
);
background
:
var
(
--uj-lead-none
);
}
.uc-lead-level--o
b
{
background
:
var
(
--uj-lead-o
);
}
.uc-lead-level--h
b
{
background
:
var
(
--uj-lead-h
);
}
.uc-lead-level--a
b
{
background
:
var
(
--uj-lead-a
);
}
.uc-lead-level--b
b
{
background
:
var
(
--uj-lead-b
);
}
.uc-lead-level--c
b
{
background
:
var
(
--uj-lead-c
);
}
/* 线索详情私有样式。卡片/档案条/时间线等通用部分在 src/styles/detail.css。 */
.uc-lead-follow__body
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
4px
16px
;
margin-top
:
6px
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.6
;
overflow-wrap
:
anywhere
;
}
.uc-lead-follow__wide
{
grid-column
:
span
2
;
}
.uc-lead-grade
{
display
:
flex
;
align-items
:
center
;
gap
:
14px
;
}
.uc-lead-grade__badge
{
flex
:
none
;
display
:
inline-grid
;
place-items
:
center
;
width
:
44px
;
height
:
44px
;
border-radius
:
50%
;
color
:
var
(
--uj-on-primary
);
font-size
:
var
(
--uj-font-lg
);
font-weight
:
600
;
background
:
var
(
--uj-lead-none
);
}
.uc-lead-grade__badge--o
{
background
:
var
(
--uj-lead-o
);
}
.uc-lead-grade__badge--h
{
background
:
var
(
--uj-lead-h
);
}
.uc-lead-grade__badge--a
{
background
:
var
(
--uj-lead-a
);
}
.uc-lead-grade__badge--b
{
background
:
var
(
--uj-lead-b
);
}
.uc-lead-grade__badge--c
{
background
:
var
(
--uj-lead-c
);
}
.uc-lead-grade__desc
{
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
font-weight
:
600
;
line-height
:
1.5
;
}
.uc-lead-grade__next
{
margin-top
:
4px
;
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-variant-numeric
:
var
(
--uj-num
);
}
.uc-lead-remark
{
margin
:
0
;
color
:
var
(
--uj-text-2
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.7
;
white-space
:
pre-wrap
;
overflow-wrap
:
anywhere
;
}
@media
(
max-width
:
700px
)
{
.uc-lead-follow__body
{
grid-template-columns
:
1
fr
;
}
.uc-lead-follow__wide
{
grid-column
:
auto
;
}
}
apps/web/subapps/usedcar/src/pages/Ledger/FinancialLedger.tsx
View file @
e7c74a0
...
@@ -101,9 +101,10 @@ export default function FinancialLedger() {
...
@@ -101,9 +101,10 @@ export default function FinancialLedger() {
{q.isError ? (
{q.isError ? (
<UAlert type="error" showIcon title="财务台账加载失败" description={errorDetail(q.error)} />
<UAlert type="error" showIcon title="财务台账加载失败" description={errorDetail(q.error)} />
) : null}
) : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Row>
<DataTable<Row>
rowKey="id"
rowKey="id"
fillHeight
columns={columns}
columns={columns}
dataSource={q.data?.records ?? []}
dataSource={q.data?.records ?? []}
loading={q.isPending || q.isFetching}
loading={q.isPending || q.isFetching}
...
...
apps/web/subapps/usedcar/src/pages/Ledger/VehicleLedger.tsx
View file @
e7c74a0
...
@@ -211,9 +211,10 @@ export default function VehicleLedger() {
...
@@ -211,9 +211,10 @@ export default function VehicleLedger() {
{q.isError ? (
{q.isError ? (
<UAlert type="error" showIcon title="车辆台账加载失败" description={errorDetail(q.error)} />
<UAlert type="error" showIcon title="车辆台账加载失败" description={errorDetail(q.error)} />
) : null}
) : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Row>
<DataTable<Row>
rowKey="id"
rowKey="id"
fillHeight
columns={columns}
columns={columns}
dataSource={q.data?.records ?? []}
dataSource={q.data?.records ?? []}
loading={q.isPending || q.isFetching}
loading={q.isPending || q.isFetching}
...
...
apps/web/subapps/usedcar/src/pages/Ledger/index.tsx
View file @
e7c74a0
...
@@ -13,15 +13,16 @@ export default function Ledger() {
...
@@ -13,15 +13,16 @@ export default function Ledger() {
<UResult status="403" title="无访问车辆台账的权限" subTitle="请联系管理员开通访问权限。" />
<UResult status="403" title="无访问车辆台账的权限" subTitle="请联系管理员开通访问权限。" />
);
);
return (
return (
<PageShell title="车辆台账">
<PageShell
fill
title="车辆台账">
<UTabs
<UTabs
activeKey={tab}
activeKey={tab}
onChange={setTab}
onChange={setTab}
items={[
items={[
{ key: 'vehicle', label: '车辆台账'
, children: <VehicleLedger />
},
{ key: 'vehicle', label: '车辆台账' },
{ key: 'financial', label: '财务台账'
, children: <FinancialLedger />
},
{ key: 'financial', label: '财务台账' },
]}
]}
/>
/>
{tab === 'vehicle' ? <VehicleLedger /> : <FinancialLedger />}
</PageShell>
</PageShell>
);
);
}
}
apps/web/subapps/usedcar/src/pages/Operation/ContractDetail.tsx
View file @
e7c74a0
import { useState } from 'react';
import { useState
, type ReactNode
} from 'react';
import { useMutation, useQuery } from '@tanstack/react-query';
import { useMutation, useQuery } from '@tanstack/react-query';
import {
import {
UAlert,
UAlert,
...
@@ -56,8 +56,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -56,8 +56,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
});
});
const save = useMutation({
const save = useMutation({
mutationFn: (next: string) =>
mutationFn: (next: string) => contractApi.getContractEdit({ id, description: next }),
contractApi.getContractEdit({ id, description: next }),
onSuccess: () => {
onSuccess: () => {
msg.success('操作成功');
msg.success('操作成功');
goTo('operation');
goTo('operation');
...
@@ -73,10 +72,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -73,10 +72,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
subTitle="请联系管理员开通“合同详情”权限。"
subTitle="请联系管理员开通“合同详情”权限。"
/>
/>
);
);
if (!id)
if (!id) return <UResult status="404" title="未找到合同" subTitle="详情地址缺少合同记录 id。" />;
return (
<UResult status="404" title="未找到合同" subTitle="详情地址缺少合同记录 id。" />
);
const data: Detail = detail.data ?? { id };
const data: Detail = detail.data ?? { id };
const signers = parseSigners(data.electronicContractField);
const signers = parseSigners(data.electronicContractField);
...
@@ -125,11 +121,6 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -125,11 +121,6 @@ export default function ContractDetail({ params }: { params: PageParams }) {
<PageShell
<PageShell
title="合同详情"
title="合同详情"
description="查看合同状态、合同信息、合同内容、签署人信息与操作记录。"
description="查看合同状态、合同信息、合同内容、签署人信息与操作记录。"
actions={
<UButton type="default" size="small" onClick={() => goTo('operation')}>
返回列表
</UButton>
}
>
>
{detail.isError ? (
{detail.isError ? (
<UAlert
<UAlert
...
@@ -145,55 +136,86 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -145,55 +136,86 @@ export default function ContractDetail({ params }: { params: PageParams }) {
/>
/>
) : null}
) : null}
<div className="uc-contract-detail">
<UCard className="uc-detail-card" loading={detail.isPending}>
<UCard>
<div className="uc-detail-dossier">
<h3 className="uc-contract-detail__title">
<div className="uc-detail-dossier__identity">
合同状态
<div className="uc-detail-dossier__name">
<UTag color={dictTone(DICT.status, data.electronicContractStatus)}>
{contractModel(data)}
{dictValue(DICT.status, data.electronicContractStatus)}
<span className="uc-detail-dossier__chip">
</UTag>
{dictValue(DICT.contractType, data.electronicContractType)}
</h3>
</span>
<UDescriptions column={2} size="small">
</div>
<UDescriptions.Item label="合同流转状态">
<div className="uc-detail-dossier__code">评估单编号:{display(data.evalOrderNo)}</div>
{dictValue(DICT.status, data.electronicContractStatus)}
</div>
</UDescriptions.Item>
<div className="uc-detail-dossier__meta">
<UDescriptions.Item label="评估单编号">{display(data.evalOrderNo)}</UDescriptions.Item>
<MetaItem label="合同状态">
<UDescriptions.Item label="合同来源">{dictValue(DICT.source, data.source)}</UDescriptions.Item>
<UTag color={dictTone(DICT.status, data.electronicContractStatus)}>
<UDescriptions.Item label="付款方式">
{dictValue(DICT.status, data.electronicContractStatus)}
</UTag>
</MetaItem>
<MetaItem label="合同来源">{dictValue(DICT.source, data.source)}</MetaItem>
<MetaItem label="付款方式">
{dictValue(DICT.paymentMethod, data.paymentMethod)}
{dictValue(DICT.paymentMethod, data.paymentMethod)}
</UDescriptions.Item>
</MetaItem>
</UDescriptions>
<MetaItem label="合同金额">
<h4 className="uc-contract-detail__subtitle">付款信息</h4>
{oaAudits.length ? (
<UTable<ContractOaAudit>
rowKey={(_, index) => String(index)}
size="small"
pagination={false}
dataSource={oaAudits}
columns={payColumns}
scroll={{ x: 900 }}
/>
) : (
<UEmpty description="暂无付款信息" />
)}
</UCard>
<UCard>
<h3 className="uc-contract-detail__title">合同信息</h3>
<UDescriptions column={2} size="small">
<UDescriptions.Item label="合同类型">
{dictValue(DICT.contractType, data.electronicContractType)}
</UDescriptions.Item>
<UDescriptions.Item label="合同车型">{contractModel(data)}</UDescriptions.Item>
<UDescriptions.Item label="合同模板">{display(data.docTemplateName)}</UDescriptions.Item>
<UDescriptions.Item label="合同金额">
{data.contractPrice === undefined || data.contractPrice === ''
{data.contractPrice === undefined || data.contractPrice === ''
? '-'
? '-'
: `¥${String(data.contractPrice)}`}
: `¥${String(data.contractPrice)}`}
</UDescriptions.Item>
</MetaItem>
<UDescriptions.Item label="合同描述" span={2}>
</div>
</div>
</UCard>
<div className="uc-detail-stack">
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead
title="付款信息"
aux={oaAudits.length ? `共 ${oaAudits.length} 笔` : undefined}
/>
<div className="uc-detail-card__body">
{oaAudits.length ? (
<UTable<ContractOaAudit>
rowKey={(_, index) => String(index)}
size="small"
pagination={false}
dataSource={oaAudits}
columns={payColumns}
scroll={{ x: 900 }}
/>
) : (
<UEmpty description="暂无付款信息" />
)}
</div>
</UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="合同信息" />
<div className="uc-detail-card__body">
<UDescriptions
className="uc-detail-descriptions"
column={{ xs: 1, sm: 2 }}
styles={{ label: { width: 112, whiteSpace: 'nowrap' } }}
items={[
{
key: 'type',
label: '合同类型',
children: dictValue(DICT.contractType, data.electronicContractType),
},
{ key: 'model', label: '合同车型', children: contractModel(data) },
{ key: 'template', label: '合同模板', children: display(data.docTemplateName) },
{
key: 'price',
label: '合同金额',
children:
data.contractPrice === undefined || data.contractPrice === ''
? '-'
: `¥${String(data.contractPrice)}`,
},
]}
/>
<div className="uc-contract-desc">
<span className="uc-contract-desc__label">合同描述</span>
<UInput.TextArea
<UInput.TextArea
className="uc-contract-detail__desc"
value={currentDescription === '-' ? '' : currentDescription}
value={currentDescription === '-' ? '' : currentDescription}
onChange={(event) => setDescription(event.target.value)}
onChange={(event) => setDescription(event.target.value)}
maxLength={200}
maxLength={200}
...
@@ -201,12 +223,11 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -201,12 +223,11 @@ export default function ContractDetail({ params }: { params: PageParams }) {
rows={3}
rows={3}
placeholder="请输入合同描述"
placeholder="请输入合同描述"
/>
/>
</
UDescriptions.Item
>
</
div
>
</
UDescriptions
>
</
div
>
<div className="uc-
contract-detail__actions
">
<div className="uc-
detail-card__foot
">
<UButton
<UButton
type="primary"
type="primary"
size="small"
loading={save.isPending}
loading={save.isPending}
disabled={!currentDescription || currentDescription === '-'}
disabled={!currentDescription || currentDescription === '-'}
onClick={() => void save.mutate(currentDescription === '-' ? '' : currentDescription)}
onClick={() => void save.mutate(currentDescription === '-' ? '' : currentDescription)}
...
@@ -216,116 +237,158 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -216,116 +237,158 @@ export default function ContractDetail({ params }: { params: PageParams }) {
</div>
</div>
</UCard>
</UCard>
<UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<h3 className="uc-contract-detail__title">合同内容</h3>
<CardHead title="合同内容" />
{fieldItems.length ? (
<div className="uc-detail-card__body">
<div className="uc-contract-detail__fields">
{fieldItems.length ? (
{fieldItems.map((item, index) => {
<div className="uc-contract-fields">
const urls = splitUrls(item.value);
{fieldItems.map((item, index) => {
const type = urls.length ? fileType(urls[0]) : 'unknown';
const urls = splitUrls(item.value);
return (
const type = urls.length ? fileType(urls[0]) : 'unknown';
<div className="uc-contract-detail__field" key={`${String(item.label)}-${index}`}>
<span className="uc-contract-detail__field-label">{display(item.label)}:</span>
<span className="uc-contract-detail__field-value">
{urls.length ? (
urls.map((url, urlIndex) =>
type === 'image' ? (
<img
className="uc-contract-detail__thumb"
key={`${url}-${urlIndex}`}
src={ossThumb(url)}
alt={String(item.label ?? '合同资料')}
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 运营管理 / 合同内容',
label: `${String(item.label ?? '合同资料')} · 图片 ${urlIndex + 1}`,
url,
silent: true,
dedupeKey: `usedcar-contract-field-${url}`,
})
}
/>
) : type === 'video' ? (
<UButton
type="link"
size="small"
key={`${url}-${urlIndex}`}
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 运营管理 / 合同内容',
label: `${String(item.label ?? '合同资料')} · 视频 ${urlIndex + 1}`,
url,
silent: true,
dedupeKey: `usedcar-contract-field-${url}`,
})
}
>
视频 {urlIndex + 1}
</UButton>
) : (
<span key={`${url}-${urlIndex}`}>{url}</span>
),
)
) : (
display(item.value)
)}
</span>
</div>
);
})}
</div>
) : (
<UEmpty description="暂无合同内容" />
)}
</UCard>
<UCard>
<h3 className="uc-contract-detail__title">签署人信息</h3>
{([1, 2] as const).map((side) => (
<div className="uc-contract-detail__signer" key={side}>
<h4 className="uc-contract-detail__subtitle">
{side === 1 ? '甲方' : '乙方'}
</h4>
<UDescriptions column={2} size="small">
{SIGNER_FIELDS.map((field) => {
let value: string;
if (field.kind === 'side') value = side === 1 ? '甲方' : '乙方';
else if (field.kind === 'type') value = signerTypeName(data, side);
else if (field.kind === 'idType') value = '身份证/营业执照';
else {
const key = side === 1 ? field.keyA : field.keyB;
value = display(key ? signers[key] : undefined);
}
return (
return (
<UDescriptions.Item label={field.title} key={field.title}>
<div className="uc-contract-field" key={`${String(item.label)}-${index}`}>
{value}
<span className="uc-contract-field__label">{display(item.label)}</span>
</UDescriptions.Item>
<span className="uc-contract-field__value">
{urls.length
? urls.map((url, urlIndex) =>
type === 'image' ? (
<img
className="uc-contract-field__thumb"
key={`${url}-${urlIndex}`}
src={ossThumb(url)}
alt={String(item.label ?? '合同资料')}
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 运营管理 / 合同内容',
label: `${String(item.label ?? '合同资料')} · 图片 ${urlIndex + 1}`,
url,
// 点缩略图是要看原图,不是要把文件存到磁盘。
preview: true,
silent: true,
dedupeKey: `usedcar-contract-field-${url}`,
})
}
/>
) : type === 'video' ? (
<UButton
type="link"
size="small"
key={`${url}-${urlIndex}`}
onClick={() =>
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 运营管理 / 合同内容',
label: `${String(item.label ?? '合同资料')} · 视频 ${urlIndex + 1}`,
url,
preview: true,
silent: true,
dedupeKey: `usedcar-contract-field-${url}`,
})
}
>
视频 {urlIndex + 1}
</UButton>
) : (
<span key={`${url}-${urlIndex}`}>{url}</span>
),
)
: display(item.value)}
</span>
</div>
);
);
})}
})}
</UDescriptions>
</div>
</div>
) : (
))}
<UEmpty description="暂无合同内容" />
)}
</div>
</UCard>
</UCard>
<UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<h3 className="uc-contract-detail__title">操作记录</h3>
<CardHead title="签署人信息" />
{logs.length ? (
<div className="uc-detail-card__body">
<div className="uc-contract-detail__logs">
<div className="uc-contract-signers">
{logs.map((item, index) => (
{([1, 2] as const).map((side) => (
<div className="uc-contract-detail__log" key={`${String(item.createdDate)}-${index}`}>
<div className="uc-contract-signer" key={side}>
<b>{logTypeName(item.opType)}</b>
<div className="uc-contract-signer__head">
<span>操作人:{display(item.createdBy)}</span>
{side === 1 ? '甲方' : '乙方'}
<span>操作时间:{display(item.createdDate)}</span>
<span className="uc-contract-signer__type">{signerTypeName(data, side)}</span>
</div>
<UDescriptions
className="uc-detail-descriptions"
column={1}
styles={{ label: { width: 110, whiteSpace: 'nowrap' } }}
items={SIGNER_FIELDS.map((field) => {
let value: string;
if (field.kind === 'side') value = side === 1 ? '甲方' : '乙方';
else if (field.kind === 'type') value = signerTypeName(data, side);
else if (field.kind === 'idType') value = '身份证/营业执照';
else {
const key = side === 1 ? field.keyA : field.keyB;
value = display(key ? signers[key] : undefined);
}
return { key: field.title, label: field.title, children: value };
})}
/>
</div>
</div>
))}
))}
</div>
</div>
) : (
</div>
<UEmpty description="暂无操作记录" />
</UCard>
)}
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="操作记录" aux={logs.length ? `共 ${logs.length} 条` : undefined} />
<div className="uc-detail-card__body">
{logs.length ? (
<div className="uc-detail-timeline">
{logs.map((item, index) => (
<div
className="uc-detail-timeline__item"
key={`${String(item.createdDate)}-${index}`}
>
<span className="uc-detail-timeline__marker" />
<div>
<div className="uc-detail-timeline__head">
<span className="uc-detail-timeline__title">
{logTypeName(item.opType)}
</span>
<span className="uc-detail-timeline__time">
{display(item.createdDate)}
</span>
</div>
<div className="uc-detail-timeline__body">
<div>
<span className="uc-detail-timeline__label">操作人:</span>
{display(item.createdBy)}
</div>
</div>
</div>
</div>
))}
</div>
) : (
<UEmpty description="暂无操作记录" />
)}
</div>
</UCard>
</UCard>
</div>
</div>
</PageShell>
</PageShell>
);
);
}
}
function CardHead({ title, aux }: { title: string; aux?: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
{aux ? <span className="uc-detail-card__aux">{aux}</span> : null}
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
apps/web/subapps/usedcar/src/pages/Operation/ContractEdit.tsx
View file @
e7c74a0
...
@@ -20,6 +20,7 @@ import { UC } from '@/permissions/codes';
...
@@ -20,6 +20,7 @@ import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import type { PageParams } from '@/routes';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
import { goTo } from '../Leads/navigate';
import { goTo } from '../Leads/navigate';
import './contractDetail.css';
/**
/**
* 合同编辑独立页(源 contract/edit.vue):
* 合同编辑独立页(源 contract/edit.vue):
...
...
apps/web/subapps/usedcar/src/pages/Operation/components/ContractTab.tsx
View file @
e7c74a0
...
@@ -114,9 +114,10 @@ export default function ContractTab() {
...
@@ -114,9 +114,10 @@ export default function ContractTab() {
/>
/>
</UCard>
</UCard>
{q.isError ? <UAlert type="error" showIcon title="合同列表加载失败" /> : null}
{q.isError ? <UAlert type="error" showIcon title="合同列表加载失败" /> : null}
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Contract>
<DataTable<Contract>
rowKey="id"
rowKey="id"
fillHeight
columns={CONTRACT_COLUMNS}
columns={CONTRACT_COLUMNS}
dataSource={q.data?.records ?? []}
dataSource={q.data?.records ?? []}
loading={q.isLoading}
loading={q.isLoading}
...
...
apps/web/subapps/usedcar/src/pages/Operation/components/SunshineDetailDrawer.tsx
0 → 100644
View file @
e7c74a0
import type { ReactNode } from 'react';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UCard, UDrawer, UEmpty, UTable } from '@uj/ui';
import { operationApi, type Sunshine } from '@/api';
/** 空值统一占位(与 usedcar 其它页面 text() 一致)。 */
const text = (value: unknown): string =>
value === undefined || value === null || value === '' ? '-' : String(value);
/** 源 constants.js vehicleCategoryOpt:carType 存 confId,展示 confValue。 */
const CAR_TYPE_LABEL: Record<string, string> = { '1': '置换车', '2': '报废车' };
type LogRow = {
operator?: string;
operateTime?: string;
operateContent?: string;
[key: string]: unknown;
};
const LOG_COLUMNS = [
{ title: '操作人', dataIndex: 'operator', render: text },
{ title: '操作时间', dataIndex: 'operateTime', render: text },
{ title: '操作内容', dataIndex: 'operateContent', render: text },
];
/**
* 阳光激励详情抽屉:与源 sunshine/components/detail.vue 一致,
* 打开时并行拉详情(details)与操作日志(log/page),不再拿列表行数据充当详情。
*/
export default function SunshineDetailDrawer({
record,
onClose,
}: {
record: Sunshine | null;
onClose: () => void;
}) {
const id = record?.id ?? '';
const detail = useQuery({
queryKey: ['op', 'sun', 'detail', id],
queryFn: () => operationApi.sunshineDetail(id),
enabled: Boolean(id),
});
const logs = useQuery({
queryKey: ['op', 'sun', 'log', id],
queryFn: () => operationApi.sunshineLog(id),
enabled: Boolean(id),
});
const data: Partial<Sunshine> = detail.data ?? record ?? {};
const logRows: LogRow[] = Array.isArray(logs.data) ? (logs.data as LogRow[]) : [];
return (
<UDrawer
open={Boolean(record)}
title="阳光激励详情"
size={640}
onClose={onClose}
styles={{
body: {
padding: 16,
background: 'var(--uj-bg)',
display: 'flex',
flexDirection: 'column',
gap: 'var(--uj-space-module)',
},
}}
>
{detail.isError ? <UAlert type="error" showIcon title="详情加载失败" /> : null}
<UCard className="uc-detail-card" loading={detail.isPending}>
<div className="uc-detail-dossier">
<div className="uc-detail-dossier__identity">
<div className="uc-detail-dossier__name">
{text(data.sellerMerchantName)}
<span className="uc-detail-dossier__chip">
{CAR_TYPE_LABEL[String(data.carType)] ?? text(data.carType)}
</span>
</div>
</div>
<div className="uc-detail-dossier__meta">
<MetaItem label="激励价格">
{data.sunlightInspiresPrice === undefined
? '-'
: `${String(data.sunlightInspiresPrice)}元`}
</MetaItem>
<MetaItem label="录入时间">{text(data.createdDate)}</MetaItem>
</div>
</div>
</UCard>
<UCard className="uc-detail-card">
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">操作日志</h2>
{logRows.length ? (
<span className="uc-detail-card__aux">共 {logRows.length} 条</span>
) : null}
</div>
<div className="uc-detail-card__body">
{logRows.length ? (
<UTable<LogRow>
rowKey={(_, index) => String(index)}
size="small"
pagination={false}
dataSource={logRows}
columns={LOG_COLUMNS}
loading={logs.isPending || logs.isFetching}
/>
) : (
<UEmpty description="暂无操作日志" />
)}
</div>
</UCard>
</UDrawer>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
apps/web/subapps/usedcar/src/pages/Operation/components/SunshineTab.tsx
View file @
e7c74a0
...
@@ -13,7 +13,7 @@ import { dashboardApi, operationApi, type StoreItem, type Sunshine } from '@/api
...
@@ -13,7 +13,7 @@ import { dashboardApi, operationApi, type StoreItem, type Sunshine } from '@/api
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import { SUNSHINE_COLUMNS } from './tableConfig';
import { SUNSHINE_COLUMNS } from './tableConfig';
import SunshineFormModal from './SunshineFormModal';
import SunshineFormModal from './SunshineFormModal';
import SunshineDetail
Modal from './SunshineDetailModal
';
import SunshineDetail
Drawer from './SunshineDetailDrawer
';
import { downloadCenter } from '@uj/platform-sdk';
import { downloadCenter } from '@uj/platform-sdk';
import { errorDetail } from '@/utils/error';
import { errorDetail } from '@/utils/error';
...
@@ -113,9 +113,10 @@ export default function SunshineTab() {
...
@@ -113,9 +113,10 @@ export default function SunshineTab() {
onReset={() => setF({})}
onReset={() => setF({})}
/>
/>
</UCard>
</UCard>
<UCard size="small">
<UCard size="small"
fill
>
<DataTable<Sunshine>
<DataTable<Sunshine>
rowKey="id"
rowKey="id"
fillHeight
columns={SUNSHINE_COLUMNS}
columns={SUNSHINE_COLUMNS}
dataSource={q.data?.records ?? []}
dataSource={q.data?.records ?? []}
loading={q.isLoading}
loading={q.isLoading}
...
@@ -154,7 +155,7 @@ export default function SunshineTab() {
...
@@ -154,7 +155,7 @@ export default function SunshineTab() {
/>
/>
</UCard>
</UCard>
<SunshineFormModal record={edit} onClose={() => setEdit(null)} onSaved={reload} />
<SunshineFormModal record={edit} onClose={() => setEdit(null)} onSaved={reload} />
<SunshineDetail
Modal
record={detail} onClose={() => setDetail(null)} />
<SunshineDetail
Drawer
record={detail} onClose={() => setDetail(null)} />
<ConfirmModal
<ConfirmModal
open={Boolean(pendingDelete)}
open={Boolean(pendingDelete)}
content="请确认是否要执行当前操作?删除后不可恢复。"
content="请确认是否要执行当前操作?删除后不可恢复。"
...
...
apps/web/subapps/usedcar/src/pages/Operation/contractDetail.css
View file @
e7c74a0
.uc-contract-detail
{
display
:
grid
;
gap
:
16px
;
}
/* 合同详情私有样式。卡片/档案条/时间线等通用部分在 src/styles/detail.css。 */
.uc-contract-detail__title
{
display
:
flex
;
align-items
:
center
;
gap
:
10px
;
margin
:
0
0
16px
;
font-size
:
15px
;
}
.uc-contract-detail__subtitle
{
margin
:
16px
0
8px
;
font-size
:
13px
;
color
:
var
(
--uj-text-2
);
}
/* ContractEdit(合同编辑页)也复用这两个类,保持其原有观感。 */
.uc-contract-detail__desc
{
max-width
:
100%
;
}
.uc-contract-detail
{
.uc-contract-detail__actions
{
display
:
flex
;
justify-content
:
flex-end
;
margin-top
:
12px
;
}
display
:
grid
;
.uc-contract-detail__fields
{
display
:
grid
;
gap
:
12px
;
}
gap
:
var
(
--uj-space-module
);
.uc-contract-detail__field
{
display
:
grid
;
grid-template-columns
:
140px
minmax
(
0
,
1
fr
);
gap
:
8px
;
align-items
:
start
;
}
}
.uc-contract-detail__field-label
{
color
:
var
(
--uj-text-2
);
}
.uc-contract-detail__title
{
.uc-contract-detail__field-value
{
display
:
flex
;
flex-wrap
:
wrap
;
gap
:
8px
;
align-items
:
center
;
}
display
:
flex
;
.uc-contract-detail__thumb
{
width
:
72px
;
height
:
72px
;
object-fit
:
cover
;
border-radius
:
6px
;
cursor
:
zoom-in
;
border
:
1px
solid
var
(
--uj-border
,
#e5e7eb
);
}
align-items
:
center
;
.uc-contract-detail__signer
+
.uc-contract-detail__signer
{
margin-top
:
8px
;
}
gap
:
10px
;
.uc-contract-detail__logs
{
display
:
grid
;
gap
:
10px
;
}
margin
:
0
0
16px
;
.uc-contract-detail__log
{
display
:
flex
;
gap
:
20px
;
align-items
:
center
;
border-left
:
2px
solid
var
(
--uj-primary
);
padding-left
:
14px
;
color
:
var
(
--uj-text-2
);
}
font-size
:
var
(
--uj-font-lg
);
.uc-contract-detail__log
b
{
color
:
var
(
--uj-text-1
);
font-weight
:
500
;
}
}
.uc-contract-desc
{
display
:
grid
;
gap
:
6px
;
margin-top
:
12px
;
}
.uc-contract-desc__label
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-sm
);
}
.uc-contract-fields
{
display
:
grid
;
gap
:
12px
;
}
.uc-contract-field
{
display
:
grid
;
grid-template-columns
:
140px
minmax
(
0
,
1
fr
);
gap
:
8px
;
align-items
:
start
;
}
.uc-contract-field__label
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.6
;
}
.uc-contract-field__value
{
display
:
flex
;
flex-wrap
:
wrap
;
gap
:
8px
;
align-items
:
center
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.6
;
overflow-wrap
:
anywhere
;
}
.uc-contract-field__thumb
{
width
:
88px
;
height
:
88px
;
object-fit
:
cover
;
border-radius
:
var
(
--uj-radius-md
);
cursor
:
zoom-in
;
border
:
1px
solid
var
(
--uj-border
);
transition
:
border-color
0.2s
;
}
.uc-contract-field__thumb
:hover
{
border-color
:
var
(
--uj-border-strong
);
}
/* 甲乙双方并排软面板:淡底无边框,不与卡片外框抢线。 */
.uc-contract-signers
{
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
12px
;
}
.uc-contract-signer
{
padding
:
12px
16px
;
background
:
var
(
--uj-surface-2
);
border-radius
:
var
(
--uj-radius-lg
);
}
.uc-contract-signer__head
{
display
:
flex
;
align-items
:
center
;
gap
:
8px
;
margin-bottom
:
10px
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
font-weight
:
600
;
}
.uc-contract-signer__type
{
padding
:
1px
8px
;
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-weight
:
normal
;
background
:
var
(
--uj-surface
);
border
:
1px
solid
var
(
--uj-border
);
border-radius
:
var
(
--uj-radius-sm
);
}
@media
(
max-width
:
900px
)
{
@media
(
max-width
:
900px
)
{
.uc-contract-detail__field
{
grid-template-columns
:
1
fr
;
}
.uc-contract-signers
{
.uc-contract-detail__log
{
flex-direction
:
column
;
gap
:
4px
;
}
grid-template-columns
:
1
fr
;
}
.uc-contract-field
{
grid-template-columns
:
1
fr
;
gap
:
2px
;
}
}
}
apps/web/subapps/usedcar/src/pages/Operation/index.tsx
View file @
e7c74a0
import { useState } from 'react';
import { useState } from 'react';
import { UResult, UTabs } from '@uj/ui';
import { UResult, UTabs } from '@uj/ui';
import { PageShell } from '@/components';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { UC } from '@/permissions/codes';
import ContractTab from './components/ContractTab';
import ContractTab from './components/ContractTab';
...
@@ -12,7 +13,7 @@ export default function Operation() {
...
@@ -12,7 +13,7 @@ export default function Operation() {
<UResult status="403" title="无访问运营管理的权限" subTitle="请联系管理员开通访问权限。" />
<UResult status="403" title="无访问运营管理的权限" subTitle="请联系管理员开通访问权限。" />
);
);
return (
return (
<
div className="uj-page
">
<
PageShell fill title="运营管理
">
<UTabs
<UTabs
activeKey={tab}
activeKey={tab}
onChange={setTab}
onChange={setTab}
...
@@ -22,6 +23,6 @@ export default function Operation() {
...
@@ -22,6 +23,6 @@ export default function Operation() {
]}
]}
/>
/>
{tab === 'contract' ? <ContractTab /> : <SunshineTab />}
{tab === 'contract' ? <ContractTab /> : <SunshineTab />}
</
div
>
</
PageShell
>
);
);
}
}
apps/web/subapps/usedcar/src/pages/Reports/index.tsx
View file @
e7c74a0
...
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react';
...
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import type { Dayjs } from 'dayjs';
import type { Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UImage, UResult, UTag } from '@uj/ui';
import { UAlert, UButton, UCard, UImage, UResult, UTag } from '@uj/ui';
import { downloadCenter } from '@uj/platform-sdk';
import { downloadCenter
, openExternal
} from '@uj/platform-sdk';
import {
import {
DataTable,
DataTable,
PageShell,
PageShell,
...
@@ -121,7 +121,7 @@ export default function Reports() {
...
@@ -121,7 +121,7 @@ export default function Reports() {
permission: UC.REPORT_DETAIL,
permission: UC.REPORT_DETAIL,
visible: (r) => String(r.status) === '1' && Boolean(r.reportUrl),
visible: (r) => String(r.status) === '1' && Boolean(r.reportUrl),
onClick: (r) => {
onClick: (r) => {
if (r.reportUrl)
window.open(r.reportUrl, '_blank', 'noopener,noreferrer'
);
if (r.reportUrl)
openExternal(r.reportUrl
);
},
},
},
},
];
];
...
...
apps/web/subapps/usedcar/src/pages/Vehicles/VehicleDetail.tsx
View file @
e7c74a0
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useState
, type ReactNode
} from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import dayjs, { type Dayjs } from 'dayjs';
import dayjs, { type Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UDatePicker, UForm, UModal, UResult, useUMessage } from '@uj/ui';
import { UAlert, UButton, UCard, UDatePicker, UForm, UModal, UResult, useUMessage } from '@uj/ui';
...
@@ -245,138 +245,177 @@ export default function VehicleDetail({ params }: { params: PageParams }) {
...
@@ -245,138 +245,177 @@ export default function VehicleDetail({ params }: { params: PageParams }) {
description={errorDetail(detail.error)}
description={errorDetail(detail.error)}
/>
/>
) : null}
) : null}
<div className="uc-vehicle-detail">
<UCard className="uc-detail-card" loading={detail.isPending}>
{editing ? (
<div className="uc-detail-dossier">
<UCard>
<div className="uc-detail-dossier__identity">
<CombiForm
<div className="uc-detail-dossier__name">
mode="form"
{display(data.carTypeName)}
form={form}
{data.licensePlate ? (
fields={editFields}
<span className="uc-detail-dossier__chip">{String(data.licensePlate)}</span>
initialValues={{}}
) : null}
layout="horizontal"
</div>
labelWidth={128}
<div className="uc-detail-dossier__code">车源号:{display(data.sourceNo)}</div>
sectionContentStyle={{
</div>
display: 'grid',
<div className="uc-detail-dossier__meta">
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
<MetaItem label="车辆状态">{statusLabel(currentStatus)}</MetaItem>
columnGap: 24,
<MetaItem label="车辆来源门店">{display(data.sourceStoreName)}</MetaItem>
}}
<MetaItem label="车辆创建时间">{display(data.createTime)}</MetaItem>
renderSectionTitle={(title) => (
</div>
<h3 className="uc-vehicle-detail__section-title">{title}</h3>
</div>
)}
</UCard>
renderControl={(field) =>
<div className="uc-detail-split">
field.name === 'sellingTime' ? <UDatePicker disabled={!sold} /> : undefined
<div className="uc-detail-split__main">
}
{editing ? (
onSubmit={() => setConfirmOpen(true)}
<UCard className="uc-detail-card">
/>
<CardHead title="编辑车辆信息" />
</UCard>
<div className="uc-detail-card__body">
) : null}
<CombiForm
{!editing ? (
mode="form"
<UCard title="车辆状态与保管信息">
form={form}
<CombiForm
fields={editFields}
mode="detail"
initialValues={{}}
detailColumns={2}
layout="horizontal"
labelWidth={128}
labelWidth={128}
fields={[
sectionContentStyle={{
{ name: 'carStatus', label: '车辆状态', type: 'input', render: statusLabel },
display: 'grid',
{ name: 'carCreator', label: '车辆创建人', type: 'input', render: display },
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
{ name: 'storageLocation', label: '保管地', type: 'input', render: display },
columnGap: 24,
{ name: 'custodian', label: '保管人', type: 'input', render: display },
}}
{
renderSectionTitle={(title) => <h3 className="uc-vehicle-section">{title}</h3>}
name: 'custodyContract',
renderControl={(field) =>
label: '代保管合同',
field.name === 'sellingTime' ? <UDatePicker disabled={!sold} /> : undefined
type: 'input',
}
render: (value) => <FilePreview value={value} />,
onSubmit={() => setConfirmOpen(true)}
},
/>
{
</div>
name: 'deliveryConfirmation',
<div className="uc-detail-card__foot">
label: '交车确认书',
<UButton type="default" onClick={() => goTo('vehicles')}>
type: 'input',
关闭
render: (value) => <FilePreview value={value} />,
</UButton>
},
<UButton type="primary" loading={saving} onClick={() => form.submit()}>
{
保存
name: 'supplementaryAgreement',
</UButton>
label: '补充协议',
</div>
type: 'input',
</UCard>
render: (value) => <FilePreview value={value} />,
) : null}
},
<UCard className="uc-detail-card" loading={detail.isPending}>
]}
<CardHead title="车辆信息" />
initialValues={data}
<div className="uc-detail-card__body">
/>
<div className="uc-detail-descriptions">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['licensePlate', '车牌号'],
['vin', '车架号'],
['sourceNo', '车源号'],
['carTypeName', '车型'],
['listingDate', '上牌时间'],
['listingCity', '上牌城市'],
['mileage', '表显里程'],
['usageType', '使用性质'],
['ownerType', '所有人性质'],
['hasAccident', '是否事故'],
['sunroof', '天窗'],
['sourceStoreName', '车辆来源门店'],
['createTime', '车辆创建时间'],
['originalOwner', '原车主姓名'],
['ownerContact', '原车主联系方式'],
['insuranceExpiry', '交强险到期日'],
['inspectionExpiry', '年审到期日'],
['msrp', '新车指导价'],
['productionDate', '车辆生产日期'],
['source', '车辆来源'],
['vehicleNotes', '车辆备注'],
])}
initialValues={data}
/>
</div>
</div>
</UCard>
</UCard>
) : null}
<UCard title="车辆采购与卖出信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['purchasePrice', '收车价'],
['purchaseTime', '收车时间'],
['sellingPrice', '卖出价'],
['sellingTime', '卖出时间'],
['seller', '卖出方'],
['sellingNotes', '车辆卖出备注'],
])}
initialValues={data}
/>
</UCard>
<UCard title="车辆信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['licensePlate', '车牌号'],
['vin', '车架号'],
['sourceNo', '车源号'],
['carTypeName', '车型'],
['listingDate', '上牌时间'],
['listingCity', '上牌城市'],
['mileage', '表显里程'],
['usageType', '使用性质'],
['ownerType', '所有人性质'],
['hasAccident', '是否事故'],
['sunroof', '天窗'],
['sourceStoreName', '车辆来源门店'],
['createTime', '车辆创建时间'],
['originalOwner', '原车主姓名'],
['ownerContact', '原车主联系方式'],
['insuranceExpiry', '交强险到期日'],
['inspectionExpiry', '年审到期日'],
['msrp', '新车指导价'],
['productionDate', '车辆生产日期'],
['source', '车辆来源'],
['vehicleNotes', '车辆备注'],
])}
initialValues={data}
/>
</UCard>
<UCard title="牌证信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['keyCode', '钥匙编码'],
['keyCount', '钥匙数'],
['transfersNumber', '过户次数'],
])}
initialValues={data}
/>
</UCard>
</div>
{editing ? (
<div className="uc-vehicle-detail-actions">
<UButton type="primary" loading={saving} onClick={() => form.submit()}>
保存
</UButton>
<UButton onClick={() => goTo('vehicles')}>关闭</UButton>
</div>
</div>
) : (
<div className="uc-detail-split__rail">
<div className="uc-vehicle-detail-actions">
{!editing ? (
<UButton onClick={() => goTo('vehicles')}>返回</UButton>
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="车辆状态与保管信息" />
<div className="uc-detail-card__body">
<div className="uc-detail-descriptions">
<CombiForm
mode="detail"
detailColumns={1}
labelWidth={110}
fields={[
{ name: 'carStatus', label: '车辆状态', type: 'input', render: statusLabel },
{ name: 'carCreator', label: '车辆创建人', type: 'input', render: display },
{ name: 'storageLocation', label: '保管地', type: 'input', render: display },
{ name: 'custodian', label: '保管人', type: 'input', render: display },
{
name: 'custodyContract',
label: '代保管合同',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
{
name: 'deliveryConfirmation',
label: '交车确认书',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
{
name: 'supplementaryAgreement',
label: '补充协议',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
]}
initialValues={data}
/>
</div>
</div>
</UCard>
) : null}
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="车辆采购与卖出信息" />
<div className="uc-detail-card__body">
<div className="uc-detail-descriptions">
<CombiForm
mode="detail"
detailColumns={1}
labelWidth={110}
fields={readFields([
['purchasePrice', '收车价'],
['purchaseTime', '收车时间'],
['sellingPrice', '卖出价'],
['sellingTime', '卖出时间'],
['seller', '卖出方'],
['sellingNotes', '车辆卖出备注'],
])}
initialValues={data}
/>
</div>
</div>
</UCard>
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="牌证信息" />
<div className="uc-detail-card__body">
<div className="uc-detail-descriptions">
<CombiForm
mode="detail"
detailColumns={1}
labelWidth={110}
fields={readFields([
['keyCode', '钥匙编码'],
['keyCount', '钥匙数'],
['transfersNumber', '过户次数'],
])}
initialValues={data}
/>
</div>
</div>
</UCard>
</div>
</div>
)}
</div>
<UModal
<UModal
open={confirmOpen}
open={confirmOpen}
title="提示"
title="提示"
...
@@ -389,3 +428,18 @@ export default function VehicleDetail({ params }: { params: PageParams }) {
...
@@ -389,3 +428,18 @@ export default function VehicleDetail({ params }: { params: PageParams }) {
</PageShell>
</PageShell>
);
);
}
}
function CardHead({ title }: { title: string }) {
return (
<div className="uc-detail-card__head">
<h2 className="uc-detail-card__title">{title}</h2>
</div>
);
}
function MetaItem({ label, children }: { label: string; children: ReactNode }) {
return (
<div className="uc-detail-dossier__item">
<span className="uc-detail-dossier__label">{label}</span>
<span className="uc-detail-dossier__value">{children}</span>
</div>
);
}
apps/web/subapps/usedcar/src/pages/Vehicles/vehicles.css
View file @
e7c74a0
...
@@ -6,35 +6,34 @@
...
@@ -6,35 +6,34 @@
border-radius
:
4px
;
border-radius
:
4px
;
background
:
var
(
--ant-color-fill-quaternary
);
background
:
var
(
--ant-color-fill-quaternary
);
}
}
.uc-vehicle-detail
{
/* 编辑表单的分节标题:与卡头同一套竖签语言,但弱一级。 */
display
:
grid
;
.uc-vehicle-section
{
gap
:
16px
;
}
.uc-vehicle-detail
.ant-descriptions-view
>
table
{
width
:
100%
;
table-layout
:
fixed
;
}
.uc-vehicle-detail
.ant-descriptions-item-label
{
width
:
128px
;
min-width
:
128px
;
white-space
:
nowrap
;
}
.uc-vehicle-detail-actions
{
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
gap
:
12px
;
gap
:
8px
;
margin-top
:
16px
;
}
.uc-vehicle-detail__section-title
{
margin
:
0
0
16px
;
margin
:
0
0
16px
;
padding-bottom
:
12px
;
color
:
var
(
--uj-text-1
);
border-bottom
:
1px
solid
var
(
--ant-color-border-secondary
);
font-size
:
var
(
--uj-font-md
);
font-size
:
16px
;
font-weight
:
600
;
}
.uc-vehicle-section
::before
{
content
:
''
;
flex
:
none
;
width
:
3px
;
height
:
12px
;
border-radius
:
1px
;
background
:
var
(
--uj-border-strong
);
}
/* 后续分节与上一节之间用通长发丝线分开(标题是每个 section 的首个子节点)。 */
form
>
section
+
section
>
.uc-vehicle-section
{
margin-top
:
8px
;
padding-top
:
16px
;
border-top
:
1px
solid
var
(
--uj-divider
);
}
}
.uc-vehicle-file
{
.uc-vehicle-file
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
width
:
24
0px
;
max-width
:
26
0px
;
min-width
:
0
;
min-width
:
0
;
}
}
.uc-vehicle-file__name
{
.uc-vehicle-file__name
{
...
...
apps/web/subapps/usedcar/src/styles/detail.css
0 → 100644
View file @
e7c74a0
/* ============ 详情页共享样式层 ============
线只有一种粗细(1px)、两种颜色:卡片外框 --uj-border,卡头/卡脚分隔 --uj-divider,
且一律通长。区块之间靠卡片边界与模块间距分开,不用粗色条、列边框或半截线。
车况/评估/合同/车辆/交付/线索/离职继承的详情共用这一套,页面私有样式留在各自 css。 */
.uc-detail-stack
{
display
:
grid
;
gap
:
var
(
--uj-space-module
);
min-width
:
0
;
}
/* 主栏 + 右栏按 1.6:1 比例分宽:右栏要放得下单列长字段(编号/时间/地址),
固定窄栏会把内容挤成逐字换行。窄屏收为单列。 */
.uc-detail-split
{
display
:
grid
;
grid-template-columns
:
minmax
(
0
,
1.6
fr
)
minmax
(
340px
,
1
fr
);
gap
:
var
(
--uj-space-module
);
align-items
:
start
;
}
.uc-detail-split__main
,
.uc-detail-split__rail
{
display
:
grid
;
gap
:
var
(
--uj-space-module
);
min-width
:
0
;
}
/* ---- 卡片解剖:头(标题+辅助+动作)/ 体 / 脚,所有卡同一套 ---- */
.uc-detail-card
>
.ant-card-body
{
padding
:
0
;
}
.uc-detail-card__head
{
display
:
flex
;
align-items
:
center
;
gap
:
8px
;
min-height
:
48px
;
padding
:
8px
16px
;
border-bottom
:
1px
solid
var
(
--uj-divider
);
}
/* 收起/空态时卡头是最后一个节点:去掉底线,避免与卡片外框叠出双线。 */
.uc-detail-card__head
:last-child
{
border-bottom
:
0
;
}
.uc-detail-card__title
{
display
:
flex
;
align-items
:
center
;
gap
:
8px
;
margin
:
0
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-lg
);
font-weight
:
600
;
line-height
:
1.4
;
}
.uc-detail-card__title
::before
{
content
:
''
;
flex
:
none
;
width
:
3px
;
height
:
14px
;
border-radius
:
1px
;
background
:
var
(
--uj-primary
);
}
.uc-detail-card__aux
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-variant-numeric
:
var
(
--uj-num
);
white-space
:
nowrap
;
}
.uc-detail-card__actions
{
display
:
flex
;
align-items
:
center
;
gap
:
4px
;
margin-left
:
auto
;
}
.uc-detail-card__body
{
padding
:
16px
;
}
.uc-detail-card__foot
{
display
:
flex
;
justify-content
:
flex-end
;
gap
:
8px
;
padding
:
12px
16px
;
border-top
:
1px
solid
var
(
--uj-divider
);
}
/* ---- 档案条:主体名称 + 标志芯片 + 编号 | 状态 / 关键元信息 ---- */
.uc-detail-dossier
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
center
;
justify-content
:
space-between
;
gap
:
12px
32px
;
padding
:
12px
16px
;
}
.uc-detail-dossier__identity
{
display
:
grid
;
gap
:
4px
;
min-width
:
0
;
}
.uc-detail-dossier__name
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
center
;
gap
:
8px
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-lg
);
font-weight
:
600
;
line-height
:
1.4
;
overflow-wrap
:
anywhere
;
}
.uc-detail-dossier__chip
{
flex
:
none
;
padding
:
2px
8px
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-xs
);
font-weight
:
600
;
font-variant-numeric
:
var
(
--uj-num
);
letter-spacing
:
0.4px
;
background
:
var
(
--uj-surface-2
);
border
:
1px
solid
var
(
--uj-border-strong
);
border-radius
:
var
(
--uj-radius-sm
);
}
.uc-detail-dossier__code
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-variant-numeric
:
var
(
--uj-num
);
}
.uc-detail-dossier__meta
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
flex-start
;
gap
:
12px
28px
;
}
.uc-detail-dossier__item
{
display
:
grid
;
gap
:
4px
;
}
.uc-detail-dossier__label
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
line-height
:
1.4
;
}
.uc-detail-dossier__value
{
display
:
flex
;
align-items
:
center
;
gap
:
6px
;
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.5
;
font-variant-numeric
:
var
(
--uj-num
);
}
/* ---- 状态点:列表与详情共用同一套色调判定 ---- */
.uc-detail-status
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
8px
;
color
:
var
(
--uj-text-2
);
}
.uc-detail-status
::before
{
content
:
''
;
width
:
6px
;
height
:
6px
;
border-radius
:
50%
;
background
:
var
(
--uj-text-4
);
}
.uc-detail-status--success
::before
{
background
:
var
(
--uj-primary
);
}
.uc-detail-status--pending
::before
{
background
:
var
(
--uj-text-4
);
}
.uc-detail-status--progress
::before
{
background
:
var
(
--uj-warning
);
}
.uc-detail-status--failed
::before
{
background
:
var
(
--uj-error
);
}
/* ---- 只读描述表:标签弱化、值强调,行距统一,末行不留底距 ---- */
.uc-detail-descriptions
.ant-descriptions-view
>
table
{
width
:
100%
;
table-layout
:
fixed
;
}
.uc-detail-descriptions
.ant-descriptions-item-label
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-sm
);
vertical-align
:
top
;
padding-bottom
:
12px
;
}
.uc-detail-descriptions
.ant-descriptions-item-content
{
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
vertical-align
:
top
;
padding-bottom
:
12px
;
overflow-wrap
:
anywhere
;
}
.uc-detail-descriptions
.ant-descriptions-row
:last-child
>
td
{
padding-bottom
:
0
;
}
/* ---- 时间线:8px 圆点 + 1px 竖线,替代粗左边框块 ---- */
.uc-detail-timeline
{
display
:
grid
;
}
.uc-detail-timeline__item
{
display
:
grid
;
grid-template-columns
:
16px
minmax
(
0
,
1
fr
);
column-gap
:
12px
;
padding-bottom
:
16px
;
}
.uc-detail-timeline__item
:last-child
{
padding-bottom
:
0
;
}
.uc-detail-timeline__marker
{
position
:
relative
;
}
.uc-detail-timeline__marker
::before
{
content
:
''
;
position
:
absolute
;
top
:
5px
;
left
:
50%
;
width
:
8px
;
height
:
8px
;
border-radius
:
50%
;
background
:
var
(
--uj-primary
);
box-shadow
:
0
0
0
3px
var
(
--uj-primary-soft
);
translate
:
-50%
0
;
}
.uc-detail-timeline__marker
::after
{
content
:
''
;
position
:
absolute
;
top
:
18px
;
bottom
:
-16px
;
left
:
50%
;
width
:
1px
;
background
:
var
(
--uj-divider
);
}
.uc-detail-timeline__item
:last-child
.uc-detail-timeline__marker
::after
{
content
:
none
;
}
.uc-detail-timeline__head
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
baseline
;
justify-content
:
space-between
;
gap
:
4px
12px
;
}
.uc-detail-timeline__title
{
color
:
var
(
--uj-text-1
);
font-size
:
var
(
--uj-font-sm
);
font-weight
:
600
;
line-height
:
1.5
;
}
.uc-detail-timeline__time
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-xs
);
font-variant-numeric
:
var
(
--uj-num
);
white-space
:
nowrap
;
}
.uc-detail-timeline__body
{
display
:
grid
;
gap
:
4px
;
margin-top
:
6px
;
color
:
var
(
--uj-text-2
);
font-size
:
var
(
--uj-font-sm
);
line-height
:
1.6
;
overflow-wrap
:
anywhere
;
}
.uc-detail-timeline__label
{
color
:
var
(
--uj-text-3
);
}
/* ---- 同一卡片内多轮记录:通长发丝线分隔 ---- */
.uc-detail-block
+
.uc-detail-block
{
margin-top
:
16px
;
padding-top
:
16px
;
border-top
:
1px
solid
var
(
--uj-divider
);
}
/* ---- 附件/资料行:标签定宽弱化,链接可换行 ---- */
.uc-detail-files
{
display
:
grid
;
gap
:
10px
;
}
.uc-detail-files__row
{
display
:
grid
;
grid-template-columns
:
96px
minmax
(
0
,
1
fr
);
gap
:
8px
;
align-items
:
baseline
;
}
.uc-detail-files__label
{
color
:
var
(
--uj-text-3
);
font-size
:
var
(
--uj-font-sm
);
}
.uc-detail-files__value
{
display
:
flex
;
flex-wrap
:
wrap
;
align-items
:
center
;
gap
:
0
4px
;
min-width
:
0
;
font-size
:
var
(
--uj-font-sm
);
}
@media
(
max-width
:
1100px
)
{
.uc-detail-split
{
grid-template-columns
:
1
fr
;
}
}
@media
(
max-width
:
700px
)
{
.uc-detail-dossier
{
gap
:
12px
20px
;
}
.uc-detail-dossier__meta
{
gap
:
12px
20px
;
}
.uc-detail-files__row
{
grid-template-columns
:
1
fr
;
gap
:
2px
;
}
}
docs/PORT_CONVERSION.md
View file @
e7c74a0
...
@@ -149,9 +149,9 @@ UResult UEmpty USteps UTimeline UDropdown UDatePicker URadio USwit
...
@@ -149,9 +149,9 @@ UResult UEmpty USteps UTimeline UDropdown UDatePicker URadio USwit
-
全都不标
`essential`
→
非日期字段全部常显(锚点);
-
全都不标
`essential`
→
非日期字段全部常显(锚点);
-
**
时间区间
`dateRange`
默认进「更多筛选」
**
(区间要跨
2
列才完整);例外:轻量表单(常显非日期
≤
2
且整页条件
≤
3
,如「积分详情」只有积分类型
+
积分变化时间)或显式
`essential:true`
的区间会常显。阈值在组件内
`lightForm`
启发式,
**
不要改页面去手调
**
。
-
**
时间区间
`dateRange`
默认进「更多筛选」
**
(区间要跨
2
列才完整);例外:轻量表单(常显非日期
≤
2
且整页条件
≤
3
,如「积分详情」只有积分类型
+
积分变化时间)或显式
`essential:true`
的区间会常显。阈值在组件内
`lightForm`
启发式,
**
不要改页面去手调
**
。
-
收起区是
CSS
隐藏而非卸载(避免
Form
.
Item
卸载丢值),这点组件已处理,页面只管传字段。
-
收起区是
CSS
隐藏而非卸载(避免
Form
.
Item
卸载丢值),这点组件已处理,页面只管传字段。
-
**
「更多筛选」双数角标
**
(组件统一处理,页面不要自己算数):按钮文案右上角的
**
无背景上标
**
是
**
整张表的筛选条件总数
**
(含常显字段,按
`filterGroup`
归并、排除
`countsAsFilter:false`
),主色实心角标是
**
整张表已填写的条件数
**
,两者语义不同。总数不随填写变化、只作说明,所以不带底色
/
边框、不占按钮宽度;主色角标是唯一带底色的强调。计数口径:与
`initialValues`
相同的默认值不算用户设的条件(如
finance
页
`dateType:'payment'`
、
`paymentMethod:'全部'`
);无背景总数上标只在收起态显示(展开后条件都在眼前,再挂总数
纯属重复),主色已填数角标收起
/
展开两态都显示(展开态它是悬浮卡的触发区)。
hover
/
键盘
focus
主色实心的「已填数」角标才弹出条件卡,按钮文案与无背景总数上标
hover
都不触发:头部显示已填数量,每条条件按「标签
|
值
|
×」单行密集排列(行高
24
px
,一屏约
16
条,超出才滚动),右上角
×
行内删除(按
`filterGroup`
清整组并立即用剩余条件重查),底部左侧提示、右侧「全部清空」走
`onReset`
。只有已填数大于
0
才弹卡片,且
hover
满
500
ms
才出现(扫过不打扰);展开「更多筛选」时卡片照常可弹,但方向从向下改为向上(
`topRight`
),避免盖住刚展开的收拢区;点击切换展开
/
收起时卡片先收起,防止上下翻转时跳位。
-
**
「更多筛选」双数角标
**
(组件统一处理,页面不要自己算数):按钮文案右上角的
**
无背景上标
**
是
**
收进「更多筛选」的条件数
**
(不含常显字段,按
`filterGroup`
归并、排除
`countsAsFilter:false`
),主色实心角标是
**
整张表已填写的条件数
**
,两者语义不同。收起数不随填写变化、只作说明,所以不带底色
/
边框、不占按钮宽度;主色角标是唯一带底色的强调。计数口径:与
`initialValues`
相同的默认值不算用户设的条件(如
finance
页
`dateType:'payment'`
、
`paymentMethod:'全部'`
);无背景收起数上标只在收起态显示(展开后这些条件都在眼前,再挂数字
纯属重复),主色已填数角标收起
/
展开两态都显示(展开态它是悬浮卡的触发区)。
hover
/
键盘
focus
主色实心的「已填数」角标才弹出条件卡,按钮文案与无背景总数上标
hover
都不触发:头部显示已填数量,每条条件按「标签
|
值
|
×」单行密集排列(行高
24
px
,一屏约
16
条,超出才滚动),右上角
×
行内删除(按
`filterGroup`
清整组并立即用剩余条件重查),底部左侧提示、右侧「全部清空」走
`onReset`
。只有已填数大于
0
才弹卡片,且
hover
满
500
ms
才出现(扫过不打扰);展开「更多筛选」时卡片照常可弹,但方向从向下改为向上(
`topRight`
),避免盖住刚展开的收拢区;点击切换展开
/
收起时卡片先收起,防止上下翻转时跳位。
-
**
组合字段用
`filterGroup`
归并
**
:一个业务条件拆成多个平铺字段时(金额区间
`amtMin`
/
`amtMax`
、日期类型
+
区间
`dateType`
/
`dateValue`
),给同组字段标同一个
`filterGroup`
,角标里整组只算
1
个条件;不标就按字段各自计。字段表是唯一真源,不要在页面里另写一份计数。组合控件里只起辅助作用、单独变化不产生查询参数的字段(如
`dateType`
)标
`countsAsFilter: false`
,不参与计数。
-
**
组合字段用
`filterGroup`
归并
**
:一个业务条件拆成多个平铺字段时(金额区间
`amtMin`
/
`amtMax`
、日期类型
+
区间
`dateType`
/
`dateValue`
),给同组字段标同一个
`filterGroup`
,角标里整组只算
1
个条件;不标就按字段各自计。字段表是唯一真源,不要在页面里另写一份计数。组合控件里只起辅助作用、单独变化不产生查询参数的字段(如
`dateType`
)标
`countsAsFilter: false`
,不参与计数。
-
按钮的
`aria-label`
在收起
/
展开两态都会报出「
共
N
个
/
已填
M
个
」供读屏使用;不再挂原生
`title`
,避免与悬浮卡叠两层提示;页面不需要传任何计数参数。主色已填角标自身带
`aria-label`
、可
Tab
聚焦并有
`focus-visible`
焦点框;悬浮卡内每个
×
另有
`aria-label`
(含条件标签),
`focus-visible`
有独立焦点底色。
-
按钮的
`aria-label`
在收起
/
展开两态都会报出「
N
个条件已收起
/
已填
M
项
」供读屏使用;不再挂原生
`title`
,避免与悬浮卡叠两层提示;页面不需要传任何计数参数。主色已填角标自身带
`aria-label`
、可
Tab
聚焦并有
`focus-visible`
焦点框;悬浮卡内每个
×
另有
`aria-label`
(含条件标签),
`focus-visible`
有独立焦点底色。
---
---
...
...
packages/api-core/src/core/facade.ts
View file @
e7c74a0
...
@@ -448,6 +448,15 @@ function buildError(message: string, init: Partial<RequestError> = {}): RequestE
...
@@ -448,6 +448,15 @@ function buildError(message: string, init: Partial<RequestError> = {}): RequestE
return
new
RequestError
(
message
,
init
);
return
new
RequestError
(
message
,
init
);
}
}
/**
* 已经在本层 normalize 里触发过登出的错误,catch 分支不再重复触发。
*
* 双层门面(web 子应用 transport:'host' → 主壳 http.request)下,业务码可能由主壳先判失败、
* 再由子应用 catch 接手;登出回调只应命中一次。WeakSet 只标记本 realm 抛出的错误对象,
* 不跨 realm 传播,因此不会吞掉主壳自己的登出回调。
*/
const
logoutHandledErrors
=
new
WeakSet
<
object
>
();
/** 取错误文案:跨 realm 抛来的错误不是本 realm 的 Error 实例,只能认 message 字段。 */
/** 取错误文案:跨 realm 抛来的错误不是本 realm 的 Error 实例,只能认 message 字段。 */
function
messageOf
(
error
:
unknown
):
string
{
function
messageOf
(
error
:
unknown
):
string
{
const
message
=
(
error
as
{
message
?:
unknown
}
|
undefined
)?.
message
;
const
message
=
(
error
as
{
message
?:
unknown
}
|
undefined
)?.
message
;
...
@@ -674,6 +683,28 @@ export class Request {
...
@@ -674,6 +683,28 @@ export class Request {
lastError
=
error
;
lastError
=
error
;
const
wrapped
=
wrapError
(
error
,
config
);
const
wrapped
=
wrapError
(
error
,
config
);
const
isBusiness
=
wrapped
.
code
!==
undefined
;
const
isBusiness
=
wrapped
.
code
!==
undefined
;
// 双层门面兜底:业务码不一定在本层 normalize 产生。
// web 子应用 transport:'host' 时,主壳先按自己的 response 语义判失败并 reject,
// 子应用 normalize(唯一执行 logoutCodes 判定的地方)被 catch 跳过,
// 于是子应用声明的登出码与 onLoginRequired 永远不会触发(积分 code=20 即此路径)。
// 这里对已 reject 的请求按本层 response.logoutCodes 再判一次,与 normalize 同源。
const
resp
=
config
.
response
??
{};
if
(
isBusiness
&&
!
logoutHandledErrors
.
has
(
wrapped
)
&&
looseMatch
(
resp
.
logoutCodes
??
[
20
,
21
],
wrapped
.
code
)
)
{
const
body
=
(
wrapped
.
response
??
wrapped
.
data
??
{})
as
Record
<
string
,
unknown
>
;
safeEvent
(()
=>
config
.
events
?.
logout
?.(
body
,
config
));
const
decision
=
config
.
onLoginRequired
?.(
wrapped
.
code
as
string
|
number
,
{
resource
,
config
,
body
,
});
logoutHandledErrors
.
add
(
wrapped
);
if
(
decision
&&
typeof
decision
===
'object'
&&
'resolve'
in
decision
)
return
decision
.
resolve
as
T
;
if
((
resp
.
throwOnError
??
true
)
===
false
)
return
(
wrapped
.
response
??
wrapped
.
data
)
as
T
;
}
const
shouldRetry
=
Boolean
(
retry
&&
attempt
<
maxAttempts
-
1
&&
(
retry
.
condition
?
retry
.
condition
(
wrapped
)
:
!
isBusiness
));
const
shouldRetry
=
Boolean
(
retry
&&
attempt
<
maxAttempts
-
1
&&
(
retry
.
condition
?
retry
.
condition
(
wrapped
)
:
!
isBusiness
));
if
(
!
shouldRetry
)
{
if
(
!
shouldRetry
)
{
if
(
!
isBusiness
)
{
if
(
!
isBusiness
)
{
...
@@ -809,7 +840,9 @@ export class Request {
...
@@ -809,7 +840,9 @@ export class Request {
safeUI
(()
=>
ui
.
stopPullDownRefresh
());
safeUI
(()
=>
ui
.
stopPullDownRefresh
());
return
new
Promise
(()
=>
{});
return
new
Promise
(()
=>
{});
}
}
throw
buildError
(
message
,
{
code
:
code
as
string
|
number
,
data
:
errorData
,
config
,
response
:
body
});
const
failure
=
buildError
(
message
,
{
code
:
code
as
string
|
number
,
data
:
errorData
,
config
,
response
:
body
});
logoutHandledErrors
.
add
(
failure
);
throw
failure
;
}
}
if
(
resp
.
resolveOnOther
)
{
if
(
resp
.
resolveOnOther
)
{
...
...
packages/api-core/test/facade.test.mjs
View file @
e7c74a0
...
@@ -459,6 +459,37 @@ test('IT-FACADE-ENVMSG-001 GSC 信封 msg 键:失败文案原样进 Error.mess
...
@@ -459,6 +459,37 @@ test('IT-FACADE-ENVMSG-001 GSC 信封 msg 键:失败文案原样进 Error.mess
);
);
});
});
test('IT-FACADE-ENVMSG-001B GSC 信封 22 声明为登出码时触发 onLoginRequired', async () => {
let required = false;
let requiredCode;
const client = createClient({
kind: 'gsc',
sender: {
async send() {
return {
status: 200,
data: { code: 22, msg: 'sessionId不存在', data: null, success: false },
headers: { 'content-type': 'application/json' },
};
},
},
baseURL: 'https://gsc.test.glsx.com.cn/gsc-vcp-web-facade',
appKey: 'Web_DJia',
appSecret: 's',
// 与 usedcar/src/api/core/client.ts callConfig 的声明保持一致:
// 不声明时兜底 [20,21] 不含 22,code=22 只会 toast + throw,页面停在原页。
response: { logoutCodes: [20, 21, 22] },
onLoginRequired: (code) => {
required = true;
requiredCode = code;
},
});
await assert.rejects(() => client.post('/dataBoard/evaluation', {}), /sessionId不存在/);
assert.ok(required, 'GSC code=22 命中 logoutCodes 后必须触发 onLoginRequired');
assert.equal(requiredCode, 22);
});
test('IT-FACADE-ENVMSG-002 messageMap:信封无文案时按码回退,信封有文案时信封优先', async () => {
test('IT-FACADE-ENVMSG-002 messageMap:信封无文案时按码回退,信封有文案时信封优先', async () => {
// 信封无 msg → 用 messageMap[22]
// 信封无 msg → 用 messageMap[22]
const withMap = createClient({
const withMap = createClient({
...
...
packages/api-core/test/strategy.test.mjs
View file @
e7c74a0
...
@@ -592,3 +592,47 @@ test('ST-RPC-008 网关声明的 logoutCodes 命中即触发 onLoginRequired(
...
@@ -592,3 +592,47 @@ test('ST-RPC-008 网关声明的 logoutCodes 命中即触发 onLoginRequired(
assert.ok(required, '网关登出码 21 命中后必须触发 onLoginRequired');
assert.ok(required, '网关登出码 21 命中后必须触发 onLoginRequired');
assert.equal(requiredCode, 21);
assert.equal(requiredCode, 21);
});
});
test('ST-RPC-009 双层门面:主壳按自身码判失败后,子应用仍能凭网关登出码触发 onLoginRequired', async () => {
let required = false;
let requiredCode;
// 模拟真实 web 链路:主壳用 web-host 语义(成功 200 / 登出 401、10002)归一子应用网关响应。
// code=20 在主壳不是登出码,会 throw RequestError;这正是积分明细 code=20 不跳登录页的路径。
const hostApi = new Request(
createStrategy({
kind: 'web-host',
sender: {
async send() {
return { status: 200, data: '{"code":20,"message":"Missing Session"}', headers: {} };
},
},
}),
);
// createHostSender 只透传这些字段,不把子应用的 response.logoutCodes 交给主壳。
const hostSend = (cfg) =>
hostApi.request({
url: cfg.url,
method: cfg.method,
data: cfg.data,
headers: cfg.headers,
transformResponse: cfg.transformResponse,
});
const api = new Request(
createStrategy({
transport: 'host',
hostSend,
gatewayCredential: rpcCredential,
gatewayToken: rpcToken,
timeout: 180000,
contentType: false,
onLoginRequired: (code) => {
required = true;
requiredCode = code;
},
}),
);
await assert.rejects(() => api.post('m.missing.session', {}, { gateway: 'st-rpc' }), /Missing Session/);
assert.ok(required, '主壳 reject 后,子应用门面必须按自己的 logoutCodes 再判一次');
assert.equal(requiredCode, 20);
});
packages/biz/src/components/BrandLoader.tsx
View file @
e7c74a0
...
@@ -106,3 +106,41 @@ export function BrandLoader({ size = 64, className }: BrandLoaderProps) {
...
@@ -106,3 +106,41 @@ export function BrandLoader({ size = 64, className }: BrandLoaderProps) {
</div>
</div>
);
);
}
}
export interface BrandLoadingProps {
/** 图标下方文案,传空字符串隐藏 */
label?: string;
size?: number;
className?: string;
/** 容器最小高度:抽屉/页面加载态要撑出可用的落点,默认 200px */
minHeight?: number | string;
}
/**
* BrandLoader 的带容器版本:居中图标 + 文案,给页面/抽屉的加载态直接用。
*
* 全系统页面/详情加载态只用这一种(原 antd Skeleton 骨架屏的 shimmer 波浪已下线):
* - 壳层路由 fallback(BasicLayout)→ BrandLoading
* - 主壳/子应用页面内 loading → BrandLoading
* - 详情抽屉 loading → BrandLoading
* 表格数据的加载态另走 TableLoader(由 UTable/FillTable 的 resolveTableLoading 注入),
* 两者视觉同源但语义分工:BrandLoading = 整块内容还在路上,TableLoader = 表格在拉数据。
*/
export function BrandLoading({
label = '正在加载…',
size = 64,
minHeight = 200,
className,
}: BrandLoadingProps) {
return (
<div
className={`uj-brand-loading${className ? ` ${className}` : ''}`}
style={{ minHeight }}
role="status"
aria-label={label || '正在加载'}
>
<BrandLoader size={size} />
{label ? <span className="uj-brand-loading__label">{label}</span> : null}
</div>
);
}
packages/biz/src/components/SearchForm/index.tsx
View file @
e7c74a0
...
@@ -141,11 +141,11 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -141,11 +141,11 @@ export function SearchForm<T extends Record<string, unknown>>({
};
};
const primaryFields = fields.filter(isPrimary);
const primaryFields = fields.filter(isPrimary);
const extraFields = fields.filter((field) => !isPrimary(field));
const extraFields = fields.filter((field) => !isPrimary(field));
// 两个数字都按整张表算:常显条件同样是筛选条件,不能只在「更多筛选」里数。
// 同 filterGroup 归并成 1 个业务条件,countsAsFilter:false 的辅助字段不参与;
// 生效数另外排除与 initialValues 相同的默认值。
const hasExtra = extraFields.length > 0;
const hasExtra = extraFields.length > 0;
const conditionTotal = countConditions(fields);
// 「更多筛选」上标只数被收起来的条件:常显的已经看得见,不该计入。
// 口径与总数一致——同 filterGroup 归并成 1 个业务条件,countsAsFilter:false 的辅助字段不参与。
const hiddenCount = countConditions(extraFields);
// 主色「已填数」角标与悬浮卡按整张表算(含常显条件),排除与 initialValues 相同的默认值。
const activeConditions = collectActiveConditions(fields, values, formInitialValues);
const activeConditions = collectActiveConditions(fields, values, formInitialValues);
const activeFilterCount = activeConditions.length;
const activeFilterCount = activeConditions.length;
...
@@ -368,21 +368,21 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -368,21 +368,21 @@ export function SearchForm<T extends Record<string, unknown>>({
setActivePopoverOpen(false);
setActivePopoverOpen(false);
}}
}}
aria-expanded={expanded}
aria-expanded={expanded}
aria-label={`${expanded ? '收起' : '更多筛选'}:
共 ${conditionTotal} 个条件,已填写 ${activeFilterCount} 个
`}
aria-label={`${expanded ? '收起' : '更多筛选'}:
${hiddenCount} 个条件已收起,当前已填写 ${activeFilterCount} 项
`}
>
>
<span className="uj-filter-more-btn__label">
<span className="uj-filter-more-btn__label">
{expanded ? '收起' : '更多筛选'}
{expanded ? '收起' : '更多筛选'}
{/*
总数上标只在收起态出现:展开后条件都在眼前,再挂一个总数
纯属重复。
{/*
收起数上标只在收起态出现:展开后这些条件都在眼前,再挂数字
纯属重复。
主色「已填数」角标两态保留(展开态它是悬浮卡的触发区)。 */}
主色「已填数」角标两态保留(展开态它是悬浮卡的触发区)。 */}
{!expanded ? (
{!expanded ? (
<sup className="uj-filter-more-total" aria-hidden>
<sup className="uj-filter-more-total" aria-hidden>
{
conditionTotal
}
{
hiddenCount
}
</sup>
</sup>
) : null}
) : null}
</span>
</span>
{activeFilterCount > 0 ? (
{activeFilterCount > 0 ? (
<UPopover
<UPopover
// 触发区是主色实心的「已填数」角标:无背景的
总
数上标、按钮文案都不触发。
// 触发区是主色实心的「已填数」角标:无背景的
收起
数上标、按钮文案都不触发。
// 开/关由角标自己的 mouse/focus 事件控制,不给 Popover 留触发方式,
// 开/关由角标自己的 mouse/focus 事件控制,不给 Popover 留触发方式,
// 否则点击按钮也会经由 onOpenChange 把它打开。
// 否则点击按钮也会经由 onOpenChange 把它打开。
trigger={[]}
trigger={[]}
...
...
packages/biz/src/components/formSchema.ts
View file @
e7c74a0
...
@@ -42,7 +42,7 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
...
@@ -42,7 +42,7 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
*/
*/
essential
?:
boolean
;
essential
?:
boolean
;
/**
/**
* 同一个业务条件的多个字段归为一组(仅 SearchForm 的筛选条件角标计数使用,
含常显字段
)。
* 同一个业务条件的多个字段归为一组(仅 SearchForm 的筛选条件角标计数使用,
常显/收起字段都按此归并
)。
* 例如金额区间拆成 amtMin/amtMax、日期类型+区间拆成 dateType/dateValue,
* 例如金额区间拆成 amtMin/amtMax、日期类型+区间拆成 dateType/dateValue,
* 同组不论几个字段生效都只算 1 个条件。不设时按字段各自计数。
* 同组不论几个字段生效都只算 1 个条件。不设时按字段各自计数。
*/
*/
...
...
packages/biz/src/components/index.ts
View file @
e7c74a0
export
{
Logo
}
from
'./Logo'
;
export
{
Logo
}
from
'./Logo'
;
export
{
BrandLoader
}
from
'./BrandLoader'
;
export
{
BrandLoader
,
BrandLoading
}
from
'./BrandLoader'
;
export
type
{
BrandLoaderProps
}
from
'./BrandLoader'
;
export
type
{
BrandLoaderProps
,
BrandLoadingProps
}
from
'./BrandLoader'
;
export
{
StatusTag
}
from
'./StatusTag'
;
export
{
StatusTag
}
from
'./StatusTag'
;
export
{
default
as
PagePlaceholder
}
from
'./PagePlaceholder'
;
export
{
default
as
PagePlaceholder
}
from
'./PagePlaceholder'
;
export
{
PageShell
}
from
'./PageShell'
;
export
{
PageShell
}
from
'./PageShell'
;
...
...
packages/contracts/src/download-center.ts
View file @
e7c74a0
...
@@ -151,6 +151,15 @@ export const DOWNLOAD_CENTER_REGISTER_EVENT = 'uj:download-center:register';
...
@@ -151,6 +151,15 @@ export const DOWNLOAD_CENTER_REGISTER_EVENT = 'uj:download-center:register';
export
const
DOWNLOAD_CENTER_CANCEL_EVENT
=
'uj:download-center:cancel'
;
export
const
DOWNLOAD_CENTER_CANCEL_EVENT
=
'uj:download-center:cancel'
;
/**
/**
* 子应用 -> 主壳:打开一个可见的外部标签页(payload 为 URL)。
*
* 用途:非线性下载的外部页面跳转(报告、AI 分析页)也统一由主壳开标签,
* 子应用 iframe 内直接 window.open 容易被弹窗拦截,且行为与主壳预览不一致。
* 与下载任务无关:这里只开标签,不登记任务、不落盘。
*/
export
const
OPEN_EXTERNAL_EVENT
=
'uj:open-external'
;
/**
* 子应用 -> 主壳:注册一个请求通道(供下载任务的 handler 按 channel 名选用)。
* 子应用 -> 主壳:注册一个请求通道(供下载任务的 handler 按 channel 名选用)。
*
*
* payload: `{ name: string; request: RemoteRequestFn }`。函数经 wujie bus 引用传递
* payload: `{ name: string; request: RemoteRequestFn }`。函数经 wujie bus 引用传递
...
...
packages/download-center/src/DownloadCenterButton.tsx
View file @
e7c74a0
...
@@ -8,7 +8,8 @@ import {
...
@@ -8,7 +8,8 @@ import {
InfoCircleFilled,
InfoCircleFilled,
} from '@ant-design/icons';
} from '@ant-design/icons';
import { useDownloadCenterStore } from './store';
import { useDownloadCenterStore } from './store';
import { cancelTask, removeTask, redownload } from './engine';
import { cancelTask, removeTask, redownload, saveTaskAs, hasTaskFile } from './engine';
import { TaskPreviewModal } from './TaskPreviewModal';
import type { DownloadTaskStatus, DownloadTask } from './types';
import type { DownloadTaskStatus, DownloadTask } from './types';
type TaskFilter = 'all' | 'active' | 'success' | 'failed';
type TaskFilter = 'all' | 'active' | 'success' | 'failed';
...
@@ -149,12 +150,22 @@ function displaySource(t: DownloadTask): string {
...
@@ -149,12 +150,22 @@ function displaySource(t: DownloadTask): string {
return t.sourceLabel ?? SOURCE_LABELS[t.source] ?? t.source;
return t.sourceLabel ?? SOURCE_LABELS[t.source] ?? t.source;
}
}
/**
* 跨域无 CORS 的直链拿不到字节,只能打开可见标签让用户右键另存。
* 这类任务的 stage 由 deliverRemoteFile 写成「未自动保存…」,面板据此标「待另存」,
* 不能再顶着「可下载」让用户去浏览器下载记录里白找。
*/
function needsManualSave(t: DownloadTask): boolean {
return t.status === 'done' && /未自动保存|点击「另存为」/.test(t.stage ?? '');
}
/** 主壳 Header 右侧的全系统下载中心入口。 */
/** 主壳 Header 右侧的全系统下载中心入口。 */
export function DownloadCenterButton() {
export function DownloadCenterButton() {
const tasks = useDownloadCenterStore((s) => s.tasks);
const tasks = useDownloadCenterStore((s) => s.tasks);
const clearFinished = useDownloadCenterStore((s) => s.clearFinished);
const clearFinished = useDownloadCenterStore((s) => s.clearFinished);
const notice = useDownloadCenterStore((s) => s.notice);
const notice = useDownloadCenterStore((s) => s.notice);
const clearNotice = useDownloadCenterStore((s) => s.clearNotice);
const clearNotice = useDownloadCenterStore((s) => s.clearNotice);
const showPreview = useDownloadCenterStore((s) => s.showPreview);
const [filter, setFilter] = useState<TaskFilter>('all');
const [filter, setFilter] = useState<TaskFilter>('all');
const [copiedId, setCopiedId] = useState<string | null>(null);
const [copiedId, setCopiedId] = useState<string | null>(null);
const [showHelp, setShowHelp] = useState(false);
const [showHelp, setShowHelp] = useState(false);
...
@@ -179,6 +190,7 @@ export function DownloadCenterButton() {
...
@@ -179,6 +190,7 @@ export function DownloadCenterButton() {
const successCount = tasks.filter((t) => t.status === 'done').length;
const successCount = tasks.filter((t) => t.status === 'done').length;
const failedCount = tasks.filter((t) => t.status === 'failed').length;
const failedCount = tasks.filter((t) => t.status === 'failed').length;
const hasFinished = tasks.some((t) => FINISHED.has(t.status));
const hasFinished = tasks.some((t) => FINISHED.has(t.status));
const manualSaveCount = tasks.filter(needsManualSave).length;
const filteredTasks = useMemo(() => {
const filteredTasks = useMemo(() => {
if (filter === 'active') return tasks.filter((t) => IN_FLIGHT.has(t.status));
if (filter === 'active') return tasks.filter((t) => IN_FLIGHT.has(t.status));
...
@@ -235,12 +247,17 @@ export function DownloadCenterButton() {
...
@@ -235,12 +247,17 @@ export function DownloadCenterButton() {
/>
/>
</div>
</div>
{
successCount > 0
&& (
{
(successCount > 0 || manualSaveCount > 0)
&& (
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 8, lineHeight: 1.6 }}>
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 8, lineHeight: 1.6 }}>
{/* {manualSaveCount > 0 && (
<div style={{ color: '#cf1322' }}>
有 {manualSaveCount} 个任务未自动保存(标记「待另存」),请点「预览」后在画面上右键另存为。
</div>
)} */}
<div>
<div>
文件已自动下载;找不到
可按
已自动下载的文件
可按
<strong style={{ color: '#cf1322' }}> {DOWNLOAD_MANAGER_SHORTCUT} </strong>
<strong style={{ color: '#cf1322' }}> {DOWNLOAD_MANAGER_SHORTCUT} </strong>
在浏览器下载管理查看。
在浏览器下载管理查看
;也可在下方任务里点「预览 / 另存为」
。
<a
<a
onClick={() => setShowHelp((v) => !v)}
onClick={() => setShowHelp((v) => !v)}
style={{ marginLeft: 6, cursor: 'pointer', whiteSpace: 'nowrap' }}
style={{ marginLeft: 6, cursor: 'pointer', whiteSpace: 'nowrap' }}
...
@@ -251,7 +268,8 @@ export function DownloadCenterButton() {
...
@@ -251,7 +268,8 @@ export function DownloadCenterButton() {
{showHelp && (
{showHelp && (
<div style={{ marginTop: 4 }}>
<div style={{ marginTop: 4 }}>
{[
{[
'下载中心无法直接查看或获取已下载的文件。',
'带「预览 / 保存」按钮的任务可直接在面板查看或保存到本地。',
'跨域直链无法读取文件内容,面板内可直接预览,请在画面上右键另存为。',
'部分浏览器插件可能占用该快捷键,无响应可从浏览器菜单进入下载管理。',
'部分浏览器插件可能占用该快捷键,无响应可从浏览器菜单进入下载管理。',
'链接可能过期,仅作备用。',
'链接可能过期,仅作备用。',
'删除记录或「清除已完成」不会删除已下载到本地的文件。',
'删除记录或「清除已完成」不会删除已下载到本地的文件。',
...
@@ -293,8 +311,8 @@ export function DownloadCenterButton() {
...
@@ -293,8 +311,8 @@ export function DownloadCenterButton() {
>
>
{t.label}
{t.label}
</span>
</span>
<Tag color={meta.color} style={{ marginInlineEnd: 0 }}>
<Tag color={
needsManualSave(t) ? 'warning' :
meta.color} style={{ marginInlineEnd: 0 }}>
{meta.text}
{
needsManualSave(t) ? '待另存' :
meta.text}
</Tag>
</Tag>
</div>
</div>
...
@@ -328,6 +346,27 @@ export function DownloadCenterButton() {
...
@@ -328,6 +346,27 @@ export function DownloadCenterButton() {
)}
)}
{t.status === 'done' && (
{t.status === 'done' && (
<>
<>
{(hasTaskFile(t.id) || t.fileUrl) && (
<Button
type="link"
size="small"
style={{ padding: 0 }}
onClick={(e) => {
e.stopPropagation();
// 先收起面板:Popover(z-index 1030) 会盖住预览 Modal,
// 且留着面板遮挡视线。Modal 自身 zIndex 1200 也高于浮窗 1050。
setPanelOpen(false);
showPreview(t.id);
}}
>
预览
</Button>
)}
{hasTaskFile(t.id) && (
<Button type="link" size="small" style={{ padding: 0 }} onClick={(e) => { e.stopPropagation(); saveTaskAs(t.id); }}>
保存
</Button>
)}
<Button type="link" size="small" style={{ padding: 0 }} onClick={(e) => { e.stopPropagation(); redownload(t); }}>
<Button type="link" size="small" style={{ padding: 0 }} onClick={(e) => { e.stopPropagation(); redownload(t); }}>
再次下载
再次下载
</Button>
</Button>
...
@@ -401,6 +440,8 @@ export function DownloadCenterButton() {
...
@@ -401,6 +440,8 @@ export function DownloadCenterButton() {
onClick={openPanelFromToast}
onClick={openPanelFromToast}
/>
/>
)}
)}
<TaskPreviewModal />
</span>
</span>
);
);
}
}
packages/download-center/src/DownloadCenterProvider.tsx
View file @
e7c74a0
...
@@ -5,6 +5,7 @@ import {
...
@@ -5,6 +5,7 @@ import {
DOWNLOAD_CENTER_REGISTER_EVENT,
DOWNLOAD_CENTER_REGISTER_EVENT,
DOWNLOAD_CENTER_CANCEL_EVENT,
DOWNLOAD_CENTER_CANCEL_EVENT,
DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT,
DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT,
OPEN_EXTERNAL_EVENT,
} from '@uj/contracts';
} from '@uj/contracts';
import {
import {
configureDownloadCenter,
configureDownloadCenter,
...
@@ -14,6 +15,7 @@ import {
...
@@ -14,6 +15,7 @@ import {
cancelTask,
cancelTask,
} from './engine';
} from './engine';
import { registerDownload } from './register';
import { registerDownload } from './register';
import { openPreview } from './deliver';
import { useDownloadCenterStore } from './store';
import { useDownloadCenterStore } from './store';
import type { DownloadTask } from './types';
import type { DownloadTask } from './types';
...
@@ -55,9 +57,14 @@ export function DownloadCenterProvider({
...
@@ -55,9 +57,14 @@ export function DownloadCenterProvider({
registerChannel(payload.name, payload.request as RemoteRequestFn);
registerChannel(payload.name, payload.request as RemoteRequestFn);
}
}
};
};
const onOpenExternal = (...args: unknown[]) => {
const url = args[0];
if (typeof url === 'string' && url) openPreview(url);
};
bus.$on(DOWNLOAD_CENTER_REGISTER_EVENT, onRegister);
bus.$on(DOWNLOAD_CENTER_REGISTER_EVENT, onRegister);
bus.$on(DOWNLOAD_CENTER_CANCEL_EVENT, onCancel);
bus.$on(DOWNLOAD_CENTER_CANCEL_EVENT, onCancel);
bus.$on(DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT, onRegisterChannel);
bus.$on(DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT, onRegisterChannel);
bus.$on(OPEN_EXTERNAL_EVENT, onOpenExternal);
// 提示去重:按「任务的第几次尝试」去重,而不是按任务 id 永久去重。
// 提示去重:按「任务的第几次尝试」去重,而不是按任务 id 永久去重。
//
//
...
@@ -102,6 +109,12 @@ export function DownloadCenterProvider({
...
@@ -102,6 +109,12 @@ export function DownloadCenterProvider({
notifiedAt.set(t.id, t.updatedAt);
notifiedAt.set(t.id, t.updatedAt);
if (t.status === 'done') {
if (t.status === 'done') {
// preview:true 的任务(合同缩略图点开看原图等)完成后直接弹 Modal。
// silent 只压浮窗提示,不能压掉用户主动要求的预览。
if ((t.input.payload as { preview?: unknown } | null)?.preview === true) {
// 避免在 store.subscribe 回调里同步再 set,交给微任务执行。
queueMicrotask(() => useDownloadCenterStore.getState().showPreview(t.id));
}
// silent 只压「完成」类提示;失败永远要提示,不能被 silent 吞掉。
// silent 只压「完成」类提示;失败永远要提示,不能被 silent 吞掉。
if (t.input.silent) return;
if (t.input.silent) return;
// 仅异步导出(长任务、需「稍后查看」)弹完成提示;
// 仅异步导出(长任务、需「稍后查看」)弹完成提示;
...
@@ -133,6 +146,7 @@ export function DownloadCenterProvider({
...
@@ -133,6 +146,7 @@ export function DownloadCenterProvider({
bus.$off(DOWNLOAD_CENTER_REGISTER_EVENT, onRegister);
bus.$off(DOWNLOAD_CENTER_REGISTER_EVENT, onRegister);
bus.$off(DOWNLOAD_CENTER_CANCEL_EVENT, onCancel);
bus.$off(DOWNLOAD_CENTER_CANCEL_EVENT, onCancel);
bus.$off(DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT, onRegisterChannel);
bus.$off(DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT, onRegisterChannel);
bus.$off(OPEN_EXTERNAL_EVENT, onOpenExternal);
unsubscribe();
unsubscribe();
stopDownloadCenter();
stopDownloadCenter();
};
};
...
...
packages/download-center/src/TaskPreviewModal.tsx
0 → 100644
View file @
e7c74a0
import { useState } from 'react';
import { Button, Modal } from 'antd';
import { useDownloadCenterStore } from './store';
import { getTaskPreviewUrl, hasTaskFile, saveTaskAs } from './engine';
import type { DownloadTask } from './types';
type PreviewKind = 'image' | 'pdf' | 'video' | 'other';
/** 按文件名 / 地址后缀判断预览方式。content-disposition 给的名字优先于直链末段。 */
function previewKind(task: DownloadTask): PreviewKind {
const s = `${task.fileName ?? ''} ${task.fileUrl ?? ''}`.toLowerCase();
if (/\.(png|jpe?g|gif|webp|bmp|svg)(\?|$)/.test(s)) return 'image';
if (/\.pdf(\?|$)/.test(s)) return 'pdf';
if (/\.(mp4|webm|ogg|mov|m4v)(\?|$)/.test(s)) return 'video';
return 'other';
}
/** http 开发环境(非安全上下文)下 clipboard API 不可用,降级到 textarea + execCommand。 */
function copyText(text: string): void {
const native =
typeof navigator !== 'undefined' && navigator.clipboard?.writeText
? navigator.clipboard.writeText(text)
: Promise.reject(new Error('clipboard unavailable'));
native.catch(() => {
const ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
try {
document.execCommand('copy');
} finally {
ta.remove();
}
});
}
/**
* 全系统统一的预览弹窗。
*
* 有字节(probe ok / stream / blob)时用 objectURL 渲染,同源且不受原站鉴权影响;
* 没有字节(跨域无 CORS)时用原始直链渲染——浏览器允许 <img>/<iframe>/<video>
* 显示跨域资源,只是 JS 读不到字节,用户仍可在画面上右键另存。
* 不支持内联的格式(xlsx/doc/zip 等)不自动下载:弹窗只给链接与「下载文件」按钮,
* 用户主动点击才把直链挂给隐藏 iframe 触发下载/本机打开,避免看一眼就下载一次。
* 两种情形都不开新标签,不打断用户当前页面。
*/
export function TaskPreviewModal() {
const previewTaskId = useDownloadCenterStore((s) => s.previewTaskId);
const hidePreview = useDownloadCenterStore((s) => s.hidePreview);
const task = useDownloadCenterStore((s) =>
s.previewTaskId ? s.tasks.find((t) => t.id === s.previewTaskId) : undefined,
);
const [copied, setCopied] = useState(false);
// other 格式:弹窗打开时绝不自动下载。只有用户主动点「下载文件」才挂载 iframe 触发。
// state 带 taskId:切到别的任务时旧请求自动失效;关闭弹窗时清空,重开同一任务也不会再触发。
const [downloadReq, setDownloadReq] = useState<{ taskId: string; seq: number }>({ taskId: '', seq: 0 });
if (!previewTaskId || !task) return null;
// previewUrl 仅用于渲染:有字节是 blob:,无字节是直链。
// linkUrl 是真实文件地址(出口已把明文 http 升级为 https),用于展示和复制——
// 复制 blob: 粘到浏览器打不开,必须区分开。
const previewUrl = getTaskPreviewUrl(previewTaskId);
if (!previewUrl) return null;
const linkUrl = task.fileUrl;
const kind = previewKind(task);
const hasBytes = hasTaskFile(previewTaskId);
const downloadActive = downloadReq.taskId === previewTaskId && downloadReq.seq > 0;
const handleCopy = () => {
copyText(linkUrl ?? previewUrl);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
};
const handleClose = () => {
setDownloadReq({ taskId: '', seq: 0 });
setCopied(false);
hidePreview();
};
return (
<Modal
open
zIndex={1200}
title={`预览 · ${task.label}`}
width={kind === 'image' ? 720 : 860}
onCancel={handleClose}
footer={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12 }}>
<span style={{ fontSize: 12, color: '#8c8c8c', textAlign: 'left' }}>
{hasBytes
? '文件已缓存,点「保存到本地」即可保存'
: kind === 'other'
? '此格式无法在线预览,需主动点「下载文件」才会触发下载'
: '请在预览画面上右键另存为'}
</span>
<span style={{ display: 'flex', gap: 8, flexShrink: 0 }}>
{/* 复制真实文件地址(出口已升级 https),不是 blob: 预览地址。 */}
{linkUrl && <Button onClick={handleCopy}>{copied ? '已复制' : '复制地址'}</Button>}
{/* 只有确实拿到字节才显示:没有字节时 a[download] 也救不了跨域直链。 */}
{hasBytes && (
<Button type="primary" onClick={() => saveTaskAs(task.id)}>
保存到本地
</Button>
)}
<Button onClick={handleClose}>关闭</Button>
</span>
</div>
}
>
{kind === 'image' && (
<div style={{ textAlign: 'center', background: '#fafafa', padding: 12 }}>
<img
src={previewUrl}
alt={task.label}
style={{ maxWidth: '100%', maxHeight: '65vh', objectFit: 'contain' }}
/>
</div>
)}
{kind === 'pdf' && (
<iframe src={previewUrl} title={task.label} style={{ width: '100%', height: '65vh', border: 0 }} />
)}
{kind === 'video' && (
<div style={{ textAlign: 'center', background: '#fafafa', padding: 12 }}>
<video src={previewUrl} controls style={{ maxWidth: '100%', maxHeight: '65vh' }} />
</div>
)}
{kind === 'other' && !hasBytes && (
<div style={{ padding: 8 }}>
<div style={{ color: '#8c8c8c', marginBottom: 8 }}>
此格式无法在页面内渲染(xlsx / doc / zip 等)。点「下载文件」后浏览器才会下载或用本机程序打开;
仅打开预览不会下载。没反应可再点「重新下载」,或复制下方地址到浏览器地址栏。
</div>
{/* 只在用户主动点下载后才挂载 iframe:src 一挂上浏览器就会触发下载/本机打开。
打开弹窗先不渲染,避免看一眼预览就莫名下载一次。0×0 移出视口不占版面。 */}
{downloadActive && (
<iframe
key={downloadReq.seq}
src={previewUrl}
title={task.label}
aria-hidden="true"
style={{ position: 'fixed', width: 0, height: 0, border: 0, left: -9999, top: -9999 }}
/>
)}
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
<Button
type="primary"
size="small"
onClick={() => setDownloadReq({ taskId: previewTaskId, seq: downloadReq.seq + 1 })}
>
{downloadActive ? '重新下载' : '下载文件'}
</Button>
</div>
{linkUrl && (
<div
role="button"
tabIndex={0}
title="点击复制地址"
onClick={handleCopy}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') handleCopy();
}}
style={{
marginTop: 8,
padding: 10,
background: '#fafafa',
border: '1px solid #f0f0f0',
borderRadius: 4,
fontFamily: 'monospace',
fontSize: 12,
wordBreak: 'break-all',
cursor: 'pointer',
color: '#1677ff',
}}
>
{linkUrl}
</div>
)}
</div>
)}
{kind === 'other' && hasBytes && (
<div style={{ padding: 12 }}>
<div style={{ color: '#8c8c8c', lineHeight: 1.7, marginBottom: 8 }}>
此格式无法在页面内预览,但文件已完整缓存到本地。点右下角「保存到本地」即可保存,
保存位置由浏览器的下载设置决定。
</div>
{linkUrl && (
<div
role="button"
tabIndex={0}
title="点击复制地址"
onClick={handleCopy}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') handleCopy();
}}
style={{
padding: 10,
background: '#fafafa',
border: '1px solid #f0f0f0',
borderRadius: 4,
fontFamily: 'monospace',
fontSize: 12,
wordBreak: 'break-all',
cursor: 'pointer',
color: '#1677ff',
}}
>
{linkUrl}
</div>
)}
</div>
)}
{kind !== 'other' && linkUrl && (
<div
role="button"
tabIndex={0}
title="点击复制地址"
onClick={handleCopy}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') handleCopy();
}}
style={{
margin: '8px 12px 0',
padding: 10,
background: '#fafafa',
border: '1px solid #f0f0f0',
borderRadius: 4,
fontFamily: 'monospace',
fontSize: 12,
wordBreak: 'break-all',
cursor: 'pointer',
color: '#1677ff',
}}
>
{linkUrl}
</div>
)}
</Modal>
);
}
packages/download-center/src/deliver.ts
View file @
e7c74a0
import
type
{
DeliverTools
}
from
'./types'
;
import
type
{
DeliverTools
,
RemoteDelivery
}
from
'./types'
;
export
type
{
RemoteDelivery
}
from
'./types'
;
const
DEFAULT_FILENAME
=
'下载文件'
;
const
DEFAULT_FILENAME
=
'下载文件'
;
...
@@ -30,6 +32,9 @@ export function parseFileName(disposition: string, fallback = DEFAULT_FILENAME):
...
@@ -30,6 +32,9 @@ export function parseFileName(disposition: string, fallback = DEFAULT_FILENAME):
return
sanitizeFileName
(
filename
,
fallback
);
return
sanitizeFileName
(
filename
,
fallback
);
}
}
/** objectURL 延迟释放:0ms 释放会让 async 链路里的下载在浏览器消费前失效。 */
const
OBJECT_URL_TTL
=
60
_000
;
/** Blob -> <a download>。objectURL 延迟释放,确保浏览器已消费下载链接。 */
/** Blob -> <a download>。objectURL 延迟释放,确保浏览器已消费下载链接。 */
export
function
saveBlob
(
blob
:
Blob
,
fileName
:
string
):
void
{
export
function
saveBlob
(
blob
:
Blob
,
fileName
:
string
):
void
{
const
objectUrl
=
URL
.
createObjectURL
(
blob
);
const
objectUrl
=
URL
.
createObjectURL
(
blob
);
...
@@ -42,10 +47,21 @@ export function saveBlob(blob: Blob, fileName: string): void {
...
@@ -42,10 +47,21 @@ export function saveBlob(blob: Blob, fileName: string): void {
link
.
click
();
link
.
click
();
}
finally
{
}
finally
{
link
.
remove
();
link
.
remove
();
setTimeout
(()
=>
URL
.
revokeObjectURL
(
objectUrl
),
0
);
setTimeout
(()
=>
URL
.
revokeObjectURL
(
objectUrl
),
OBJECT_URL_TTL
);
}
}
}
}
/**
* 面板「另存为」:统一走 probe ok 链路已验证过的 a[download]。
*
* 不用 showSaveFilePicker 的原因:微前端沙箱 / 非安全上下文下它经常直接抛
* SecurityError 或静默不弹窗,而打开预览弹窗时已经过了用户手势窗口,
* 表现为「点了没反应」。保存位置由浏览器自身下载策略(下载前询问)决定。
*/
export
function
saveBlobAs
(
blob
:
Blob
,
fileName
:
string
):
void
{
saveBlob
(
blob
,
fileName
);
}
/** 本地回环地址没有 TLS 服务,浏览器本身也不拦,改写只会把它改坏。 */
/** 本地回环地址没有 TLS 服务,浏览器本身也不拦,改写只会把它改坏。 */
const
LOCAL_HOSTNAMES
=
new
Set
([
'localhost'
,
'127.0.0.1'
,
'::1'
]);
const
LOCAL_HOSTNAMES
=
new
Set
([
'localhost'
,
'127.0.0.1'
,
'::1'
]);
...
@@ -320,10 +336,76 @@ export function invalidDownload(payload: unknown): Error {
...
@@ -320,10 +336,76 @@ export function invalidDownload(payload: unknown): Error {
return
new
Error
(
'导出响应不是可下载的文件'
);
return
new
Error
(
'导出响应不是可下载的文件'
);
}
}
/**
* url / 异步导出共用的落地出口。
*
* 为什么统一:过去两条链路各自处理 probe 结果,opaque 一律退回 0×0 隐藏 iframe。
* 浏览器对 inline 资源(PNG / PDF)只会内联渲染,不写下载记录——用户看到任务
* 「完成 / 可下载」,磁盘和浏览器下载管理里却什么都没有,零提示。现在:
* - ok:用响应体 saveBlob 真落盘,并把 blob 交给引擎缓存;
* - opaque:只回传地址与明确 note,由主壳 Modal 内联渲染预览(跨域无 CORS 时
* JS 拿不到字节,浏览器也禁止跨源 <a download> 强制保存,这是安全边界);
* - error:抛错,由引擎落 failed 并弹失败提示。
*/
export
async
function
deliverRemoteFile
(
rawUrl
:
string
,
fallbackName
:
string
,
signal
:
AbortSignal
|
undefined
,
opts
:
{
preview
?:
boolean
;
autoDownload
?:
boolean
;
openInNewTab
?:
boolean
}
=
{},
):
Promise
<
RemoteDelivery
>
{
// HTTPS 页面里的明文 http 直链必被浏览器 Mixed Content 拦死。必须在 probe 之前
// 升级:assertDownloadableUrl 见到明文 http 会直接判失败,异步导出拿到的后端
// fileUrl(dj.dev.glsx.com.cn 等)过去就卡在这里,没有兜底。
// 升级是幂等的(https / 相对 / blob 原样返回),urlHandler 里那次升级可保留。
const
url
=
upgradeInsecureUrl
(
rawUrl
);
const
probe
=
await
probeDownloadUrl
(
url
,
fallbackName
,
signal
);
// 探测期间可能被取消(abort 会让 probe 返回 opaque 而不是抛错)。
// 必须在任何落地动作(saveBlob / 开标签)之前停下,否则取消后还弹出标签页。
if
(
signal
?.
aborted
)
throw
new
DOMException
(
'已取消'
,
'AbortError'
);
if
(
probe
.
kind
===
'error'
)
throw
new
Error
(
probe
.
message
);
if
(
probe
.
kind
===
'ok'
)
{
if
(
opts
.
preview
)
{
// 只回传字节,由主壳 Modal 渲染;不自动落盘(点缩略图是要看原图,不是下载)。
return
{
url
,
fileName
:
probe
.
fileName
,
bytes
:
probe
.
bytes
,
blob
:
probe
.
blob
,
note
:
'已打开预览'
,
openedOnly
:
false
,
};
}
if
(
opts
.
autoDownload
!==
false
)
saveBlob
(
probe
.
blob
,
probe
.
fileName
);
return
{
url
,
fileName
:
probe
.
fileName
,
bytes
:
probe
.
bytes
,
blob
:
probe
.
blob
,
note
:
'下载完成'
,
openedOnly
:
false
,
};
}
// opaque:JS 读不到字节,但浏览器允许 <img>/<iframe>/<video> 内联显示跨域资源。
// 不再开可见标签打断用户:预览统一由下载中心的 Modal 渲染,用户在画面上右键另存。
assertDownloadableUrl
(
url
);
return
{
url
,
fileName
:
fallbackName
,
note
:
opts
.
preview
?
'已获取预览地址,请在预览画面上右键另存为'
:
'文件未自动保存:请在下载中心点「预览」后右键另存为'
,
openedOnly
:
true
,
};
}
export
const
deliverTools
:
DeliverTools
=
{
export
const
deliverTools
:
DeliverTools
=
{
saveBlob
,
saveBlob
,
saveBlobAs
,
openUrl
,
openUrl
,
openPreview
,
openPreview
,
deliverRemoteFile
,
parseFileName
,
parseFileName
,
sanitizeFileName
,
sanitizeFileName
,
};
};
packages/download-center/src/engine.ts
View file @
e7c74a0
import
type
{
RemoteRequestFn
}
from
'@uj/contracts'
;
import
type
{
RemoteRequestFn
}
from
'@uj/contracts'
;
import
{
useDownloadCenterStore
}
from
'./store'
;
import
{
useDownloadCenterStore
}
from
'./store'
;
import
{
deliverTools
}
from
'./deliver'
;
import
{
deliverTools
,
saveBlobAs
}
from
'./deliver'
;
import
{
handlerOf
,
registerHandler
}
from
'./handlers/registry'
;
import
{
handlerOf
,
registerHandler
}
from
'./handlers/registry'
;
import
{
registerBuiltinHandlers
}
from
'./handlers/builtin'
;
import
{
registerBuiltinHandlers
}
from
'./handlers/builtin'
;
import
type
{
DownloadContext
,
DownloadHandler
,
DownloadTask
}
from
'./types'
;
import
type
{
DownloadContext
,
DownloadHandler
,
DownloadTask
}
from
'./types'
;
...
@@ -16,6 +16,13 @@ let concurrency = DEFAULT_CONCURRENCY;
...
@@ -16,6 +16,13 @@ let concurrency = DEFAULT_CONCURRENCY;
const
channels
=
new
Map
<
string
,
RemoteRequestFn
>
();
const
channels
=
new
Map
<
string
,
RemoteRequestFn
>
();
/** 正在执行的任务 -> 可中止控制器。用于并发计数、取消、登出清理。 */
/** 正在执行的任务 -> 可中止控制器。用于并发计数、取消、登出清理。 */
const
controllers
=
new
Map
<
string
,
AbortController
>
();
const
controllers
=
new
Map
<
string
,
AbortController
>
();
/**
* 已完成任务的字节缓存(仅内存,不进 localStorage)。
* probe ok 时 handler 会回传 blob,面板据此提供真正的「预览 / 另存为」;
* 跨域无 CORS 的任务没有 blob,按钮退化为开可见标签让用户右键另存。
* objectUrl 只在首次预览时生成并复用,避免每次点击都泄漏一个 URL。
*/
const
taskFiles
=
new
Map
<
string
,
{
blob
:
Blob
;
fileName
:
string
;
objectUrl
?:
string
}
>
();
/** 主壳启动时注入请求能力;同时注册内置下载方式与可选自定义方式。 */
/** 主壳启动时注入请求能力;同时注册内置下载方式与可选自定义方式。 */
export
function
configureDownloadCenter
(
opts
:
{
export
function
configureDownloadCenter
(
opts
:
{
...
@@ -110,9 +117,20 @@ async function runOne(task: DownloadTask): Promise<void> {
...
@@ -110,9 +117,20 @@ async function runOne(task: DownloadTask): Promise<void> {
try
{
try
{
const
result
=
await
handler
.
execute
(
task
,
ctx
);
const
result
=
await
handler
.
execute
(
task
,
ctx
);
if
(
ctx
.
isCanceled
())
return
;
if
(
ctx
.
isCanceled
())
return
;
// 先缓存字节再落 done:React 在 patch 后重渲染,此时 hasTaskFile 必须已经是 true。
if
(
result
.
blob
)
{
taskFiles
.
set
(
task
.
id
,
{
blob
:
result
.
blob
,
fileName
:
result
.
fileName
??
task
.
fileName
??
task
.
label
,
});
}
else
{
taskFiles
.
delete
(
task
.
id
);
}
useDownloadCenterStore
.
getState
().
patch
(
task
.
id
,
{
useDownloadCenterStore
.
getState
().
patch
(
task
.
id
,
{
status
:
'done'
,
status
:
'done'
,
stage
:
'完成'
,
// 用 handler 的 note 取代笼统的「完成」:opaque 分支靠它告诉用户
// 「未自动保存,请在标签页中右键另存为」,不再制造「可下载」的假象。
stage
:
result
.
note
??
'完成'
,
progress
:
100
,
progress
:
100
,
fileName
:
result
.
fileName
??
task
.
fileName
,
fileName
:
result
.
fileName
??
task
.
fileName
,
fileUrl
:
result
.
fileUrl
,
fileUrl
:
result
.
fileUrl
,
...
@@ -178,6 +196,11 @@ export function stopDownloadCenter(opts?: { markCanceled?: boolean }): void {
...
@@ -178,6 +196,11 @@ export function stopDownloadCenter(opts?: { markCanceled?: boolean }): void {
controllers
.
forEach
((
c
)
=>
c
.
abort
());
controllers
.
forEach
((
c
)
=>
c
.
abort
());
controllers
.
clear
();
controllers
.
clear
();
if
(
!
opts
?.
markCanceled
)
return
;
if
(
!
opts
?.
markCanceled
)
return
;
// 登出:字节缓存可能属于上一个账号,连同 objectURL 一起丢弃。
taskFiles
.
forEach
((
f
)
=>
{
if
(
f
.
objectUrl
)
URL
.
revokeObjectURL
(
f
.
objectUrl
);
});
taskFiles
.
clear
();
const
store
=
useDownloadCenterStore
.
getState
();
const
store
=
useDownloadCenterStore
.
getState
();
store
.
tasks
.
forEach
((
t
)
=>
{
store
.
tasks
.
forEach
((
t
)
=>
{
if
(
t
.
status
===
'waiting'
||
t
.
status
===
'running'
)
{
if
(
t
.
status
===
'waiting'
||
t
.
status
===
'running'
)
{
...
@@ -198,9 +221,44 @@ export function cancelTask(id: string): void {
...
@@ -198,9 +221,44 @@ export function cancelTask(id: string): void {
*/
*/
export
function
removeTask
(
id
:
string
):
void
{
export
function
removeTask
(
id
:
string
):
void
{
controllers
.
get
(
id
)?.
abort
();
controllers
.
get
(
id
)?.
abort
();
forgetFile
(
id
);
useDownloadCenterStore
.
getState
().
remove
(
id
);
useDownloadCenterStore
.
getState
().
remove
(
id
);
}
}
function
forgetFile
(
id
:
string
):
void
{
const
cached
=
taskFiles
.
get
(
id
);
if
(
cached
?.
objectUrl
)
URL
.
revokeObjectURL
(
cached
.
objectUrl
);
taskFiles
.
delete
(
id
);
}
/** 面板按钮显示条件:缓存里有字节(probe ok / stream / blob 类)。 */
export
function
hasTaskFile
(
taskId
:
string
):
boolean
{
return
taskFiles
.
has
(
taskId
);
}
/**
* 取预览地址:有字节用 objectURL(同源、不受原站鉴权与 CORS 影响),
* 否则退回原始直链。只返回 URL,不打开任何新标签——渲染交给 TaskPreviewModal。
*/
export
function
getTaskPreviewUrl
(
taskId
:
string
):
string
|
undefined
{
const
cached
=
taskFiles
.
get
(
taskId
);
if
(
cached
)
{
if
(
!
cached
.
objectUrl
)
cached
.
objectUrl
=
URL
.
createObjectURL
(
cached
.
blob
);
return
cached
.
objectUrl
;
}
const
task
=
useDownloadCenterStore
.
getState
().
tasks
.
find
((
t
)
=>
t
.
id
===
taskId
);
return
task
?.
fileUrl
;
}
/**
* 面板「另存为」:有字节走 showSaveFilePicker 让用户选位置(不支持则回退 a[download])。
* 没有字节时由 Modal 提示用户右键另存,这里不开标签也不做无意义的跳转。
*/
export
function
saveTaskAs
(
taskId
:
string
):
void
{
const
cached
=
taskFiles
.
get
(
taskId
);
if
(
cached
)
saveBlobAs
(
cached
.
blob
,
cached
.
fileName
);
}
/**
/**
* 面板「再次下载」:统一重新登记同类任务、走 handler 完整重跑一遍。
* 面板「再次下载」:统一重新登记同类任务、走 handler 完整重跑一遍。
*
*
...
...
packages/download-center/src/handlers/asyncExport.ts
View file @
e7c74a0
...
@@ -309,8 +309,21 @@ export const asyncExportHandler: DownloadHandler = {
...
@@ -309,8 +309,21 @@ export const asyncExportHandler: DownloadHandler = {
);
);
}
}
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
openUrl
(
fileUrl
);
// 与 url 直链共用落地出口:拿到 fileUrl 后先探测再保存,inline 的 PDF / 图片
return
{
fileUrl
,
fileName
,
note
:
'导出完成'
};
// 不再只在 0×0 隐藏 iframe 里渲染;明文 http 在出口统一升级为 https(否则
// HTTPS 主壳下直接被 Mixed Content 拦死);拿不到字节(跨域无 CORS)时走
// opaque 兜底,并把「未自动保存」写进 stage,不再误报「完成」。
const
delivery
=
await
ctx
.
deliver
.
deliverRemoteFile
(
fileUrl
,
fileName
,
ctx
.
signal
,
{
autoDownload
:
task
.
input
.
autoDownload
,
});
if
(
ctx
.
isCanceled
())
throw
new
DOMException
(
'已取消'
,
'AbortError'
);
return
{
fileUrl
:
delivery
.
url
,
fileName
:
delivery
.
fileName
,
bytes
:
delivery
.
bytes
,
blob
:
delivery
.
blob
,
note
:
delivery
.
note
,
};
}
}
if
(
status
===
2
)
{
if
(
status
===
2
)
{
throw
new
Error
(
buildFailError
(
info
,
envelope
,
uuid
,
'后端生成文件失败'
));
throw
new
Error
(
buildFailError
(
info
,
envelope
,
uuid
,
'后端生成文件失败'
));
...
...
packages/download-center/src/handlers/simple.ts
View file @
e7c74a0
...
@@ -5,12 +5,7 @@ import type {
...
@@ -5,12 +5,7 @@ import type {
DownloadResult
,
DownloadResult
,
UrlPayload
,
UrlPayload
,
}
from
'../types'
;
}
from
'../types'
;
import
{
import
{
blobFromBase64
,
upgradeInsecureUrl
}
from
'../deliver'
;
assertDownloadableUrl
,
blobFromBase64
,
probeDownloadUrl
,
upgradeInsecureUrl
,
}
from
'../deliver'
;
/** 从 URL 路径末段推断文件名(预签名 URL 的 query 不参与)。 */
/** 从 URL 路径末段推断文件名(预签名 URL 的 query 不参与)。 */
function
fileNameFromUrl
(
url
:
string
):
string
{
function
fileNameFromUrl
(
url
:
string
):
string
{
...
@@ -32,51 +27,27 @@ export const urlHandler: DownloadHandler = {
...
@@ -32,51 +27,27 @@ export const urlHandler: DownloadHandler = {
async
execute
(
task
,
ctx
):
Promise
<
DownloadResult
>
{
async
execute
(
task
,
ctx
):
Promise
<
DownloadResult
>
{
const
payload
=
task
.
input
.
payload
as
UrlPayload
;
const
payload
=
task
.
input
.
payload
as
UrlPayload
;
if
(
!
payload
?.
url
)
throw
new
Error
(
'URL 下载缺少 url'
);
if
(
!
payload
?.
url
)
throw
new
Error
(
'URL 下载缺少 url'
);
// 后端历史数据里还有明文 http 直链(典型是付款回单
// 明文 http 直链(付款回单 http://qcimg01.glsx.com.cn:7060/...)在 HTTPS 主壳下
// http://qcimg01.glsx.com.cn:7060/group1/...)。主壳是 HTTPS,原样交给浏览器
// 必被 Mixed Content 拦死。这里先升级一次用于从路径推文件名;真正的协议兜底在
// 必被 Mixed Content 拦死,过去只能整条链路报失败。入口统一升级协议并去掉
// deliverRemoteFile 出口统一做(异步导出也走那里),入口这步是幂等的。
// 原 HTTP 业务端口,业务页(finance 列表页 / 详情抽屉)不用各自处理。
const
url
=
upgradeInsecureUrl
(
payload
.
url
);
const
url
=
upgradeInsecureUrl
(
payload
.
url
);
const
fileName
=
task
.
input
.
fileName
??
fileNameFromUrl
(
url
);
const
fileName
=
task
.
input
.
fileName
??
fileNameFromUrl
(
url
);
// 先 fetch 探测:同源 / 带 CORS 的直链能读到 HTTP 状态与响应体,
// 探测 + 落地统一走 deliverRemoteFile:ok 用响应体真落盘并回传字节;
// 过去 iframe 读不到的「请求资源不存在」(404 或 200+JSON 业务错误)
// opaque 走弹窗预览(不再用 0×0 隐藏 iframe 静默吞掉 inline 图片);
// 现在会走 error 分支抛错,由引擎落 failed 并触发失败通知。
// error 抛错由引擎落 failed。取消与落地顺序也由它统一保证。
const
probe
=
await
probeDownloadUrl
(
url
,
fileName
,
ctx
.
signal
);
const
delivery
=
await
ctx
.
deliver
.
deliverRemoteFile
(
url
,
fileName
,
ctx
.
signal
,
{
// 探测期间任务可能被取消(signal abort 会让 probe 返回 opaque 而非抛错)。
preview
:
payload
.
preview
,
// 这里主动抛 AbortError,交回引擎按「已取消」落状态,避免取消后仍继续下载。
autoDownload
:
task
.
input
.
autoDownload
,
openInNewTab
:
payload
.
openInNewTab
,
});
if
(
ctx
.
isCanceled
())
throw
new
DOMException
(
'已取消'
,
'AbortError'
);
if
(
ctx
.
isCanceled
())
throw
new
DOMException
(
'已取消'
,
'AbortError'
);
if
(
probe
.
kind
===
'error'
)
throw
new
Error
(
probe
.
message
);
if
(
probe
.
kind
===
'ok'
)
{
if
(
payload
.
preview
)
{
ctx
.
deliver
.
openPreview
(
url
);
return
{
fileUrl
:
url
,
fileName
:
probe
.
fileName
,
bytes
:
probe
.
bytes
,
note
:
'已打开预览'
};
}
// 探测成功即直接用响应体落盘,不再重复发一次 iframe 请求。
if
(
task
.
input
.
autoDownload
!==
false
)
{
ctx
.
deliver
.
saveBlob
(
probe
.
blob
,
probe
.
fileName
);
}
return
{
fileUrl
:
url
,
fileName
:
probe
.
fileName
,
bytes
:
probe
.
bytes
,
note
:
'下载完成'
,
};
}
// opaque:跨域无 CORS 的 OSS 预签名地址,无法探测,退回原 iframe 行为。
// 这类地址的加载失败浏览器不让 JS 感知,是既定限制,不能因此误判为失败。
assertDownloadableUrl
(
url
);
if
(
payload
.
preview
)
{
ctx
.
deliver
.
openPreview
(
url
);
}
else
if
(
task
.
input
.
autoDownload
!==
false
)
{
ctx
.
deliver
.
openUrl
(
url
,
payload
.
openInNewTab
??
true
);
}
return
{
return
{
fileUrl
:
url
,
fileUrl
:
delivery
.
url
,
fileName
,
fileName
:
delivery
.
fileName
,
note
:
payload
.
preview
?
'已打开预览'
:
'已打开下载地址'
,
bytes
:
delivery
.
bytes
,
blob
:
delivery
.
blob
,
note
:
delivery
.
note
,
};
};
},
},
};
};
...
@@ -89,7 +60,7 @@ export const blobHandler: DownloadHandler = {
...
@@ -89,7 +60,7 @@ export const blobHandler: DownloadHandler = {
if
(
!
(
payload
?.
blob
instanceof
Blob
))
throw
new
Error
(
'Blob 下载缺少有效 blob'
);
if
(
!
(
payload
?.
blob
instanceof
Blob
))
throw
new
Error
(
'Blob 下载缺少有效 blob'
);
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
payload
.
blob
,
fileName
);
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
payload
.
blob
,
fileName
);
return
{
fileName
,
bytes
:
payload
.
blob
.
size
,
note
:
'下载完成'
};
return
{
fileName
,
bytes
:
payload
.
blob
.
size
,
note
:
'下载完成'
,
blob
:
payload
.
blob
};
},
},
};
};
...
@@ -102,7 +73,7 @@ export const base64Handler: DownloadHandler = {
...
@@ -102,7 +73,7 @@ export const base64Handler: DownloadHandler = {
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
const
fileName
=
task
.
input
.
fileName
??
task
.
label
;
const
blob
=
blobFromBase64
(
payload
.
base64
,
payload
.
mime
??
'application/octet-stream'
);
const
blob
=
blobFromBase64
(
payload
.
base64
,
payload
.
mime
??
'application/octet-stream'
);
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
blob
,
fileName
);
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
blob
,
fileName
);
return
{
fileName
,
bytes
:
blob
.
size
,
note
:
'下载完成'
};
return
{
fileName
,
bytes
:
blob
.
size
,
note
:
'下载完成'
,
blob
};
},
},
};
};
...
...
packages/download-center/src/handlers/stream.ts
View file @
e7c74a0
...
@@ -69,6 +69,6 @@ export const streamHandler: DownloadHandler = {
...
@@ -69,6 +69,6 @@ export const streamHandler: DownloadHandler = {
ctx
.
report
({
stage
:
'正在保存文件'
});
ctx
.
report
({
stage
:
'正在保存文件'
});
const
blob
=
blobFromArrayBuffer
(
body
,
mime
);
const
blob
=
blobFromArrayBuffer
(
body
,
mime
);
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
blob
,
fileName
);
if
(
task
.
input
.
autoDownload
!==
false
)
ctx
.
deliver
.
saveBlob
(
blob
,
fileName
);
return
{
fileName
,
bytes
:
blob
.
size
,
note
:
'下载完成'
};
return
{
fileName
,
bytes
:
blob
.
size
,
note
:
'下载完成'
,
blob
};
},
},
};
};
packages/download-center/src/index.ts
View file @
e7c74a0
...
@@ -30,6 +30,7 @@ export type {
...
@@ -30,6 +30,7 @@ export type {
DownloadContext
,
DownloadContext
,
DownloadResult
,
DownloadResult
,
DeliverTools
,
DeliverTools
,
RemoteDelivery
,
ExportQueryItem
,
ExportQueryItem
,
ExportQueryEnvelope
,
ExportQueryEnvelope
,
}
from
'./types'
;
}
from
'./types'
;
...
@@ -43,6 +44,9 @@ export {
...
@@ -43,6 +44,9 @@ export {
stopDownloadCenter
,
stopDownloadCenter
,
cancelTask
,
cancelTask
,
redownload
,
redownload
,
getTaskPreviewUrl
,
saveTaskAs
,
hasTaskFile
,
}
from
'./engine'
;
}
from
'./engine'
;
export
{
export
{
registerHandler
,
registerHandler
,
...
@@ -56,7 +60,10 @@ export { streamHandler } from './handlers/stream';
...
@@ -56,7 +60,10 @@ export { streamHandler } from './handlers/stream';
export
{
urlHandler
,
blobHandler
,
base64Handler
}
from
'./handlers/simple'
;
export
{
urlHandler
,
blobHandler
,
base64Handler
}
from
'./handlers/simple'
;
export
{
export
{
saveBlob
,
saveBlob
,
saveBlobAs
,
openUrl
,
openUrl
,
openPreview
,
deliverRemoteFile
,
parseFileName
,
parseFileName
,
sanitizeFileName
,
sanitizeFileName
,
blobFromArrayBuffer
,
blobFromArrayBuffer
,
...
@@ -66,4 +73,5 @@ export {
...
@@ -66,4 +73,5 @@ export {
}
from
'./deliver'
;
}
from
'./deliver'
;
export
{
registerDownload
,
registerExportTask
}
from
'./register'
;
export
{
registerDownload
,
registerExportTask
}
from
'./register'
;
export
{
DownloadCenterButton
}
from
'./DownloadCenterButton'
;
export
{
DownloadCenterButton
}
from
'./DownloadCenterButton'
;
export
{
TaskPreviewModal
}
from
'./TaskPreviewModal'
;
export
{
DownloadCenterProvider
}
from
'./DownloadCenterProvider'
;
export
{
DownloadCenterProvider
}
from
'./DownloadCenterProvider'
;
packages/download-center/src/store.ts
View file @
e7c74a0
...
@@ -89,6 +89,12 @@ interface DownloadCenterState {
...
@@ -89,6 +89,12 @@ interface DownloadCenterState {
notice
:
DownloadNotice
|
null
;
notice
:
DownloadNotice
|
null
;
/** 最近一次登记(用户点导出/下载)的时间戳:驱动图标短时反馈动画,与任务状态解耦。 */
/** 最近一次登记(用户点导出/下载)的时间戳:驱动图标短时反馈动画,与任务状态解耦。 */
lastRegisterAt
:
number
;
lastRegisterAt
:
number
;
/** 当前预览的任务 id。Modal 由 DownloadCenterButton 渲染,不持久化。 */
previewTaskId
:
string
|
null
;
/** 打开预览弹窗。 */
showPreview
:
(
id
:
string
)
=>
void
;
/** 关闭预览弹窗。 */
hidePreview
:
()
=>
void
;
/** 推送一条浮窗提示。 */
/** 推送一条浮窗提示。 */
pushNotice
:
(
notice
:
Omit
<
DownloadNotice
,
'seq'
>
)
=>
void
;
pushNotice
:
(
notice
:
Omit
<
DownloadNotice
,
'seq'
>
)
=>
void
;
/** 清掉指定序号的提示;seq 不匹配时不动,避免旧 timer 关掉后来的新提示。 */
/** 清掉指定序号的提示;seq 不匹配时不动,避免旧 timer 关掉后来的新提示。 */
...
@@ -114,6 +120,10 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
...
@@ -114,6 +120,10 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
tasks
:
loadPersisted
(),
tasks
:
loadPersisted
(),
notice
:
null
,
notice
:
null
,
lastRegisterAt
:
0
,
lastRegisterAt
:
0
,
previewTaskId
:
null
,
showPreview
:
(
id
)
=>
set
({
previewTaskId
:
id
}),
hidePreview
:
()
=>
set
({
previewTaskId
:
null
}),
pushNotice
:
(
notice
)
=>
set
({
notice
:
{
...
notice
,
seq
:
++
noticeSeq
}
}),
pushNotice
:
(
notice
)
=>
set
({
notice
:
{
...
notice
,
seq
:
++
noticeSeq
}
}),
...
@@ -161,7 +171,11 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
...
@@ -161,7 +171,11 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
),
),
),
),
remove
:
(
id
)
=>
set
((
s
)
=>
write
(
s
.
tasks
.
filter
((
t
)
=>
t
.
id
!==
id
))),
remove
:
(
id
)
=>
set
((
s
)
=>
({
...
write
(
s
.
tasks
.
filter
((
t
)
=>
t
.
id
!==
id
)),
...(
s
.
previewTaskId
===
id
?
{
previewTaskId
:
null
}
:
{}),
})),
cancel
:
(
id
)
=>
cancel
:
(
id
)
=>
set
((
s
)
=>
set
((
s
)
=>
...
@@ -175,6 +189,13 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
...
@@ -175,6 +189,13 @@ export const useDownloadCenterStore = create<DownloadCenterState>((set, get) =>
),
),
clearFinished
:
()
=>
clearFinished
:
()
=>
set
((
s
)
=>
write
(
s
.
tasks
.
filter
((
t
)
=>
!
FINISHED
.
includes
(
t
.
status
)))),
set
((
s
)
=>
{
const
next
=
write
(
s
.
tasks
.
filter
((
t
)
=>
!
FINISHED
.
includes
(
t
.
status
)));
// 预览中的任务被清掉时一并关窗,避免 Modal 显示一条已不存在的记录。
const
previewing
=
s
.
tasks
.
find
((
t
)
=>
t
.
id
===
s
.
previewTaskId
);
return
previewing
&&
FINISHED
.
includes
(
previewing
.
status
)
?
{
...
next
,
previewTaskId
:
null
}
:
next
;
}),
};
};
});
});
packages/download-center/src/types.ts
View file @
e7c74a0
...
@@ -24,16 +24,39 @@ export type {
...
@@ -24,16 +24,39 @@ export type {
export
interface
DeliverTools
{
export
interface
DeliverTools
{
/** Blob -> <a download>(含 objectURL 释放)。 */
/** Blob -> <a download>(含 objectURL 释放)。 */
saveBlob
(
blob
:
Blob
,
fileName
:
string
):
void
;
saveBlob
(
blob
:
Blob
,
fileName
:
string
):
void
;
/** Blob -> 用户选择位置保存(统一走 a[download],避免沙箱下手势丢失)。 */
saveBlobAs
(
blob
:
Blob
,
fileName
:
string
):
void
;
/** 打开自带鉴权的 URL(新标签页,避免主壳被导航走)。 */
/** 打开自带鉴权的 URL(新标签页,避免主壳被导航走)。 */
openUrl
(
url
:
string
,
openInNewTab
?:
boolean
):
void
;
openUrl
(
url
:
string
,
openInNewTab
?:
boolean
):
void
;
/** 可见新标签预览:与 openUrl 的隐藏 iframe 落盘不同,只给用户看,不触发下载。 */
/** 可见新标签预览:与 openUrl 的隐藏 iframe 落盘不同,只给用户看,不触发下载。 */
openPreview
(
url
:
string
):
void
;
openPreview
(
url
:
string
):
void
;
/**
* 远程 URL 统一落地:可探测则 saveBlob + 回传字节;不可探测则开可见标签并给出
* 明确 note,不再静默「完成」但磁盘上没文件。
*/
deliverRemoteFile
(
url
:
string
,
fallbackName
:
string
,
signal
:
AbortSignal
|
undefined
,
opts
?:
{
preview
?:
boolean
;
autoDownload
?:
boolean
;
openInNewTab
?:
boolean
},
):
Promise
<
RemoteDelivery
>
;
/** 从 content-disposition 解析并清洗文件名。 */
/** 从 content-disposition 解析并清洗文件名。 */
parseFileName
(
disposition
:
string
,
fallback
:
string
):
string
;
parseFileName
(
disposition
:
string
,
fallback
:
string
):
string
;
/** 清洗文件名中的非法字符与 C0 控制字符。 */
/** 清洗文件名中的非法字符与 C0 控制字符。 */
sanitizeFileName
(
name
:
string
,
fallback
?:
string
):
string
;
sanitizeFileName
(
name
:
string
,
fallback
?:
string
):
string
;
}
}
/** deliverRemoteFile 的返回,单独导出供类型引用。 */
export
interface
RemoteDelivery
{
/** 实际访问的下载地址(明文 http 已升级为 https,回写给任务供弹窗展示 / 复制)。 */
url
:
string
;
fileName
:
string
;
bytes
?:
number
;
blob
?:
Blob
;
note
:
string
;
openedOnly
:
boolean
;
}
/** handler 执行完交给统一层的结果(用于面板展示与「再次下载」)。 */
/** handler 执行完交给统一层的结果(用于面板展示与「再次下载」)。 */
export
interface
DownloadResult
{
export
interface
DownloadResult
{
/** 最终文件名。 */
/** 最终文件名。 */
...
@@ -42,7 +65,9 @@ export interface DownloadResult {
...
@@ -42,7 +65,9 @@ export interface DownloadResult {
fileUrl
?:
string
;
fileUrl
?:
string
;
/** 字节数(stream / blob 类,用于面板展示)。 */
/** 字节数(stream / blob 类,用于面板展示)。 */
bytes
?:
number
;
bytes
?:
number
;
/** 附加说明。 */
/** 实际拿到的文件字节(probe ok 时由 deliverRemoteFile 回传),引擎按 taskId 缓存供预览 / 另存为。 */
blob
?:
Blob
;
/** 附加说明。引擎写入 stage,面板直接展示——opaque 分支靠它告诉用户「未自动保存,请右键另存为」。 */
note
?:
string
;
note
?:
string
;
}
}
...
...
packages/platform-core/src/access/backend/adapter.ts
View file @
e7c74a0
...
@@ -21,22 +21,7 @@ function toFrontendPoint(code: string): string {
...
@@ -21,22 +21,7 @@ function toFrontendPoint(code: string): string {
/* ---------------- 菜单树:后端 /system/menu/tree/current → 前端菜单结构 ---------------- */
/* ---------------- 菜单树:后端 /system/menu/tree/current → 前端菜单结构 ---------------- */
/**
/** 前端菜单项(path/label/icon 供渲染,resource 供面包屑等派生用途) */
* 仅开发构建打印菜单诊断。platform-core 也会被测试/脚本等非 Vite 环境导入,
* 用可选链读 import.meta.env,避免 env 未注入时直接抛错。
*/
const
IS_DEV
=
(()
=>
{
try
{
return
Boolean
((
import
.
meta
as
unknown
as
{
env
?:
{
DEV
?:
boolean
}
}).
env
?.
DEV
);
}
catch
{
return
false
;
}
})();
/** 「分组 + 缺失码集合」为 key,权限点变化后能重新提示,同时避免每次 buildMenus 都刷屏。 */
const
warnedDroppedGroups
=
new
Set
<
string
>
();
/** 前端菜单项(path/label/icon 供渲染,resource 供权限与面包屑) */
export
interface
MenuItemDef
{
export
interface
MenuItemDef
{
path
:
string
;
path
:
string
;
label
:
string
;
label
:
string
;
...
@@ -75,7 +60,9 @@ export interface MenuGroupDef {
...
@@ -75,7 +60,9 @@ export interface MenuGroupDef {
* - status !== 1(停用)的节点丢弃。
* - status !== 1(停用)的节点丢弃。
* - path 与 icon 直接取自后端下发的 node.route / node.icon,前端不再做映射。
* - path 与 icon 直接取自后端下发的 node.route / node.icon,前端不再做映射。
* 一级(分组)图标取 nodeType=1 节点自己的 icon,与二级同用一套图标名。
* 一级(分组)图标取 nodeType=1 节点自己的 icon,与二级同用一套图标名。
* - permCode 与当前账号持有的权限点取交集(/current 后端已按角色过滤,这里作双保险再过滤一次)。
* - 菜单可见性完全由后端 /current 决定:后端已按当前登录角色装配好菜单树,前端原样渲染,
* 不再拿登录返回的 permCodes 做交集(双保险)。曾因两个接口口径不一致,树里有页面但
* permCodes 缺对应 :view 码,页面被这里静默丢弃、整组连标题都不渲染且零日志。
* - node.route 缺失 → 跳过并告警(点了会 404,不应渲染)。
* - node.route 缺失 → 跳过并告警(点了会 404,不应渲染)。
* - 分组/页面均按 sort 升序。
* - 分组/页面均按 sort 升序。
*
*
...
@@ -85,10 +72,8 @@ export interface MenuGroupDef {
...
@@ -85,10 +72,8 @@ export interface MenuGroupDef {
*/
*/
export
function
buildMenus
(
export
function
buildMenus
(
tree
:
MenuNode
[],
tree
:
MenuNode
[],
owned
:
Iterable
<
string
>
,
pathByResource
?:
ReadonlyMap
<
string
,
string
>
,
pathByResource
?:
ReadonlyMap
<
string
,
string
>
,
):
MenuGroupDef
[]
{
):
MenuGroupDef
[]
{
const
points
=
new
Set
(
owned
);
const
groups
:
MenuGroupDef
[]
=
[];
const
groups
:
MenuGroupDef
[]
=
[];
// 先统计 route 复用情况(只统计会进菜单的节点)
// 先统计 route 复用情况(只统计会进菜单的节点)
...
@@ -112,17 +97,15 @@ export function buildMenus(
...
@@ -112,17 +97,15 @@ export function buildMenus(
.
sort
((
a
,
b
)
=>
a
.
sort
-
b
.
sort
);
.
sort
((
a
,
b
)
=>
a
.
sort
-
b
.
sort
);
pages
.
forEach
((
n
)
=>
{
pages
.
forEach
((
n
)
=>
{
const
code
=
n
.
permCode
;
const
code
=
n
.
permCode
;
if
(
!
code
)
return
;
// 归一为前端点号后与权限点集合比较(points 已是归一后的点号形态)
const
point
=
toFrontendPoint
(
code
);
if
(
!
points
.
has
(
point
))
return
;
// 路由由后端树直接下发;缺失则跳过(不应渲染一个点了会 404 的菜单项)
// 路由由后端树直接下发;缺失则跳过(不应渲染一个点了会 404 的菜单项)
if
(
!
n
.
route
)
{
if
(
!
n
.
route
)
{
console
.
warn
(
`[menu] 后端菜单「
${
n
.
label
}
」(
${
code
}
) 未下发 route,已跳过`
);
console
.
warn
(
`[menu] 后端菜单「
${
n
.
label
}
」(
${
code
??
'无权限码'
})
未下发
route
,已跳过
`);
return;
return;
}
}
// resource 仅用于 route 复用时的路径兜底,与显隐无关;无 permCode 也照常渲染。
const point = code ? toFrontendPoint(code) : '';
const i = point.lastIndexOf(':');
const i = point.lastIndexOf(':');
const
resource
=
(
i
>
0
?
point
.
slice
(
0
,
i
)
:
point
)
as
ResourceKey
;
const resource =
point ? ((i > 0 ? point.slice(0, i) : point) as ResourceKey) : undefined
;
let path = n.route;
let path = n.route;
const uses = routeUses.get(path) ?? 0;
const uses = routeUses.get(path) ?? 0;
if (uses > 1) {
if (uses > 1) {
...
@@ -138,32 +121,6 @@ export function buildMenus(
...
@@ -138,32 +121,6 @@ export function buildMenus(
children.push({ path, label: n.label, icon: n.icon ?? null, resource });
children.push({ path, label: n.label, icon: n.icon ?? null, resource });
});
});
// 整组被丢弃时点名原因。此前是静默 return:后端菜单树明明下发了分组,
// 侧边栏却连一级标题都没有,且控制台零输出,排查只能靠猜。
if
(
!
children
.
length
&&
pages
.
length
)
{
const
missing
=
pages
.
filter
((
n
)
=>
!!
n
.
permCode
&&
!
points
.
has
(
n
.
permCode
))
.
map
((
n
)
=>
`
${
n
.
label
}
→
${
n
.
permCode
}
`
);
if
(
missing
.
length
&&
IS_DEV
)
{
const
key
=
`
${
g
.
label
}
|
${
missing
.
join
(
'|'
)}
`
;
if
(
!
warnedDroppedGroups
.
has
(
key
))
{
warnedDroppedGroups
.
add
(
key
);
const
prefix
=
String
(
pages
[
0
]?.
permCode
??
''
)
.
split
(
':'
)
.
slice
(
0
,
2
)
.
join
(
':'
);
const
related
=
prefix
?
[...
points
].
filter
((
p
)
=>
p
.
startsWith
(
prefix
))
:
[];
console
.
warn
(
`[menu] 分组「
${
g
.
label
}
」整组未渲染:
${
missing
.
length
}
/
${
pages
.
length
}
个页面的 permCode 不在当前登录态 permCodes 中。\n`
+
` 缺失:
${
missing
.
join
(
'、'
)}
\n`
+
` permCodes 中
${
prefix
}
前缀的码:
${
related
.
length
?
related
.
join
(
'、'
)
:
'(无)'
}
\n`
+
' 原因:/system/menu/tree/current 与 /system/auth/login|info 的 permCodes 口径不同'
+
'(后者按 sys_role_menu 关联聚合),或权限码缓存未刷新。\n'
+
' 处理:补齐 sys_role_menu 授权 → POST /system/auth/perm/refresh → 退出重登(刷新 auth.info() 缓存)。'
,
);
}
}
}
if (children.length) groups.push({ group: g.label, icon: g.icon ?? null, children });
if (children.length) groups.push({ group: g.label, icon: g.icon ?? null, children });
});
});
...
...
packages/platform-core/src/api/modules/menu.ts
View file @
e7c74a0
...
@@ -32,21 +32,15 @@ export interface MenuNode {
...
@@ -32,21 +32,15 @@ export interface MenuNode {
class
Menu
extends
ApiClient
{
class
Menu
extends
ApiClient
{
/**
/**
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
*
* 需要它仅因为开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,
* 需要它的两个真实原因:
* 导致同一棵树双发请求。菜单可见性以 /current 为准、不依赖权限点,故不需要按 points 重算。
* 1) 开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,直接双发请求;
* 2) 权限点 points 会变化(AccessProvider 挂载后异步 auth.info() 返回再 applyLogin 一次),
* BasicLayout 的 effect 依赖 points,points 一变就会重跑。
*
* 缓存的是「网络请求」,不是「菜单结果」:调用方仍用当前 points 重新 buildMenus,
* 所以权限点更新后菜单过滤依旧准确,只是不会重复请求。
*/
*/
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
/**
/**
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 后端已按当前登录用户的角色装配并返回,前端
仍与登录下发的 permCodes 取交集后再渲染
* 后端已按当前登录用户的角色装配并返回,前端
原样渲染,不再与登录下发的 permCodes 取交集。
*
(双保险:即便后端未按角色过滤,也不会有越权菜单被渲染出来)
。
*
菜单显隐的唯一真源就是这棵树;越权菜单由后端装配时拦截,不在前端二次过滤
。
*/
*/
tree
():
Promise
<
MenuNode
[]
>
{
tree
():
Promise
<
MenuNode
[]
>
{
if
(
!
this
.
treePromise
)
{
if
(
!
this
.
treePromise
)
{
...
...
packages/platform-sdk/src/compat/access/backend/adapter.ts
View file @
e7c74a0
...
@@ -21,7 +21,7 @@ function toFrontendPoint(code: string): string {
...
@@ -21,7 +21,7 @@ function toFrontendPoint(code: string): string {
/* ---------------- 菜单树:后端 /system/menu/tree/current → 前端菜单结构 ---------------- */
/* ---------------- 菜单树:后端 /system/menu/tree/current → 前端菜单结构 ---------------- */
/** 前端菜单项(path/label/icon 供渲染,resource 供
权限与面包屑
) */
/** 前端菜单项(path/label/icon 供渲染,resource 供
面包屑等派生用途
) */
export
interface
MenuItemDef
{
export
interface
MenuItemDef
{
path
:
string
;
path
:
string
;
label
:
string
;
label
:
string
;
...
@@ -53,12 +53,12 @@ export interface MenuGroupDef {
...
@@ -53,12 +53,12 @@ export interface MenuGroupDef {
* - 只取 nodeType 1(分组)下的 nodeType 2(页面);nodeType 3 是按钮操作点,不进菜单。
* - 只取 nodeType 1(分组)下的 nodeType 2(页面);nodeType 3 是按钮操作点,不进菜单。
* - status !== 1(停用)的节点丢弃。
* - status !== 1(停用)的节点丢弃。
* - path 与 icon 直接取自后端下发的 node.route / node.icon,前端不再做映射。
* - path 与 icon 直接取自后端下发的 node.route / node.icon,前端不再做映射。
* - permCode 与当前账号持有的权限点取交集(/current 后端已按角色过滤,这里作双保险再过滤一次)。
* - 菜单可见性完全由后端 /current 决定:后端已按当前登录角色装配好菜单树,前端原样渲染,
* 不再拿登录返回的 permCodes 做交集(双保险)。
* - node.route 缺失 → 跳过并告警(点了会 404,不应渲染)。
* - node.route 缺失 → 跳过并告警(点了会 404,不应渲染)。
* - 分组/页面均按 sort 升序。
* - 分组/页面均按 sort 升序。
*/
*/
export
function
buildMenus
(
tree
:
MenuNode
[],
owned
:
Iterable
<
string
>
):
MenuGroupDef
[]
{
export
function
buildMenus
(
tree
:
MenuNode
[]):
MenuGroupDef
[]
{
const
points
=
new
Set
(
owned
);
const
groups
:
MenuGroupDef
[]
=
[];
const
groups
:
MenuGroupDef
[]
=
[];
(
tree
??
[])
(
tree
??
[])
...
@@ -71,21 +71,19 @@ export function buildMenus(tree: MenuNode[], owned: Iterable<string>): MenuGroup
...
@@ -71,21 +71,19 @@ export function buildMenus(tree: MenuNode[], owned: Iterable<string>): MenuGroup
.
sort
((
a
,
b
)
=>
a
.
sort
-
b
.
sort
)
.
sort
((
a
,
b
)
=>
a
.
sort
-
b
.
sort
)
.
forEach
((
n
)
=>
{
.
forEach
((
n
)
=>
{
const
code
=
n
.
permCode
;
const
code
=
n
.
permCode
;
if
(
!
code
)
return
;
// 归一为前端点号后与权限点集合比较(points 已是归一后的点号形态)
const
point
=
toFrontendPoint
(
code
);
if
(
!
points
.
has
(
point
))
return
;
// 路由由后端树直接下发;缺失则跳过(不应渲染一个点了会 404 的菜单项)
// 路由由后端树直接下发;缺失则跳过(不应渲染一个点了会 404 的菜单项)
if
(
!
n
.
route
)
{
if
(
!
n
.
route
)
{
console
.
warn
(
`[menu] 后端菜单「
${
n
.
label
}
」(
${
code
}
) 未下发 route,已跳过`
);
console
.
warn
(
`[menu] 后端菜单「
${
n
.
label
}
」(
${
code
??
'无权限码'
})
未下发
route
,已跳过
`);
return;
return;
}
}
// resource 仅作派生用途,与显隐无关;无 permCode 也照常渲染。
const point = code ? toFrontendPoint(code) : '';
const i = point.lastIndexOf(':');
const i = point.lastIndexOf(':');
children.push({
children.push({
path: n.route,
path: n.route,
label: n.label,
label: n.label,
icon: n.icon ?? null,
icon: n.icon ?? null,
resource
:
(
i
>
0
?
point
.
slice
(
0
,
i
)
:
point
)
as
ResourceKey
,
resource:
point ? ((i > 0 ? point.slice(0, i) : point) as ResourceKey) : undefined
,
});
});
});
});
if (children.length) groups.push({ group: g.label, children });
if (children.length) groups.push({ group: g.label, children });
...
...
packages/platform-sdk/src/compat/api/modules/menu.ts
View file @
e7c74a0
...
@@ -29,21 +29,15 @@ export interface MenuNode {
...
@@ -29,21 +29,15 @@ export interface MenuNode {
class
Menu
extends
ApiClient
{
class
Menu
extends
ApiClient
{
/**
/**
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
* 菜单树的请求缓存(同一登录态内菜单树不会变,没必要重复打网络)。
*
* 需要它仅因为开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,
* 需要它的两个真实原因:
* 导致同一棵树双发请求。菜单可见性以 /current 为准、不依赖权限点,故不需要按 points 重算。
* 1) 开发期 React.StrictMode 会把 effect 跑成 mount → cleanup → mount,直接双发请求;
* 2) 权限点 points 会变化(AccessProvider 挂载后异步 auth.info() 返回再 applyLogin 一次),
* BasicLayout 的 effect 依赖 points,points 一变就会重跑。
*
* 缓存的是「网络请求」,不是「菜单结果」:调用方仍用当前 points 重新 buildMenus,
* 所以权限点更新后菜单过滤依旧准确,只是不会重复请求。
*/
*/
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
private
treePromise
:
Promise
<
MenuNode
[]
>
|
null
=
null
;
/**
/**
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 当前登录用户的菜单树(/system/menu/tree/current)。
* 后端已按当前登录用户的角色装配并返回,前端
仍与登录下发的 permCodes 取交集后再渲染
* 后端已按当前登录用户的角色装配并返回,前端
原样渲染,不再与登录下发的 permCodes 取交集。
*
(双保险:即便后端未按角色过滤,也不会有越权菜单被渲染出来)
。
*
菜单显隐的唯一真源就是这棵树;越权菜单由后端装配时拦截,不在前端二次过滤
。
*/
*/
tree
():
Promise
<
MenuNode
[]
>
{
tree
():
Promise
<
MenuNode
[]
>
{
if
(
!
this
.
treePromise
)
{
if
(
!
this
.
treePromise
)
{
...
...
packages/platform-sdk/src/downloadCenter.ts
View file @
e7c74a0
...
@@ -3,6 +3,7 @@ import {
...
@@ -3,6 +3,7 @@ import {
DOWNLOAD_CENTER_REGISTER_EVENT
,
DOWNLOAD_CENTER_REGISTER_EVENT
,
DOWNLOAD_CENTER_CANCEL_EVENT
,
DOWNLOAD_CENTER_CANCEL_EVENT
,
DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT
,
DOWNLOAD_CENTER_REGISTER_CHANNEL_EVENT
,
OPEN_EXTERNAL_EVENT
,
downloadChannelRop
,
downloadChannelRop
,
type
AsyncExportPayload
,
type
AsyncExportPayload
,
type
Base64Payload
,
type
Base64Payload
,
...
@@ -103,6 +104,14 @@ function withDefaults(input: AsyncExportInput): AsyncExportInput {
...
@@ -103,6 +104,14 @@ function withDefaults(input: AsyncExportInput): AsyncExportInput {
return
withProvider
(
withRopChannel
(
input
));
return
withProvider
(
withRopChannel
(
input
));
}
}
/**
* 打开外部页面(报告 / AI 分析等),不登记下载任务。
* 子应用 iframe 内直接 window.open 常被弹窗拦截,统一交给主壳开可见标签并处理回退。
*/
export
function
openExternal
(
url
:
string
):
void
{
subappBus
()?.
$emit
(
OPEN_EXTERNAL_EVENT
,
url
);
}
export
const
downloadCenter
=
{
export
const
downloadCenter
=
{
/** 统一登记(显式 kind);兼容旧写法:不带 kind 但带 method 时默认 async-export。 */
/** 统一登记(显式 kind);兼容旧写法:不带 kind 但带 method 时默认 async-export。 */
register
(
input
:
RegisterDownloadInput
|
RegisterExportTaskInput
):
void
{
register
(
input
:
RegisterDownloadInput
|
RegisterExportTaskInput
):
void
{
...
...
packages/ui/src/styles/ui.css
View file @
e7c74a0
...
@@ -437,17 +437,17 @@ html body {
...
@@ -437,17 +437,17 @@ html body {
grid-row
:
auto
;
grid-row
:
auto
;
}
}
}
}
/* 「更多筛选」双数角标:上标
总数是整张表的条件总数,主色实心数是
已填写的条件数。
/* 「更多筛选」双数角标:上标
是收进「更多筛选」的条件数(不含常显字段),主色实心数是整张表
已填写的条件数。
总数上标只在收起态出现(展开后条件都在眼前,再挂总数
纯属重复);主色已填数角标
收起数上标只在收起态出现(展开后这些条件都在眼前,再挂数字
纯属重复);主色已填数角标
两态都显示,展开态它还是悬浮条件卡的触发区。
两态都显示,展开态它还是悬浮条件卡的触发区。
总
数只是静态说明(不随填写变化),不该和强调性的已填数抢视觉重量:退化成无背景
收起
数只是静态说明(不随填写变化),不该和强调性的已填数抢视觉重量:退化成无背景
上标后按钮宽度回落到接近纯文案,主色角标成了唯一带底色的元素。 */
上标后按钮宽度回落到接近纯文案,主色角标成了唯一带底色的元素。 */
.uj-filter-more-btn
{
.uj-filter-more-btn
{
display
:
inline-flex
;
display
:
inline-flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
gap
:
4px
;
gap
:
4px
;
/* 安全宽:按「更多筛选 + 两位数
总
数上标 + 两位数已填角标 + 箭头」的最宽态固定,
/* 安全宽:按「更多筛选 + 两位数
收起
数上标 + 两位数已填角标 + 箭头」的最宽态固定,
有无角标按钮都占同一宽度——角标从无到有时按钮不再变宽去挤紧邻字段。 */
有无角标按钮都占同一宽度——角标从无到有时按钮不再变宽去挤紧邻字段。 */
box-sizing
:
border-box
;
box-sizing
:
border-box
;
min-width
:
126px
;
min-width
:
126px
;
...
@@ -931,6 +931,23 @@ html body {
...
@@ -931,6 +931,23 @@ html body {
/* 与 LoginCoverage 的青绿脉冲逐字同源;登录页深色底、这里浅色底,色值不变 */
/* 与 LoginCoverage 的青绿脉冲逐字同源;登录页深色底、这里浅色底,色值不变 */
--uj-brand-pulse
:
#1fe0c8
;
--uj-brand-pulse
:
#1fe0c8
;
}
}
/* 页面/详情加载态容器:BrandLoader 居中 + 文案。取代原 antd Skeleton 骨架屏
(shimmer 波浪),全系统页面级 loading 只有这一种图形。最小高度给抽屉/页面
一个稳定落点,避免内容到达前后高度跳变。 */
.uj-brand-loading
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
gap
:
14px
;
width
:
100%
;
box-sizing
:
border-box
;
}
.uj-brand-loading__label
{
color
:
var
(
--uj-text-3
);
font-size
:
12px
;
letter-spacing
:
0.5px
;
}
.uj-brand-loader
{
.uj-brand-loader
{
flex
:
none
;
flex
:
none
;
line-height
:
0
;
line-height
:
0
;
...
...
scripts/audit-module.mjs
View file @
e7c74a0
...
@@ -635,6 +635,91 @@ function checkFile(file) {
...
@@ -635,6 +635,91 @@ function checkFile(file) {
}
}
}
}
}
}
// §7 / §9:整页列表的填充链。真源是 PORT_CONVERSION.md §7「需要整屏定高时给
// DataTable 传 fillHeight 并在外层用 PageShell fill」+ §9「列表页 fill 开整屏定高」。
// 三个断点任一缺失,表现就是「筛选区与列表紧贴 / 表头变高 / 表体空白变大」——
// 11-18 的 43faf63 一次移除 4 页 fillHeight 就是这么漏过基线的,故加闸门钉死。
// 抽屉 / 弹窗里的表不在该容器里(body 无定高),明确豁免,不强求 fill。
const isEmbedded = /Drawer\.tsx$/.test(file) || /Modal\.tsx$/.test(file);
const hasFilterCard = text.includes('uj-filter-card');
const hasDataTable = /<DataTable\b/.test(text);
if (isTs && hasFilterCard && hasDataTable && !isEmbedded) {
// ① PageShell 必须 fill(分页贴底、表体内滚的定高链第一段)。pane 组件(tab 里的
// LiveCodesTab/VehicleLedger 等)自己没有 PageShell,定高由宿主页负责,跳过。
const shell = /<PageShell\b[\s\S]{0,120}?>/.exec(text);
if (shell && !/\bfill\b/.test(shell[0])) {
add(
'list/page-shell-fill',
'§7 / §9',
'error',
file,
lineOf(text, shell.index),
'整页列表的 PageShell 必须带 fill:否则内容区不定高,表体无法内滚、分页贴不了底(§7 / §9)',
);
}
// ② 表格外层 UCard 必须 fill(.uj-card--fill 把高度传给表体)。
const tableCards = [...text.matchAll(/<UCard\b[^>]*>/g)].filter(
(m) => !/uj-filter-card/.test(m[0]),
);
if (!tableCards.some((m) => /\bfill\b/.test(m[0]))) {
add(
'list/table-card-fill',
'§7 / §9',
'error',
file,
tableCards.length ? lineOf(text, tableCards[0].index) : 1,
'表格外层 UCard 必须带 fill:否则 .uj-card--fill 高度链断开,出现表头变高 / 空白变大(§7 / §9)',
);
}
// ③ DataTable 必须 fillHeight。
if (!/\bfillHeight\b/.test(text)) {
const dt = /<DataTable\b/.exec(text);
add(
'list/table-fill-height',
'§7',
'error',
file,
dt ? lineOf(text, dt.index) : 1,
'整页列表的 DataTable 必须带 fillHeight:表体才能内滚、分页才能贴底(§7)',
);
}
}
// §13 tab 落地规则:单路由 + 页内 UTabs。tab 差异只在按钮 perm_code,内容是同一个
// 定高列表——所以 tab 只放 label/key,pane 在 tabs 之外按 activeKey 渲染。把 pane 塞进
// items[].children 会让它被 .ant-tabs-content-holder 包住、脱离 .uj-page__body 的定高
// flex 链,fill/fillHeight 随之失效(11-18 台账/一客一群就是这么坏的)。只报不改:
// 结构改写涉及 JSX 语义,交给人工按评估管理 / WithdrawManage 的形态改。
if (isTs && /<UTabs\b/.test(text) && /<PageShell\b/.test(text)) {
const shell = /<PageShell\b[\s\S]{0,120}?>/.exec(text);
if (shell && !/\bfill\b/.test(shell[0])) {
add(
'list/tab-host-shell-fill',
'§13 / §7 / §9',
'error',
file,
lineOf(text, shell.index),
'带页内 UTabs 的列表宿主页,PageShell 必须 fill:否则 pane 的 fill/fillHeight 没有定高链可接(§9)',
);
}
const tabsBlock = /<UTabs\b[\s\S]*?\/?>/.exec(text)?.[0] ?? '';
const itemsBlock = /items=\{([\s\S]*?)\}\s*\n\s*\/>|items=\{([\s\S]*?)\}\s*\n\s*[\w}]/.exec(
text,
);
const scoped = itemsBlock ? itemsBlock[1] || itemsBlock[2] || '' : tabsBlock;
if (/\bchildren\s*:/.test(scoped)) {
const m = /\bchildren\s*:/.exec(text);
add(
'list/tab-pane-children',
'§13 / §7',
'error',
file,
m ? lineOf(text, m.index) : 1,
'页面级 UTabs 的 items 不要带 children:把 pane 放进 .ant-tabs-content-holder 会断开定高 flex 链、让 fill/fillHeight 失效;改成 label/key-only + 按 activeKey 在 tabs 外渲染 pane(见评估管理 / WithdrawManage)',
);
}
}
}
}
/** 入口骨架:tokens.css 导入 + uj-scope 根类名(§5)。 */
/** 入口骨架:tokens.css 导入 + uj-scope 根类名(§5)。 */
...
...
scripts/finance-menu-migration.sql
View file @
e7c74a0
...
@@ -108,16 +108,16 @@ INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`)
...
@@ -108,16 +108,16 @@ INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`)
SELECT
rm
.
`role_id`
,
101
FROM
`sys_role_menu`
rm
WHERE
rm
.
`menu_id`
=
96
;
SELECT
rm
.
`role_id`
,
101
FROM
`sys_role_menu`
rm
WHERE
rm
.
`menu_id`
=
96
;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- 4b) 权限码口径补齐(关键,别漏)
-- 4b) 权限码口径补齐(历史坑,现前端已不再依赖,保留仅为数据一致性)
-- /system/auth/login 与 /system/auth/info 的 permCodes 是按 sys_role_menu
-- 背景:/system/auth/login|info 的 permCodes 按 sys_role_menu 关联 sys_menu.perm_code
-- 关联 sys_menu.perm_code 聚合的;/system/menu/tree/current 对超管返回全量树,
-- 聚合;/system/menu/tree/current 对超管返回全量树,两接口口径曾不一致——树里有页面
-- 两个接口口径不一致:树里能看到「财务管理」不等于 permCodes 里有 finance: 码。
-- 不等于 permCodes 里有 finance: 码。旧版前端 buildMenus 用 points.has(n.permCode)
-- 前端 packages/platform-core/src/access/backend/adapter.ts:103 的
-- 做交集,缺码就把页面节点 return、整组不渲染且零日志,这是本脚本存在的直接原因。
-- points.has(n.permCode) 只要不匹配,页面节点就被 return,
-- 现状:菜单显隐已改为完全以 /system/menu/tree/current 为准(单路由真源),前端
-- children.length === 0 时整组不 push —— 侧边栏连一级标题都没有,且零日志。
-- buildMenus / BasicLayout 不再拿 permCodes 二次过滤。故下面这段授权补齐不再是
-- 「不补就看不到菜单」的硬前提;仍保留是为了让 permCodes 与菜单树口径一致
-- (按钮级 PermButton / canPoint 仍按 permCodes 判定),避免角色导出/审计口径分歧。
-- 本脚本原地改了 96~100 的 perm_code(usedcar:payment:* → finance:payment:*),
-- 本脚本原地改了 96~100 的 perm_code(usedcar:payment:* → finance:payment:*),
-- 若某角色原本只授权了部分 menu_id,或 10027* 的新节点没进关联,
-- permCodes 就会缺 finance:payment:view,页面照样不显示。
-- 口径:凡是原本有「付款管理」页面(96)的角色,自动补齐 10027* 全部 6 行授权。
-- 口径:凡是原本有「付款管理」页面(96)的角色,自动补齐 10027* 全部 6 行授权。
-- 幂等,可重复执行。
-- 幂等,可重复执行。
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
...
@@ -175,19 +175,20 @@ COMMIT;
...
@@ -175,19 +175,20 @@ COMMIT;
-- 这样 SQL 回滚时旧页面仍在,不会出现菜单有、页面空的窗口。
-- 这样 SQL 回滚时旧页面仍在,不会出现菜单有、页面空的窗口。
--
--
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- 6) 跑完 SQL 之后必做:刷新权限码(否则菜单树有、侧边栏没有)
-- 6) 跑完 SQL 之后的验证
-- ① 后端权限码有缓存:调 POST /system/auth/perm/refresh
-- ① 菜单显隐以 /system/menu/tree/current 为唯一真源,前端不再用 permCodes 过滤:
-- (前端 packages/platform-core/src/api/modules/auth.ts:105 已定义
-- 页面是否在侧边栏出现,取决于该角色是否被授予对应 menu_id(sys_role_menu),
-- auth.refreshPerm(),但全仓零调用,需手动触发或由后端刷)。
-- 不再取决于 permCodes 里有没有 finance:payment:view。
-- ② 退出登录再重新登录:登录流程会 menuApi.clearCache() + auth.clearCache(),
-- ② 仍要刷新 permCodes 的地方是按钮级权限(PermButton / canPoint):
-- 重新拉 /system/auth/info 并 applyLogin() 覆盖 points。
-- - 后端权限码有缓存时调 POST /system/auth/perm/refresh
-- 只按 F5 刷新页面也行(模块重建会重拉 info),但 SPA 内切页不重拉。
-- (前端 packages/platform-core/src/api/modules/auth.ts 的 auth.refreshPerm())。
-- ③ 浏览器控制台验证(应看到 5 个 finance: 码、0 个 usedcar:payment 码):
-- - 或退出重登:登录流程 menuApi.clearCache() + auth.clearCache(),重拉
-- /system/auth/info 并 applyLogin() 覆盖 points;只按 F5 刷新页面也行。
-- ③ 浏览器控制台核对 permCodes 口径(应看到 finance: 码、0 个 usedcar:payment 码):
-- const s = JSON.parse(localStorage.getItem('session'));
-- const s = JSON.parse(localStorage.getItem('session'));
-- console.log(s.permCodes.filter(c => c.startsWith('finance:')));
-- console.log(s.permCodes.filter(c => c.startsWith('finance:')));
-- console.log(s.permCodes.filter(c => c.startsWith('usedcar:payment')));
-- console.log(s.permCodes.filter(c => c.startsWith('usedcar:payment')));
-- 判据:必须含 'finance:payment:view' —— buildMenus 只认页面 :view 码,
-- 缺码只影响按钮级权限,不再影响页面菜单是否渲染。
-- 少这一个页面就不渲染,整组「财务管理」静默消失。
-- ④ 页面仍不显示时查 sys_role_menu 是否授予 10027* 的 menu_id(尤其页面节点 97);
-- ④ 仍不显示时查 5b 的 granted_finance_nodes 是否为 6;
-- /current 是按角色装配的,树里没有就是没授权,与 permCodes 无关。
-- 超管账号不 bypass:/current 返回全量树,permCodes 却按 sys_role_menu 聚合。
-- =====================================================================
-- =====================================================================
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment