feat: 资产管理前端从管理端拆分为独立工程
CI / build-and-test (push) Canceled after 0s

以 ckcloudManage a44810c 为基础,只保留资产页面(台账、单据、基础数据、同步任务)、
登录/错误/个人资料等公共页面,以及资产单据“查看流程”用到的流程详情页;
统一登录应用编码默认 CK_ASSET,标题“资产管理”,本地端口 9090。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 03:44:26 -08:00
co-authored by Claude Opus 5.5
commit 2072c6780f
713 changed files with 96036 additions and 0 deletions
+101
View File
@@ -0,0 +1,101 @@
import {
eachTree,
filter,
findNode,
findPath,
forEach,
handleTree,
handleTree2,
treeMap,
treeToList
} from '@/utils/tree'
interface Dept {
id: number
parentId: number
name: string
children?: Dept[]
}
const flat = (): Dept[] => [
{ id: 1, parentId: 0, name: '财开' },
{ id: 2, parentId: 1, name: '信息部' },
{ id: 3, parentId: 1, name: '财务部' },
{ id: 4, parentId: 2, name: '开发组' },
{ id: 5, parentId: 99, name: '孤立节点' }
]
describe('utils/tree', () => {
it('handleTree 按 parentId 组装树,父节点不存在的作为根', () => {
const tree = handleTree<Dept>(flat())
expect(tree.map((n) => n.id)).toEqual([1, 5])
expect(tree[0].children!.map((n) => n.id)).toEqual([2, 3])
expect(tree[0].children![0].children![0].name).toBe('开发组')
})
it('handleTree 非数组输入返回空数组', () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
expect(handleTree(null as unknown as Dept[])).toEqual([])
expect(warn).toHaveBeenCalled()
})
it('handleTree 支持自定义字段名', () => {
const data = [
{ key: 'a', pid: '', label: 'A' },
{ key: 'b', pid: 'a', label: 'B' }
]
const tree = handleTree<Record<string, unknown>>(data, 'key', 'pid', 'items')
expect(tree).toHaveLength(1)
expect((tree[0].items as unknown[]).length).toBe(1)
})
it('handleTree2 以 rootId 取根且不修改入参', () => {
const files = [
{ id: 'src', parentId: '/', label: 'src' },
{ id: 'src/a.ts', parentId: 'src', label: 'a.ts' }
]
const tree = handleTree2(files, 'id', 'parentId', 'children', '/')
expect(tree).toHaveLength(1)
expect((tree[0] as { children?: unknown[] }).children).toHaveLength(1)
expect('children' in files[0]).toBe(false)
// 默认根取最小 parentId
const numeric = handleTree2(flat().slice(0, 4))
expect(numeric.map((n) => n.id)).toEqual([1])
})
it('treeToList / findNode / findPath / forEach 遍历', () => {
const tree = handleTree<Dept>(flat())
expect(treeToList(tree).map((n) => n.id)).toEqual([1, 2, 4, 3, 5])
expect(findNode(tree, (n) => n.id === 4)?.name).toBe('开发组')
expect(findNode(tree, (n) => n.id === 404)).toBeNull()
expect(findPath(tree, (n) => n.id === 4)?.map((n) => n.id)).toEqual([1, 2, 4])
expect(findPath(tree, (n) => n.id === 404)).toBeNull()
const visited: number[] = []
forEach(tree, (n) => {
visited.push(n.id)
return n.id === 2 // 返回 true 终止遍历
})
expect(visited).toEqual([1, 2])
})
it('filter 保留命中节点及其祖先', () => {
const tree = handleTree<Dept>(flat())
const result = filter(tree, (n) => n.name === '开发组')
expect(result.map((n) => n.id)).toEqual([1])
expect(result[0].children!.map((n) => n.id)).toEqual([2])
expect(result[0].children![0].children!.map((n) => n.id)).toEqual([4])
})
it('treeMap 转换结构,eachTree 传入父节点', () => {
const tree = handleTree<Dept>(flat())
const mapped = treeMap(tree, { conversion: (n: Dept) => ({ value: n.id, label: n.name }) })
expect(mapped[0]).toMatchObject({ value: 1, label: '财开' })
expect((mapped[0] as unknown as { children: unknown[] }).children).toHaveLength(2)
const parents: Record<number, string | undefined> = {}
eachTree(tree, (node: Dept, parent: Dept) => {
parents[node.id] = parent.name
})
expect(parents[4]).toBe('信息部')
expect(parents[1]).toBeUndefined()
})
})