Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19afdf3615 | ||
|
|
31b723839e | ||
|
|
1f48a02083 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shrimp-server",
|
||||
"version": "0.7.7",
|
||||
"version": "0.7.12",
|
||||
"description": "Shrimp 框架后端 — 声明式字段驱动的 Node.js 管理后台框架(Express + Mongoose + JWT)",
|
||||
"main": "dist/main/index.js",
|
||||
"types": "dist/main/index.d.ts",
|
||||
|
||||
@@ -292,7 +292,8 @@ export class ShrimpTableModule<T, P extends ITableCrudProto<T> = ITableCrudProto
|
||||
private collectOne(f: IFieldConfig, v: any, add: (moduleKey: string, labelKey: string, id: any) => void): void {
|
||||
if (v == null) return
|
||||
if (f.type === "relation" && f.relation) {
|
||||
;(Array.isArray(v) ? v : [v]).forEach((id: any) => id != null && add(f.relation!.moduleKey, f.relation!.labelKey, id))
|
||||
// 跳过空串:可选 Relation 常存 "",混进 { _id: { $in } } 会让 Mongoose 转 ObjectId 抛 CastError、整页 500。
|
||||
;(Array.isArray(v) ? v : [v]).forEach((id: any) => id != null && id !== "" && add(f.relation!.moduleKey, f.relation!.labelKey, id))
|
||||
} else if (f.type === ShrimpFieldTypes.Tab && Array.isArray(f.tabs) && typeof v === "object") {
|
||||
const branch = f.tabs.find(t => t.key === v.type)
|
||||
if (branch) for (const c of branch.fields) this.collectOne(c, v[c.key], add)
|
||||
|
||||
@@ -34,6 +34,7 @@ describe("crudRegistry 自动登记", () => {
|
||||
await productCrud.add({ code: "P001", tagIds: [t1._id, t2._id] } as any)
|
||||
|
||||
const result = await productModule.list({})
|
||||
expect((result.list[0] as any).tagIds_label).toEqual(["热门", "促销"])
|
||||
// _label 逐行机制已退场:relation 显示名走整页 refs 字典(refs[moduleKey][id])
|
||||
expect((result as any).refs?.tag).toEqual({ [t1._id]: "热门", [t2._id]: "促销" })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user