修改启动按钮

This commit is contained in:
GGJ
2025-01-09 10:16:44 +08:00
parent 979765db76
commit 8490cbb68e
2 changed files with 56 additions and 15 deletions

View File

@@ -100,3 +100,19 @@ export const deleteTimer = (data: any) => {
data: data data: data
}) })
} }
// 关闭任务
export const stop = (params: any) => {
return request({
url: '/system-boot/timer/stop',
method: 'get',
params
})
}
// 启动任务
export const start = (params: any) => {
return request({
url: '/system-boot/timer/start',
method: 'get',
params
})
}

View File

@@ -35,7 +35,7 @@
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide, } from 'vue' import { ref, onMounted, provide, } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
@@ -44,7 +44,7 @@ import TableHeader from '@/components/table/header/index.vue'
import taskForm from '@/views/system/scheduledTasks/form.vue' import taskForm from '@/views/system/scheduledTasks/form.vue'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import { ElMessage, ElMessageBox, ElDatePicker } from 'element-plus' import { ElMessage, ElMessageBox, ElDatePicker } from 'element-plus'
import { timerRun, runTimer, deleteTimer } from '@/api/system-boot/csDictData' import { timerRun, runTimer, deleteTimer, stop, start } from '@/api/system-boot/csDictData'
defineOptions({ defineOptions({
name: 'Distributedphotovoltaic/templateConfiguration' name: 'Distributedphotovoltaic/templateConfiguration'
}) })
@@ -64,18 +64,43 @@ const tableStore: any = new TableStore({
{ field: 'actionClass', title: '任务执行器' }, { field: 'actionClass', title: '任务执行器' },
{ field: 'cron', title: '定时任务表达式' }, { field: 'cron', title: '定时任务表达式' },
{ field: 'remark', title: '备注' }, { field: 'remark', title: '备注' },
// {
// field: 'jobStatus', title: '状态', width: '100',
// render: 'tag',
// custom: {
// 0: 'danger',
// 1: 'success',
// 2: 'danger'
// },
// replaceValue: {
// 0: '未启动',
// 1: '运行中',
// 2: '未启动',
// }
// },
{ {
field: 'jobStatus', title: '状态', width: '100', title: '状态',
render: 'tag', render: 'switch',
custom: { width: 100,
0: 'danger', field: 'jobStatus',
1: 'success', activeText: '启用',
2: 'danger' activeValue: '1',
}, inactiveText: '停用',
replaceValue: { inactiveValue: '2',
0: '未启动', onChangeField: (row: any, value: any) => {
1: '运行中', if (row.jobStatus == 1) {
2: '未启动', stop({ id: row.id }).then(res => {
ElMessage.success('停止成功')
tableStore.index()
})
}else{
start({ id: row.id }).then(res => {
ElMessage.success('启动成功')
tableStore.index()
})
}
} }
}, },
{ field: 'sort', title: '排序', width: '80' }, { field: 'sort', title: '排序', width: '80' },
@@ -141,13 +166,13 @@ const tableStore: any = new TableStore({
title: '确定删除?' title: '确定删除?'
}, },
click: row => { click: row => {
deleteTimer([row.id ]).then(res => { deleteTimer([row.id]).then(res => {
ElMessage.success('删除成功') ElMessage.success('删除成功')
tableStore.index() tableStore.index()
}) })
} }
}, },