47 1 month ago
parent
commit
a767165337

+ 22 - 5
src/views/system/studentSelf/SForm.vue

@@ -173,27 +173,44 @@ const open = async (id?: number) => {
 }
 defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
+const imageUrls = ref<string[]>([]);
 /** 提交表单 */
 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
 const submitForm = async () => {
   // 校验表单
-  console.log(formData.value,'提交的表单');
   if (!formRef) return
   const valid = await formRef.value.validate()
   if (!valid) return
   // 提交请求
   formLoading.value = true
   try {
-    const data = formData.value as unknown as UserProfileUpdateReqVO
-      await updateUserProfile(data)
+    const content = formData.value.remark; // 获取富文本内容
+    imageUrls.value = extractImages(content);
+    const data = {
+      ...formData.value,
+      remark: content,
+    } as unknown as UserProfileUpdateReqVO
+    await updateUserProfile(data)
+    message.success(t('common.updateSuccess'));
     dialogVisible.value = false
-    // 发送操作成功的事件
-    emit('success')
+    emit('success' , imageUrls.value)
   } finally {
     formLoading.value = false
   }
+  console.log(formData.value,'提交的表单');
 }
 
+const extractImages = (htmlContent: string): string[] => {
+  const imgRegex = /<img[^>]+src="([^">]+)"/g;
+  let images: string[] = [];  // 明确声明 images 数组的类型为 string[]
+  let match;
+  while ((match = imgRegex.exec(htmlContent)) !== null) {
+    images.push(match[1]); // match[1] 是图片URL
+  }
+  return images;
+};
+
+
 /** 重置表单 */
 const resetForm = () => {
   formData.value = {

+ 1 - 0
src/views/system/studentSelf/index.vue

@@ -117,6 +117,7 @@ const openDialog = () => {
   loading.value = true; // 显示加载中
   dialogVisible.value = true;
   formRef.value.open(); // 打开弹窗
+  loading.value = false; // 隐藏加载中
 };
 
 const extractedImageUrls = ref<string[]>([]);

+ 4 - 5
src/views/system/workroomTeacher/TeacherSelf/TForm.vue

@@ -179,7 +179,6 @@ const imageUrls = ref<string[]>([]);
 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
 const submitForm = async () => {
   // 校验表单
-  console.log(formData.value,'提交的表单');
   if (!formRef) return
   const valid = await formRef.value.validate()
   if (!valid) return
@@ -192,13 +191,14 @@ const submitForm = async () => {
       ...formData.value,
       remark: content,
     } as unknown as UserProfileUpdateReqVO
-      await updateUserProfile(data)
+    await updateUserProfile(data)
+    message.success(t('common.updateSuccess'));
     dialogVisible.value = false
-    // 发送操作成功的事件
-    emit('success')
+    emit('success' , imageUrls.value)
   } finally {
     formLoading.value = false
   }
+  console.log(formData.value,'提交的表单');
 }
 
 const extractImages = (htmlContent: string): string[] => {
@@ -211,7 +211,6 @@ const extractImages = (htmlContent: string): string[] => {
   return images;
 };
 
-
 /** 重置表单 */
 const resetForm = () => {
   formData.value = {

+ 1 - 1
src/views/system/workroomTeacher/TeacherSelf/index.vue

@@ -130,6 +130,7 @@ const openDialog = () => {
   loading.value = true; // 显示加载中
   dialogVisible.value = true;
   formRef.value.open(); // 打开弹窗
+  loading.value = false; // 关闭加载状态
 };
 
 const extractedImageUrls = ref<string[]>([]);
@@ -162,7 +163,6 @@ const fetchImageUrls = async () => {
   return userInfo.value.remark ? userInfo.value.remark.replace(/<\/?[^>]+(>|$)/g, '') : '';
 });
 
-
     // // 表单提交
     // const submit = async () => {
     //   try {