feat: 管理端定时日扩到1至28号,学时顺带写回列表
This commit is contained in:
@@ -326,6 +326,19 @@ async function loadTarget() {
|
||||
const startLoaded = ref(false);
|
||||
const scheduleEnabled = ref(true);
|
||||
const startDay = ref<number | null>(STUDY_DAY_DEFAULT);
|
||||
const loadedStartDay = ref<number | null>(null);
|
||||
const userDayOptions = computed(() => {
|
||||
const current = loadedStartDay.value;
|
||||
if (
|
||||
current != null
|
||||
&& (current < STUDY_DAY_MIN || current > STUDY_DAY_MAX)
|
||||
&& current >= 1
|
||||
&& current <= 28
|
||||
) {
|
||||
return [...dayOptions, { label: `每月 ${current} 日`, value: current }].sort((left, right) => left.value - right.value);
|
||||
}
|
||||
return dayOptions;
|
||||
});
|
||||
const startHour = ref<number | null>(0);
|
||||
const startMinute = ref<number | null>(0);
|
||||
const startSecond = ref<number | null>(0);
|
||||
@@ -350,6 +363,7 @@ async function loadStart() {
|
||||
if (!res.ok) return false;
|
||||
const data = await res.json();
|
||||
startDay.value = typeof data.day === "number" ? data.day : STUDY_DAY_DEFAULT;
|
||||
loadedStartDay.value = startDay.value;
|
||||
startHour.value = typeof data.hour === "number" ? data.hour : 0;
|
||||
startMinute.value = typeof data.minute === "number" ? data.minute : 0;
|
||||
startSecond.value = typeof data.second === "number" ? data.second : 0;
|
||||
@@ -412,7 +426,8 @@ function scheduleBody(): Record<string, unknown> | null {
|
||||
scheduleError.value = "请填写完整的开始时刻";
|
||||
return null;
|
||||
}
|
||||
if (day < STUDY_DAY_MIN || day > STUDY_DAY_MAX) {
|
||||
const keptByAdmin = loadedStartDay.value != null && day === loadedStartDay.value && (day < STUDY_DAY_MIN || day > STUDY_DAY_MAX);
|
||||
if (!keptByAdmin && (day < STUDY_DAY_MIN || day > STUDY_DAY_MAX)) {
|
||||
scheduleError.value = "每月开始日须为 5 到 25 的整数";
|
||||
return null;
|
||||
}
|
||||
@@ -1048,7 +1063,7 @@ onUnmounted(() => {
|
||||
<n-select
|
||||
v-model:value="startDay"
|
||||
size="small"
|
||||
:options="dayOptions"
|
||||
:options="userDayOptions"
|
||||
class="day-select"
|
||||
:disabled="!scheduleEnabled"
|
||||
aria-label="每月开始日"
|
||||
|
||||
Reference in New Issue
Block a user