| | |
| | | class="join-form"
|
| | | v-loading="joinLoading"
|
| | | >
|
| | | <el-form-item prop="clusterid">
|
| | | <!-- <el-form-item prop="clusterid">
|
| | | <div class="p-title">集群ID</div>
|
| | | <el-input v-model="joinForm.clusterid" size="small"></el-input>
|
| | | </el-form-item>
|
| | |
| | | size="small"
|
| | | autocomplete="new-password"
|
| | | ></el-input>
|
| | | </el-form-item>
|
| | | </el-form-item> -->
|
| | | <el-form-item prop="clusterpwd">
|
| | | <div class="p-title">集群密码</div>
|
| | | <el-input
|
| | |
| | | </el-form-item>
|
| | | </el-form>
|
| | | <div class="clu-list">
|
| | | <!-- :class="pickedNodeI == index ? 'clu-item-active' : ''" -->
|
| | | <div
|
| | | class="clu-item"
|
| | | v-for="(item, index) in members"
|
| | |
| | | {{ item.Address }}
|
| | | </div>
|
| | | </div>
|
| | | <div class="btns">
|
| | | <!-- <div class="btns">
|
| | | <div class="ok" @click="join('joinForm')">加入集群</div>
|
| | | </div>
|
| | | </div> -->
|
| | | </div>
|
| | | </div>
|
| | | </div>
|
| | |
| | | export default {
|
| | | data() {
|
| | | const checkPwd = (rule, value, callback) => {
|
| | | if (!value) {
|
| | | if (value=="") {
|
| | | return callback(new Error("密码不能为空"));
|
| | | }
|
| | | setTimeout(() => {
|
| | | // setTimeout(() => {
|
| | | if (value.length != 6) {
|
| | | callback(new Error("密码应为6位!"));
|
| | | } else {
|
| | | callback();
|
| | | }
|
| | | }, 1000);
|
| | | // }, 1000);
|
| | | };
|
| | | const checkID = (rule, value, callback) => {
|
| | | if (!value) {
|
| | |
| | | clustername: [
|
| | | { required: true, message: "请输入集群名称", trigger: "blur" },
|
| | | ],
|
| | | clusterpwd: [{ validator: checkPwd, required: true }],
|
| | | clusterpwd: [{ validator: checkPwd, required: true,trigger: "blur" }],
|
| | | virtualIp: [{ required: true, validator: isIPv4, trigger: "change" }],
|
| | | },
|
| | | joinExistRules: {
|
| | | clusterid: [{ validator: checkID, trigger: "blur" }],
|
| | | clusterip: [{ validator: isIPv4, trigger: "blur" }],
|
| | | clusterpwd: [{ validator: checkPwd, required: true }],
|
| | | clusterpwd: [{ validator: checkPwd, required: true,trigger: "blur" }],
|
| | | },
|
| | | };
|
| | | },
|
| | |
| | | },
|
| | | methods: {
|
| | | pickNode(index) {
|
| | | // this.pickedNodeI=index
|
| | | this.pickedNodeI = index;
|
| | | const node = this.members[index];
|
| | | const h = this.$createElement;
|
| | | // Address: "192.168.20.189:30190"
|
| | | // cluster_id: "5ee1dfa8-e3fb-4d62-8692-388d7632859b"
|
| | | // create_time: ""
|
| | | // id: "DSVAD010120190703"
|
| | | // nodeName: "192.168.20.189:30190"
|
| | | // node_id: "DSVAD010120190703"
|
| | | // role: "pc"
|
| | | this.$msgbox({
|
| | | title: "",
|
| | | message: h(
|
| | | "div",
|
| | | {
|
| | | style:
|
| | | "display: flex; flex-direction: column; justify-content: center; align-items: center;",
|
| | | },
|
| | | [
|
| | | h("span", { class: "icon iconfont warn-icon" }, "\ue71c"),
|
| | | h("span", { class: "warn-title" }, "加入集群"),
|
| | | h(
|
| | | "span",
|
| | | { class: "warn-dec" },
|
| | | `您是否要加入 ${node.Address} 吗?`
|
| | | ),
|
| | | ]
|
| | | ),
|
| | | showCancelButton: true,
|
| | | showClose: true,
|
| | | confirmButtonText: "确定",
|
| | | cancelButtonText: "取消",
|
| | | customClass: "del-account-message-box",
|
| | | }).then(() => {
|
| | | this.joinLoading = true;
|
| | | let data = {
|
| | | clusterId: node.cluster_id,
|
| | | password: this.joinForm.clusterpwd,
|
| | | nodeIps: [node.Address],
|
| | | };
|
| | | this.joinCluster(data)
|
| | | .then(() => {
|
| | | this.joinLoading = false;
|
| | | this.findCluster();
|
| | | })
|
| | | .catch((e) => {
|
| | | this.joinLoading = false;
|
| | | });
|
| | | });
|
| | | },
|
| | | async createCluster(json) {
|
| | | let res = await createSerfCluster(json);
|
| | |
| | | this.$refs[formName].validate((valid) => {
|
| | | if (valid) {
|
| | | _this.joinLoading = true;
|
| | | // let nodeIps = _this.members.map((i) => {
|
| | | // return i.Address;
|
| | | // });
|
| | | debugger;
|
| | | let data = {
|
| | | clusterId: _this.joinForm.clusterid,
|
| | | password: _this.joinForm.clusterpwd,
|
| | |
| | | cancelButtonText: "取消",
|
| | | customClass: "del-account-message-box",
|
| | | }).then(
|
| | | async () => {
|
| | | let res = await leave();
|
| | | this.$notify({
|
| | | title: res.success ? "成功" : "失败",
|
| | | message: res.msg,
|
| | | type: res.success ? "success" : "error",
|
| | | });
|
| | | if (res && res.success) {
|
| | | clearInterval(this.intervalTimer);
|
| | | this.showCurCluster = false;
|
| | | this.ruleForm.virtualIp = "";
|
| | | this.ruleForm.clustername = "";
|
| | | this.ruleForm.clusterpwd = "";
|
| | | this.clusterid = "";
|
| | | }
|
| | | },
|
| | | (err) => {
|
| | | clearInterval(this.intervalTimer);
|
| | | () => {
|
| | | this.showCurCluster = false;
|
| | | this.ruleForm.virtualIp = "";
|
| | | this.ruleForm.clustername = "";
|
| | | this.ruleForm.clusterpwd = "";
|
| | | this.clusterid = "";
|
| | | }
|
| | | // async () => {
|
| | | // let res = await leave();
|
| | | // this.$notify({
|
| | | // title: res.success ? "成功" : "失败",
|
| | | // message: res.msg,
|
| | | // type: res.success ? "success" : "error",
|
| | | // });
|
| | | // if (res && res.success) {
|
| | | // clearInterval(this.intervalTimer);
|
| | | // this.showCurCluster = false;
|
| | | // this.ruleForm.virtualIp = "";
|
| | | // this.ruleForm.clustername = "";
|
| | | // this.ruleForm.clusterpwd = "";
|
| | | // this.clusterid = "";
|
| | | // }
|
| | | // },
|
| | | // (err) => {
|
| | | // clearInterval(this.intervalTimer);
|
| | | // this.showCurCluster = false;
|
| | | // this.ruleForm.virtualIp = "";
|
| | | // this.ruleForm.clustername = "";
|
| | | // this.ruleForm.clusterpwd = "";
|
| | | // this.clusterid = "";
|
| | | // }
|
| | | );
|
| | | },
|
| | | clearInput(typ) {
|
| | |
| | | .clu-item {
|
| | | border-radius: 8px;
|
| | | height: 40px;
|
| | | // cursor: pointer;
|
| | | cursor: pointer;
|
| | | line-height: 40px;
|
| | | text-align: left;
|
| | | padding: 0 20px;
|
| | |
| | | margin-right: 8px;
|
| | | }
|
| | | }
|
| | | // .clu-item:hover {
|
| | | // background: var(--colorCard);
|
| | | // color: #fff;
|
| | | // }
|
| | | .clu-item:hover {
|
| | | background: var(--colorCard);
|
| | | color: #fff;
|
| | | }
|
| | | .clu-item-active {
|
| | | background: var(--colorCard);
|
| | | color: #fff;
|
| | | }
|
| | | }
|
| | | .el-form-item__content {
|
| | | line-height: 48px;
|