feat(oa): add dept select FormCreate control with print formatting

Register type=dept on main app and oa-fc-host, with PC tree-select and
narrow drawer pickers storing {id,name} path snapshots; format dept values
in print and related-summary flatten.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-27 18:32:44 +08:00
1 parent 45d84d9642
commit 2e6e1f47d6
9 files changed
+475

No files matched your search

@@ -104,6 +104,18 @@ def _format_value(typ: str, raw: Any) -> Tuple[str, bool]:
else:
n = 0
return f"已关联 {n} 条", False
if typ == "dept":
if isinstance(raw, list):
names = []
for x in raw:
if isinstance(x, dict):
n = str(x.get("name") or "").strip()
if n:
names.append(n)
return "、".join(names) if names else "", False
if isinstance(raw, dict):
return str(raw.get("name") or "").strip(), False
return "", False
if isinstance(raw, list):
text = "、".join(str(x) for x in raw if x is not None and str(x) != "")
elif isinstance(raw, dict):
+24
View File
@@ -37,6 +37,30 @@ class TestFlatten(unittest.TestCase):
self.assertEqual(fields[2].get("relatedIds"), ["id1", "id2"])
self.assertTrue(fields[3].get("fullWidth"))
def test_dept_formats_path_names(self):
schema = {
"rule": [
{"type": "dept", "field": "dept", "title": "部门"},
{
"type": "dept",
"field": "depts",
"title": "多部门",
"props": {"multiple": True},
},
]
}
data = {
"dept": {"id": "d1", "name": "中科兴皖 / 研发"},
"depts": [
{"id": "d1", "name": "中科兴皖 / 研发"},
{"id": "d2", "name": "中科兴皖 / 质量"},
],
}
fields = flatten_form_fields_for_summary(schema, data)
by_label = {f["label"]: f["value"] for f in fields}
self.assertEqual(by_label["部门"], "中科兴皖 / 研发")
self.assertEqual(by_label["多部门"], "中科兴皖 / 研发、中科兴皖 / 质量")
def test_related_approval_field_includes_related_ids(self):
schema = {
"rule": [