修复content_type默认值的问题

This commit is contained in:
2025-09-21 20:20:22 +08:00
parent 69f673b494
commit 21b357a97c

View File

@@ -117,7 +117,8 @@ export default {
description: '', description: '',
execution_type: 'automatic', // 默认自动执行 execution_type: 'automatic', // 默认自动执行
execute_num: 0, // 0表示无限执行 execute_num: 0, // 0表示无限执行
cron_expression: '' // cron表达式 cron_expression: '', // cron表达式
content_type: 'tasks' // 默认类型为tasks
}); });
// 表单验证规则 // 表单验证规则
@@ -171,6 +172,11 @@ export default {
...formData ...formData
}; };
// 确保content_type字段有默认值
if (!submitData.content_type) {
submitData.content_type = 'tasks';
}
// 如果是手动执行清除执行次数和cron表达式 // 如果是手动执行清除执行次数和cron表达式
if (formData.execution_type === 'manual') { if (formData.execution_type === 'manual') {
submitData.execute_num = 0; submitData.execute_num = 0;
@@ -198,17 +204,24 @@ export default {
formData[key] = newVal[key]; formData[key] = newVal[key];
} }
}); });
// 确保content_type字段有默认值
if (!formData.content_type) {
formData.content_type = 'tasks';
}
} else { } else {
// 重置表单数据 // 重置表单数据
Object.keys(formData).forEach(key => { Object.keys(formData).forEach(key => {
if (key === 'execute_num') { if (key === 'execute_num') {
formData[key] = 0; formData[key] = 0;
} else if (key === 'content_type') {
formData[key] = 'tasks'; // 默认类型为tasks
} else { } else {
formData[key] = ''; formData[key] = '';
} }
}); });
// 默认值 // 默认值
formData.execution_type = 'automatic'; formData.execution_type = 'automatic';
formData.content_type = 'tasks'; // 确保content_type有默认值
} }
}, { immediate: true }); }, { immediate: true });