From b3f81ba3f0511b8df71557f7bf994411804ec222 Mon Sep 17 00:00:00 2001 From: AN <1983933789@qq.com> Date: Wed, 18 Jun 2025 15:15:19 +0800 Subject: [PATCH] =?UTF-8?q?optimize(projects):=20=E7=BB=9F=E4=B8=80button?= =?UTF-8?q?=E7=9A=84=E6=B7=BB=E5=8A=A0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/workflow/category/index.vue | 2 +- src/views/workflow/leave/index.vue | 1 - .../workflow/process-definition/index.vue | 143 +++++++++--------- src/views/workflow/process-instance/index.vue | 73 +++++---- 4 files changed, 108 insertions(+), 111 deletions(-) diff --git a/src/views/workflow/category/index.vue b/src/views/workflow/category/index.vue index a345d4f2..8a52ddf9 100644 --- a/src/views/workflow/category/index.vue +++ b/src/views/workflow/category/index.vue @@ -110,7 +110,7 @@ const { if (hasAuth('workflow:category:remove')) buttons.push(deleteBtn()); return ( -
+
{buttons.map((btn, index) => ( <> {index !== 0 && } diff --git a/src/views/workflow/leave/index.vue b/src/views/workflow/leave/index.vue index cf5795f2..d3a054e3 100644 --- a/src/views/workflow/leave/index.vue +++ b/src/views/workflow/leave/index.vue @@ -168,7 +168,6 @@ const { ); } - // 插入分隔符(仅在前后两个按钮之间插入 Divider) const buttonWithDividers = buttons.flatMap((btn, index) => { if (index === 0) return [btn]; return [, btn]; diff --git a/src/views/workflow/process-definition/index.vue b/src/views/workflow/process-definition/index.vue index cb8b6d2a..7b2b8746 100644 --- a/src/views/workflow/process-definition/index.vue +++ b/src/views/workflow/process-definition/index.vue @@ -176,38 +176,56 @@ const { width: 150, fixed: 'right', render: row => { - const Divider = ; + const buttons = []; + buttons.push( + edit(row.id)} + /> + ); + buttons.push( + handleDelete(row.id)} + /> + ); + buttons.push( + handleCopy(row.id)} + /> + ); - const buttons = { - edit: ( - edit(row.id)} - /> - ), - delete: ( - handleDelete(row.id)} - /> - ), - design: ( - handleDesign(row.id)} - /> - ), - preview: ( + const firstRowButtons = buttons.flatMap((btn, index) => { + if (index === 0) return [btn]; + return [, btn]; + }); + + const secondRowButtons = []; + + secondRowButtons.push( + handleExport(row)} + /> + ); + + secondRowButtons.push( + isPublish.value ? ( handlePreview(row.id)} /> - ), - publish: ( + ) : ( + handleDesign(row.id)} + /> + ) + ); + + if (!isPublish.value) { + secondRowButtons.push( handlePublish(row.id)} /> - ), - copy: ( - handleCopy(row.id)} - /> - ), - export: ( - handleExport(row)} - /> - ) - }; + ); + } + + const secondRowWithDividers = secondRowButtons.flatMap((btn, index) => { + if (index === 0) return [btn]; + return [, btn]; + }); return (
-
- {buttons.edit} - {Divider} - {buttons.delete} - {Divider} - {buttons.copy} -
-
- {buttons.export} - {Divider} - {isPublish.value ? buttons.preview : buttons.design} - {!isPublish.value && ( - <> - {Divider} - {buttons.publish} - - )} -
+
{firstRowButtons}
+
{secondRowWithDividers}
); } diff --git a/src/views/workflow/process-instance/index.vue b/src/views/workflow/process-instance/index.vue index 8fd5c044..3f5122ce 100644 --- a/src/views/workflow/process-instance/index.vue +++ b/src/views/workflow/process-instance/index.vue @@ -153,38 +153,42 @@ const operateColumns = ref[]>( render: row => { const id = row.id; const showAll = runningStatus.value; - const Divider = ; + const buttons = []; - const cancelBtn = ( - - } - onPositiveClick={() => handleCancel(id)} - /> - ); + if (showAll) { + buttons.push( + + } + onPositiveClick={() => handleCancel(id)} + /> + ); + } - const deleteBtn = ( - handleDelete(id)} - /> - ); + if (showAll) { + buttons.push( + handleDelete(id)} + /> + ); + } - const previewBtn = ( + buttons.push( ); - const variableBtn = ( + buttons.push( []>( /> ); - return ( -
- {showAll && cancelBtn} - {showAll && Divider} - {showAll && deleteBtn} - {showAll && Divider} - {previewBtn} - {Divider} - {variableBtn} -
- ); + const buttonWithDividers = buttons.flatMap((btn, index) => { + if (index === 0) return [btn]; + return [, btn]; + }); + + return
{buttonWithDividers}
; } } ]);