feat(oa): add mobile detail action defaults helpers
Centralize default approval remarks and more-menu action order for the folded footer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7da691e4c6
commit
ef6d0ef175
2 files changed
+70
No files matched your search
@@ -0,0 +1,30 @@
|
||||
const DEFAULT_COMMENTS = {
|
||||
approve: '同意',
|
||||
reject: '拒绝',
|
||||
return: '请修改后重新提交',
|
||||
addSign: '加签',
|
||||
transfer: '转交'
|
||||
}
|
||||
|
||||
/** @param {string} kind */
|
||||
export function defaultComment(kind) {
|
||||
return DEFAULT_COMMENTS[kind] || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* More ActionSheet items for approve mode (spec order).
|
||||
* @param {{ allowAddSign?: boolean } | null | undefined} detail
|
||||
* @returns {{ key: string, name: string, color?: string }[]}
|
||||
*/
|
||||
export function buildMoreActions(detail) {
|
||||
const list = [{ key: 'reject', name: '拒绝', color: '#ee0a24' }]
|
||||
if (detail?.allowAddSign !== false) {
|
||||
list.push({ key: 'addSign', name: '加签' })
|
||||
}
|
||||
list.push(
|
||||
{ key: 'transfer', name: '转交' },
|
||||
{ key: 'print', name: '打印' },
|
||||
{ key: 'close', name: '关闭' }
|
||||
)
|
||||
return list
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { defaultComment, buildMoreActions } from './oa-action-defaults.js'
|
||||
|
||||
describe('defaultComment', () => {
|
||||
it('returns fixed defaults by kind', () => {
|
||||
assert.equal(defaultComment('approve'), '同意')
|
||||
assert.equal(defaultComment('reject'), '拒绝')
|
||||
assert.equal(defaultComment('return'), '请修改后重新提交')
|
||||
assert.equal(defaultComment('addSign'), '加签')
|
||||
assert.equal(defaultComment('transfer'), '转交')
|
||||
})
|
||||
|
||||
it('returns empty string for unknown kind', () => {
|
||||
assert.equal(defaultComment('x'), '')
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildMoreActions', () => {
|
||||
it('orders reject, addSign, transfer, print, close when all allowed', () => {
|
||||
const keys = buildMoreActions({ allowAddSign: true }).map((a) => a.key)
|
||||
assert.deepEqual(keys, ['reject', 'addSign', 'transfer', 'print', 'close'])
|
||||
})
|
||||
|
||||
it('omits addSign when allowAddSign is false', () => {
|
||||
const keys = buildMoreActions({ allowAddSign: false }).map((a) => a.key)
|
||||
assert.deepEqual(keys, ['reject', 'transfer', 'print', 'close'])
|
||||
})
|
||||
|
||||
it('includes addSign when allowAddSign is undefined', () => {
|
||||
const keys = buildMoreActions({}).map((a) => a.key)
|
||||
assert.ok(keys.includes('addSign'))
|
||||
})
|
||||
|
||||
it('sets name and optional color on actions', () => {
|
||||
const reject = buildMoreActions({}).find((a) => a.key === 'reject')
|
||||
assert.equal(reject.name, '拒绝')
|
||||
assert.equal(reject.color, '#ee0a24')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user