const form2 = ref()
function doSave() {
  loading.value = true;

  form2.value.validate((valid: any) => {
    if (valid) {
      httpPost({ method: "project.save", form: form.value }).then((res: any) => {
        emit("afterSave", "");
        if (res.status == 200) {
          alert(res.msg);
        }
        loading.value = false;
      }).catch(() => {
        loading.value = false;
      });
    } else {
      alert("请按提示完善表单项目")
      loading.value = false;
    }
  })
}






<el-form ref="form2" :model="form" label-width="80px">
<el-form-item label="名称" prop="名称" required
                :rules="[{ required: true, message: '此项不能为空', trigger: 'blur' }]">
                <el-input autoComplete="off" v-model="form.名称" clearable placeholder="请输入名称" />
              </el-form-item>
<el-button :loading="loading" type="primary" @click="doSave">
          <span v-if="!loading"> 保 存 </span>
          <span v-else>提 交 中...</span>
        </el-button>
</el-form>

Logo

前往低代码交流专区

更多推荐