fix: 警告问题修复

This commit is contained in:
Ray.Hao
2026-01-31 16:23:26 +08:00
parent dbeca689be
commit 452bbbc966
2 changed files with 24 additions and 21 deletions

View File

@@ -359,11 +359,12 @@ function handleOpenDialog(id?: string) {
if (id) {
dialog.title = "修改公告";
NoticeAPI.getFormData(id).then((data) => {
const normalized = {
Object.assign(formData, {
...data,
targetUsers: normalizeTargetUsers(data?.targetUsers),
};
Object.assign(formData, normalized);
targetUsers: normalizeTargetUsers(
(data as NoticeForm & { targetUserIds?: unknown }).targetUserIds
),
});
});
} else {
Object.assign(formData, { level: "L", targetType: 1, targetUsers: [] });
@@ -392,12 +393,14 @@ function handleSubmit() {
dataFormRef.value.validate((valid: any) => {
if (valid) {
loading.value = true;
if (formData.targetType !== 2) {
formData.targetUsers = [];
}
const payload = {
...formData,
targetUserIds: formData.targetType === 2 ? (formData.targetUsers ?? []) : [],
} as NoticeForm & { targetUserIds: number[] };
delete (payload as NoticeForm).targetUsers;
const id = formData.id;
if (id) {
NoticeAPI.update(id, formData)
NoticeAPI.update(id, payload)
.then(() => {
ElMessage.success("修改成功");
handleCloseDialog();
@@ -405,7 +408,7 @@ function handleSubmit() {
})
.finally(() => (loading.value = false));
} else {
NoticeAPI.create(formData)
NoticeAPI.create(payload)
.then(() => {
ElMessage.success("新增成功");
handleCloseDialog();