提交
This commit is contained in:
1 parent
80138c6388
commit
693e8a678e
682 files changed
+211375
-5306
No files matched your search
@@ -17,7 +17,12 @@ 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 {
|
||||
formatFormValueDisplay,
|
||||
formatRegionLikeDisplay
|
||||
} from '@/utils/oa-form-value-display'
|
||||
import { toRmbUpper } from '@/utils/rmb-upper'
|
||||
import { formatOaUploadPathsForPrint } from '@/utils/oa-upload-file-type'
|
||||
|
||||
export const OA_PRINT_COMPANY_NAME = '安徽中科兴皖医学研究有限公司'
|
||||
|
||||
@@ -29,19 +34,24 @@ export type OaPrintFieldRow = {
|
||||
label: string
|
||||
/** 普通文本(可含换行) */
|
||||
text?: string
|
||||
/** 附件 / 链接列表 */
|
||||
/** 附件文件名 / 链接列表(上传字段仅文件名) */
|
||||
urls?: string[]
|
||||
/** 关联审批单多行块(优先于 text) */
|
||||
blocks?: RelatedPrintBlock[]
|
||||
}
|
||||
|
||||
export type OaPrintPersonLine = {
|
||||
left: string
|
||||
right: string
|
||||
}
|
||||
|
||||
export type OaPrintFlowItem = {
|
||||
left: string
|
||||
right: string
|
||||
/** @deprecated 多人节点改用 personLines;单人/发起人可保留 */
|
||||
comment?: string
|
||||
/** 或签/会签按人纯文本行 */
|
||||
personLines?: string[]
|
||||
/** 或签/会签按人行:左侧文案 + 右侧时间(右对齐) */
|
||||
personLines?: OaPrintPersonLine[]
|
||||
}
|
||||
|
||||
export type OaPrintModel = {
|
||||
@@ -172,25 +182,7 @@ function extractUrls(value: unknown): string[] {
|
||||
}
|
||||
|
||||
function formatScalar(value: unknown, sep = '、'): string {
|
||||
if (value == null || value === '') return '-'
|
||||
if (typeof value === 'boolean') return value ? '是' : '否'
|
||||
if (typeof value === 'number') return String(value)
|
||||
if (typeof value === 'string') return value.trim() || '-'
|
||||
if (Array.isArray(value)) {
|
||||
if (!value.length) return '-'
|
||||
return value
|
||||
.map((v) => formatScalar(v))
|
||||
.filter((s) => s && s !== '-')
|
||||
.join(sep)
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
try {
|
||||
return JSON.stringify(value)
|
||||
} catch {
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
return String(value)
|
||||
return formatFormValueDisplay(value, sep)
|
||||
}
|
||||
|
||||
/** 日期/时间区间(FormCreate:日期区间、时间区间等)打印用 ~ 连接起止 */
|
||||
@@ -322,14 +314,26 @@ async function walkRules(
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'region' || type === 'cascader') {
|
||||
const text = formatRegionLikeDisplay(value)
|
||||
out.push({ label, text: text || '-' })
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'tripItinerary') {
|
||||
out.push({ label, text: formatTripItineraryForPrint(value) })
|
||||
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 : '-' })
|
||||
const dragTag = String(rule._fc_drag_tag || '').trim()
|
||||
if (
|
||||
UPLOAD_TYPES.has(type) ||
|
||||
UPLOAD_TYPES.has(dragTag) ||
|
||||
String(rule.name || '').toLowerCase().includes('upload') ||
|
||||
dragTag.toLowerCase().includes('upload')
|
||||
) {
|
||||
const names = formatOaUploadPathsForPrint(value)
|
||||
out.push({ label, urls: names.length ? names : [], text: names.length ? undefined : '-' })
|
||||
continue
|
||||
}
|
||||
// 字符串里像 URL 列表的也拆开展示
|
||||
@@ -349,21 +353,40 @@ async function walkRules(
|
||||
}
|
||||
}
|
||||
|
||||
function ensurePlainObject(raw: unknown): Record<string, any> {
|
||||
if (raw == null) return {}
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(raw)
|
||||
return parsed && typeof parsed === 'object' ? (parsed as Record<string, any>) : {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
if (typeof raw === 'object') return raw as Record<string, any>
|
||||
return {}
|
||||
}
|
||||
|
||||
async function buildFormRows(detail: any): Promise<OaPrintFieldRow[]> {
|
||||
const schema = detail?.formSchemaJson
|
||||
const formData = (detail?.formDataJson || {}) as Record<string, any>
|
||||
const schema = ensurePlainObject(detail?.formSchemaJson)
|
||||
const formData = ensurePlainObject(detail?.formDataJson)
|
||||
const rule = Array.isArray(schema?.rule)
|
||||
? schema.rule
|
||||
: Array.isArray(schema)
|
||||
? schema
|
||||
: Array.isArray(detail?.formSchemaJson)
|
||||
? detail.formSchemaJson
|
||||
: []
|
||||
const out: OaPrintFieldRow[] = []
|
||||
await walkRules(rule, formData, out)
|
||||
if (out.length) return out
|
||||
// schema 缺失:兜底平铺 formData
|
||||
// schema 缺失:兜底平铺 formData(附件路径收成文件名)
|
||||
for (const [k, v] of Object.entries(formData)) {
|
||||
const names = formatOaUploadPathsForPrint(v)
|
||||
if (names.length && extractUrls(v).every((u) => /\/minio\//i.test(u) || /\.[a-z0-9]{2,5}(\?|$)/i.test(u))) {
|
||||
out.push({ label: k, urls: names })
|
||||
continue
|
||||
}
|
||||
const urls = extractUrls(v).filter(isHttpUrl)
|
||||
if (urls.length) out.push({ label: k, urls })
|
||||
if (urls.length) out.push({ label: k, urls: formatOaUploadPathsForPrint(urls) })
|
||||
else out.push({ label: k, text: formatScalar(v) })
|
||||
}
|
||||
return out
|
||||
@@ -380,10 +403,13 @@ function peopleDisplayNames(p: any): string[] {
|
||||
return name ? [name] : []
|
||||
}
|
||||
|
||||
function progressPersonLinesFromItem(p: any): string[] {
|
||||
function progressPersonLinesFromItem(p: any): OaPrintPersonLine[] {
|
||||
const people = Array.isArray(p?.people) ? p.people : []
|
||||
if (!people.length) return []
|
||||
return formatProgressPersonLines(people).map((x) => x.text)
|
||||
return formatProgressPersonLines(people).map((x) => ({
|
||||
left: x.body || x.text,
|
||||
right: x.timestamp || ''
|
||||
}))
|
||||
}
|
||||
|
||||
function isCcProgressItem(p: any): boolean {
|
||||
|
||||
Reference in new issue
Block a user