ソースを参照

优化 添加代理验证

wzg 1 年間 前
コミット
cf97ea4fac
1 ファイル変更19 行追加15 行削除
  1. 19 15
      src/views/agencyManage/agencyCompanyList.vue

+ 19 - 15
src/views/agencyManage/agencyCompanyList.vue

@@ -57,7 +57,7 @@
           <el-form
             :model="ruleForm"
             :rules="rules"
-            ref="form"
+            ref="ruleFormRef"
             label-width="110px"
             label-position="left"
           >
@@ -241,22 +241,26 @@ function pageChange(e) {
   getAgencyList();
 }
 let visable = ref(false);
-let form = ref(null);
+let ruleFormRef = ref(null);
 async function addAgency() {
-  let res = await api.addAgency({
-    ...ruleForm.value,
-    loginAccountId: loginAccountId.value,
-  });
-  console.log(res);
-  let status = res.data.status == 0;
-  ElNotification({
-    title: status ? "成功" : "失败",
-    duration: 1500,
-    message: res.data.msg,
-    type: status ? "success" : "error",
+  ruleFormRef.value.validate(async (valid) => {
+    if (valid) {
+      let res = await api.addAgency({
+        ...ruleForm.value,
+        loginAccountId: loginAccountId.value,
+      });
+      console.log(res);
+      let status = res.data.status == 0;
+      ElNotification({
+        title: status ? "成功" : "失败",
+        duration: 1500,
+        message: res.data.msg,
+        type: status ? "success" : "error",
+      });
+      resetForm();
+      getAgencyList();
+    }
   });
-  resetForm();
-  getAgencyList();
 }
 function resetForm() {
   visable.value = false;