(), {
@@ -92,6 +93,11 @@ const handleCancel = () => {
emit('cancel')
}
+// 立即发送
+const handleSendNow = () => {
+ emit('sendNow')
+}
+
// 组件挂载时加载数据
loadAvailableTasks()
@@ -117,6 +123,9 @@ loadAvailableTasks()
+
+ ⚠️ 请确保所选任务已配置至少一个发送实例,否则无法发送
+
@@ -152,6 +161,9 @@ loadAvailableTasks()
+
diff --git a/web/src/components/pages/cronMessages/EditCronMessages.vue b/web/src/components/pages/cronMessages/EditCronMessages.vue
index 0e51fd2..8bf2509 100644
--- a/web/src/components/pages/cronMessages/EditCronMessages.vue
+++ b/web/src/components/pages/cronMessages/EditCronMessages.vue
@@ -89,6 +89,44 @@ const handleCancel = () => {
emit('update:open', false)
}
+// 立即发送
+const handleSendNow = async () => {
+ // 验证必填字段
+ if (!formData.task_id) {
+ toast.error('请先选择关联的发信任务')
+ return
+ }
+ if (!formData.title) {
+ toast.error('请先填写消息标题')
+ return
+ }
+ if (!formData.content) {
+ toast.error('请先填写消息内容')
+ return
+ }
+
+ loading.value = true
+ try {
+ const postData = {
+ task_id: formData.task_id,
+ title: formData.title,
+ content: formData.content,
+ url: formData.url
+ }
+
+ const rsp = await request.post('/cronmessages/sendnow', postData)
+ if (rsp.data.code === 200) {
+ toast.success(rsp.data.msg)
+ } else {
+ toast.error(rsp.data.msg)
+ }
+ } catch (error) {
+ toast.error('发送失败,请稍后重试')
+ } finally {
+ loading.value = false
+ }
+}
+
// 监听 cronMessage 变化,更新表单数据
watch(
() => props.cronMessage,
@@ -114,6 +152,7 @@ watch(
:loading="loading"
@submit="handleSubmit"
@cancel="handleCancel"
+ @send-now="handleSendNow"
/>