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:
1 parent
45d84d9642
commit
2e6e1f47d6
9 files changed
+475
No files matched your search
@@ -0,0 +1,45 @@
|
||||
export type OaDeptValueItem = { id: string; name: string }
|
||||
|
||||
export function isDeptValueItem(v: unknown): v is OaDeptValueItem {
|
||||
if (!v || typeof v !== 'object') return false
|
||||
const o = v as Record<string, unknown>
|
||||
return String(o.id || '').trim() !== '' && String(o.name || '').trim() !== ''
|
||||
}
|
||||
|
||||
/** 单选 → item|null;多选 → items(容错把单对象包成数组) */
|
||||
export function normalizeDeptModelValue(
|
||||
raw: unknown,
|
||||
multiple: boolean
|
||||
): OaDeptValueItem | OaDeptValueItem[] | null {
|
||||
if (multiple) {
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.filter(isDeptValueItem).map((x) => ({
|
||||
id: String(x.id).trim(),
|
||||
name: String(x.name).trim()
|
||||
}))
|
||||
}
|
||||
if (isDeptValueItem(raw)) {
|
||||
return [{ id: String(raw.id).trim(), name: String(raw.name).trim() }]
|
||||
}
|
||||
return []
|
||||
}
|
||||
if (isDeptValueItem(raw)) {
|
||||
return { id: String(raw.id).trim(), name: String(raw.name).trim() }
|
||||
}
|
||||
if (Array.isArray(raw) && raw.length === 1 && isDeptValueItem(raw[0])) {
|
||||
return { id: String(raw[0].id).trim(), name: String(raw[0].name).trim() }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function formatDeptDisplay(raw: unknown): string {
|
||||
if (Array.isArray(raw)) {
|
||||
return raw
|
||||
.filter(isDeptValueItem)
|
||||
.map((x) => x.name)
|
||||
.filter(Boolean)
|
||||
.join('、')
|
||||
}
|
||||
if (isDeptValueItem(raw)) return raw.name
|
||||
return ''
|
||||
}
|
||||
Reference in new issue
Block a user