<template>
|
<div class="all">
|
<div class="net-content">
|
<div class="net-center" ref="left">
|
<div
|
class="menu-item"
|
:class="activePage == i ? 'menu-item-active' : ''"
|
v-for="(item, i) in tabList"
|
:key="i"
|
@click="openRight(i)"
|
ref="leftbar"
|
>
|
<div>
|
<span class="icon iconfont">{{ item.icon }}</span>
|
<span class="text">{{ item.name }}</span>
|
</div>
|
<span v-if="showStatus && i==2" class="status">已连接</span>
|
</div>
|
</div>
|
<div class="net-right">
|
<div class="net-set" v-if="activePage == 0">
|
<div class="title">网络设置</div>
|
<el-form
|
:model="ruleForm"
|
:rules="rules"
|
ref="joinForm"
|
class="join-form"
|
label-width="150px"
|
>
|
<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>
|
</el-form>
|
<div class="save-btn" @click="saveServerName">保存</div>
|
</div>
|
|
<div class="wifi" v-if="activePage == 1 && !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; cursor: pointer"
|
@click="checkWifi(item)"
|
></span
|
>
|
</div>
|
</div>
|
</div>
|
<div class="wifi-detail" v-if="activePage == 2 && 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"
|
>
|
<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"
|
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" @click="inWifiDetail = false">取消</div>
|
<div class="right">保存</div>
|
</div>
|
</div>
|
|
<div class="wire" v-if="activePage == 2 && !inWireDetail">
|
<div class="title">有线网络</div>
|
<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 good" v-if="item.lower_up&&item.active"
|
></span
|
>
|
<span class="icon iconfont bad" v-if="!item.lower_up&&item.active"></span>
|
<el-switch
|
v-model="item.active"
|
active-color="rgba(61, 104, 225, 1)"
|
@change="switchNetCard(item)"
|
></el-switch>
|
</div>
|
</div>
|
|
</div>
|
<div class="wire-detail" v-if="activePage == 2 && 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 {
|
setServerName,
|
getWireList,
|
setNetWorkCard,
|
getNetWorkCardInfo,
|
getDevInfo,
|
downNetCard,
|
upNetCard,
|
} from "@/api/system";
|
|
import ipInput from "@/components/subComponents/IPInput";
|
import switchBar from "../components/switchBar";
|
|
export default {
|
components: {
|
ipInput,
|
switchBar,
|
},
|
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: 0,
|
activeWireItem: {},
|
rules: {
|
deviceName: [
|
{ required: true, message: "请输入设备名称", trigger: "change" },
|
],
|
},
|
ipv4Form: {},
|
ipv6Form: {},
|
ipv4FormRules: {},
|
tabList: [
|
{ name: "网络设置", icon: "\ue6ed" },
|
{ name: "无线网络", icon: "\ue991" },
|
{ name: "有线网络", icon: "\ue6dd" },
|
],
|
ipv6FormRules: {},
|
options: [],
|
value: "",
|
};
|
},
|
components: {
|
ipInput,
|
switchBar,
|
},
|
mounted() {
|
this.getCurServer();
|
this.fetchWireList();
|
},
|
methods: {
|
switchNetCard(item) {
|
if (item.active) {
|
upNetCard({ ifname: item.name }).then(
|
(res) => {
|
if (res.success) {
|
this.$message.success(res.data);
|
this.fetchWireList();
|
}
|
},
|
(err) => {
|
item.active = false;
|
this.$message.error(err.msg);
|
}
|
);
|
} else {
|
downNetCard({ ifname: item.name }).then(
|
(res) => {
|
if (res.success) {
|
this.$message.success(res.data);
|
this.fetchWireList();
|
}
|
},
|
(err) => {
|
item.active = true;
|
this.$message.error(err.msg);
|
}
|
);
|
}
|
},
|
getCurServer() {
|
getDevInfo().then((res) => {
|
this.ruleForm.deviceName = res.data.server_name;
|
this.ruleForm.port = res.data.server_port;
|
});
|
},
|
fetchWireList() {
|
getWireList().then((res) => {
|
if (res && res.success) {
|
this.wireArr = res.data;
|
this.wireArr.forEach((x) => {
|
let t = x.flags.split("|")[0] == "up";
|
this.$set(x, "active", t);
|
});
|
}
|
});
|
},
|
cancelSaveWire() {
|
this.inWireDetail = false;
|
this.wireForm.ip = "";
|
this.wireForm.gateway = "";
|
this.wireForm.dns = "";
|
this.wireForm.subMask = "";
|
},
|
saveServerName() {
|
setServerName({
|
server_name: this.ruleForm.deviceName,
|
server_port: this.ruleForm.port,
|
}).then((res) => {
|
if (res && res.success) {
|
this.$message.success(res.data);
|
}
|
});
|
},
|
openRight(i) {
|
this.activePage = i;
|
if (i == 1) {
|
this.inWifiDetail = false;
|
}
|
},
|
saveWire(ifname) {
|
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;
|
},
|
openWireDetail(item) {
|
this.inWireDetail = true;
|
this.activeWireItem = item;
|
getNetWorkCardInfo({
|
ifname: item.name,
|
}).then(
|
(res) => {
|
if (res && res.success) {
|
this.wireForm.ip = res.data.ip;
|
this.wireForm.gateway = res.data.gateway;
|
this.wireForm.dns = res.data.dns;
|
this.wireForm.subMask = res.data.subMask;
|
}
|
},
|
(err) => {
|
this.$message.error("查找不到数据: " + err.msg);
|
}
|
);
|
},
|
checkWire(item) {
|
if (item.addrs) {
|
this.openWireDetail(item);
|
return;
|
}
|
this.$confirm("您还未配置网络信息,是否现在配置?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(() => {
|
this.openWireDetail(item);
|
});
|
},
|
},
|
computed: {
|
showStatus(){
|
return this.wireArr.some((item) => item.lower_up==true)
|
}
|
},
|
};
|
</script>
|
<style lang="scss">
|
.all {
|
width: 100%;
|
}
|
.wire-detail {
|
.title {
|
font-size: 16px;
|
margin-bottom: 10px;
|
}
|
.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;
|
}
|
}
|
}
|
.net-set {
|
.title {
|
font-size: 16px;
|
margin-bottom: 10px;
|
height: 30px;
|
line-height: 30px;
|
}
|
.el-input--small .el-input__inner {
|
height: 35px;
|
line-height: 35px;
|
background-color: rgba(240, 240, 240, 1);
|
border: none;
|
}
|
.el-input__inner::placeholder {
|
color: rgba(134, 134, 134, 1);
|
}
|
}
|
.net-content {
|
height: 100%;
|
display: flex;
|
flex-direction: row;
|
flex: 1;
|
flex-basis: auto;
|
box-sizing: border-box;
|
.net-center {
|
height: 100%;
|
width: 280px;
|
overflow: auto;
|
box-sizing: border-box;
|
flex-shrink: 0;
|
padding: 10px;
|
border-right: 5px solid #f8f8f8;
|
|
.menu-item {
|
background-color: #f8f8f8;
|
height: 50px;
|
margin-bottom: 10px;
|
border-radius: 8px;
|
line-height: 50px;
|
box-sizing: border-box;
|
font-size: 14px; cursor: pointer;
|
padding: 0 20px;
|
display: flex;
|
justify-content: space-between;
|
.icon {
|
margin-right: 8px;
|
font-size: 18px;
|
}
|
.text {
|
font-size: 15px;
|
}
|
}
|
.menu-item-active {
|
background-color: var(--colorCard);
|
color: white;
|
}
|
.menu-item:hover {
|
background-color: var(--colorCard);
|
color: white;
|
}
|
}
|
.net-right {
|
flex: 1;
|
flex-basis: auto;
|
overflow: auto;
|
box-sizing: border-box;
|
position: relative;
|
padding: 20px 40px;
|
.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__label{
|
font-size: 15px;
|
}
|
.el-form-item {
|
margin-bottom: 10px;
|
height: 54px;
|
padding: 6px 20px;
|
background: #f8f8f8;
|
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;
|
.el-input--small {
|
font-size: 15px;
|
}
|
}
|
.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 {
|
.title {
|
line-height: 30px;
|
height: 30px;
|
font-size: 16px;
|
margin-bottom: 10px;
|
}
|
.wire-bar {
|
height: 50px;
|
background-color: #f8f8f8;
|
cursor: pointer;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
box-sizing: border-box;
|
padding: 0 20px;
|
margin-bottom: 10px;
|
border-radius: 10px;
|
.name {
|
font-size: 15px;
|
}
|
.right {
|
display: flex;
|
align-items: center;
|
.icon {
|
margin-right: 15px;
|
}
|
.good {
|
color: #3d68e1;
|
font-size: 18px;
|
}
|
.bad {
|
color: rgb(243, 105, 54);
|
font-size: 18px;
|
}
|
}
|
}
|
.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;
|
cursor: pointer;
|
font-size: 14px;
|
margin-top: 30px;
|
}
|
}
|
}
|
</style>
|