From ef6d0ef175f291e2a8ddb7fdf3e096f06cdf7d83 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Wed, 12 Aug 2026 18:14:11 +0800 Subject: [PATCH] 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 --- mobile-oa-h5/src/oa/oa-action-defaults.js | 30 ++++++++++++++ .../src/oa/oa-action-defaults.test.js | 40 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 mobile-oa-h5/src/oa/oa-action-defaults.js create mode 100644 mobile-oa-h5/src/oa/oa-action-defaults.test.js diff --git a/mobile-oa-h5/src/oa/oa-action-defaults.js b/mobile-oa-h5/src/oa/oa-action-defaults.js new file mode 100644 index 00000000..5a40a2ca --- /dev/null +++ b/mobile-oa-h5/src/oa/oa-action-defaults.js @@ -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 +} diff --git a/mobile-oa-h5/src/oa/oa-action-defaults.test.js b/mobile-oa-h5/src/oa/oa-action-defaults.test.js new file mode 100644 index 00000000..676a3fbf --- /dev/null +++ b/mobile-oa-h5/src/oa/oa-action-defaults.test.js @@ -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') + }) +})