mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-07-05 10:08:15 +08:00
feat: ✨ 手动执行计划作业 (#122)
This commit is contained in:
@ -60,6 +60,17 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行作业
|
||||
*/
|
||||
execute: {
|
||||
url: `${config.API_URL}/api/sys/job/execute`,
|
||||
name: `执行作业`,
|
||||
post: async function (data = {}, config = {}) {
|
||||
return await http.post(this.url, data, config)
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 计划作业是否存在
|
||||
*/
|
||||
|
@ -137,13 +137,19 @@
|
||||
</el-table-column>
|
||||
<na-col-operation
|
||||
:buttons="
|
||||
naColOperation.buttons.concat({
|
||||
icon: 'el-icon-delete',
|
||||
confirm: true,
|
||||
type: 'danger',
|
||||
title: $t('删除作业'),
|
||||
click: rowDel,
|
||||
})
|
||||
naColOperation.buttons.concat(
|
||||
{
|
||||
icon: 'el-icon-video-play',
|
||||
click: execute,
|
||||
},
|
||||
{
|
||||
icon: 'el-icon-delete',
|
||||
confirm: true,
|
||||
type: 'danger',
|
||||
title: $t('删除作业'),
|
||||
click: rowDel,
|
||||
},
|
||||
)
|
||||
"
|
||||
:vue="this" />
|
||||
</sc-table>
|
||||
@ -171,6 +177,7 @@ export default {
|
||||
inject: ['reload'],
|
||||
data() {
|
||||
return {
|
||||
timer: null,
|
||||
loading: false,
|
||||
query: {
|
||||
dynamicFilter: {
|
||||
@ -220,6 +227,31 @@ export default {
|
||||
}
|
||||
this.$refs.table.refresh()
|
||||
},
|
||||
async execute(row) {
|
||||
try {
|
||||
await this.$API.sys_job.execute.post({ id: row.id })
|
||||
this.$refs.table.refresh()
|
||||
this.$notify.success({
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: `<div id="countdown">已发起执行请求,5 秒后弹出执行结果</div>`,
|
||||
onClose: async () => {
|
||||
clearInterval(this.timer)
|
||||
this.loading = true
|
||||
this.dialog.save = true
|
||||
await this.$nextTick()
|
||||
await this.$refs.saveDialog.open('view', row, 1)
|
||||
this.loading = false
|
||||
},
|
||||
})
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
const countdown = new RegExp('\\d+').exec(document.getElementById('countdown').innerText)[0]
|
||||
document.getElementById('countdown').innerText = document
|
||||
.getElementById('countdown')
|
||||
.innerText.replace(countdown, `${parseInt(countdown) - 1}`)
|
||||
}, 1000)
|
||||
} catch {}
|
||||
},
|
||||
//删除
|
||||
async rowDel(row) {
|
||||
try {
|
||||
|
@ -189,7 +189,7 @@ export default {
|
||||
mounted() {},
|
||||
methods: {
|
||||
//显示
|
||||
async open(mode = 'add', data) {
|
||||
async open(mode = 'add', data, tabIndex = 0) {
|
||||
this.visible = true
|
||||
this.loading = true
|
||||
this.mode = mode
|
||||
@ -198,6 +198,7 @@ export default {
|
||||
Object.assign(this.form, res.data)
|
||||
}
|
||||
this.loading = false
|
||||
this.tabIndex = tabIndex
|
||||
return this
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user