Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-store
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 d2e16544
authored
Oct 13, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat 样式修改
1 parent
28500a8a
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
762 additions
and
54 deletions
README.md
src/api/core/backend-resolver.ts
src/api/modules/__tests__/store.test.ts
src/api/modules/store.ts
src/api/modules/storeTypes.ts
src/components/SearchForm/index.tsx
src/config/storeStatus.ts
src/features/store/ApprovalDetailPresentation.tsx
src/features/store/ListingDetailOverview.tsx
src/features/store/StoreDetailDrawer.test.tsx
src/features/store/StoreDetailDrawer.tsx
src/features/store/approvalDetail.css
src/features/store/approvalPolicy.css
src/features/store/dictionaries.ts
src/features/store/listingDetail.css
src/features/store/useStoreFilterOptions.test.tsx
src/features/store/useStoreFilterOptions.tsx
src/pages/StoreApprove/__tests__/StoreApprove.test.tsx
src/pages/StoreApprove/approveTable.css
src/pages/StoreApprove/index.tsx
src/pages/StoreApprove/tools/columns.tsx
src/pages/StoreListing/StoreListing.test.tsx
src/pages/StoreListing/index.tsx
src/pages/StoreListing/listing.css
README.md
View file @
d2e1654
...
@@ -91,6 +91,6 @@ Windows 荳玖凶 `nvm use` 謠千、コ邉サ扈滄得謗・隶ソ髣ョ陲ォ諡堤サ晢シ悟庄蝨ィ邂。逅遭扈育
...
@@ -91,6 +91,6 @@ Windows 荳玖凶 `nvm use` 謠千、コ邉サ扈滄得謗・隶ソ髣ョ陲ォ諡堤サ晢シ悟庄蝨ィ邂。逅遭扈育
开发代理:
`/api`
→
`http://192.168.3.197:8788`
,配置位于
`vite.config.ts`
。需处于可访问后端的内网;生产环境应配置对应网关代理。
开发代理:
`/api`
→
`http://192.168.3.197:8788`
,配置位于
`vite.config.ts`
。需处于可访问后端的内网;生产环境应配置对应网关代理。
门店审批与门店列表已连接
`/store/approval/*`
、
`/store/listing/*`
。筛选和详情共用
`src/features/store/dictionaries.ts`
本地字典,查询提交中文业务值,未知回显值原样展示;新增业务场景或产品分类在此维护。查看权限及按钮权限取登录接口的
`permCodes`
;审批状态和层级
以后端返回为准。详情按一条「门店+业务场景」记录展示,批量审批使用后端批量接口,重新提交入口及对接已屏蔽,导出直接下载当前筛选结果。
门店审批与门店列表已连接
`/store/approval/*`
、
`/store/listing/*`
。业务场景和产品分
类筛选使用后端分类查询接口;产品分类支持远程搜索和下拉滚动分页加载,不预先拉取全部选项,查询仍提交中文名称。详情保留
`src/features/store/dictionaries.ts`
的显示映射,未知回显值原样展示,不调用
`/store/import/spec`
。查看权限及按钮权限取登录接口的
`permCodes`
;审批状态和层级以后端返回为准。详情按一条「门店+业务场景」记
录展示,批量审批使用后端批量接口,重新提交入口及对接已屏蔽,导出直接下载当前筛选结果。
审批和列表接口通过
`lossless-json`
保留长 ID、金额及比例原文;运营成本合计直接展示
`costTotal`
,不从已格式化单价或分类明细重新计算。真实页面联调记录位于
`artifacts/store-ui-selftest-2026-10-09/`
。
审批和列表接口通过
`lossless-json`
保留长 ID、金额及比例原文;运营成本合计直接展示
`costTotal`
,不从已格式化单价或分类明细重新计算。真实页面联调记录位于
`artifacts/store-ui-selftest-2026-10-09/`
。
src/api/core/backend-resolver.ts
View file @
d2e1654
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*/
*/
// 浏览器侧:根据「当前访问地址」动态解析后端服务地址。
// 浏览器侧:根据「当前访问地址」动态解析后端服务地址。
const
HOST_BACKEND_MAP
:
Record
<
string
,
string
>
=
{
const
HOST_BACKEND_MAP
:
Record
<
string
,
string
>
=
{
'192.168.1.
237
'
:
'192.168.3.197:8788'
,
// 省略协议 → 访问 http 拼 http、访问 https 拼 https
'192.168.1.
178
'
:
'192.168.3.197:8788'
,
// 省略协议 → 访问 http 拼 http、访问 https 拼 https
// 'localhost:5173': '192.168.3.197:8788',
// 'localhost:5173': '192.168.3.197:8788',
// 'x.dev.cn': 'http://192.168.3.197:8788', // 写全协议则不跟随,固定 http
// 'x.dev.cn': 'http://192.168.3.197:8788', // 写全协议则不跟随,固定 http
};
};
...
...
src/api/modules/__tests__/store.test.ts
View file @
d2e1654
...
@@ -5,6 +5,12 @@ import { setToken } from '../../core/token';
...
@@ -5,6 +5,12 @@ import { setToken } from '../../core/token';
import
*
as
signing
from
'../../core/sign'
;
import
*
as
signing
from
'../../core/sign'
;
import
{
store
}
from
'../store'
;
import
{
store
}
from
'../store'
;
// 业务路径契约独立于本机 .env 的部署前缀;公共 /youjia 前缀由 HTTP 层统一添加。
vi
.
mock
(
'../../core/config'
,
async
(
importOriginal
)
=>
({
...(
await
importOriginal
<
typeof
import
(
'../../core/config'
)
>
()),
API_CONTEXT_PATH
:
''
,
}));
const
originalAdapter
=
http
.
defaults
.
adapter
;
const
originalAdapter
=
http
.
defaults
.
adapter
;
const
approvalRecord
=
{
const
approvalRecord
=
{
listingId
:
'9007199254740993'
,
listingId
:
'9007199254740993'
,
...
@@ -73,6 +79,69 @@ afterEach(() => {
...
@@ -73,6 +79,69 @@ afterEach(() => {
});
});
describe
(
'store API contract'
,
()
=>
{
describe
(
'store API contract'
,
()
=>
{
it
(
'loads scene options with flat paging and search parameters and preserves scene names'
,
async
()
=>
{
serve
((
config
)
=>
{
expect
(
config
.
method
).
toBe
(
'get'
);
expect
(
config
.
url
).
toBe
(
'/store/category/scenes'
);
expect
(
config
.
params
).
toEqual
({
current
:
2
,
size
:
20
,
name
:
'售后'
,
status
:
1
});
return
{
data
:
result
([
{
id
:
201
,
name
:
'售后会员权益升级'
,
baseSceneCode
:
'110102'
,
status
:
1
},
{
id
:
202
,
name
:
'售后众筹'
,
baseSceneCode
:
'110103'
,
status
:
1
},
]),
};
});
expect
(
await
store
.
listScenes
({
current
:
2
,
size
:
20
,
name
:
'售后'
,
status
:
1
})).
toEqual
([
{
id
:
201
,
name
:
'售后会员权益升级'
,
baseSceneCode
:
'110102'
,
status
:
1
},
{
id
:
202
,
name
:
'售后众筹'
,
baseSceneCode
:
'110103'
,
status
:
1
},
]);
});
it
(
'loads only the requested goods category page and preserves its category hierarchy'
,
async
()
=>
{
let
requestCount
=
0
;
serve
((
config
)
=>
{
requestCount
+=
1
;
expect
(
config
.
method
).
toBe
(
'get'
);
expect
(
config
.
url
).
toBe
(
'/store/category/goods/page'
);
expect
(
config
.
params
).
toEqual
({
current
:
3
,
size
:
20
,
categoryName
:
'太阳膜'
});
return
{
data
:
result
({
records
:
[
{
id
:
51
,
categoryType
:
6
,
categoryName
:
'太阳膜'
,
children
:
[{
id
:
52
,
categoryType
:
7
,
categoryName
:
'原厂'
,
children
:
[]
}],
},
],
current
:
3
,
size
:
20
,
total
:
81
,
pages
:
5
,
}),
};
});
expect
(
await
store
.
listGoodsCategories
({
current
:
3
,
size
:
20
,
categoryName
:
'太阳膜'
}),
).
toEqual
({
records
:
[
{
id
:
51
,
categoryType
:
6
,
categoryName
:
'太阳膜'
,
children
:
[{
id
:
52
,
categoryType
:
7
,
categoryName
:
'原厂'
,
children
:
[]
}],
},
],
current
:
3
,
size
:
20
,
total
:
81
,
pages
:
5
,
});
expect
(
requestCount
).
toBe
(
1
);
});
it
.
each
([
it
.
each
([
[
'todo'
,
'/store/approval/pending'
],
[
'todo'
,
'/store/approval/pending'
],
[
'done'
,
'/store/approval/done'
],
[
'done'
,
'/store/approval/done'
],
...
...
src/api/modules/store.ts
View file @
d2e1654
...
@@ -8,10 +8,14 @@ import type {
...
@@ -8,10 +8,14 @@ import type {
ListingPageParams
,
ListingPageParams
,
StoreChangeLog
,
StoreChangeLog
,
StoreColumnConfig
,
StoreColumnConfig
,
StoreGoodsCategory
,
StoreGoodsCategoryQuery
,
StoreId
,
StoreId
,
StoreListingDetail
,
StoreListingDetail
,
StoreListingRow
,
StoreListingRow
,
StorePage
,
StorePage
,
StoreScene
,
StoreSceneQuery
,
}
from
'./storeTypes'
;
}
from
'./storeTypes'
;
export
*
from
'./storeTypes'
;
export
*
from
'./storeTypes'
;
...
@@ -149,6 +153,17 @@ const APPROVAL_PATHS: Record<ApproveTab, string> = {
...
@@ -149,6 +153,17 @@ const APPROVAL_PATHS: Record<ApproveTab, string> = {
};
};
class
Store
extends
ApiClient
{
class
Store
extends
ApiClient
{
listScenes
(
params
:
StoreSceneQuery
=
{})
{
return
this
.
get
<
StoreScene
[]
>
(
'/store/category/scenes'
,
params
as
Record
<
string
,
unknown
>
);
}
listGoodsCategories
(
params
:
StoreGoodsCategoryQuery
=
{})
{
return
this
.
get
<
StorePage
<
StoreGoodsCategory
>>
(
'/store/category/goods/page'
,
params
as
Record
<
string
,
unknown
>
,
);
}
listStores
(
params
:
ListingPageParams
=
{})
{
listStores
(
params
:
ListingPageParams
=
{})
{
return
this
.
get
<
StorePage
<
StoreListingRow
>>
(
return
this
.
get
<
StorePage
<
StoreListingRow
>>
(
'/store/listing/page'
,
'/store/listing/page'
,
...
...
src/api/modules/storeTypes.ts
View file @
d2e1654
...
@@ -11,6 +11,65 @@ export interface StorePage<T> {
...
@@ -11,6 +11,65 @@ export interface StorePage<T> {
pages
:
number
;
pages
:
number
;
}
}
/** GET /store/category/scenes 的扁平查询参数。 */
export
interface
StoreSceneQuery
{
current
?:
number
;
size
?:
number
;
name
?:
string
;
bizTypeCode
?:
string
;
subTypeCode
?:
string
;
sceneType
?:
number
;
businessType
?:
number
;
status
?:
number
;
baseSceneCode
?:
string
;
}
export
interface
StoreScene
{
id
?:
StoreId
|
null
;
num
?:
string
|
null
;
name
?:
string
|
null
;
baseSceneCode
?:
string
|
null
;
bizTypeCode
?:
string
|
null
;
bizTypeName
?:
string
|
null
;
subTypeCode
?:
string
|
null
;
subTypeName
?:
string
|
null
;
description
?:
string
|
null
;
sceneType
?:
number
|
null
;
businessType
?:
number
|
null
;
status
?:
number
|
null
;
statusName
?:
string
|
null
;
tagIds
?:
StoreId
[]
|
null
;
tagNames
?:
string
[]
|
null
;
createdBy
?:
string
|
null
;
createdDate
?:
string
|
null
;
updatedBy
?:
string
|
null
;
updatedDate
?:
string
|
null
;
}
/** GET /store/category/goods/page;分类名称由后端模糊匹配。 */
export
interface
StoreGoodsCategoryQuery
{
current
?:
number
;
size
?:
number
;
categoryName
?:
string
;
}
export
interface
StoreGoodsCategory
{
id
?:
StoreId
|
null
;
categoryType
?:
number
|
null
;
categoryName
?:
string
|
null
;
sceneType
?:
string
|
null
;
sceneName
?:
string
|
null
;
createdBy
?:
string
|
null
;
createdDate
?:
string
|
null
;
updatedBy
?:
string
|
null
;
updatedDate
?:
string
|
null
;
goodsSource
?:
string
|
null
;
parentId
?:
StoreId
|
null
;
level
?:
string
|
null
;
systemCategory
?:
string
|
null
;
children
?:
StoreGoodsCategory
[]
|
null
;
}
export
interface
ApprovalPageParams
{
export
interface
ApprovalPageParams
{
current
?:
number
;
current
?:
number
;
size
?:
number
;
size
?:
number
;
...
...
src/components/SearchForm/index.tsx
View file @
d2e1654
...
@@ -45,6 +45,7 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -45,6 +45,7 @@ export function SearchForm<T extends Record<string, unknown>>({
style={{ width }}
style={{ width }}
options={field.options}
options={field.options}
mode={field.type === 'selectMultiple' ? 'multiple' : undefined}
mode={field.type === 'selectMultiple' ? 'multiple' : undefined}
{...field.selectProps}
/>
/>
);
);
if (field.type === 'cascader')
if (field.type === 'cascader')
...
...
src/config/storeStatus.ts
View file @
d2e1654
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
// 共五个状态覆盖全部生命周期,其中仅「已生效」可对外展示(门店列表只展示已生效数据)。
// 共五个状态覆盖全部生命周期,其中仅「已生效」可对外展示(门店列表只展示已生效数据)。
export
type
StoreStatus
=
'PENDING'
|
'APPROVED'
|
'REJECTED'
|
'REVOKED'
|
'VOID'
;
export
type
StoreStatus
=
'PENDING'
|
'APPROVED'
|
'REJECTED'
|
'REVOKED'
|
'VOID'
;
// 状态徽标配色规范(待审批黄 / 已生效
绿
/ 已打回红 / 已撤回灰 / 已作废灰)
// 状态徽标配色规范(待审批黄 / 已生效
蓝
/ 已打回红 / 已撤回灰 / 已作废灰)
export
const
STORE_STATUS
:
Record
<
StoreStatus
,
{
label
:
string
;
color
:
string
}
>
=
{
export
const
STORE_STATUS
:
Record
<
StoreStatus
,
{
label
:
string
;
color
:
string
}
>
=
{
PENDING
:
{
label
:
'待审批'
,
color
:
'gold'
},
PENDING
:
{
label
:
'待审批'
,
color
:
'gold'
},
APPROVED
:
{
label
:
'已生效'
,
color
:
'
green
'
},
APPROVED
:
{
label
:
'已生效'
,
color
:
'
blue
'
},
REJECTED
:
{
label
:
'已打回'
,
color
:
'red'
},
REJECTED
:
{
label
:
'已打回'
,
color
:
'red'
},
REVOKED
:
{
label
:
'已撤回'
,
color
:
'#8A94A6'
},
REVOKED
:
{
label
:
'已撤回'
,
color
:
'#8A94A6'
},
VOID
:
{
label
:
'已作废'
,
color
:
'#C9CED6'
},
VOID
:
{
label
:
'已作废'
,
color
:
'#C9CED6'
},
...
...
src/features/store/ApprovalDetailPresentation.tsx
View file @
d2e1654
...
@@ -32,7 +32,7 @@ interface FlowStage {
...
@@ -32,7 +32,7 @@ interface FlowStage {
key: string;
key: string;
title: string;
title: string;
state: StageState;
state: StageState;
number
?
: number;
number: number;
actor?: string | null;
actor?: string | null;
time?: string | null;
time?: string | null;
caption?: string;
caption?: string;
...
@@ -101,10 +101,10 @@ function ApprovalStatus({ detail }: { detail: StoreListingDetail }) {
...
@@ -101,10 +101,10 @@ function ApprovalStatus({ detail }: { detail: StoreListingDetail }) {
}
}
function StageIcon({ state, number }: { state: StageState; number?: number }) {
function StageIcon({ state, number }: { state: StageState; number?: number }) {
if (number !== undefined) return <>{number}</>;
if (state === 'rejected') return <CloseOutlined />;
if (state === 'rejected') return <CloseOutlined />;
if (state === 'stopped') return <MinusOutlined />;
if (state === 'stopped') return <MinusOutlined />;
if (state === 'done' || number === undefined) return <CheckOutlined />;
return <CheckOutlined />;
return <>{number}</>;
}
}
export function ApprovalDetailHeader({
export function ApprovalDetailHeader({
...
@@ -174,6 +174,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
...
@@ -174,6 +174,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
{
{
key: 'submit',
key: 'submit',
title: '提交',
title: '提交',
number: 1,
state: 'done',
state: 'done',
actor: detail.submitUserName || EMPTY,
actor: detail.submitUserName || EMPTY,
time: detail.submitTime,
time: detail.submitTime,
...
@@ -198,7 +199,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
...
@@ -198,7 +199,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
return {
return {
key: title,
key: title,
title,
title,
number: index +
1
,
number: index +
2
,
state,
state,
actor: done ? passedLog?.operatorName : undefined,
actor: done ? passedLog?.operatorName : undefined,
time: done ? passedLog?.operateTime : undefined,
time: done ? passedLog?.operateTime : undefined,
...
@@ -215,6 +216,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
...
@@ -215,6 +216,7 @@ export function ApprovalStages({ detail }: { detail: StoreListingDetail }) {
{
{
key: 'effective',
key: 'effective',
title: '生效',
title: '生效',
number: roles.length + 2,
state: approved ? 'done' : stopped ? 'stopped' : 'waiting',
state: approved ? 'done' : stopped ? 'stopped' : 'waiting',
time: approved ? (detail.effectiveTime ?? detail.approveTime) : undefined,
time: approved ? (detail.effectiveTime ?? detail.approveTime) : undefined,
caption: approved ? undefined : stopped || rejected ? '未生效' : '写入门店列表',
caption: approved ? undefined : stopped || rejected ? '未生效' : '写入门店列表',
...
...
src/features/store/ListingDetailOverview.tsx
View file @
d2e1654
...
@@ -66,9 +66,11 @@ function ListingStatus({ detail }: { detail: StoreListingDetail }) {
...
@@ -66,9 +66,11 @@ function ListingStatus({ detail }: { detail: StoreListingDetail }) {
export function ListingDetailHeader({
export function ListingDetailHeader({
detail,
detail,
spec,
onClose,
onClose,
}: {
}: {
detail: StoreListingDetail;
detail: StoreListingDetail;
spec?: StoreDictionaries;
onClose: () => void;
onClose: () => void;
}) {
}) {
return (
return (
...
@@ -93,7 +95,7 @@ export function ListingDetailHeader({
...
@@ -93,7 +95,7 @@ export function ListingDetailHeader({
</div>
</div>
<div>
<div>
<dt>业务场景</dt>
<dt>业务场景</dt>
<dd>{d
etail.businessScene?.trim() ? '1 个' : EMPTY
}</dd>
<dd>{d
ictionaryLabel(spec?.businessScenes, detail.businessScene?.trim())
}</dd>
</div>
</div>
<div>
<div>
<dt>产品分类</dt>
<dt>产品分类</dt>
...
...
src/features/store/StoreDetailDrawer.test.tsx
View file @
d2e1654
...
@@ -150,7 +150,7 @@ describe('store detail presentation', () => {
...
@@ -150,7 +150,7 @@ describe('store detail presentation', () => {
});
});
const overview = within(screen.getByLabelText('门店概览'));
const overview = within(screen.getByLabelText('门店概览'));
expect(overview.getByRole('heading', { name: '当前门店' })).toBeInTheDocument();
expect(overview.getByRole('heading', { name: '当前门店' })).toBeInTheDocument();
for (const text of ['SQ001', '
1 个
', '6 个', '2026-10-09', 'v3', '已生效']) {
for (const text of ['SQ001', '
售后会员权益升级
', '6 个', '2026-10-09', 'v3', '已生效']) {
expect(overview.getByText(text)).toBeInTheDocument();
expect(overview.getByText(text)).toBeInTheDocument();
}
}
expect(overview.queryByText('提交人')).not.toBeInTheDocument();
expect(overview.queryByText('提交人')).not.toBeInTheDocument();
...
@@ -166,7 +166,7 @@ describe('store detail presentation', () => {
...
@@ -166,7 +166,7 @@ describe('store detail presentation', () => {
expect(onClose).toHaveBeenCalledOnce();
expect(onClose).toHaveBeenCalledOnce();
});
});
it('does not invent a version or scene
count
when listing fields are missing', () => {
it('does not invent a version or scene when listing fields are missing', () => {
show({
show({
mode: 'listing',
mode: 'listing',
detail: {
detail: {
...
@@ -179,6 +179,7 @@ describe('store detail presentation', () => {
...
@@ -179,6 +179,7 @@ describe('store detail presentation', () => {
});
});
const overview = within(screen.getByLabelText('门店概览'));
const overview = within(screen.getByLabelText('门店概览'));
expect(overview.getByText('当前版本')).toBeInTheDocument();
expect(overview.getByText('当前版本')).toBeInTheDocument();
expect(overview.getByText('业务场景').nextElementSibling).toHaveTextContent('—');
expect(overview.queryByText(/^v\d/)).not.toBeInTheDocument();
expect(overview.queryByText(/^v\d/)).not.toBeInTheDocument();
expect(overview.queryByText('1 个')).not.toBeInTheDocument();
expect(overview.queryByText('1 个')).not.toBeInTheDocument();
expect(overview.queryByText('0 个')).not.toBeInTheDocument();
expect(overview.queryByText('0 个')).not.toBeInTheDocument();
...
@@ -272,7 +273,46 @@ describe('store detail presentation', () => {
...
@@ -272,7 +273,46 @@ describe('store detail presentation', () => {
const flow = within(screen.getByLabelText('审批流程'));
const flow = within(screen.getByLabelText('审批流程'));
expect(flow.queryByText('优加商务经理')).not.toBeInTheDocument();
expect(flow.queryByText('优加商务经理')).not.toBeInTheDocument();
expect(flow.getByText('优加财务经理')).toBeInTheDocument();
expect(flow.getByText('优加财务经理')).toBeInTheDocument();
for (const [title, number] of [
['提交', '1'],
['优加财务经理', '2'],
['生效', '3'],
]) {
const stage = flow.getByText(title).closest('li')!;
expect(within(stage).getByText(number)).toBeInTheDocument();
}
});
it.each(['PENDING', 'APPROVED', 'REJECTED', 'REVOKED'] as const)(
'keeps all flow nodes continuously numbered after the flow advances to %s',
(status) => {
show({
detail: {
...detail,
status,
currentLevel: 2,
approvalLogs: [
{
action: 'PASS',
operatorRole: 'YJ_BUSINESS_MGR',
operatorName: '商务甲',
operateTime: '2026-10-09T11:00:00',
},
],
},
});
});
const flow = within(screen.getByLabelText('审批流程'));
for (const [title, number] of [
['提交', '1'],
['优加商务经理', '2'],
['优加财务经理', '3'],
['生效', '4'],
]) {
const stage = flow.getByText(title).closest('li')!;
expect(within(stage).getByText(number)).toBeInTheDocument();
}
},
);
it('does not describe a rejected record as awaiting approval and preserves the audit reason', () => {
it('does not describe a rejected record as awaiting approval and preserves the audit reason', () => {
show({ detail: { ...detail, status: 'REJECTED', rejectReason: '请核对政策' } });
show({ detail: { ...detail, status: 'REJECTED', rejectReason: '请核对政策' } });
...
...
src/features/store/StoreDetailDrawer.tsx
View file @
d2e1654
...
@@ -200,7 +200,7 @@ export function StoreDetailDrawer({
...
@@ -200,7 +200,7 @@ export function StoreDetailDrawer({
title={
title={
showCustomHeader ? (
showCustomHeader ? (
mode === 'listing' ? (
mode === 'listing' ? (
<ListingDetailHeader detail={detail!} onClose={onClose} />
<ListingDetailHeader detail={detail!}
spec={spec}
onClose={onClose} />
) : (
) : (
<ApprovalDetailHeader detail={detail!} spec={spec} onClose={onClose} />
<ApprovalDetailHeader detail={detail!} spec={spec} onClose={onClose} />
)
)
...
...
src/features/store/approvalDetail.css
View file @
d2e1654
...
@@ -72,8 +72,8 @@
...
@@ -72,8 +72,8 @@
}
}
.approval-detail-status--approved
{
.approval-detail-status--approved
{
background
:
#e6f5ee
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#087b54
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
}
}
.approval-detail-status--rejected
{
.approval-detail-status--rejected
{
...
@@ -141,8 +141,8 @@
...
@@ -141,8 +141,8 @@
.approval-detail-flow__heading
>
span
{
.approval-detail-flow__heading
>
span
{
padding
:
1px
8px
;
padding
:
1px
8px
;
border-radius
:
4px
;
border-radius
:
4px
;
background
:
#e4f5f4
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#008f88
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
font-size
:
13px
;
font-size
:
13px
;
line-height
:
22px
;
line-height
:
22px
;
}
}
...
@@ -176,7 +176,7 @@
...
@@ -176,7 +176,7 @@
}
}
.approval-detail-flow__node--done
:not
(
:last-child
)
::after
{
.approval-detail-flow__node--done
:not
(
:last-child
)
::after
{
background
:
#0da370
;
background
:
var
(
--uj-primary
,
#2b5ce6
)
;
}
}
.approval-detail-flow__icon
{
.approval-detail-flow__icon
{
...
@@ -197,8 +197,8 @@
...
@@ -197,8 +197,8 @@
.approval-detail-flow__node--done
.approval-detail-flow__icon
,
.approval-detail-flow__node--done
.approval-detail-flow__icon
,
.approval-detail-chaincard__icon--done
{
.approval-detail-chaincard__icon--done
{
border-color
:
#0da370
;
border-color
:
var
(
--uj-primary
,
#2b5ce6
)
;
background
:
#0da370
;
background
:
var
(
--uj-primary
,
#2b5ce6
)
;
color
:
#fff
;
color
:
#fff
;
}
}
...
...
src/features/store/approvalPolicy.css
View file @
d2e1654
...
@@ -47,8 +47,8 @@
...
@@ -47,8 +47,8 @@
max-width
:
280px
;
max-width
:
280px
;
padding
:
1px
7px
;
padding
:
1px
7px
;
border-radius
:
4px
;
border-radius
:
4px
;
background
:
#e4f5f4
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#07796f
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
font-size
:
12px
;
font-size
:
12px
;
font-weight
:
500
;
font-weight
:
500
;
line-height
:
20px
;
line-height
:
20px
;
...
...
src/features/store/dictionaries.ts
View file @
d2e1654
...
@@ -12,9 +12,9 @@ const textOptions = (values: string[]): DictOption[] =>
...
@@ -12,9 +12,9 @@ const textOptions = (values: string[]): DictOption[] =>
values
.
map
((
value
)
=>
({
value
,
label
:
value
}));
values
.
map
((
value
)
=>
({
value
,
label
:
value
}));
/**
/**
*
门店筛选和详情共用的本地字典;查询接口接收中文业务值
。
*
详情展示所用的本地映射和计算规则字典;未知业务名称原样回显
。
* 来源:2026-10-09 导入模板的计算/是否取值、模板示例及已返回的门店记录。
* 来源:2026-10-09 导入模板的计算/是否取值、模板示例及已返回的门店记录。
*
模板未提供完整场景/分类目录;新增业务值在此维护,未知回显值仍原样展示
。
*
场景/分类目录仅含历史示例,不用于筛选;筛选选项由分类查询接口提供
。
*/
*/
export
const
STORE_DICTIONARIES
:
StoreDictionaries
=
{
export
const
STORE_DICTIONARIES
:
StoreDictionaries
=
{
businessScenes
:
textOptions
([
'售后众筹'
,
'精品升级'
,
'售后会员权益升级'
,
'售前延保'
]),
businessScenes
:
textOptions
([
'售后众筹'
,
'精品升级'
,
'售后会员权益升级'
,
'售前延保'
]),
...
...
src/features/store/listingDetail.css
View file @
d2e1654
...
@@ -93,8 +93,8 @@
...
@@ -93,8 +93,8 @@
}
}
.listing-detail-status--approved
{
.listing-detail-status--approved
{
background
:
#e6f5ee
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#087b54
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
}
}
.listing-detail-status--pending
{
.listing-detail-status--pending
{
...
@@ -198,8 +198,8 @@
...
@@ -198,8 +198,8 @@
max-width
:
100%
;
max-width
:
100%
;
padding
:
1px
8px
;
padding
:
1px
8px
;
border-radius
:
4px
;
border-radius
:
4px
;
background
:
#e4f5f4
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#008f88
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
font-size
:
13px
;
font-size
:
13px
;
line-height
:
22px
;
line-height
:
22px
;
}
}
...
...
src/features/store/useStoreFilterOptions.test.tsx
0 → 100644
View file @
d2e1654
import type { PropsWithChildren } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import {
act,
cleanup,
fireEvent,
render,
renderHook,
screen,
waitFor,
} from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { useStoreFilterOptions } from './useStoreFilterOptions';
const api = vi.hoisted(() => ({ listScenes: vi.fn(), listGoodsCategories: vi.fn() }));
vi.mock('@/api', () => ({ store: api }));
const clients: QueryClient[] = [];
function setup(enabled = true, includeProducts = true) {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
clients.push(client);
const wrapper = ({ children }: PropsWithChildren) => (
<QueryClientProvider client={client}>{children}</QueryClientProvider>
);
return renderHook(() => useStoreFilterOptions({ enabled, includeProducts }), { wrapper });
}
const bottomScroll = {
currentTarget: { scrollHeight: 320, scrollTop: 280, clientHeight: 40 },
} as React.UIEvent<HTMLDivElement>;
beforeEach(() => {
vi.resetAllMocks();
api.listScenes.mockResolvedValue([{ name: '接口新增场景' }]);
api.listGoodsCategories.mockResolvedValue({
records: [{ categoryName: '接口新增分类' }],
current: 1,
size: 20,
total: 1,
pages: 1,
});
});
afterEach(() => {
cleanup();
clients.forEach((client) => client.clear());
clients.length = 0;
});
describe('store remote filter options', () => {
it('loads only one page, appends on scroll, and stops at the last page', async () => {
api.listGoodsCategories.mockImplementation(async ({ current }) => ({
records:
current === 1
? [
{
categoryName: '车辆美容',
children: [
{
categoryName: '车辆美容2级',
children: [{ categoryName: '车辆美容3级(集采)' }],
},
],
},
]
: [{ categoryName: '车辆美容' }, { categoryName: '第二页分类' }],
current,
size: 20,
total: 21,
pages: 2,
}));
const { result } = setup();
await waitFor(() =>
expect(result.current.productCategory.options).toContainEqual({
value: '车辆美容-车辆美容2级',
label: '车辆美容-车辆美容2级',
}),
);
expect(api.listGoodsCategories).toHaveBeenCalledTimes(1);
expect(api.listGoodsCategories).toHaveBeenCalledWith({
current: 1,
size: 20,
categoryName: undefined,
});
act(() => {
result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll);
result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll);
});
await waitFor(() =>
expect(result.current.productCategory.options.map((option) => option.value)).toEqual([
'',
'车辆美容',
'车辆美容-车辆美容2级',
'车辆美容-车辆美容2级-车辆美容3级(集采)',
'第二页分类',
]),
);
act(() => result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll));
expect(api.listGoodsCategories).toHaveBeenCalledTimes(2);
});
it('debounces remote search, resets pagination, and ignores an older search response', async () => {
let resolveOld!: (value: unknown) => void;
const response = (name: string) => ({
records: [{ categoryName: name }],
current: 1,
size: 20,
total: 1,
pages: 1,
});
api.listGoodsCategories.mockImplementation(({ categoryName }) =>
categoryName === '旧搜索'
? new Promise((resolve) => {
resolveOld = resolve;
})
: Promise.resolve(response(categoryName || '初始分类')),
);
const { result } = setup();
await waitFor(() => expect(result.current.productCategory.options).toHaveLength(2));
const search = (text: string) => {
const config = result.current.productCategory.selectProps.showSearch;
if (typeof config === 'object') config.onSearch?.(text);
};
act(() => {
search('旧');
search('旧搜索');
});
expect(api.listGoodsCategories).toHaveBeenCalledTimes(1);
await waitFor(() =>
expect(api.listGoodsCategories).toHaveBeenCalledWith({
current: 1,
size: 20,
categoryName: '旧搜索',
}),
);
act(() => search('新搜索'));
await waitFor(() =>
expect(result.current.productCategory.options).toContainEqual({
value: '新搜索',
label: '新搜索',
}),
);
await act(async () => resolveOld(response('旧搜索结果')));
expect(result.current.productCategory.options.map((option) => option.value)).toEqual([
'',
'新搜索',
]);
act(() => result.current.reset());
await waitFor(() =>
expect(result.current.productCategory.options.map((option) => option.value)).toEqual([
'',
'初始分类',
]),
);
});
it('uses scene names from the endpoint and skips product calls on the listing page', async () => {
const { result } = setup(true, false);
await waitFor(() =>
expect(result.current.businessScene.options).toContainEqual({
value: '接口新增场景',
label: '接口新增场景',
}),
);
expect(api.listGoodsCategories).not.toHaveBeenCalled();
});
it('can paginate a new keyword while an older keyword page is still loading', async () => {
let resolveOld!: (value: unknown) => void;
const page = (current: number, name: string) => ({
records: [{ categoryName: name }],
current,
size: 20,
total: 21,
pages: 2,
});
api.listGoodsCategories.mockImplementation(({ current, categoryName }) =>
!categoryName && current === 2
? new Promise((resolve) => {
resolveOld = resolve;
})
: Promise.resolve(page(current, `${categoryName || '初始'}${current}`)),
);
const { result } = setup();
await waitFor(() => expect(result.current.productCategory.options).toHaveLength(2));
act(() => result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll));
act(() => {
const config = result.current.productCategory.selectProps.showSearch;
if (typeof config === 'object') config.onSearch?.('新词');
});
await waitFor(() =>
expect(result.current.productCategory.options).toContainEqual({
value: '新词1',
label: '新词1',
}),
);
act(() => result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll));
await waitFor(() =>
expect(result.current.productCategory.options).toContainEqual({
value: '新词2',
label: '新词2',
}),
);
await act(async () => resolveOld(page(2, '旧页')));
expect(result.current.productCategory.options.map((option) => option.value)).toEqual([
'',
'新词1',
'新词2',
]);
});
it('preserves loaded options when loading more fails and retries the same page', async () => {
api.listGoodsCategories
.mockResolvedValueOnce({
records: [{ categoryName: '第一页' }],
current: 1,
size: 20,
total: 21,
pages: 2,
})
.mockRejectedValueOnce(new Error('网络异常'))
.mockResolvedValueOnce({
records: [{ categoryName: '第二页' }],
current: 2,
size: 20,
total: 21,
pages: 2,
});
const { result } = setup();
await waitFor(() => expect(result.current.productCategory.options).toHaveLength(2));
act(() => result.current.productCategory.selectProps.onPopupScroll?.(bottomScroll));
await waitFor(() => expect(api.listGoodsCategories).toHaveBeenCalledTimes(2));
await waitFor(() => expect(result.current.productCategory.selectProps.loading).toBe(false));
expect(result.current.productCategory.options[1].value).toBe('第一页');
render(<>{result.current.productCategory.selectProps.popupRender?.(<div />)}</>);
fireEvent.click(screen.getByRole('button', { name: '加载失败,点击重试' }));
await waitFor(() =>
expect(result.current.productCategory.options.map((option) => option.value)).toEqual([
'',
'第一页',
'第二页',
]),
);
expect(api.listGoodsCategories).toHaveBeenLastCalledWith({
current: 2,
size: 20,
categoryName: undefined,
});
});
it('does not load dictionaries without view permission', async () => {
setup(false);
await act(async () => {});
expect(api.listScenes).not.toHaveBeenCalled();
expect(api.listGoodsCategories).not.toHaveBeenCalled();
});
});
src/features/store/useStoreFilterOptions.tsx
0 → 100644
View file @
d2e1654
import { useEffect, useRef, useState } from 'react';
import { useInfiniteQuery } from '@tanstack/react-query';
import type { SelectProps } from 'antd';
import { UButton } from '@uj/ui';
import { store, type StoreGoodsCategory } from '@/api';
import type { FieldOption } from '@/components/formSchema';
const PAGE_SIZE = 20;
const ALL: FieldOption = { value: '', label: '全部' };
type OptionKind = 'scenes' | 'goods';
interface OptionPage {
options: FieldOption[];
next?: number;
}
function nameOptions(names: (string | null | undefined)[]): FieldOption[] {
return [
...new Set(names.map((name) => name?.trim()).filter((name): name is string => !!name)),
].map((name) => ({ value: name, label: name }));
}
function categoryNames(categories: StoreGoodsCategory[], ancestors: string[] = []): string[] {
return categories.flatMap((category) => {
const name = category.categoryName?.trim();
const path = name ? [...ancestors, name] : ancestors;
// 门店导入/审批记录存的是以“-”连接的完整分类路径,而字典 children 是分层名称。
return [...(name ? [path.join('-')] : []), ...categoryNames(category.children ?? [], path)];
});
}
/** 筛选接口仍接收名称;字典 ID 只属于字典接口,不能代替查询值。 */
async function loadOptions(
kind: OptionKind,
current: number,
keyword: string,
): Promise<OptionPage> {
if (kind === 'goods') {
const page = await store.listGoodsCategories({
current,
size: PAGE_SIZE,
categoryName: keyword || undefined,
});
return {
options: nameOptions(categoryNames(page.records ?? [])),
next: page.records?.length && page.current < page.pages ? page.current + 1 : undefined,
};
}
const scenes = await store.listScenes({ current, size: PAGE_SIZE, name: keyword || undefined });
return {
options: nameOptions((scenes ?? []).map((scene) => scene.name)),
// 场景接口返回数组,没有 total/pages;不足一页表示已加载完。
next: scenes?.length >= PAGE_SIZE ? current + 1 : undefined,
};
}
function useRemoteOptions(kind: OptionKind, enabled: boolean) {
const [search, setSearch] = useState('');
const [keyword, setKeyword] = useState('');
const fetchingNext = useRef<string | undefined>(undefined);
useEffect(() => {
const timer = window.setTimeout(() => setKeyword(search.trim()), 300);
return () => window.clearTimeout(timer);
}, [search]);
const query = useInfiniteQuery({
queryKey: ['store', 'filter-options', kind, keyword],
queryFn: ({ pageParam }) => loadOptions(kind, pageParam, keyword),
initialPageParam: 1,
getNextPageParam: (last, pages) => {
if (kind === 'scenes' && pages.length > 1) {
const previous = new Set(
pages.slice(0, -1).flatMap((page) => page.options.map((option) => option.value)),
);
// 兼容返回全量数组的场景服务,避免一直请求相同数据。
if (last.options.every((option) => previous.has(option.value))) return undefined;
}
return last.next;
},
enabled,
staleTime: 5 * 60_000,
retry: false,
});
const searching = search.trim() !== keyword;
const options = [ALL];
const seen = new Set<string | number>(['']);
for (const page of searching ? [] : (query.data?.pages ?? [])) {
for (const option of page.options) {
if (!seen.has(option.value)) {
seen.add(option.value);
options.push(option);
}
}
}
const reset = () => {
setSearch('');
setKeyword('');
};
const loadMore = () => {
if (
!enabled ||
searching ||
!query.hasNextPage ||
query.isFetching ||
fetchingNext.current === keyword
)
return;
fetchingNext.current = keyword;
void query.fetchNextPage({ cancelRefetch: false }).finally(() => {
if (fetchingNext.current === keyword) fetchingNext.current = undefined;
});
};
const loading = enabled && (searching || query.isFetching);
const selectProps: SelectProps = {
showSearch: { searchValue: search, onSearch: setSearch, filterOption: false },
loading,
onChange: reset,
onOpenChange: (open) => {
if (!open) reset();
},
onPopupScroll: (event) => {
const target = event.currentTarget;
if (target.scrollHeight - target.scrollTop - target.clientHeight < 32) loadMore();
},
popupRender: (menu) => (
<>
{menu}
<div
style={{ padding: '6px 12px', color: 'var(--uj-text-3)', fontSize: 12 }}
aria-live="polite"
>
{loading ? (
'加载中…'
) : query.isError ? (
<UButton
type="link"
size="small"
onMouseDown={(event) => event.preventDefault()}
onClick={() => {
if (query.isFetchNextPageError) loadMore();
else void query.refetch();
}}
>
加载失败,点击重试
</UButton>
) : options.length === 1 ? (
'暂无匹配选项'
) : query.hasNextPage ? (
'向下滚动加载更多'
) : (
'已加载全部'
)}
</div>
</>
),
};
return { options, selectProps, reset };
}
export function useStoreFilterOptions({
enabled,
includeProducts = false,
}: {
enabled: boolean;
includeProducts?: boolean;
}) {
const productCategory = useRemoteOptions('goods', enabled && includeProducts);
const businessScene = useRemoteOptions('scenes', enabled);
return {
productCategory,
businessScene,
reset: () => {
productCategory.reset();
businessScene.reset();
},
};
}
src/pages/StoreApprove/__tests__/StoreApprove.test.tsx
View file @
d2e1654
...
@@ -7,6 +7,8 @@ import type { ApprovalRow } from '@/api';
...
@@ -7,6 +7,8 @@ import type { ApprovalRow } from '@/api';
import StoreApprove from '../index';
import StoreApprove from '../index';
const api = vi.hoisted(() => ({
const api = vi.hoisted(() => ({
listScenes: vi.fn(),
listGoodsCategories: vi.fn(),
listApprovals: vi.fn(),
listApprovals: vi.fn(),
getApproval: vi.fn(),
getApproval: vi.fn(),
passApproval: vi.fn(),
passApproval: vi.fn(),
...
@@ -50,6 +52,14 @@ let detail = {
...
@@ -50,6 +52,14 @@ let detail = {
beforeEach(() => {
beforeEach(() => {
vi.resetAllMocks();
vi.resetAllMocks();
api.listScenes.mockResolvedValue([]);
api.listGoodsCategories.mockResolvedValue({
records: [],
total: 0,
current: 1,
size: 20,
pages: 0,
});
pending = [{ ...row }];
pending = [{ ...row }];
mine = [
mine = [
{ ...row, listingId: '202', status: 'REJECTED', statusLabel: '已打回', actionable: false },
{ ...row, listingId: '202', status: 'REJECTED', statusLabel: '已打回', actionable: false },
...
@@ -121,22 +131,42 @@ describe('门店审批页面', () => {
...
@@ -121,22 +131,42 @@ describe('门店审批页面', () => {
expect(screen.getByText('49 小时')).toBeInTheDocument();
expect(screen.getByText('49 小时')).toBeInTheDocument();
});
});
it('使用本地字典按实际中文业务场景和产品分类筛选', async () => {
it('使用接口新增的业务场景和产品分类选项,查询提交中文名称', async () => {
api.listScenes.mockResolvedValue([{ id: 11, name: '新能源车交付' }]);
api.listGoodsCategories.mockImplementation(async ({ categoryName }) => ({
records:
categoryName === '汽车精品'
? [{ id: 91, categoryType: 91, categoryName: '汽车精品专属服务', children: [] }]
: [],
total: categoryName === '汽车精品' ? 1 : 0,
current: 1,
size: 20,
pages: categoryName === '汽车精品' ? 1 : 0,
}));
mount();
mount();
await screen.findByText('测试门店');
await screen.findByText('测试门店');
fireEvent.mouseDown(screen.getByLabelText('业务场景'));
fireEvent.mouseDown(screen.getByLabelText('业务场景'));
fireEvent.click(
fireEvent.click(
await screen.findByText('
精品升级
', { selector: '.ant-select-item-option-content' }),
await screen.findByText('
新能源车交付
', { selector: '.ant-select-item-option-content' }),
);
);
fireEvent.mouseDown(screen.getByLabelText('产品分类'));
fireEvent.mouseDown(screen.getByLabelText('产品分类'));
fireEvent.change(screen.getByLabelText('产品分类'), { target: { value: '汽车精品' } });
fireEvent.click(
fireEvent.click(
await screen.findByText('
车辆美容
', { selector: '.ant-select-item-option-content' }),
await screen.findByText('
汽车精品专属服务
', { selector: '.ant-select-item-option-content' }),
);
);
expect(api.listGoodsCategories).toHaveBeenCalledWith({
current: 1,
size: 20,
categoryName: '汽车精品',
});
fireEvent.click(screen.getByRole('button', { name: '查询' }));
fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() =>
await waitFor(() =>
expect(api.listApprovals).toHaveBeenCalledWith(
expect(api.listApprovals).toHaveBeenCalledWith(
'todo',
'todo',
expect.objectContaining({ businessScene: '精品升级', productCategory: '车辆美容' }),
expect.objectContaining({
businessScene: '新能源车交付',
productCategory: '汽车精品专属服务',
}),
),
),
);
);
expect(screen.queryByText('筛选字典加载失败')).not.toBeInTheDocument();
expect(screen.queryByText('筛选字典加载失败')).not.toBeInTheDocument();
...
@@ -325,6 +355,8 @@ describe('门店审批页面', () => {
...
@@ -325,6 +355,8 @@ describe('门店审批页面', () => {
mount([]);
mount([]);
expect(screen.getByText('无门店审批访问权限')).toBeInTheDocument();
expect(screen.getByText('无门店审批访问权限')).toBeInTheDocument();
expect(api.listApprovals).not.toHaveBeenCalled();
expect(api.listApprovals).not.toHaveBeenCalled();
expect(api.listScenes).not.toHaveBeenCalled();
expect(api.listGoodsCategories).not.toHaveBeenCalled();
});
});
it('仅有通过权限不能替代页面查看权限,也不加载审批详情', () => {
it('仅有通过权限不能替代页面查看权限,也不加载审批详情', () => {
...
...
src/pages/StoreApprove/approveTable.css
View file @
d2e1654
...
@@ -37,14 +37,31 @@
...
@@ -37,14 +37,31 @@
white-space
:
nowrap
;
white-space
:
nowrap
;
}
}
.store-approve-categories
[
tabindex
]
{
cursor
:
help
;
}
.store-approve-category-list
{
max-height
:
320px
;
margin
:
0
;
padding
:
0
0
0
18px
;
overflow-y
:
auto
;
overflow-wrap
:
anywhere
;
white-space
:
normal
;
}
.store-approve-category-list
>
li
+
li
{
margin-top
:
4px
;
}
.store-approve-tag
{
.store-approve-tag
{
display
:
inline-flex
;
display
:
inline-flex
;
align-items
:
center
;
align-items
:
center
;
height
:
20px
;
height
:
20px
;
padding
:
0
7px
;
padding
:
0
7px
;
border-radius
:
4px
;
border-radius
:
4px
;
background
:
#e6f7f5
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#07796f
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
font-size
:
11px
;
font-size
:
11px
;
font-weight
:
500
;
font-weight
:
500
;
white-space
:
nowrap
;
white-space
:
nowrap
;
...
@@ -89,8 +106,8 @@
...
@@ -89,8 +106,8 @@
}
}
.store-approve-stay--normal
{
.store-approve-stay--normal
{
background
:
#e8f7f0
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#0b6b47
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
}
}
.store-approve-stay--warning
{
.store-approve-stay--warning
{
...
...
src/pages/StoreApprove/index.tsx
View file @
d2e1654
...
@@ -19,6 +19,7 @@ import {
...
@@ -19,6 +19,7 @@ import {
} from '@/api';
} from '@/api';
import { StoreDetailDrawer } from '@/features/store/StoreDetailDrawer';
import { StoreDetailDrawer } from '@/features/store/StoreDetailDrawer';
import { STORE_DICTIONARIES } from '@/features/store/dictionaries';
import { STORE_DICTIONARIES } from '@/features/store/dictionaries';
import { useStoreFilterOptions } from '@/features/store/useStoreFilterOptions';
import { buildApproveColumns } from './tools/columns';
import { buildApproveColumns } from './tools/columns';
import { ApprovalActionModal, type ApprovalAction } from './components/ApprovalActionModal';
import { ApprovalActionModal, type ApprovalAction } from './components/ApprovalActionModal';
import { errorMessage, tabDefs } from './tools/consts';
import { errorMessage, tabDefs } from './tools/consts';
...
@@ -35,6 +36,7 @@ const cleanText = (value: unknown) =>
...
@@ -35,6 +36,7 @@ const cleanText = (value: unknown) =>
export default function StoreApprove() {
export default function StoreApprove() {
const { canPoint } = useAccess();
const { canPoint } = useAccess();
const allowed = canPoint(P.STORE_APPROVE_VIEW);
const allowed = canPoint(P.STORE_APPROVE_VIEW);
const filterOptions = useStoreFilterOptions({ enabled: allowed, includeProducts: true });
const canPass = canPoint(P.STORE_APPROVE_AUDIT);
const canPass = canPoint(P.STORE_APPROVE_AUDIT);
const canReject = canPoint(P.STORE_APPROVE_REJECT);
const canReject = canPoint(P.STORE_APPROVE_REJECT);
const canRevoke = canPoint(P.STORE_APPROVE_REVOKE);
const canRevoke = canPoint(P.STORE_APPROVE_REVOKE);
...
@@ -186,14 +188,16 @@ export default function StoreApprove() {
...
@@ -186,14 +188,16 @@ export default function StoreApprove() {
label: '产品分类',
label: '产品分类',
type: 'select',
type: 'select',
width: '100%',
width: '100%',
options: [{ value: '', label: '全部' }, ...STORE_DICTIONARIES.productCategories],
options: filterOptions.productCategory.options,
selectProps: filterOptions.productCategory.selectProps,
},
},
{
{
name: 'businessScene',
name: 'businessScene',
label: '业务场景',
label: '业务场景',
type: 'select',
type: 'select',
width: '100%',
width: '100%',
options: [{ value: '', label: '全部' }, ...STORE_DICTIONARIES.businessScenes],
options: filterOptions.businessScene.options,
selectProps: filterOptions.businessScene.selectProps,
},
},
{
{
name: 'submitUserName',
name: 'submitUserName',
...
@@ -288,7 +292,10 @@ export default function StoreApprove() {
...
@@ -288,7 +292,10 @@ export default function StoreApprove() {
submitUserName: '',
submitUserName: '',
}}
}}
onSearch={changeQuery}
onSearch={changeQuery}
onReset={() => changeQuery({})}
onReset={() => {
filterOptions.reset();
changeQuery({});
}}
/>
/>
</UCard>
</UCard>
{list.isError ? (
{list.isError ? (
...
...
src/pages/StoreApprove/tools/columns.tsx
View file @
d2e1654
import type { ColumnsType } from 'antd/es/table';
import type { ColumnsType } from 'antd/es/table';
import { UTag } from '@uj/ui';
import { UTag
, UTooltip
} from '@uj/ui';
import { StatusTag } from '@/components/StatusTag';
import { StatusTag } from '@/components/StatusTag';
import type { ApprovalRow, ApproveTab } from '@/api';
import type { ApprovalRow, ApproveTab } from '@/api';
import type { StoreDictionaries } from '@/features/store/dictionaries';
import type { StoreDictionaries } from '@/features/store/dictionaries';
...
@@ -38,17 +38,34 @@ export function buildApproveColumns(
...
@@ -38,17 +38,34 @@ export function buildApproveColumns(
render: (_, row) => {
render: (_, row) => {
const categories = row.productCategories ?? [];
const categories = row.productCategories ?? [];
const count = row.categoryCount ?? categories.length;
const count = row.categoryCount ?? categories.length;
const categoryNames = categories
.filter((category) => category.trim())
.map((category) => dictionaryLabel(spec?.productCategories, category));
return (
return (
<span className="store-approve-categories">
<UTooltip
{categories[0] ? (
trigger={['hover', 'focus']}
<span className="store-approve-tag">
title={
{dictionaryLabel(spec?.productCategories, categories[0])}
categoryNames.length ? (
</span>
<ul className="store-approve-category-list" aria-label="全部产品分类">
{categoryNames.map((name, index) => (
<li key={`${name}-${index}`}>{name}</li>
))}
</ul>
) : undefined
}
>
<span
className="store-approve-categories"
tabIndex={categoryNames.length ? 0 : undefined}
>
{categoryNames[0] ? (
<span className="store-approve-tag">{categoryNames[0]}</span>
) : (
) : (
'—'
'—'
)}
)}
{count > 1 && <span className="store-approve-category-count">等 {count} 个分类</span>}
{count > 1 && <span className="store-approve-category-count">等 {count} 个分类</span>}
</span>
</span>
</UTooltip>
);
);
},
},
},
},
...
@@ -113,9 +130,7 @@ export function buildApproveColumns(
...
@@ -113,9 +130,7 @@ export function buildApproveColumns(
width: 110,
width: 110,
render: (_, row) => (
render: (_, row) => (
<UTag
<UTag
color={
color={row.myAction === 'PASS' ? 'blue' : row.myAction === 'REJECT' ? 'red' : undefined}
row.myAction === 'PASS' ? 'green' : row.myAction === 'REJECT' ? 'red' : undefined
}
>
>
{row.myActionLabel ||
{row.myActionLabel ||
({ PASS: '通过', REJECT: '打回' }[row.myAction ?? ''] ?? row.myAction ?? '—')}
({ PASS: '通过', REJECT: '打回' }[row.myAction ?? ''] ?? row.myAction ?? '—')}
...
...
src/pages/StoreListing/StoreListing.test.tsx
View file @
d2e1654
...
@@ -7,6 +7,8 @@ import { AccessTestProvider } from '@/test/AccessTestProvider';
...
@@ -7,6 +7,8 @@ import { AccessTestProvider } from '@/test/AccessTestProvider';
import StoreListing from './index';
import StoreListing from './index';
const api = vi.hoisted(() => ({
const api = vi.hoisted(() => ({
listScenes: vi.fn(),
listGoodsCategories: vi.fn(),
listStores: vi.fn(),
listStores: vi.fn(),
getStore: vi.fn(),
getStore: vi.fn(),
getChanges: vi.fn(),
getChanges: vi.fn(),
...
@@ -60,6 +62,14 @@ function renderPage(permissions = ['store:list:view', 'store:list:export']) {
...
@@ -60,6 +62,14 @@ function renderPage(permissions = ['store:list:view', 'store:list:export']) {
beforeEach(() => {
beforeEach(() => {
vi.clearAllMocks();
vi.clearAllMocks();
api.listScenes.mockResolvedValue([]);
api.listGoodsCategories.mockResolvedValue({
records: [],
total: 0,
current: 1,
size: 20,
pages: 0,
});
api.listStores.mockImplementation(async (params) => ({
api.listStores.mockImplementation(async (params) => ({
records: rows,
records: rows,
total: 42,
total: 42,
...
@@ -99,16 +109,17 @@ afterEach(() => {
...
@@ -99,16 +109,17 @@ afterEach(() => {
});
});
describe('门店列表', () => {
describe('门店列表', () => {
it('本地业务场景可筛选且导出沿用同一实际中文值', async () => {
it('接口新增的业务场景可筛选且导出沿用同一实际中文值', async () => {
api.listScenes.mockResolvedValue([{ id: 11, name: '新能源车交付' }]);
renderPage();
renderPage();
fireEvent.mouseDown(await screen.findByLabelText('业务场景'));
fireEvent.mouseDown(await screen.findByLabelText('业务场景'));
fireEvent.click(
fireEvent.click(
await screen.findByText('
售后众筹
', { selector: '.ant-select-item-option-content' }),
await screen.findByText('
新能源车交付
', { selector: '.ant-select-item-option-content' }),
);
);
fireEvent.click(screen.getByRole('button', { name: /查\s*询/ }));
fireEvent.click(screen.getByRole('button', { name: /查\s*询/ }));
await waitFor(() =>
await waitFor(() =>
expect(api.listStores).toHaveBeenLastCalledWith(
expect(api.listStores).toHaveBeenLastCalledWith(
expect.objectContaining({ businessScene: '
售后众筹
', current: 1 }),
expect.objectContaining({ businessScene: '
新能源车交付
', current: 1 }),
),
),
);
);
const exportButton = screen.getByRole('button', { name: /导\s*出/ });
const exportButton = screen.getByRole('button', { name: /导\s*出/ });
...
@@ -116,10 +127,11 @@ describe('门店列表', () => {
...
@@ -116,10 +127,11 @@ describe('门店列表', () => {
fireEvent.click(exportButton);
fireEvent.click(exportButton);
await waitFor(() =>
await waitFor(() =>
expect(api.exportStores).toHaveBeenCalledWith(
expect(api.exportStores).toHaveBeenCalledWith(
expect.objectContaining({ businessScene: '
售后众筹
' }),
expect.objectContaining({ businessScene: '
新能源车交付
' }),
),
),
);
);
expect(screen.queryByText('业务场景加载失败')).not.toBeInTheDocument();
expect(screen.queryByText('业务场景加载失败')).not.toBeInTheDocument();
expect(api.listGoodsCategories).not.toHaveBeenCalled();
});
});
it('提交真实筛选参数,翻页保留筛选,重置同时清空表单与请求', async () => {
it('提交真实筛选参数,翻页保留筛选,重置同时清空表单与请求', async () => {
...
@@ -379,6 +391,8 @@ describe('门店列表', () => {
...
@@ -379,6 +391,8 @@ describe('门店列表', () => {
expect(api.listStores).not.toHaveBeenCalled();
expect(api.listStores).not.toHaveBeenCalled();
expect(api.getColumnConfig).not.toHaveBeenCalled();
expect(api.getColumnConfig).not.toHaveBeenCalled();
expect(api.getStore).not.toHaveBeenCalled();
expect(api.getStore).not.toHaveBeenCalled();
expect(api.listScenes).not.toHaveBeenCalled();
expect(api.listGoodsCategories).not.toHaveBeenCalled();
});
});
it('仅有导出权限不能替代列表查看权限,也不显示导出操作', async () => {
it('仅有导出权限不能替代列表查看权限,也不显示导出操作', async () => {
...
...
src/pages/StoreListing/index.tsx
View file @
d2e1654
...
@@ -15,6 +15,7 @@ import {
...
@@ -15,6 +15,7 @@ import {
} from '@/components';
} from '@/components';
import { StoreDetailDrawer } from '@/features/store/StoreDetailDrawer';
import { StoreDetailDrawer } from '@/features/store/StoreDetailDrawer';
import { STORE_DICTIONARIES } from '@/features/store/dictionaries';
import { STORE_DICTIONARIES } from '@/features/store/dictionaries';
import { useStoreFilterOptions } from '@/features/store/useStoreFilterOptions';
import { buildColumns } from './components/columns';
import { buildColumns } from './components/columns';
import { ColumnConfigModal } from './components/ColumnConfigModal';
import { ColumnConfigModal } from './components/ColumnConfigModal';
import {
import {
...
@@ -34,6 +35,7 @@ export default function StoreListing() {
...
@@ -34,6 +35,7 @@ export default function StoreListing() {
const { message } = App.useApp();
const { message } = App.useApp();
const { canPoint } = useAccess();
const { canPoint } = useAccess();
const allowed = canPoint(P.STORE_LISTING_VIEW);
const allowed = canPoint(P.STORE_LISTING_VIEW);
const filterOptions = useStoreFilterOptions({ enabled: allowed, includeProducts: false });
const queryClient = useQueryClient();
const queryClient = useQueryClient();
const [params, setParams] = useState<ListingPageParams>(INITIAL_PARAMS);
const [params, setParams] = useState<ListingPageParams>(INITIAL_PARAMS);
const [queryVersion, setQueryVersion] = useState(0);
const [queryVersion, setQueryVersion] = useState(0);
...
@@ -103,7 +105,8 @@ export default function StoreListing() {
...
@@ -103,7 +105,8 @@ export default function StoreListing() {
label: '业务场景',
label: '业务场景',
type: 'select',
type: 'select',
width: '100%',
width: '100%',
options: [{ value: '', label: '全部' }, ...STORE_DICTIONARIES.businessScenes],
options: filterOptions.businessScene.options,
selectProps: filterOptions.businessScene.selectProps,
},
},
{ name: 'effectiveRange', label: '上架时间', type: 'dateRange', width: '100%' },
{ name: 'effectiveRange', label: '上架时间', type: 'dateRange', width: '100%' },
];
];
...
@@ -186,6 +189,7 @@ export default function StoreListing() {
...
@@ -186,6 +189,7 @@ export default function StoreListing() {
if (!exportFile.isPending) exportFile.reset();
if (!exportFile.isPending) exportFile.reset();
}}
}}
onReset={() => {
onReset={() => {
filterOptions.reset();
setParams({ ...INITIAL_PARAMS, size: params.size });
setParams({ ...INITIAL_PARAMS, size: params.size });
setQueryVersion((version) => version + 1);
setQueryVersion((version) => version + 1);
if (!exportFile.isPending) exportFile.reset();
if (!exportFile.isPending) exportFile.reset();
...
...
src/pages/StoreListing/listing.css
View file @
d2e1654
...
@@ -96,8 +96,8 @@
...
@@ -96,8 +96,8 @@
padding
:
0
7px
;
padding
:
0
7px
;
border
:
0
;
border
:
0
;
border-radius
:
4px
;
border-radius
:
4px
;
background
:
#e6f7f5
;
background
:
var
(
--ant-color-primary-bg
,
#eef3ff
)
;
color
:
#07796f
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
font-size
:
11px
;
font-size
:
11px
;
font-weight
:
500
;
font-weight
:
500
;
line-height
:
1.57
;
line-height
:
1.57
;
...
...
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