fix: add ways/cronmessage error

This commit is contained in:
engigu
2025-08-31 13:47:29 +08:00
parent 7bd3ad8323
commit ee2f9480c2
4 changed files with 20 additions and 9 deletions
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref, reactive, watch } from 'vue'
import { toast } from 'vue-sonner' import { toast } from 'vue-sonner'
import { request } from '@/api/api' import { request } from '@/api/api'
import { generateBizUniqueID } from '@/util/uuid' import { generateBizUniqueID } from '@/util/uuid'
@@ -32,6 +32,7 @@ const formData = reactive({
url: '' url: ''
}) })
// 加载状态 // 加载状态
const loading = ref(false) const loading = ref(false)
@@ -56,8 +57,8 @@ const handleSubmit = async () => {
window.location.reload() window.location.reload()
}, 1000) }, 1000)
} else { } else {
toast.success(rsp.data.msg) toast.error(rsp.data.msg)
} }
} finally { } finally {
loading.value = false loading.value = false
} }
@@ -72,7 +73,11 @@ const handleCancel = () => {
<template> <template>
<CronMessageForm <CronMessageForm
v-model="formData" :model-value="formData"
@update:model-value="(val) => {
console.log('Received update:model-value:', val);
Object.assign(formData, val);
}"
mode="add" mode="add"
:loading="loading" :loading="loading"
@submit="handleSubmit" @submit="handleSubmit"
@@ -48,7 +48,7 @@ watch(() => props.modelValue, (newValue) => {
// 监听本地数据变化,同步到外部 // 监听本地数据变化,同步到外部
watch(localFormData, (newValue) => { watch(localFormData, (newValue) => {
emit('update:modelValue', { ...newValue }) emit('update:modelValue', newValue)
}, { deep: true }) }, { deep: true })
// 可用的发信任务列表 // 可用的发信任务列表
@@ -105,7 +105,7 @@ loadAvailableTasks()
<div class="space-y-1"> <div class="space-y-1">
<Label for="task_id" class="text-sm">关联发信任务</Label> <Label for="task_id" class="text-sm">关联发信任务</Label>
<Select v-model="localFormData.task_id"> <Select :model-value="localFormData.task_id" @update:model-value="(val) => localFormData.task_id = String(val || '')">
<SelectTrigger class="h-8"> <SelectTrigger class="h-8">
<SelectValue placeholder="选择要关联的发信任务" /> <SelectValue placeholder="选择要关联的发信任务" />
</SelectTrigger> </SelectTrigger>
@@ -44,12 +44,17 @@ const formData = reactive({
url: '' url: ''
}) })
// 加载状态 // 加载状态
const loading = ref(false) const loading = ref(false)
// 提交表单 // 提交表单
const handleSubmit = async () => { const handleSubmit = async () => {
if (!props.cronMessage) return if (!props.cronMessage) {
toast.error('未找到要编辑的定时消息')
return
}
loading.value = true loading.value = true
try { try {
@@ -103,7 +108,8 @@ watch(
<template> <template>
<CronMessageForm <CronMessageForm
v-model="formData" :model-value="formData"
@update:model-value="(val) => Object.assign(formData, val)"
mode="edit" mode="edit"
:loading="loading" :loading="loading"
@submit="handleSubmit" @submit="handleSubmit"
@@ -221,7 +221,7 @@ const handleTest = async () => {
// 保存数据 // 保存数据
const handleSave = async () => { const handleSave = async () => {
if (!validateFormData()) { return } // if (!validateFormData()) { return }
let postData = getFinalData() let postData = getFinalData()