This commit is contained in:
zlwu committed 2026-07-30 15:02:13 +08:00
1 parent f7d1004e6b
commit 310b2efe8a
91 files changed
+14420 -10840

No files matched your search

+7
View File
@@ -14,6 +14,7 @@ import {
import { formatProgressPersonLines } from '@/utils/oa-progress-person-lines'
import { formatDeptDisplay } from '@/utils/oa-dept-value'
import { formatPersonDisplay } from '@/utils/oa-person-value'
import { formatPostDisplay } from '@/utils/oa-post-value'
import { formatMoneyDisplay } from '@/utils/money-format'
import { formatReceiveAccountDisplay } from '@/utils/oa-receive-account-value'
import { toRmbUpper } from '@/utils/rmb-upper'
@@ -254,6 +255,12 @@ async function walkRules(
continue
}
if (type === 'post') {
const text = formatPostDisplay(value)
out.push({ label, text: text || '-' })
continue
}
if (type === 'money') {
const showUpper = rule.props?.showUpper !== false
const n =
@@ -0,0 +1,17 @@
import FcDesigner from '@form-create/designer'
import OaPostSelect from '@/components/oa-approval/OaPostSelect.vue'
import { postSelectDragRule } from '@/utils/oa-post-select-rule'
const FLAG = '__oaPostSelectConfigured'
export function setupOaPostSelect(formCreate?: { component?: (name: string, c: unknown) => void }) {
if ((FcDesigner as any)[FLAG]) return
FcDesigner.component('post', OaPostSelect)
if (typeof formCreate?.component === 'function') {
formCreate.component('post', OaPostSelect)
}
if (typeof FcDesigner.addDragRule === 'function') {
FcDesigner.addDragRule(postSelectDragRule)
}
;(FcDesigner as any)[FLAG] = true
}
@@ -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) +
't'
)
}
/** FormCreate Designer DragRule:职位选择 */
export const postSelectDragRule = {
menu: 'main' as const,
icon: 'icon-input',
label: '职位',
name: 'post',
input: true,
mask: true,
validate: ['string', 'array', 'object'],
event: ['change'],
rule() {
return {
type: 'post',
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: '提示信息'
}
]
}
}
+61
View File
@@ -0,0 +1,61 @@
export type OaPostValueItem = { id: string; name: string }
export function isPostValueItem(v: unknown): v is OaPostValueItem {
if (!v || typeof v !== 'object') return false
const o = v as Record<string, unknown>
return String(o.id || '').trim() !== '' && String(o.name || '').trim() !== ''
}
export function normalizePostModelValue(
raw: unknown,
multiple: boolean
): OaPostValueItem | OaPostValueItem[] | null {
if (multiple) {
if (Array.isArray(raw)) {
return raw.filter(isPostValueItem).map((x) => ({
id: String(x.id).trim(),
name: String(x.name).trim()
}))
}
if (isPostValueItem(raw)) {
return [{ id: String(raw.id).trim(), name: String(raw.name).trim() }]
}
return []
}
if (isPostValueItem(raw)) {
return { id: String(raw.id).trim(), name: String(raw.name).trim() }
}
if (Array.isArray(raw) && raw.length === 1 && isPostValueItem(raw[0])) {
return { id: String(raw[0].id).trim(), name: String(raw[0].name).trim() }
}
return null
}
export function formatPostDisplay(raw: unknown): string {
if (Array.isArray(raw)) {
return raw
.filter(isPostValueItem)
.map((x) => x.name)
.filter(Boolean)
.join('、')
}
if (isPostValueItem(raw)) return raw.name
return ''
}
export function extractPostIds(raw: unknown): string[] {
const n = Array.isArray(raw)
? raw.filter(isPostValueItem)
: isPostValueItem(raw)
? [raw]
: []
const out: string[] = []
const seen = new Set<string>()
for (const x of n) {
const id = String(x.id).trim()
if (!id || seen.has(id)) continue
seen.add(id)
out.push(id)
}
return out
}