feat(web-admin): add OA progress person-line formatter for or/and sign
Provide shared plain-text lines (name opinion time) used by progress UI and PDF. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f951c12071
commit
043e69f818
2 files changed
+175
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
formatProgressPersonLines,
|
||||
type ProgressPersonInput
|
||||
} from '../src/utils/oa-progress-person-lines'
|
||||
|
||||
function run() {
|
||||
// 会签部分完成
|
||||
const andPartial: ProgressPersonInput[] = [
|
||||
{
|
||||
nickName: '甲',
|
||||
status: 'approved',
|
||||
commentText: '同意',
|
||||
timestamp: '2026-07-23 10:01:00'
|
||||
},
|
||||
{
|
||||
nickName: '乙',
|
||||
status: 'approved',
|
||||
commentText: '无异议',
|
||||
timestamp: '2026-07-23 10:20:00'
|
||||
},
|
||||
{ nickName: '丙', status: 'pending', commentText: '', timestamp: '' }
|
||||
]
|
||||
const andLines = formatProgressPersonLines(andPartial)
|
||||
assert.deepEqual(
|
||||
andLines.map((x) => x.text),
|
||||
[
|
||||
'甲 同意 2026-07-23 10:01:00',
|
||||
'乙 无异议 2026-07-23 10:20:00',
|
||||
'丙 待处理'
|
||||
]
|
||||
)
|
||||
assert.equal(andLines[0].tone, 'ok')
|
||||
assert.equal(andLines[2].tone, 'pending')
|
||||
|
||||
// 或签一人已批:操作人 + 免处理仍列出
|
||||
const orDone: ProgressPersonInput[] = [
|
||||
{
|
||||
nickName: '甲',
|
||||
status: 'approved',
|
||||
commentText: '同意,材料齐全',
|
||||
timestamp: '2026-07-23 10:05:00'
|
||||
},
|
||||
{ nickName: '乙', status: 'done', commentText: '', timestamp: '2026-07-23 10:00:00' },
|
||||
{ nickName: '丙', status: 'done', commentText: '', timestamp: '' }
|
||||
]
|
||||
const orLines = formatProgressPersonLines(orDone)
|
||||
assert.deepEqual(
|
||||
orLines.map((x) => x.text),
|
||||
['甲 同意,材料齐全 2026-07-23 10:05:00', '乙 无需处理', '丙 无需处理']
|
||||
)
|
||||
assert.equal(orLines[0].tone, 'ok')
|
||||
assert.equal(orLines[1].tone, 'mute')
|
||||
assert.equal(orLines[2].tone, 'mute')
|
||||
|
||||
// 已同意但无意见 → 状态文案兜底
|
||||
const emptyComment = formatProgressPersonLines([
|
||||
{
|
||||
nickName: '甲',
|
||||
status: 'approved',
|
||||
commentText: '',
|
||||
timestamp: '2026-07-23 10:05:00'
|
||||
}
|
||||
])
|
||||
assert.equal(emptyComment[0].text, '甲 已同意 2026-07-23 10:05:00')
|
||||
|
||||
// 拒绝
|
||||
const rejected = formatProgressPersonLines([
|
||||
{
|
||||
nickName: '甲',
|
||||
status: 'rejected',
|
||||
commentText: '不同意',
|
||||
timestamp: '2026-07-23 11:00:00'
|
||||
},
|
||||
{ nickName: '乙', status: 'done' }
|
||||
])
|
||||
assert.equal(rejected[0].text, '甲 不同意 2026-07-23 11:00:00')
|
||||
assert.equal(rejected[0].tone, 'danger')
|
||||
assert.equal(rejected[1].text, '乙 无需处理')
|
||||
|
||||
// 空 people
|
||||
assert.deepEqual(formatProgressPersonLines([]), [])
|
||||
assert.deepEqual(formatProgressPersonLines(undefined), [])
|
||||
|
||||
console.log('oa-progress-person-lines: all assertions passed')
|
||||
}
|
||||
|
||||
run()
|
||||
Reference in new issue
Block a user