From 6d0352b97dd47e667cbf0cae4d7bf12b40dcc2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Mon, 28 Jul 2025 17:18:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(applicationManagement):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=A7=84=E5=88=99=E5=88=97=E8=A1=A8=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -调整按钮显示逻辑,确保所有状态都能显示查看详情按钮 -规则状态为"停用"时显示编辑和删除按钮 - 修改启用/停用按钮的显示逻辑和提示文本 - 优化代码结构,提高可读性和可维护性 --- .../employRule/index.vue | 81 +++++++++++-------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/src/views/applicationManagement/employRule/index.vue b/src/views/applicationManagement/employRule/index.vue index b949395..af86348 100644 --- a/src/views/applicationManagement/employRule/index.vue +++ b/src/views/applicationManagement/employRule/index.vue @@ -239,8 +239,10 @@ export default { key: '操作', isRedraw: true, render: (h, params) => { - return h('div', [ - // 查看详情按钮 + const buttons = [] + + // 所有状态都显示查看详情按钮 + buttons.push( h( 'el-button', { @@ -254,38 +256,45 @@ export default { on: { click: () => this.handleView(params.row) } }, '' - ), - // 编辑按钮 - h( - 'el-button', - { - props: { - type: 'text', - size: 'mini', - icon: 'el-icon-edit-outline', - title: '编辑' + ) + ) + + // 规则状态为"停用"(ruleStatus === 1)时显示编辑和删除按钮 + if (params.row.ruleStatus === 1) { + buttons.push( + h( + 'el-button', + { + props: { + type: 'text', + size: 'mini', + icon: 'el-icon-edit-outline', + title: '编辑' + }, + class: 'normal-button', + on: { click: () => this.handleEdit(params.row) } }, - class: 'normal-button', - on: { click: () => this.handleEdit(params.row) } - }, - '' - ), - // 删除按钮 - h( - 'el-button', - { - props: { - type: 'text', - size: 'mini', - style: 'color: #F56C6C', - icon: 'el-icon-delete', - title: '删除' + '' + ), + h( + 'el-button', + { + props: { + type: 'text', + size: 'mini', + style: 'color: #F56C6C', + icon: 'el-icon-delete', + title: '删除' + }, + on: { click: () => this.handleDelete(params.row) } }, - on: { click: () => this.handleDelete(params.row) } - }, - '' - ), - // 启用/停用按钮(根据当前状态显示不同图标) + '' + ) + ) + } + + // 显示启用/停用按钮(根据当前状态显示不同图标) + buttons.push( h( 'el-button', { @@ -296,13 +305,15 @@ export default { params.row.ruleStatus === 0 ? 'el-icon-remove-outline' : 'el-icon-circle-check', - title: params.row.ruleStatus === 0 ? '启用' : '停用' + title: params.row.ruleStatus === 0 ? '停用' : '启用' }, on: { click: () => this.handleToggleStatus(params.row) } }, '' ) - ]) + ) + + return h('div', buttons) } } ] @@ -470,7 +481,7 @@ export default { // 1 停用 0 启用 // 启用的数据能停用,停用的数据反之 const newStatus = row.ruleStatus === 1 ? 'enable' : 'disabled' - const statusText = row.ruleStatus === 0 ? '停用' : '启用' + const statusText = row.ruleStatus === 1 ? '启用' : '停用' this.$messageBox( () => {