(e)
| 771 | } |
| 772 | |
| 773 | async function handleScheduleSubmit(e) { |
| 774 | e.preventDefault(); |
| 775 | |
| 776 | try { |
| 777 | const registrationConfig = buildCurrentRegistrationConfig(); |
| 778 | if (registrationConfig.email_service_type === 'outlook_batch' && (!registrationConfig.service_ids || registrationConfig.service_ids.length === 0)) { |
| 779 | toast.error('请至少选择一个 Outlook 账户后再保存计划'); |
| 780 | return; |
| 781 | } |
| 782 | |
| 783 | const { schedule_type, schedule_config } = buildScheduleConfig(); |
| 784 | const payload = { |
| 785 | name: (elements.scheduleName.value || '').trim(), |
| 786 | enabled: elements.scheduleEnabled.value === 'true', |
| 787 | schedule_type, |
| 788 | schedule_config, |
| 789 | registration_config: registrationConfig, |
| 790 | timezone: 'local', |
| 791 | }; |
| 792 | |
| 793 | if (!payload.name) { |
| 794 | toast.error('请输入计划名称'); |
| 795 | return; |
| 796 | } |
| 797 | |
| 798 | const endpoint = editingScheduleJobUuid |
| 799 | ? `/registration/schedules/${editingScheduleJobUuid}` |
| 800 | : '/registration/schedules'; |
| 801 | const method = editingScheduleJobUuid ? 'put' : 'post'; |
| 802 | |
| 803 | await api[method](endpoint, payload); |
| 804 | toast.success(editingScheduleJobUuid ? '计划任务已更新' : '计划任务已创建'); |
| 805 | resetScheduleForm(); |
| 806 | await loadScheduledJobs(); |
| 807 | } catch (error) { |
| 808 | toast.error(error.message); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | function resetScheduleForm() { |
| 813 | editingScheduleJobUuid = null; |
nothing calls this directly
no test coverage detected