fix: Fix grouping exception issue for cronjob (#9841)

This commit is contained in:
ssongliu 2025-08-04 22:20:06 +08:00 committed by GitHub
parent 6a5e1ebaa5
commit c131061f81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 6 deletions

View file

@ -11,7 +11,7 @@ type Cronjob struct {
Name string `gorm:"not null" json:"name"`
Type string `gorm:"not null" json:"type"`
GroupID uint `json:"groupID"`
GroupID uint `gorm:"not null;default:0" json:"groupID"`
SpecCustom bool `json:"specCustom"`
Spec string `gorm:"not null" json:"spec"`

View file

@ -710,6 +710,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobOperate) error {
upMap["status"] = constant.StatusEnable
}
upMap["name"] = req.Name
upMap["group_id"] = req.GroupID
upMap["spec_custom"] = req.SpecCustom
upMap["spec"] = spec
upMap["script"] = req.Script

View file

@ -71,6 +71,7 @@ export namespace Cronjob {
export interface CronjobOperate {
id: number;
name: string;
groupID: number;
type: string;
specCustom: boolean;
spec: string;

View file

@ -398,16 +398,20 @@ const onSubmitExport = async () => {
const loadGroups = async () => {
const res = await getGroupList('cronjob');
groupOptions.value = res.data || [];
for (const group of groupOptions.value) {
if (group.name === 'Default') {
defaultGroupID.value = group.id;
break;
}
}
for (const item of data.value) {
if (item.groupID === 0) {
item.groupBelong = 'Default';
item.groupID = defaultGroupID.value;
continue;
}
let hasGroup = false;
for (const group of groupOptions.value) {
if (group.name === 'Default') {
defaultGroupID.value = group.id;
}
if (item.groupID === group.id) {
hasGroup = true;
item.groupBelong = group.name;

View file

@ -852,6 +852,7 @@ const search = async () => {
.then((res) => {
loading.value = false;
form.name = res.data.name;
form.groupID = res.data.groupID || null;
form.type = res.data.type;
form.specCustom = res.data.specCustom;
form.spec = res.data.spec;

View file

@ -182,7 +182,6 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useRouter } from 'vue-router';
import type { ElForm } from 'element-plus';
import { loginApi, getCaptcha, mfaLoginApi, getLoginSetting } from '@/api/modules/auth';
import { GlobalStore, MenuStore, TabsStore } from '@/store';
@ -269,7 +268,6 @@ const captcha = reactive({
const loading = ref<boolean>(false);
const mfaShow = ref<boolean>(false);
const router = useRouter();
const dropdownText = ref('中文(简体)');
function handleCommand(command: string) {