Browse Source

change: indnet供应商审核通过流程改为先保存表单数据再审核通过.

peter 2 months ago
parent
commit
91fb0cf1a8
1 changed files with 36 additions and 30 deletions
  1. 36 30
      src/pages/indent-manage/supplier/components/edit.vue

+ 36 - 30
src/pages/indent-manage/supplier/components/edit.vue

@@ -303,18 +303,13 @@ const checkForm = () => {
     if (valid) {
       const p = cloneDeep(form.value)
       loading.value = true
+      p.status = 0
       if (visible === 1) {
         delete p.feedback
         create(p)
       } else if (visible === 2) {
         delete p.feedback
         edit(p)
-      } else if (visible === 3) {
-        delete p.feedback
-        edit(p)
-        setTimeout(() => {
-          auditLoading.value = false
-        }, 1000)
       }
     }
   })
@@ -336,22 +331,27 @@ const create = (p: any) => {
       loading.value = false
     })
 }
-const edit = (p: any) => {
-  updateSupplier(p)
-    .then((res: any) => {
-      if (res.code === 1) {
-        ElNotification({
-          title: '操作成功',
-          message: '正在刷新数据',
-          duration: 3000,
-        })
-        resetData()
-        close()
-      }
-    })
-    .finally(() => {
-      loading.value = false
-    })
+const edit = (p: any, flag = true) => {
+  return new Promise((resolve) => {
+    updateSupplier(p)
+      .then((res: any) => {
+        if (res.code === 1) {
+          ElNotification({
+            title: '操作成功',
+            message: '正在刷新数据',
+            duration: 3000,
+          })
+          resolve(true)
+          if (flag) {
+            resetData()
+            close()
+          }
+        }
+      })
+      .finally(() => {
+        loading.value = false
+      })
+  })
 }
 const resetData = () => {
   form.value = {
@@ -393,20 +393,26 @@ const audit = (status: number = 2) => {
   console.log(d, 'd')
   if (auditLoading.value) return
   auditLoading.value = true
-  saveExamine(d).then((res: any) => {
-    form.value.status = 1
-    // 审核通过后保存编辑的内容.
-    if (res.result == 1) {
-      checkForm()
-    } else {
+  const p = cloneDeep(form.value)
+  delete p.feedback
+  edit(p, false)
+    .then(() => {
+      saveExamine(d).then((res: any) => {
+        auditLoading.value = false
+        if (res.result === 1) {
+          resetData()
+          close()
+        }
+      })
+    })
+    .catch(() => {
       auditLoading.value = false
       ElNotification({
         title: '操作失败',
         message: '请刷新稍后再试或者联系管理员',
         duration: 3000,
       })
-    }
-  })
+    })
 }
 </script>