style:设备-任务管理-cron表达式为空不允许启用任务

main
黄伟杰 2 weeks ago
parent dc9d240eb8
commit 9e3e82f577

@ -82,6 +82,7 @@
<template #default="scope">
<el-switch
:model-value="scope.row.enabled === true || scope.row.enabled === 'true'"
:before-change="() => handleBeforeEnabledChange(scope.row)"
@change="(val) => handleEnabledChange(scope.row, val)"
/>
</template>
@ -126,6 +127,7 @@
</template>
<script setup lang="ts">
import { ElMessageBox } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download'
@ -247,6 +249,20 @@ const handleCreateTicket = async (id?: number) => {
}
}
const handleBeforeEnabledChange = async (row: TaskManagementVO) => {
const isEnabled = row.enabled === true || row.enabled === 'true'
if (isEnabled) return true
const cronExpression = (row as any)?.cronExpression
if (typeof cronExpression === 'string' && cronExpression.trim()) return true
await ElMessageBox.alert('请先填写 cron 表达式,再启用任务', '提示', {
type: 'warning',
confirmButtonText: '我知道了',
closeOnClickModal: false,
closeOnPressEscape: false
})
return false
}
const handleEnabledChange = async (row: TaskManagementVO, value: boolean) => {
if (!row.id) return
const oldEnabled = row.enabled

Loading…
Cancel
Save