Forráskód Böngészése

优化proForm组件

tongshangming 2 éve
szülő
commit
fabf079f84
2 módosított fájl, 13 hozzáadás és 10 törlés
  1. 1 1
      src/components/core/ProTable.vue
  2. 12 9
      src/components/core/form/ProForm.vue

+ 1 - 1
src/components/core/ProTable.vue

@@ -171,7 +171,7 @@ const handleCreate = async () => {
   } catch {
     result = false
   }
-  console.log(result)
+
   if (result === false) {
     return
   }

+ 12 - 9
src/components/core/form/ProForm.vue

@@ -32,7 +32,7 @@ if (!props.formSlots) {
 }
 
 const submit = async () => {
-  let message
+  let message, result
   return formRef.value.validate().then(async () => {
     const loading = ElLoading.service()
     try {
@@ -50,21 +50,24 @@ const submit = async () => {
         }
       })
       if (data.id) {
-        await props.update(data)
+        result = await props.update(data)
         message = '编辑成功'
       } else {
-        await props.create(data)
+        result = await props.create(data)
         message = '新增成功'
       }
 
       loading.close()
 
-      ElMessage({
-        type: 'success',
-        message
-      })
-
-      return true
+      if (result === false) {
+        return false
+      } else {
+        ElMessage({
+          type: 'success',
+          message
+        })
+        return true
+      }
     } catch (error) {
       loading.close()
       return false