美文网首页
antdv 表单提交

antdv 表单提交

作者: BestFei | 来源:发表于2019-12-19 14:41 被阅读0次

界面代码

      <p>Add White List</p>
      <a-form layout="inline" @submit="handleSubmit">
        <a-form-item label="Country">
            <a-select style="width: 150px;"
                v-model="countryDefault"
                @change="e => handleCountryChange(e)"
            >
                <a-select-option v-for="country in countrys" :key="country">{{ country }}</a-select-option>
            </a-select>
        </a-form-item>

        <a-form-item label="Ip" >
            <a-input v-model="ip" style="width: 180px;" />
        </a-form-item>

        <a-form-item label="Port" >
            <a-input v-model="port" style="width: 150px;" />
        </a-form-item>

        <a-form-item>
          <a-button type="primary" html-type="submit">Add To WhiteList</a-button>
        </a-form-item>
      </a-form>

JS代码

<script>
import { getEnvironmentList } from "@/api/environment";
import { apiAddWhiteList } from "@/api/whitelist";

const countrys = ["Indonesia", "Philippines", "Vietnam"];
const whiteListCountry = "";
const ip = "";
const port = "";
const data = [];

export default {
  data() {
    return {
      ip,
      port,
      countrys,
      countryDefault: "",
      titles,
      data
    };
  },
  mounted() {},
  methods: {
    jump() {
      window.open(this.log, "_blank");
    },

    handleSubmit(e) {
      e.preventDefault();

      console.info(this.whiteListCountry);
      if(this.whiteListCountry == '' || this.whiteListCountry == undefined){
        alert("Country is null");
        return;
      }
      else if(this.ip == ''){
        alert("ip is null");
        return;
      }
      else if(this.port == ''){
        alert("port is null");
        return;
      }

      apiAddWhiteList(this.whiteListCountry,this.ip,this.port).then((res) => {
          console.log("msg:"+res.data.msg);
          this.success(res.data.msg);
      })
      .catch(error => {
        if (error.response) {
          this.error("Submit failed");
        } else if (error.request) {
          this.error("Submit failed");
        } else {
          this.error("unknow  exception");
        }
      });

    },

    handleCountryChange(value) {
      this.whiteListCountry = value;
    },

    success(msg) {
      this.$message.success(msg);
    },
    error(msg) {
      this.$message.error(msg);
    },
    warning(msg) {
      this.$message.warning(msg);
    }
  }
};
</script>

<style lang="less" scoped>
.marginBottom24 {
  margin-bottom: 24px;
}
</style>

相关文章

  • antdv 表单提交

    界面代码 JS代码

  • 12、Struts2表单重复提交

    什么是表单重复提交表单的重复提交:若刷新表单页面, 再提交表单不算重复提交.在不刷新表单页面的前提下:多次点击提交...

  • Http的post请求中表单、json提交的请求头、请求体区别

    1、真正的表单提交,http默认的也是表单 python模拟表单提交 2、json提交 python模拟json提交

  • Javascript-表单脚本

    一、表单的基础知识 1、表单提交 普通提交 以编程方式调用submit()方法提交表单 解决表单重复提交的办法:1...

  • FormData

    表单,FormData 对象 表单概述 表单用来收集用户提交的数据,发送到服务器 表单提交 1. 提交 表单里...

  • JAVAWeb(第三周)

    表单提交方式 *使用submit提交 .... *使用button提交表单 -代码 //实现提交方法 functi...

  • Struts2学习笔记 | 防止表单重复提交及自定义拦截器

    表单重复提交的概述 若刷新表单页面,再提交表单不算重复提交。 若是重定向,已经提交成功后再刷新不算重复提交。 以下...

  • 表单

    表单基础 提交表单 Tips: 解决重复提交表单的问题的两个方法1)在第一次提交表单后就禁用提交按钮2)利用ons...

  • antdv4动态表单

    V3的时候做过相关的表单,参照官方文档,但是当时是通过数值及数组控制相关的展示,在getDerivedStateF...

  • JavaWeb (day5)

    1.表单提交方式 使用 submit 提交 使用 button 提交表单 使用超链接提交 onclick :鼠标点...

网友评论

      本文标题:antdv 表单提交

      本文链接:https://www.haomeiwen.com/subject/oebmnctx.html