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 3f441ae5
authored
Nov 12, 2026
by
liimin
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
59447b51
ef278720
Pipeline
#407
for
3f441ae5
failed
in 0 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
320 additions
and
8 deletions
apps/web/subapps/usedcar/src/api/core/client.ts
apps/web/subapps/usedcar/src/api/core/config-center.ts
apps/web/subapps/usedcar/src/api/index.ts
apps/web/subapps/usedcar/src/api/modules/dashboard.ts
apps/web/subapps/usedcar/src/pages/Dashboard/index.css
apps/web/subapps/usedcar/src/pages/Dashboard/index.tsx
packages/platform-core/src/api/core/http.ts
apps/web/subapps/usedcar/src/api/core/client.ts
View file @
3f441ae
/** 业务模块的 `../core/client` 桥接:继承目标换成 props.request 代理。 */
import
{
createClient
}
from
'@uj/api-core'
;
export
{
RemoteApiClient
as
ApiClient
}
from
'@uj/platform-sdk'
;
import
{
requestViaHost
}
from
'@uj/platform-sdk'
;
export
type
{
BlobResponse
}
from
'@uj/platform-sdk'
;
import
{
getLoginSession
}
from
'@/access'
;
import
{
loadUsedcarGscConfig
,
loadUsedcarRemoteConfig
}
from
'./config-center'
;
/** 旧 GSC 接口仍由主壳的唯一请求通道发送;子应用不保存密钥。 */
export
class
ApiClient
{
protected
async
post
<
T
>
(
url
:
string
,
data
:
Record
<
string
,
unknown
>
=
{}):
Promise
<
T
>
{
const
value
=
await
loadUsedcarGscConfig
();
return
createClient
({
kind
:
'gsc'
,
transport
:
'host'
,
hostSend
:
requestViaHost
(),
baseURL
:
value
.
baseURL
,
appKey
:
value
.
appId
,
appSecret
:
value
.
appSecret
,
session
:
{
sessionId
:
()
=>
getLoginSession
()?.
loginToken
??
''
,
paramName
:
'sessionId'
},
errorHandler
:
(
error
)
=>
{
throw
error
.
cause
??
error
;
}
}).
post
<
T
>
(
url
,
data
);
}
protected
async
postRop
<
T
>
(
method
:
string
,
data
:
Record
<
string
,
unknown
>
=
{}):
Promise
<
T
>
{
const
{
axios
}
=
await
loadUsedcarRemoteConfig
();
const
router
=
new
URL
(
axios
.
baseURL
);
const
path
=
router
.
pathname
.
replace
(
/router$/
,
''
);
return
createClient
({
kind
:
'rop'
,
transport
:
'host'
,
hostSend
:
requestViaHost
(),
baseURL
:
router
.
origin
,
path
,
hostType
:
'dj'
,
djSecretKey
:
{
appKey
:
axios
.
appkey
,
secret
:
axios
.
secret
},
session
:
{
sessionId
:
()
=>
getLoginSession
()?.
loginToken
??
''
,
paramName
:
'sessionId'
},
errorHandler
:
(
error
)
=>
{
throw
error
.
cause
??
error
;
}
}).
post
<
T
>
(
method
,
data
);
}
}
apps/web/subapps/usedcar/src/api/core/config-center.ts
0 → 100644
View file @
3f441ae
import
{
requestViaHost
}
from
'@uj/platform-sdk'
;
const
CONFIG_CENTER_URL
=
'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config'
;
export
interface
UsedcarGscConfig
{
baseURL
:
string
;
appId
:
string
;
appSecret
:
string
;
}
export
interface
UsedcarRopConfig
{
baseURL
:
string
;
appkey
:
string
;
secret
:
string
}
export
interface
UsedcarRemoteConfig
{
gsc
:
UsedcarGscConfig
;
axios
:
UsedcarRopConfig
}
let
pendingConfig
:
Promise
<
UsedcarRemoteConfig
>
|
undefined
;
function
unwrap
(
payload
:
unknown
):
Record
<
string
,
unknown
>
|
undefined
{
if
(
!
payload
||
typeof
payload
!==
'object'
)
return
undefined
;
const
envelope
=
payload
as
Record
<
string
,
unknown
>
;
const
data
=
String
(
envelope
.
code
)
===
'200'
?
envelope
.
data
:
payload
;
if
(
typeof
data
===
'string'
)
{
try
{
return
JSON
.
parse
(
data
)
as
Record
<
string
,
unknown
>
;
}
catch
{
return
undefined
;
}
}
return
data
&&
typeof
data
===
'object'
?
(
data
as
Record
<
string
,
unknown
>
)
:
undefined
;
}
/** 沿用旧系统:配置中心的 gsc 字段是二手车 REST 服务的唯一配置来源。 */
export
function
loadUsedcarRemoteConfig
():
Promise
<
UsedcarRemoteConfig
>
{
pendingConfig
??
=
requestViaHost
()({
method
:
'GET'
,
url
:
CONFIG_CENTER_URL
,
timeout
:
15
_000
,
_noVerify
:
true
,
_skipHostSignature
:
true
,
_skipAuthorization
:
true
,
})
.
then
((
response
)
=>
{
const
raw
=
response
as
{
data
?:
unknown
};
const
config
=
unwrap
(
raw
.
data
??
raw
);
const
gsc
=
config
?.
gsc
as
Record
<
string
,
unknown
>
|
undefined
;
const
axios
=
config
?.
axios
as
Record
<
string
,
unknown
>
|
undefined
;
const
baseURL
=
typeof
gsc
?.
baseURL
===
'string'
?
gsc
.
baseURL
:
''
;
const
appId
=
typeof
gsc
?.
appId
===
'string'
?
gsc
.
appId
:
''
;
const
appSecret
=
typeof
gsc
?.
appSecret
===
'string'
?
gsc
.
appSecret
:
''
;
const
ropBaseURL
=
typeof
axios
?.
baseURL
===
'string'
?
axios
.
baseURL
:
''
;
const
appkey
=
typeof
axios
?.
appkey
===
'string'
?
axios
.
appkey
:
''
;
const
secret
=
typeof
axios
?.
secret
===
'string'
?
axios
.
secret
:
''
;
if
(
!
baseURL
||
!
appId
||
!
appSecret
||
!
ropBaseURL
||
!
appkey
||
!
secret
)
throw
new
Error
(
'配置中心未返回二手车数据服务所需的完整配置。'
);
return
{
gsc
:
{
baseURL
,
appId
,
appSecret
},
axios
:
{
baseURL
:
ropBaseURL
,
appkey
,
secret
}
};
})
.
catch
((
error
)
=>
{
pendingConfig
=
undefined
;
throw
error
;
});
return
pendingConfig
;
}
export
async
function
loadUsedcarGscConfig
():
Promise
<
UsedcarGscConfig
>
{
return
(
await
loadUsedcarRemoteConfig
()).
gsc
;
}
apps/web/subapps/usedcar/src/api/index.ts
View file @
3f441ae
...
@@ -5,4 +5,4 @@
...
@@ -5,4 +5,4 @@
* 页面内容留空,SQL 里也没有任何接口定义,因此这里刻意不建业务模块、不臆造接口。
* 页面内容留空,SQL 里也没有任何接口定义,因此这里刻意不建业务模块、不臆造接口。
* 后续接入接口时,按 system / store / points 的写法把模块挂到这里即可。
* 后续接入接口时,按 system / store / points 的写法把模块挂到这里即可。
*/
*/
export
{}
;
export
*
from
'./modules/dashboard'
;
apps/web/subapps/usedcar/src/api/modules/dashboard.ts
0 → 100644
View file @
3f441ae
import
{
ApiClient
}
from
'../core/client'
;
export
interface
StoreItem
{
merchantId
:
string
;
merchantName
:
string
}
export
interface
DashboardStatistics
{
[
key
:
string
]:
number
|
undefined
}
export
interface
TrendPoint
{
date
:
string
;
count
:
number
}
class
DashboardApi
extends
ApiClient
{
getdataBoard
(
params
:
Record
<
string
,
unknown
>
)
{
return
this
.
post
<
DashboardStatistics
>
(
'/dataBoard/index'
,
params
);
}
getEvaluationData
(
params
:
Record
<
string
,
unknown
>
)
{
return
this
.
post
<
TrendPoint
[]
>
(
'/dataBoard/evaluation'
,
params
);
}
getDealData
(
params
:
Record
<
string
,
unknown
>
)
{
return
this
.
post
<
TrendPoint
[]
>
(
'/dataBoard/deal'
,
params
);
}
getServiceStore
(
params
:
Record
<
string
,
unknown
>
)
{
return
this
.
postRop
<
StoreItem
[]
>
(
'dj.api.scenemerchantref.query4SRefByYqShop'
,
params
);
}
}
export
const
dashboardApi
=
new
DashboardApi
();
apps/web/subapps/usedcar/src/pages/Dashboard/index.css
0 → 100644
View file @
3f441ae
.uc-dashboard
{
display
:
grid
;
gap
:
var
(
--uj-space-4
);
}
.uc-filter
,
.uc-filter
>
div
,
.uc-head
{
align-items
:
center
;
display
:
flex
;
gap
:
var
(
--uj-space-2
);
justify-content
:
space-between
;
}
.uc-filter
{
margin-bottom
:
var
(
--uj-space-5
);
}
.uc-filter
.ant-select
{
width
:
245px
;
}
.uc-filter
button
,
.uc-head
button
{
background
:
var
(
--uj-surface
);
border
:
1px
solid
var
(
--uj-border
);
color
:
var
(
--uj-text-1
);
cursor
:
pointer
;
padding
:
var
(
--uj-space-2
);
}
.uc-filter
.active
{
background
:
var
(
--uj-primary
);
color
:
var
(
--uj-on-primary
);
}
.uc-grid
{
display
:
grid
;
gap
:
var
(
--uj-space-4
);
grid-template-columns
:
repeat
(
5
,
minmax
(
0
,
1
fr
));
}
.uc-grid
>
div
{
background
:
var
(
--uj-surface-2
);
border-radius
:
var
(
--uj-radius-sm
);
display
:
grid
;
gap
:
var
(
--uj-space-3
);
min-height
:
120px
;
padding
:
var
(
--uj-space-5
);
}
.uc-grid
strong
{
font-size
:
var
(
--uj-font-3xl
);
}
.uc-grid
small
{
color
:
var
(
--uj-text-3
);
}
.uc-trend
{
display
:
grid
;
gap
:
var
(
--uj-space-2
);
grid-template-columns
:
repeat
(
auto-fit
,
minmax
(
110px
,
1
fr
));
margin-top
:
var
(
--uj-space-5
);
}
.uc-trend
div
{
background
:
var
(
--uj-surface-2
);
padding
:
var
(
--uj-space-3
);
}
.uc-trend
span
,
.uc-trend
strong
{
display
:
block
;
}
@media
(
max-width
:
1000px
)
{
.uc-grid
{
grid-template-columns
:
repeat
(
3
,
minmax
(
0
,
1
fr
));
}
}
@media
(
max-width
:
700px
)
{
.uc-filter
,
.uc-filter
>
div
{
align-items
:
flex-start
;
flex-direction
:
column
;
}
.uc-grid
{
grid-template-columns
:
1
fr
;
}
}
apps/web/subapps/usedcar/src/pages/Dashboard/index.tsx
View file @
3f441ae
import { RoutePlaceholder } from '@/features/shared/RoutePlaceholder';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { type Dayjs } from 'dayjs';
import { UCard, UDatePicker, UEmpty, USelect, UText } from '@uj/ui';
import { PageShell } from '@/components';
import { dashboardApi, type TrendPoint } from '@/api';
import './index.css';
const PERIODS = [
{ value: 1, label: '今日' },
{ value: 2, label: '昨日' },
{ value: 3, label: '本月' },
{ value: 4, label: '上月' },
];
const STATS = [
['评估量(辆)', 'appraisalCount', 'appraisalCountChainRatio'],
['总毛利(万元)', 'grossProfitTotal', 'grossProfitTotalChainRatio'],
['单车毛利(元)', 'grossProfitPerUnit', 'grossProfitPerUnitChainRatio'],
['平均售价(万元)', 'avgSellingPrice', 'avgSellingPriceChainRatio'],
['新车下定数(辆)', 'newCarOrderCount', 'newCarOrderCountChainRatio'],
['二手车收车成交量(辆)', 'transactionCount', 'transactionCountChainRatio'],
['评估转化率(比)', 'appraisalConversionRate', 'appraisalConversionRateChainRatio', '%'],
['置换率(比)', 'replacementRate', 'replacementRateChainRatio', '%'],
['新车交付数(辆)', 'newCarDeliveryCount', 'newCarDeliveryCountChainRatio'],
['二手车收购交车数(辆)', 'acquisitionDeliveryCount', 'acquisitionDeliveryCountChainRatio'],
] as const;
function Trend({ title, load }: { title: string; load: (type: number) => Promise<TrendPoint[]> }) {
const [type, setType] = useState(1);
const query = useQuery({ queryKey: ['trend', title, type], queryFn: () => load(type) });
return (
<UCard>
<div className="uc-head">
<UText strong>{title}趋势</UText>
<div>
{PERIODS.map((p) => (
<button type="button" key={p.value} onClick={() => setType(p.value)}>
{p.label}
</button>
))}
</div>
</div>
{query.isError ? (
<UEmpty description="趋势数据加载失败" />
) : (
<div className="uc-trend">
{query.data?.map((p) => (
<div key={p.date}>
<span>{p.date}</span>
<strong>{p.count}辆</strong>
</div>
)) ?? <UEmpty description="正在加载" />}
</div>
)}
</UCard>
);
}
/** menu_code 1002601 · 数据看板 · usedcar:dashboard:view */
/** menu_code 1002601 · 数据看板 · usedcar:dashboard:view */
export default function Dashboard() {
export default function Dashboard() {
return <RoutePlaceholder title="数据看板" route="/usedcar/dashboard" />;
const [merchantNos, setMerchantNos] = useState('');
const [dateType, setDateType] = useState(1);
const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
const stores = useQuery({
queryKey: ['stores'],
queryFn: () => dashboardApi.getServiceStore({ scene: 7 }),
});
const params = useMemo(
() => ({
merchantNos,
dateType: range ? 5 : dateType,
...(range
? { startDate: range[0].format('YYYY-MM-DD'), endDate: range[1].format('YYYY-MM-DD') }
: {}),
}),
[merchantNos, dateType, range],
);
const statistics = useQuery({
queryKey: ['statistics', params],
queryFn: () => dashboardApi.getdataBoard(params),
});
return (
<PageShell title="数据看板" description="查看二手车业务的关键指标及趋势。">
<div className="uc-dashboard">
<UCard>
<div className="uc-filter">
<div>
<UText>请选择门店:</UText>
<USelect
value={merchantNos}
options={[
{ label: '全部', value: '' },
...(stores.data ?? []).map((s) => ({
label: s.merchantName,
value: s.merchantId,
})),
]}
onChange={setMerchantNos}
/>
</div>
<div>
{PERIODS.map((p) => (
<button
type="button"
key={p.value}
className={dateType === p.value && !range ? 'active' : ''}
onClick={() => {
setRange(null);
setDateType(p.value);
}}
>
{p.label}
</button>
))}
<UDatePicker.RangePicker
placeholder={['开始日期', '结束日期']}
onChange={(value) => setRange(value as [Dayjs, Dayjs] | null)}
/>
</div>
</div>
{statistics.isError ? (
<UEmpty description="统计数据加载失败" />
) : (
<div className="uc-grid">
{STATS.map(([label, key, rate, suffix]) => (
<div key={key}>
<span>{label}</span>
<strong>
{statistics.data?.[key] === undefined
? '—'
: `${statistics.data[key]}${suffix ?? ''}`}
</strong>
<small>
环比 {statistics.data?.[rate] === undefined ? '—' : `${statistics.data[rate]}%`}
</small>
</div>
))}
</div>
)}
</UCard>
<Trend
title="评估量"
load={(dateType) => dashboardApi.getEvaluationData({ dateType, merchantNos: '' })}
/>
<Trend
title="二手车成交量"
load={(dateType) => dashboardApi.getDealData({ dateType, merchantNos: '' })}
/>
</div>
</PageShell>
);
}
}
packages/platform-core/src/api/core/http.ts
View file @
3f441ae
...
@@ -179,6 +179,10 @@ interface HostRequestConfig extends Record<string, unknown> {
...
@@ -179,6 +179,10 @@ interface HostRequestConfig extends Record<string, unknown> {
transformResponse
?:
Array
<
(
raw
:
unknown
,
headers
:
Record
<
string
,
string
>
)
=>
unknown
>
;
transformResponse
?:
Array
<
(
raw
:
unknown
,
headers
:
Record
<
string
,
string
>
)
=>
unknown
>
;
/** 引导接口(拉公钥)跳过验签与业务码拦截。 */
/** 引导接口(拉公钥)跳过验签与业务码拦截。 */
_noVerify
?:
boolean
;
_noVerify
?:
boolean
;
/** 配置中心等公开引导地址:不附加主业务的 RSA 请求头。 */
_skipHostSignature
?:
boolean
;
/** 配置中心不接收业务登录令牌时使用。 */
_skipAuthorization
?:
boolean
;
timeout
?:
number
;
timeout
?:
number
;
withCredentials
?:
boolean
;
withCredentials
?:
boolean
;
/** 子应用侧请求的中止信号(由 api-core 门面创建,跨 props.request 引用传递)。 */
/** 子应用侧请求的中止信号(由 api-core 门面创建,跨 props.request 引用传递)。 */
...
@@ -192,17 +196,19 @@ async function request<T = unknown>(config: HostRequestConfig): Promise<T> {
...
@@ -192,17 +196,19 @@ async function request<T = unknown>(config: HostRequestConfig): Promise<T> {
const
token
=
getToken
();
const
token
=
getToken
();
const
headers
:
Record
<
string
,
string
>
=
{
...(
config
.
headers
??
{})
};
const
headers
:
Record
<
string
,
string
>
=
{
...(
config
.
headers
??
{})
};
// 登录鉴权独立于请求签名:关闭签名或缺少私钥时仍须携带当前令牌。
// 登录鉴权独立于请求签名:关闭签名或缺少私钥时仍须携带当前令牌。
if
(
token
&&
!
headers
.
Authorization
&&
!
headers
.
authorization
)
{
if
(
token
&&
!
config
.
_skipAuthorization
&&
!
headers
.
Authorization
&&
!
headers
.
authorization
)
{
headers
.
Authorization
=
`Bearer
${
token
}
`
;
headers
.
Authorization
=
`Bearer
${
token
}
`
;
}
}
const
noVerify
=
config
.
_noVerify
===
true
;
const
noVerify
=
config
.
_noVerify
===
true
;
const
skipHostSignature
=
config
.
_skipHostSignature
===
true
;
return
client
.
request
<
T
>
({
return
client
.
request
<
T
>
({
...
config
,
...
config
,
headers
,
headers
,
// 引导接口:跳过验签,并跳过业务码拦截(老 _noVerify 分支在 code!==200 之前就 return 了),
// 引导接口:跳过验签,并跳过业务码拦截(老 _noVerify 分支在 code!==200 之前就 return 了),
// 用 returnAll 表达「原样返回解析后的信封」这一通用语义,不新增开关。
// 用 returnAll 表达「原样返回解析后的信封」这一通用语义,不新增开关。
...(
noVerify
?
{
returnAll
:
true
,
responseVerifier
:
undefined
}
:
{}),
...(
noVerify
?
{
returnAll
:
true
,
responseVerifier
:
undefined
}
:
{}),
...(
skipHostSignature
?
{
signature
:
'none'
}
:
{}),
}
as
never
);
}
as
never
);
}
}
...
...
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