fix(mobile-oa-h5): limit presign detail bottom bar to edit convert delete
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6e190665c0
commit
a2125374a8
1 file changed
+5
-54
@@ -11,9 +11,9 @@ const ACTIONS = Object.freeze({
|
||||
'submit-transfer',
|
||||
'withdraw-transfer'
|
||||
],
|
||||
protocol: ['view', 'create', 'audit', 'edit', 'delete'],
|
||||
'payment-chase': ['view-payment'],
|
||||
payment: ['view', 'register-transfer', 'edit-transfer', 'submit', 'withdraw'],
|
||||
protocol: ['view', 'create', 'edit', 'delete'],
|
||||
'payment-chase': ['view-payment', 'view-protocol'],
|
||||
payment: ['view', 'register-transfer', 'edit-transfer', 'delete-payment-transfer', 'submit', 'withdraw'],
|
||||
freight: ['view', 'create', 'edit', 'link', 'unlink']
|
||||
})
|
||||
|
||||
@@ -38,15 +38,6 @@ const PRESIGN_ORDER_ACTIONS = new Set([
|
||||
'delete'
|
||||
])
|
||||
|
||||
const PRESIGN_TRANSFER_CREATE_ACTIONS = new Set(['create-transfer'])
|
||||
|
||||
const PRESIGN_TRANSFER_ACTION_MAP = Object.freeze({
|
||||
edit: 'edit-presign-transfer',
|
||||
delete: 'delete-transfer',
|
||||
submit: 'submit-transfer',
|
||||
withdraw: 'withdraw-transfer'
|
||||
})
|
||||
|
||||
export function moduleActions(module, role) {
|
||||
return [...(ACTIONS[module] || [])]
|
||||
}
|
||||
@@ -85,30 +76,7 @@ export function intersectAllowedActions(module, role, backendActions) {
|
||||
|
||||
export function collectAllowedActions(module, role, detail) {
|
||||
if (module === 'presign') {
|
||||
const frontendWhitelist = new Set(moduleActions(module, role))
|
||||
const nested = []
|
||||
for (const transfer of detail?.transfers || []) {
|
||||
for (const action of transfer?.allowedActions || []) {
|
||||
const backendCode = typeof action === 'string'
|
||||
? action
|
||||
: String(action?.code || action?.action || action?.key || '').trim()
|
||||
const code = PRESIGN_TRANSFER_ACTION_MAP[backendCode]
|
||||
if (!code || !frontendWhitelist.has(code)) continue
|
||||
const metadata = typeof action === 'string'
|
||||
? {}
|
||||
: (() => {
|
||||
const { key: _key, action: _action, ...rest } = action
|
||||
return rest
|
||||
})()
|
||||
nested.push({
|
||||
...metadata,
|
||||
code,
|
||||
transferId: transfer.id,
|
||||
actionKey: `${code}:transfer:${transfer.id}`
|
||||
})
|
||||
}
|
||||
}
|
||||
const top = (Array.isArray(detail?.allowedActions || detail?.actions)
|
||||
return (Array.isArray(detail?.allowedActions || detail?.actions)
|
||||
? detail.allowedActions || detail.actions
|
||||
: [])
|
||||
.map((action) => {
|
||||
@@ -121,24 +89,6 @@ export function collectAllowedActions(module, role, detail) {
|
||||
return { ...metadata, code }
|
||||
})
|
||||
.filter(Boolean)
|
||||
const createTransfer = (Array.isArray(detail?.transferAllowedActions)
|
||||
? detail.transferAllowedActions
|
||||
: [])
|
||||
.map((action) => {
|
||||
const code = typeof action === 'string'
|
||||
? action
|
||||
: String(action?.code || action?.action || action?.key || '').trim()
|
||||
if (!PRESIGN_TRANSFER_CREATE_ACTIONS.has(code) || !frontendWhitelist.has(code)) return null
|
||||
if (typeof action === 'string') return action
|
||||
const { key: _key, action: _action, ...metadata } = action
|
||||
return { ...metadata, code }
|
||||
})
|
||||
.filter(Boolean)
|
||||
return [
|
||||
...nested,
|
||||
...top,
|
||||
...createTransfer
|
||||
]
|
||||
}
|
||||
if (module !== 'payment') {
|
||||
return intersectAllowedActions(module, role, detail?.allowedActions || detail?.actions)
|
||||
@@ -158,6 +108,7 @@ export function collectAllowedActions(module, role, detail) {
|
||||
const code = typeof action === 'string' ? action : action.code
|
||||
const label = {
|
||||
'edit-transfer': '编辑转账',
|
||||
'delete-payment-transfer': '删除转账',
|
||||
submit: '提交财务确认',
|
||||
withdraw: '撤回转账'
|
||||
}[code] || code
|
||||
|
||||
Reference in new issue
Block a user