Skip to content

Commit

Permalink
任务调度新增复制任务功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zhontai committed Jan 8, 2024
1 parent 3ac2d2a commit 4538b56
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const onSureArgs = (task: any) => {
// 打开对话框
const open = async (row: TaskUpdateInput = { id: '' }) => {
let formData = cloneDeep(row) as TaskUpdateInput
if (row.topic) {
if (row.id && row.topic) {
const res = await new TaskApi().get({ topic: row.topic }, { loading: true })
if (res?.success) {
Expand Down
68 changes: 42 additions & 26 deletions ui/zhontai.ui.admin.vue3/src/views/admin/task/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,40 @@
<el-table-column prop="lastRunTime" label="最后运行时间" :formatter="formatterTime" width="100" />
<el-table-column label="操作" width="180" fixed="right" header-align="center" align="center">
<template #default="{ row }">
<el-button v-auth="'api:admin:task-log:get-page'" icon="ele-Tickets" size="small" text type="primary" @click="onShowLogs(row)"
>日志</el-button
>
<el-button
v-if="row.status === 1 || row.status === 'Paused'"
v-auth="'api:admin:task:pause'"
icon="ele-CaretRight"
size="small"
text
type="primary"
@click="onStart(row)"
>启动</el-button
>
<el-button
v-if="row.status === 0 || row.status === 'Running'"
v-auth="'api:admin:task:resume'"
icon="ele-VideoPause"
size="small"
text
type="primary"
@click="onPause(row)"
>停止</el-button
>
<el-button v-auth="'api:admin:task:run'" icon="ele-Promotion" size="small" text type="primary" @click="onRun(row)">执行</el-button>
<el-button v-auth="'api:admin:task:update'" icon="ele-Edit" size="small" text type="primary" @click="onUpdate(row)">修改</el-button>
<el-button v-auth="'api:admin:task:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)">删除</el-button>
<div class="my-flex">
<el-button v-auth="'api:admin:task-log:get-page'" icon="ele-Tickets" size="small" text type="primary" @click="onShowLogs(row)"
>日志</el-button
>
<el-button v-auth="'api:admin:task:update'" icon="ele-Edit" size="small" text type="primary" @click="onUpdate(row)">修改</el-button>
<el-button v-auth="'api:admin:task:delete'" icon="ele-Delete" size="small" text type="danger" @click="onDelete(row)">删除</el-button>
</div>

<div class="my-flex">
<el-button v-auth="'api:admin:task:run'" icon="ele-Promotion" size="small" text type="primary" @click="onRun(row)">执行</el-button>
<el-button v-auth="'api:admin:task:update'" icon="ele-CopyDocument" size="small" text type="primary" @click="onCopy(row)"
>复制</el-button
>
<el-button
v-if="row.status === 1 || row.status === 'Paused'"
v-auth="'api:admin:task:pause'"
icon="ele-CaretRight"
size="small"
text
type="primary"
@click="onStart(row)"
>启动</el-button
>
<el-button
v-if="row.status === 0 || row.status === 'Running'"
v-auth="'api:admin:task:resume'"
icon="ele-VideoPause"
size="small"
text
type="primary"
@click="onPause(row)"
>停止</el-button
>
</div>
</template>
</el-table-column>
</el-table>
Expand Down Expand Up @@ -88,6 +96,7 @@ import { TaskListOutput, PageInputTaskGetPageDto } from '/@/api/admin/data-contr
import { TaskApi } from '/@/api/admin/Task'
import dayjs from 'dayjs'
import eventBus from '/@/utils/mitt'
import { cloneDeep } from 'lodash-es'
// 引入组件
const TaskLogs = defineAsyncComponent(() => import('./components/task-logs.vue'))
Expand Down Expand Up @@ -178,6 +187,13 @@ const onUpdate = (row: TaskListOutput) => {
taskFormRef.value.open(row)
}
const onCopy = (row: TaskListOutput) => {
state.taskFormTitle = '新增任务'
var task = cloneDeep(row)
task.id = null
taskFormRef.value.open(task)
}
// 查看日志
const onShowLogs = (row: TaskListOutput) => {
state.taskLogsTitle = `${row.topic}${row.id}运行日志`
Expand Down

0 comments on commit 4538b56

Please sign in to comment.