Browse Source

fix: 解决计划任务编辑错误 (#1902)

pull/1904/head
ssongliu 1 year ago committed by GitHub
parent
commit
b8480e4928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      backend/app/service/cornjob.go
  2. 15
      frontend/src/views/cronjob/record/index.vue

9
backend/app/service/cornjob.go

@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path"
"strconv"
"time"
"github.com/1Panel-dev/1Panel/backend/app/dto"
@ -55,14 +54,6 @@ func (u *CronjobService) SearchWithPage(search dto.SearchWithPage) (int64, inter
} else {
item.TargetDir = "-"
}
if item.Type == "database" && item.DBName != "all" {
itemID, _ := strconv.Atoi(item.DBName)
dbItem, err := mysqlRepo.Get(commonRepo.WithByID(uint(itemID)))
if err != nil {
return 0, nil, err
}
item.DBName = dbItem.Name
}
record, _ := cronjobRepo.RecordFirst(cronjob.ID)
if record.ID != 0 {
item.LastRecordTime = record.StartTime.Format("2006-01-02 15:04:05")

15
frontend/src/views/cronjob/record/index.vue

@ -374,6 +374,7 @@ import { Codemirror } from 'vue-codemirror';
import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark';
import { MsgError, MsgInfo, MsgSuccess } from '@/utils/message';
import { loadDBOptions } from '@/api/modules/database';
const loading = ref();
const refresh = ref(false);
@ -400,6 +401,20 @@ const cleanData = ref();
const acceptParams = async (params: DialogProps): Promise<void> => {
recordShow.value = true;
dialogData.value = params;
if (dialogData.value.rowData.type === 'database') {
const data = await loadDBOptions();
let itemDBs = data.data || [];
for (const item of itemDBs) {
if (item.id == dialogData.value.rowData.dbName) {
if (item.from === 'local') {
dialogData.value.rowData.dbName = i18n.global.t('database.localDB') + ' [' + item.name + ']';
} else {
dialogData.value.rowData.dbName = item.from + ' [' + item.name + ']';
}
break;
}
}
}
search();
timer = setInterval(() => {
search();

Loading…
Cancel
Save