feat(web-admin): add mp plan detail action splitter.
Cap the sticky footer at two primary actions and park the rest in a more sheet. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b3ad19f6a9
commit
92bb4bf0d0
2 files changed
+107
No files matched your search
@@ -0,0 +1,44 @@
|
||||
export type MpDetailActionKind =
|
||||
| 'edit'
|
||||
| 'arrange'
|
||||
| 'copy'
|
||||
| 'wait'
|
||||
| 'cancel-wait'
|
||||
| 'print'
|
||||
| 'void'
|
||||
|
||||
export type MpDetailAction = {
|
||||
kind: MpDetailActionKind
|
||||
label: string
|
||||
danger?: boolean
|
||||
}
|
||||
|
||||
/** 主栏最多 2 个:优先 edit、arrange;其余进 more */
|
||||
export function splitMpPlanDetailActions(input: {
|
||||
canEdit: boolean
|
||||
canArrange: boolean
|
||||
arrangeLabel: string
|
||||
canWait: boolean
|
||||
canCancelWait: boolean
|
||||
canVoid: boolean
|
||||
}): { primary: MpDetailAction[]; more: MpDetailAction[] } {
|
||||
const primary: MpDetailAction[] = []
|
||||
const more: MpDetailAction[] = []
|
||||
|
||||
if (input.canEdit) primary.push({ kind: 'edit', label: '编辑' })
|
||||
if (input.canArrange) {
|
||||
primary.push({ kind: 'arrange', label: input.arrangeLabel })
|
||||
}
|
||||
|
||||
more.push({ kind: 'copy', label: '复制' })
|
||||
if (input.canWait) more.push({ kind: 'wait', label: '等客户通知' })
|
||||
if (input.canCancelWait) more.push({ kind: 'cancel-wait', label: '取消等通知' })
|
||||
more.push({ kind: 'print', label: '打印单据' })
|
||||
if (input.canVoid) more.push({ kind: 'void', label: '作废', danger: true })
|
||||
|
||||
while (primary.length > 2) more.unshift(primary.pop()!)
|
||||
while (primary.length < 2 && more.length) {
|
||||
primary.push(more.shift()!)
|
||||
}
|
||||
return { primary, more }
|
||||
}
|
||||
Reference in new issue
Block a user