提交
This commit is contained in:
1 parent
80138c6388
commit
693e8a678e
682 files changed
+211375
-5306
No files matched your search
@@ -19,8 +19,13 @@ export type ProgressPersonInput = {
|
||||
export type PersonLineTone = 'ok' | 'pending' | 'danger' | 'mute' | ''
|
||||
|
||||
export type ProgressPersonLine = {
|
||||
/** 完整一行(含时间),详情页等纯文本场景用 */
|
||||
text: string
|
||||
tone: PersonLineTone
|
||||
/** 不含时间的主体,打印右对齐时间用 */
|
||||
body: string
|
||||
/** 审批时间(可空) */
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
const ACTED_STATUS = new Set(['approved', 'rejected', 'returned', 'completed', 'transferred'])
|
||||
@@ -52,6 +57,21 @@ function toneForStatus(status: string): PersonLineTone {
|
||||
return ''
|
||||
}
|
||||
|
||||
function pushLine(
|
||||
out: ProgressPersonLine[],
|
||||
body: string,
|
||||
timestamp: string,
|
||||
tone: PersonLineTone
|
||||
) {
|
||||
const ts = String(timestamp || '').trim()
|
||||
out.push({
|
||||
body,
|
||||
timestamp: ts,
|
||||
text: ts ? `${body} ${ts}` : body,
|
||||
tone
|
||||
})
|
||||
}
|
||||
|
||||
/** 将 progress.people 格式化为「姓名 意见/状态 时间」纯文本行 */
|
||||
export function formatProgressPersonLines(
|
||||
people: ProgressPersonInput[] | null | undefined
|
||||
@@ -67,7 +87,7 @@ export function formatProgressPersonLines(
|
||||
const tone = toneForStatus(status)
|
||||
|
||||
if (status === 'done') {
|
||||
out.push({ text: `${name} 无需处理`, tone: 'mute' })
|
||||
pushLine(out, `${name} 无需处理`, '', 'mute')
|
||||
continue
|
||||
}
|
||||
if (status === 'transferred') {
|
||||
@@ -77,34 +97,25 @@ export function formatProgressPersonLines(
|
||||
? `转交给${target} ${comment}`
|
||||
: `转交给${target}`
|
||||
: comment || statusFallbackLabel('transferred')
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: 'mute'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, 'mute')
|
||||
continue
|
||||
}
|
||||
if (status === 'pending' || status === 'running' || status === 'not_reached' || !status) {
|
||||
// 无 status 时:若有意见/时间仍按已处理拼;否则待处理
|
||||
if (!status && (comment || ts)) {
|
||||
const mid = comment || statusFallbackLabel('approved')
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: 'ok'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, 'ok')
|
||||
continue
|
||||
}
|
||||
out.push({ text: `${name} 待处理`, tone: 'pending' })
|
||||
pushLine(out, `${name} 待处理`, '', 'pending')
|
||||
continue
|
||||
}
|
||||
if (ACTED_STATUS.has(status) || comment || ts) {
|
||||
const mid = comment || statusFallbackLabel(status)
|
||||
out.push({
|
||||
text: ts ? `${name} ${mid} ${ts}` : `${name} ${mid}`,
|
||||
tone: tone || 'ok'
|
||||
})
|
||||
pushLine(out, `${name} ${mid}`, ts, tone || 'ok')
|
||||
continue
|
||||
}
|
||||
out.push({ text: `${name} 待处理`, tone: 'pending' })
|
||||
pushLine(out, `${name} 待处理`, '', 'pending')
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user