From 261c0917541ae0c657b49c1d4fb477054f1450a0 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Sun, 4 Jan 2026 10:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=85=E9=81=93bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ComDataTable/index.vue | 26 +++++++++++++++++++++++++ src/views/planMange/dailyPlan/index.vue | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/components/ComDataTable/index.vue b/src/components/ComDataTable/index.vue index 0e5d6e6..7072fcc 100644 --- a/src/components/ComDataTable/index.vue +++ b/src/components/ComDataTable/index.vue @@ -200,6 +200,11 @@ " :link="action.link !== false" :plain="action.plain" + :disabled=" + typeof action.disabled === 'function' + ? action.disabled(row) + : action.disabled + " @click="handleAction(action, row, $index)" v-hasPermi="action.permission" > @@ -218,6 +223,11 @@ " :link="action.link !== false" :plain="action.plain" + :disabled=" + typeof action.disabled === 'function' + ? action.disabled(row) + : action.disabled + " @click="handleAction(action, row, $index)" > {{ action.label }} @@ -243,6 +253,11 @@ {{ action.label }} @@ -251,6 +266,11 @@ {{ action.label }} @@ -507,6 +527,12 @@ const handlePaginationChange = (pagination) => { // 操作按钮点击 const handleAction = (action, row, index) => { + // 如果按钮被禁用,则不执行操作 + const isDisabled = + typeof action.disabled === 'function' ? action.disabled(row) : action.disabled + if (isDisabled) { + return + } if (action.handler && typeof action.handler === 'function') { action.handler(row, index) } else { diff --git a/src/views/planMange/dailyPlan/index.vue b/src/views/planMange/dailyPlan/index.vue index ff34f26..8ef3ca2 100644 --- a/src/views/planMange/dailyPlan/index.vue +++ b/src/views/planMange/dailyPlan/index.vue @@ -175,6 +175,14 @@ const initTableColumns = computed(() => { if (tableType.value !== '0') return [...tableColumns.value, ...processedTableColumns_2.value] }) +// 判断日期是否为今天之前 +const isBeforeToday = (dayPlan) => { + if (!dayPlan) return false + const planDate = dayjs(dayPlan) + const today = dayjs().startOf('day') + return planDate.isBefore(today) +} + // 操作列 const actionColumns = computed(() => [ { @@ -202,6 +210,7 @@ const actionColumns = computed(() => [ type: 'primary', link: true, permission: ['plan:dailyPlan:edit'], // 权限控制:使用 v-hasPermi 指令控制按钮显示 + disabled: (row) => isBeforeToday(row.dayPlan), // 当日期为今天之前时禁用 handler: (row) => { router.push({ path: '/plan/dailyPlanEdit/index', @@ -222,6 +231,7 @@ const actionColumns = computed(() => [ type: 'danger', link: true, permission: ['plan:dailyPlan:remove'], // 权限控制:使用 v-hasPermi 指令控制按钮显示 + disabled: (row) => isBeforeToday(row.dayPlan), // 当日期为今天之前时禁用 handler: (row) => { proxy.$modal.confirm('是否确认删除该日计划?').then(async () => { const result = await delDailyPlanAPI({ dayPlanId: row.dayPlanId })