fix in the future sendAt invalid

This commit is contained in:
Timi
2026-08-28 22:52:28 +08:00
parent 992e5536c8
commit 5ff6905c8f
+31 -29
View File
@@ -67,12 +67,20 @@
<script setup lang="ts"> <script setup lang="ts">
import { NotifyEditor, type NotifyEditorExpose } from "timi-tdesign-mobile"; import { NotifyEditor, type NotifyEditorExpose } from "timi-tdesign-mobile";
import { Time } from "timi-web"; import { Time } from "timi-web";
import { AttachmentAPI, type Attachment as ApiAttachment, type NotifyContentType, type NotifyDetail, useUserStore } from "timi-web-api"; import {
type Attachment as ApiAttachment,
AttachmentAPI,
type NotifyContentType,
type NotifyDetail,
useUserStore
} from "timi-web-api";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import GaoNotifyAPI from "@/api/GaoNotifyAPI"; import GaoNotifyAPI from "@/api/GaoNotifyAPI";
import type { ManagedUser } from "@/types/ManagedUser"; import type { ManagedUser } from "@/types/ManagedUser";
import NotifyRecipientPicker, { type NotifyRecipientScopeOption } from "@/pages/notify/component/NotifyRecipientPicker.vue"; import NotifyRecipientPicker, {
type NotifyRecipientScopeOption
} from "@/pages/notify/component/NotifyRecipientPicker.vue";
import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { corePermissionCodes, coreRoleCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { useNavBarStore } from "@/store/navBarStore"; import { useNavBarStore } from "@/store/navBarStore";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -183,6 +191,12 @@ const scheduleAtText = ref("");
const scheduleDraftText = ref(""); const scheduleDraftText = ref("");
const minimumScheduleText = computed(() => Time.formatDateTime(new Date(Time.now() + Time.M))); const minimumScheduleText = computed(() => Time.formatDateTime(new Date(Time.now() + Time.M)));
function updateNavActionText(): void {
navBarStore.setRightText(scheduleAtText.value ? "提交" : "发送", "var(--td-brand-color)", saveNotification);
}
watch(scheduleAtText, updateNavActionText);
function getContentText(content: string): string { function getContentText(content: string): string {
const parser = new DOMParser(); const parser = new DOMParser();
return parser.parseFromString(content, "text/html").body.textContent?.trim() || ""; return parser.parseFromString(content, "text/html").body.textContent?.trim() || "";
@@ -268,13 +282,14 @@ function openSchedulePicker(): void {
schedulePickerVisible.value = true; schedulePickerVisible.value = true;
} }
function confirmSchedule(): void { function confirmSchedule(value?: string | number): void {
const timestamp = new Date(scheduleDraftText.value.replace(" ", "T")).getTime(); const scheduleText = String(value ?? scheduleDraftText.value);
const timestamp = new Date(scheduleText.replace(" ", "T")).getTime();
if (Number.isNaN(timestamp) || timestamp < Time.now()) { if (Number.isNaN(timestamp) || timestamp < Time.now()) {
Message.warning("定时发送时间必须晚于当前时间"); Message.warning("定时发送时间必须晚于当前时间");
return; return;
} }
scheduleAtText.value = scheduleDraftText.value; scheduleAtText.value = scheduleText;
schedulePickerVisible.value = false; schedulePickerVisible.value = false;
} }
@@ -351,7 +366,7 @@ onMounted(async () => {
const loginStore = await currentStoreStore.loadLoginStore(); const loginStore = await currentStoreStore.loadLoginStore();
recipientStoreId.value = loginStore?.id || currentStoreStore.currentStoreId || ""; recipientStoreId.value = loginStore?.id || currentStoreStore.currentStoreId || "";
} }
navBarStore.setRightText("发送", "var(--td-brand-color)", saveNotification); updateNavActionText();
await loadRecipients(); await loadRecipients();
}); });
@@ -367,14 +382,6 @@ onUnmounted(() => navBarStore.clearRight());
margin: 0; margin: 0;
display: grid; display: grid;
.schedule-value {
gap: .5rem;
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
}
.recipient-item { .recipient-item {
.value { .value {
@@ -383,6 +390,16 @@ onUnmounted(() => navBarStore.clearRight());
} }
} }
.schedule-value {
--td-button-extra-small-height: 24px;
gap: .5rem;
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
}
.editor-wrapper { .editor-wrapper {
width: 100%; width: 100%;
min-width: 0; min-width: 0;
@@ -424,21 +441,6 @@ onUnmounted(() => navBarStore.clearRight());
max-width: 100%; max-width: 100%;
} }
} }
.tip {
color: #64748b;
margin: 0 1rem;
font-size: .8125rem;
line-height: 1.5;
}
}
}
:global(html.theme-dark) {
.notify-management-create {
.tip {
color: #94a3b8;
}
} }
} }
</style> </style>