feat(consignment): 支持复制寄卖模板配置与一二级分类折叠展示

This commit is contained in:
2026-11-09 16:00:09 +08:00
parent 6867431a72
commit 89a3d23874
10 changed files with 969 additions and 38 deletions
@@ -170,6 +170,18 @@ test('寄售仓库筛选选项:只取已发布且分类启用的配置,并
assert.ok(body.includes('inventoryCountByCategoryId'), '无库存的继承子分类不应出现')
})
test('寄卖配置:后台返回父分类与发布快照,打手端返回父分类层级字段', async () => {
const source = await readFile(
new URL('./consignment-profile-service.ts', import.meta.url),
'utf8',
)
assert.ok(source.includes('pc.name AS category_parent_name'), '必须返回父分类名称')
assert.ok(source.includes('publishedConfig'), '必须返回已发布版本配置')
assert.ok(source.includes('categoryParentName'), '打手端必须返回父分类名称')
assert.ok(source.includes('categoryParentId'), '打手端必须返回父分类 ID')
})
test('规格字段 filterable:选项类默认开启,其它类型默认关闭,显式值优先', () => {
const [optionField] = normalizeConsignmentSpecs([buildSpec()])
assert.equal(optionField?.filterable, true)
@@ -125,7 +125,10 @@ export type ConsignmentProfileRow = {
created_at: string
updated_at: string
category_name?: string
category_key?: string
category_parent_id?: number | null
/** 父分类名称:打手端/复制模板弹窗按「一级 / 二级」展示 */
category_parent_name?: string | null
current_version_no?: number | null
/** 当前发布版本快照(consignment_profile_versions.config_json) */
current_version_config_json?: unknown
@@ -366,8 +369,10 @@ function mapProfile(row: ConsignmentProfileRow) {
return {
profileId: Number(row.id),
categoryId: Number(row.category_id),
categoryKey: row.category_key || '',
categoryName: row.category_name || '',
categoryParentId: row.category_parent_id ? Number(row.category_parent_id) : null,
categoryParentName: row.category_parent_name || '',
name: row.name,
title: row.title || '',
description: row.description || '',
@@ -376,6 +381,10 @@ function mapProfile(row: ConsignmentProfileRow) {
currentVersionId: row.current_version_id ? Number(row.current_version_id) : null,
currentVersionNo: row.current_version_no ? Number(row.current_version_no) : null,
config: normalizeConsignmentProfileConfig(row.config_json),
/** 当前发布版本快照;从未发布过为 null。复制模板弹窗的「已发布版本」用它。 */
publishedConfig: row.current_version_config_json
? normalizeConsignmentProfileConfig(row.current_version_config_json)
: null,
createdAt: row.created_at,
updatedAt: row.updated_at,
}
@@ -385,11 +394,14 @@ const PROFILE_SELECT = `
SELECT
p.*,
c.name AS category_name,
c.category_key AS category_key,
c.parent_id AS category_parent_id,
pc.name AS category_parent_name,
v.version_no AS current_version_no,
v.config_json AS current_version_config_json
FROM consignment_profiles p
INNER JOIN work_categories c ON c.id = p.category_id
LEFT JOIN work_categories pc ON pc.id = c.parent_id
LEFT JOIN consignment_profile_versions v ON v.id = p.current_version_id
`
@@ -582,7 +594,10 @@ export async function listWorkerConsignmentProfiles(workerId?: number) {
return {
profileId: Number(row.id),
categoryId: Number(row.category_id),
categoryKey: row.category_key || '',
categoryName: row.category_name || '',
categoryParentId: row.category_parent_id ? Number(row.category_parent_id) : null,
categoryParentName: row.category_parent_name || '',
name: row.name,
title: row.title || row.name,
description: row.description || '',