<template>
|
<div class="all">
|
<div class="cluster-content">
|
<div class="cluster-center" ref="left">
|
<div class="menu-item" @click="openRight('net')">
|
<div><span class="icon iconfont"></span>网络设置</div>
|
<div class="status">已连接</div>
|
</div>
|
<div class="menu-item" @click="openRight('wifi')">
|
<div><span class="icon iconfont"></span>无线网络</div>
|
<div class="status">已连接</div>
|
</div>
|
<div class="menu-item" @click="openRight('wire')">
|
<div><span class="icon iconfont"></span>有线网络</div>
|
<div class="status">已连接</div>
|
</div>
|
</div>
|
<div class="cluster-right">
|
<div class="net-set" v-if="activePage == 'net'">
|
<div class="title">网络设置</div>
|
<el-form
|
:model="ruleForm"
|
:rules="rules"
|
ref="joinForm"
|
class="join-form"
|
label-width="150px"
|
v-loading="joinLoading"
|
>
|
<el-form-item label="设备名称" prop="deviceName">
|
<el-input
|
v-model="ruleForm.deviceName"
|
size="small"
|
placeholder="必填"
|
></el-input>
|
</el-form-item>
|
|
<el-form-item label="端口" prop="port">
|
<el-input
|
v-model="ruleForm.port"
|
placeholder="选填,外部访问的端口"
|
size="small"
|
></el-input>
|
</el-form-item>
|
<div class="save-btn" @click="saveServerName">保存</div>
|
</el-form>
|
</div>
|
|
<div class="wifi" v-if="activePage == 'wifi' && !inWifiDetail">
|
<switchBar
|
:barName="`无线网卡`"
|
@switchChange="wifiControl"
|
:value="isOpenWifi"
|
></switchBar>
|
|
<div class="wifi-option" v-for="(item, i) in wifiList" :key="i">
|
<div class="name">
|
<span class="icon iconfont"></span>
|
<span> {{ item.name }} </span>
|
</div>
|
|
<div class="more-detail">
|
<span class="icon iconfont"></span>
|
<span
|
class="icon iconfont"
|
style="margin-left: 10px"
|
@click="checkWifi(item)"
|
></span
|
>
|
</div>
|
</div>
|
</div>
|
<div class="wifi-detail" v-if="activePage == 'wifi' && inWifiDetail">
|
<div class="btns">
|
<div class="left">删除</div>
|
<div class="right">断开连接</div>
|
</div>
|
|
<div class="title">通用</div>
|
|
<el-form
|
:model="wifiForm"
|
:rules="wifiFormRules"
|
ref="wifiForm"
|
class="join-form"
|
label-width="150px"
|
>
|
<!-- v-loading="joinLoading" -->
|
<el-form-item label="名称" prop="name">
|
<div class="wifi-name">{{ 12123 }}</div>
|
</el-form-item>
|
|
<el-form-item label="密码" prop="password">
|
<el-input
|
v-model="wifiForm.password"
|
placeholder="请输入密码"
|
size="small"
|
show-password
|
></el-input>
|
</el-form-item>
|
</el-form>
|
|
<switchBar
|
:barName="`高级设置`"
|
@switchChange="highClassSetting"
|
:value="isHighClass"
|
></switchBar>
|
<div class="title">IPV4</div>
|
|
<!-- <el-form
|
:model="ipv4Form"
|
:rules="ipv4FormRules"
|
ref="ipv4Form"
|
class="join-form"
|
label-width="150px"
|
>
|
<el-form-item label="密码" prop="password">
|
<el-input
|
v-model="wifiForm.password"
|
placeholder="请输入密码"
|
size="small"
|
show-password
|
></el-input>
|
</el-form-item>
|
</el-form> -->
|
|
<el-form
|
:model="ipv4Form"
|
:rules="ipv4FormRules"
|
ref="ipv4Form"
|
label-width="150px"
|
>
|
<el-form-item label="方法">
|
<el-select v-model="value" placeholder="请选择" size="small">
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="IP" prop="ip">
|
<ip-input
|
:ip="ipv4Form.ip"
|
@on-blur="ipv4Form.ip = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="子网掩码" prop="subMask">
|
<ip-input
|
:ip="ipv4Form.subMask"
|
@on-blur="ipv4Form.subMask = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
|
<el-form-item label="网关" prop="gateway">
|
<ip-input
|
:ip="ipv4Form.gateway"
|
@on-blur="ipv4Form.gateway = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="首选DNS" prop="dns">
|
<ip-input
|
:ip="ipv4Form.dns1"
|
@on-blur="ipv4Form.dns1 = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="备用DNS" prop="dns">
|
<ip-input
|
:ip="ipv4Form.dns2"
|
@on-blur="ipv4Form.dns2 = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
</el-form>
|
|
<div class="title">IPV6</div>
|
|
<el-form
|
:model="ipv6Form"
|
:rules="ipv6FormRules"
|
ref="ipv4Form"
|
label-width="150px"
|
>
|
<el-form-item label="方法">
|
<el-select v-model="value" placeholder="请选择" size="small">
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="IP地址" prop="ip">
|
<ip-input
|
:ip="ipv6Form.ip"
|
@on-blur="ipv6Form.ip = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="前缀" prop="subMask">
|
<div style="display: flex">
|
<el-input
|
v-model="wifiForm.password"
|
placeholder=""
|
size="small"
|
></el-input>
|
|
<div class="ad">-</div>
|
<div class="ad">+</div>
|
<div class="ad">重置</div>
|
</div>
|
</el-form-item>
|
|
<el-form-item label="网关" prop="gateway">
|
<ip-input
|
:ip="ipv6Form.gateway"
|
@on-blur="ipv6Form.gateway = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="首选DNS" prop="dns">
|
<ip-input
|
:ip="ipv6Form.dns1"
|
@on-blur="ipv6Form.dns1 = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="备用DNS" prop="dns">
|
<ip-input
|
:ip="ipv6Form.dns2"
|
@on-blur="ipv6Form.dns2 = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
</el-form>
|
|
<div class="btns">
|
<div class="left">取消</div>
|
<div class="right">保存</div>
|
</div>
|
</div>
|
|
<div class="wire" v-if="activePage == 'wire' && !inWireDetail">
|
<div
|
|
class="wire-bar"
|
v-for="(item, i) in wireArr"
|
:key="i"
|
@click.self="checkWire(item)"
|
>
|
<div class="name">{{ "网络" + item.index }}</div>
|
|
<div class="right">
|
<span class="icon iconfont"></span>
|
|
<el-switch
|
v-model="value"
|
active-color="rgba(61, 104, 225, 1)"
|
@change="switchChange"
|
>
|
</el-switch>
|
</div>
|
</div>
|
</div>
|
<div class="wire-detail" v-if="activePage == 'wire' && inWireDetail">
|
<div class="title">网络设置</div>
|
<el-form
|
:model="wireForm"
|
:rules="wireFormRules"
|
ref="wireForm"
|
label-width="150px"
|
>
|
<el-form-item label="网络名称" prop="name">
|
<div class="wifi-name">{{"网络" + activeWireItem.index }}</div>
|
</el-form-item>
|
<el-form-item label="网卡" prop="ifname">
|
<div class="wifi-name">{{ activeWireItem.name }}</div>
|
</el-form-item>
|
<el-form-item label="IP" prop="ip">
|
<ip-input
|
:ip="wireForm.ip"
|
@on-blur="wireForm.ip = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="子网掩码" prop="subMask">
|
<ip-input
|
:ip="wireForm.subMask"
|
@on-blur="wireForm.subMask = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
|
<el-form-item label="网关" prop="gateway">
|
<ip-input
|
:ip="wireForm.gateway"
|
@on-blur="wireForm.gateway = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
<el-form-item label="DNS" prop="dns">
|
<ip-input
|
:ip="wireForm.dns"
|
@on-blur="wireForm.dns = arguments[0]"
|
></ip-input>
|
</el-form-item>
|
</el-form>
|
|
<div class="btns">
|
<div class="cancel" @click="cancelSaveWire">取消</div>
|
<div class="ok" @click="saveWire">保存</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import {
|
createSerfCluster,
|
randomPwd,
|
search,
|
getSearchNodes,
|
stopSearching,
|
findCluster,
|
updateClusterName,
|
joinCluster,
|
leave,
|
getVrrp,
|
setVrrp,
|
createESNode,
|
addESNode,
|
getEsClusterInfo,
|
} from "@/api/clusterManage";
|
import { setServerName, getWireList, setNetWorkCard,getNetWorkCardInfo } from "@/api/system";
|
|
import cloudNode from "../components/CloudNode";
|
import ipInput from "@/components/subComponents/IPInput";
|
import { isIPv4 } from "@/scripts/validate";
|
import switchBar from "../components/switchBar";
|
|
export default {
|
data() {
|
const checkPwd = (rule, value, callback) => {
|
if (!value) {
|
return callback(new Error("密码不能为空"));
|
}
|
setTimeout(() => {
|
if (value.length != 6) {
|
callback(new Error("密码应为6位!"));
|
} else {
|
callback();
|
}
|
}, 1000);
|
};
|
return {
|
isHighClass: false,
|
|
ruleForm: {
|
deviceName: "",
|
port: "",
|
},
|
wifiForm: {
|
name: "",
|
password: "",
|
},
|
wireArr: [],
|
inWifiDetail: false,
|
wifiList: [{ name: "无线网络1" }, { name: "无线网络2" }],
|
isOpenWifi: false,
|
inWireDetail: false,
|
wireForm: {
|
dns:"",
|
subMask:"",
|
gateway:"",
|
ip:"",
|
},
|
wireFormRules: {},
|
activePage: "net",
|
activeWireItem: {},
|
rules: {
|
deviceName: [
|
{ required: true, message: "请输入设备名称", trigger: "change" },
|
],
|
},
|
ipv4Form: {},
|
ipv6Form: {},
|
ipv4FormRules: {},
|
ipv6FormRules: {},
|
options: [
|
{
|
value: "选项1",
|
label: "手动",
|
},
|
{
|
value: "选项2",
|
label: "自动",
|
},
|
],
|
value: "",
|
};
|
},
|
components: {
|
cloudNode,
|
ipInput,
|
switchBar,
|
},
|
mounted() {},
|
beforeDestroy() {},
|
props: ["barName"],
|
methods: {
|
fetchWireList() {
|
getWireList().then((res) => {
|
if (res && res.success) {
|
console.log(res);
|
this.wireArr = res.data;
|
}
|
});
|
},
|
cancelSaveWire() {
|
this.inWireDetail = false;
|
},
|
saveServerName() {
|
setServerName({
|
server_name: this.ruleForm.deviceName,
|
server_port: this.ruleForm.port,
|
}).then((res) => {
|
console.log(res);
|
if (res && res.success) {
|
this.$message.success(res.data);
|
}
|
});
|
},
|
openRight(typ) {
|
this.activePage = typ;
|
if (typ == "wire") {
|
this.fetchWireList();
|
}
|
},
|
saveWire(ifname) {
|
debugger
|
let data ={
|
ip: this.wireForm.ip,
|
gateway: this.wireForm.gateway,
|
dns: this.wireForm.dns,
|
subMask: this.wireForm.subMask,
|
ifname: this.activeWireItem.name,
|
}
|
setNetWorkCard(data).then((res) => {
|
if (res&&res.success) {
|
this.$message.success(res.data)
|
}
|
},(err) => {
|
this.$message.error("保存失败:"+ err.msg)
|
});
|
},
|
wifiControl(val) {},
|
checkWifi() {
|
this.inWifiDetail = true;
|
},
|
checkWire(item) {
|
this.inWireDetail = true;
|
this.activeWireItem = item;
|
getNetWorkCardInfo({
|
ifname:item.name
|
}).then((res) => {
|
if (res&&res.success) {
|
debugger
|
this.wireForm.ip = res.data.ip
|
this.wireForm.gateway = res.data.gateway
|
this.wireForm.dns = res.data.dns
|
this.wireForm.subMask = res.data.subMask
|
}
|
})
|
},
|
},
|
};
|
</script>
|
<style lang="scss">
|
.all {
|
width: 100%;
|
}
|
.wire-detail {
|
.btns {
|
display: flex;
|
justify-content: space-between;
|
.cancel {
|
background-color: rgba(240, 240, 240, 1);
|
height: 40px;
|
line-height: 40px;
|
width: 48%;
|
border-radius: 10px;
|
}
|
.ok {
|
background-color: rgba(61, 104, 225, 1);
|
height: 40px;
|
line-height: 40px;
|
width: 48%;
|
color: #fff;
|
border-radius: 10px;
|
}
|
}
|
}
|
|
.cluster-content {
|
height: 100%;
|
display: flex;
|
flex-direction: row;
|
flex: 1;
|
flex-basis: auto;
|
box-sizing: border-box;
|
.cluster-center {
|
height: 100%;
|
width: 280px;
|
overflow: auto;
|
box-sizing: border-box;
|
flex-shrink: 0;
|
padding: 10px;
|
border-right: 5px solid #f8f8f8;
|
|
// background-color: lavender;
|
.menu-item {
|
background-color: #f8f8f8;
|
height: 40px;
|
margin-bottom: 10px;
|
border-radius: 8px;
|
line-height: 40px;
|
box-sizing: border-box;
|
font-size: 14px;
|
padding: 0 20px;
|
display: flex;
|
justify-content: space-between;
|
}
|
}
|
.cluster-right {
|
flex: 1;
|
flex-basis: auto;
|
overflow: auto;
|
// background-color: rgba(240, 242, 245, 1);
|
box-sizing: border-box;
|
position: relative;
|
padding: 20px 40px;
|
// .create-new .join-exist {
|
.el-form-item.is-required:not(.is-no-asterisk)
|
> .el-form-item__label:before,
|
.el-form-item.is-required:not(.is-no-asterisk)
|
.el-form-item__label-wrap
|
> .el-form-item__label:before {
|
display: none;
|
}
|
.el-select {
|
width: 100%;
|
}
|
.el-form-item {
|
margin-bottom: 10px;
|
height: 50px;
|
background: #f8f8f8;
|
padding: 4px 20px;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
border-radius: 10px;
|
.el-form-item__label {
|
text-align: left;
|
line-height: 42px;
|
}
|
}
|
.el-form-item__content {
|
line-height: 40px;
|
position: relative;
|
font-size: 14px;
|
}
|
.ip-input-container {
|
max-width: none !important;
|
}
|
// }
|
.wifi {
|
.wifi-option {
|
height: 50px;
|
background-color: #f8f8f8;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
box-sizing: border-box;
|
padding: 0 20px;
|
margin-bottom: 10px;
|
}
|
}
|
.wifi-detail {
|
.btns {
|
display: flex;
|
justify-content: space-between;
|
.left {
|
background-color: rgba(240, 240, 240, 1);
|
height: 40px;
|
line-height: 40px;
|
width: 48%;
|
border-radius: 10px;
|
}
|
.right {
|
background-color: rgba(61, 104, 225, 1);
|
height: 40px;
|
line-height: 40px;
|
width: 48%;
|
color: #fff;
|
border-radius: 10px;
|
}
|
}
|
.wifi-name {
|
height: 40px;
|
background-color: #f0f0f0;
|
text-align: left;
|
box-sizing: border-box;
|
padding: 0 20px;
|
}
|
.ad {
|
min-width: 35px;
|
background-color: rgba(240, 240, 240, 1);
|
height: 35px;
|
margin: 4px 0px 4px 5px;
|
border-radius: 5px;
|
line-height: 35px;
|
}
|
}
|
.wire {
|
.wire-bar {
|
height: 50px;
|
background-color: aliceblue;
|
display: flex;
|
justify-content: space-between;
|
box-sizing: border-box;
|
padding: 0 20px;
|
align-items: center;
|
}
|
.wifi-name {
|
height: 40px;
|
background-color: #f0f0f0;
|
text-align: left;
|
box-sizing: border-box;
|
padding: 0 20px;
|
}
|
}
|
.save-btn {
|
background-color: #3d68e1;
|
width: 240px;
|
height: 40px;
|
margin: 0 auto;
|
border-radius: 10px;
|
color: #fff;
|
line-height: 40px;
|
font-size: 14px;
|
margin-top: 20px;
|
}
|
}
|
}
|
</style>
|