zhangzengfei
2021-02-04 0175cda6150656bc74b34c6f6c71edd1e1fc653c
src/pages/settings/components/ClusterManagement.vue
@@ -222,7 +222,7 @@
    ipInput,
    cloudNode
  },
  data () {
  data() {
    const checkPwd = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("密码不能为空"));
@@ -306,7 +306,7 @@
      showJoinConfirm: false
    };
  },
  mounted () {
  mounted() {
    this.findCluster();
    let _this = this;
    this.intervalTimer = setInterval(() => {
@@ -314,20 +314,20 @@
    }, 30000);
    //this.getEsClusterNodes();
  },
  beforeDestroy () {
  beforeDestroy() {
    clearInterval(this.intervalTimer);
  },
  methods: {
    checkPsd (psd) {
    checkPsd(psd) {
      return psd.trim().length === 6
    },
    cleanValue () {
    cleanValue() {
      this.members = [];
    },
    sHandleClick (tab, event) {
    sHandleClick(tab, event) {
      console.log(tab, event);
    },
    submitForm (formName) {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          //alert("submit!");
@@ -347,7 +347,7 @@
      });
    },
    saveForm (formName) {
    saveForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
@@ -367,7 +367,7 @@
      });
    },
    join (formName) {
    join(formName) {
      let _this = this;
      this.$refs[formName].validate(valid => {
        if (valid) {
@@ -403,7 +403,7 @@
        }
      });
    },
    async createCluster (json) {
    async createCluster(json) {
      let res = await createSerfCluster(json);
      console.log(res, "创建集群");
      this.$notify({
@@ -412,13 +412,13 @@
        type: res.success ? "success" : "error"
      });
    },
    async randomPwd () {
    async randomPwd() {
      let res = await randomPwd();
      if (res && res.success) {
        this.ruleForm.clusterpwd = res.data;
      }
    },
    async searchColony () {
    async searchColony() {
      this.isSearch = true;
      this.$refs["joinForm"].clearValidate();
      this.$refs["joinForm"].validateField('clusterpwd');
@@ -448,7 +448,7 @@
      }
      //});
    },
    async search (json) {
    async search(json) {
      let res = await search(json);
      if (res && res.success) {
        console.log(res, "搜索集群");
@@ -461,7 +461,7 @@
      }, 10 * 1000);
    },
    //搜索集群
    async getSearchNodes () {
    async getSearchNodes() {
      let res = await getSearchNodes();
      if (res && res.success) {
        let list = res.data.map(i => {
@@ -485,12 +485,12 @@
        });
      }
    },
    setSchedule () {
    setSchedule() {
      this.scheduleId = window.setInterval(() => {
        this.getSearchNodes();
      }, 1000);
    },
    async stopSearch () {
    async stopSearch() {
      if (!this.loading) {
        return true;
      }
@@ -515,7 +515,7 @@
        // },2000)
      })
    },
    async findCluster () {
    async findCluster() {
      let res = await findCluster();
      if (res && res.success) {
        if (res.data && res.data.clusterId) {
@@ -552,7 +552,7 @@
        }
      }
    },
    getVrrpInfo () {
    getVrrpInfo() {
      getVrrp().then(res => {
        if (res.success) {
          this.vrIpForm.virtual_ip = res.data.virtual_ip;
@@ -562,7 +562,7 @@
        console.log(e)
      })
    },
    async updateCluster () {
    async updateCluster() {
      if (this.ruleForm.clustername === "") {
        this.$message({
          type: "error",
@@ -582,7 +582,7 @@
        type: res.success ? "success" : "error"
      });
    },
    async joinCluster (json) {
    async joinCluster(json) {
      let res = await joinCluster(json);
      if (res.success) {
        this.members = []
@@ -593,7 +593,7 @@
        type: res.success ? "success" : "error"
      });
    },
    leave () {
    leave() {
      this.$confirm(`确定退出集群吗?`, {
        center: true,
        cancelButtonClass: "comfirm-class-cancle",
@@ -617,8 +617,8 @@
      }).catch(() => { });
    },
    joinNode (event, node) {
      console.log('join',node)
    joinNode(event, node) {
      console.log('join', node)
      let _this = this;
      this.currentCluster.cluster_id = node.cluster_id;
      if (this.activeName === "3") {
@@ -627,7 +627,6 @@
        return;
      }
      if (this.activeName === "2") {
        debugger
        if (_this.showJoinConfirm) return;
        this.$confirm("是否要加入节点 " + node.nodeName + "?", "加入集群", {
@@ -684,7 +683,7 @@
        // });
      }
    },
    generatePassword () {
    generatePassword() {
      var chars =
        "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
      var uuid = [];
@@ -696,7 +695,7 @@
      this.ruleForm.clusterpwd = uuid.join("");
    },
    async getEsClusterNodes () {
    async getEsClusterNodes() {
      let rsp = await getDevInfo();
      let hostIpAddr = "";
      if (rsp && rsp.success) {
@@ -722,7 +721,7 @@
        }
      }
    },
    createEsCluster () {
    createEsCluster() {
      createESNode().then(rsp => {
        if (rsp && rsp.success) {
          this.$message({
@@ -747,7 +746,7 @@
        });
      })
    },
    joinESCluster () {
    joinESCluster() {
      if (!this.esNodeIp.length) {
        this.$message({
          type: "error",
@@ -781,7 +780,7 @@
        });
      })
    },
    onIpBlur (ip) {
    onIpBlur(ip) {
      //this.vrIpForm.virtual_ip = ip;
      this.ruleForm.virtualIp = ip;
      console.log(this.ruleForm.virtualIp)
@@ -789,7 +788,7 @@
  },
  created () { }
  created() { }
};
</script>