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
@@ -12,6 +12,7 @@ import {
|
||||
type RelatedPrintBlock
|
||||
} from '@/utils/oa-approval-print-related'
|
||||
import { formatProgressPersonLines } from '@/utils/oa-progress-person-lines'
|
||||
import { formatDeptDisplay } from '@/utils/oa-dept-value'
|
||||
|
||||
export const OA_PRINT_COMPANY_NAME = '安徽中科兴皖医学研究有限公司'
|
||||
|
||||
@@ -237,6 +238,12 @@ async function walkRules(
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'dept') {
|
||||
const text = formatDeptDisplay(value)
|
||||
out.push({ label, text: text || '-' })
|
||||
continue
|
||||
}
|
||||
|
||||
if (UPLOAD_TYPES.has(type) || String(rule.name || '').toLowerCase().includes('upload')) {
|
||||
const urls = extractUrls(value)
|
||||
out.push({ label, urls: urls.length ? urls : [], text: urls.length ? undefined : '-' })
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/** 与 FormCreate 官方 unique 同类:生成不重复 field */
|
||||
let _uidSeq = 0
|
||||
function uniqueId() {
|
||||
const num = 370 + ++_uidSeq
|
||||
return (
|
||||
'F' +
|
||||
Math.random().toString(36).slice(3, 6) +
|
||||
Number(`${Date.now()}`).toString(36) +
|
||||
num.toString(36) +
|
||||
'c'
|
||||
)
|
||||
}
|
||||
|
||||
/** FormCreate Designer DragRule:部门选择 */
|
||||
export const deptSelectDragRule = {
|
||||
menu: 'main' as const,
|
||||
icon: 'icon-tree',
|
||||
label: '部门',
|
||||
name: 'dept',
|
||||
input: true,
|
||||
mask: true,
|
||||
validate: ['string', 'array', 'object'],
|
||||
event: ['change'],
|
||||
rule() {
|
||||
return {
|
||||
type: 'dept',
|
||||
field: uniqueId(),
|
||||
title: '部门',
|
||||
info: '',
|
||||
$required: false,
|
||||
props: {
|
||||
multiple: true,
|
||||
max: undefined as number | undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
props() {
|
||||
return [
|
||||
{
|
||||
type: 'switch',
|
||||
field: 'multiple',
|
||||
title: '允许多选',
|
||||
value: true,
|
||||
props: { activeText: '是', inactiveText: '否' }
|
||||
},
|
||||
{
|
||||
type: 'inputNumber',
|
||||
field: 'max',
|
||||
title: '最大可选数',
|
||||
value: undefined,
|
||||
props: { min: 1, precision: 0, placeholder: '不填则不限制' }
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
field: 'formCreateInfo',
|
||||
title: '提示信息'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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 ''
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import FcDesigner from '@form-create/designer'
|
||||
import OaDeptSelect from '@/components/oa-approval/OaDeptSelect.vue'
|
||||
import { deptSelectDragRule } from '@/utils/oa-dept-select-rule'
|
||||
|
||||
const FLAG = '__oaDeptSelectConfigured'
|
||||
|
||||
export function setupOaDeptSelect(formCreate?: { component?: (name: string, c: unknown) => void }) {
|
||||
if ((FcDesigner as any)[FLAG]) return
|
||||
FcDesigner.component('dept', OaDeptSelect)
|
||||
if (typeof formCreate?.component === 'function') {
|
||||
formCreate.component('dept', OaDeptSelect)
|
||||
}
|
||||
if (typeof FcDesigner.addDragRule === 'function') {
|
||||
FcDesigner.addDragRule(deptSelectDragRule)
|
||||
}
|
||||
;(FcDesigner as any)[FLAG] = true
|
||||
}
|
||||
Reference in new issue
Block a user