bug修改

This commit is contained in:
qiudan 2024-04-11 14:38:56 +08:00
parent d6c3990908
commit 76f90e3f88
1 changed files with 687 additions and 655 deletions
src/views/general

View File

@ -42,13 +42,9 @@
<span style="margin-left: 10px">接通</span> <span style="margin-left: 10px">接通</span>
</el-col> </el-col>
</el-form-item> --> </el-form-item> -->
<div style="margin-bottom: 24px;"> <div style="margin-bottom: 24px">
<p class="title">dhcp4</p> <p class="title">dhcp4</p>
<el-switch <el-switch v-model="dhcp4" active-text="开" inactive-text="关"> </el-switch>
v-model="dhcp4"
active-text="开"
inactive-text="关">
</el-switch>
</div> </div>
<div v-show="!dhcp4"> <div v-show="!dhcp4">
<p class="title">静态地址</p> <p class="title">静态地址</p>
@ -58,8 +54,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-input v-model="scope.row.address" @change="changeVal(scope.row,scope.$index)"></el-input> --> <!-- <el-input v-model="scope.row.address" @change="changeVal(scope.row,scope.$index)"></el-input> -->
<el-form-item :prop="'tableData.' + scope.$index + '.address'" :rules="rules.address" class="tableFormItem"> <el-form-item :prop="'tableData.' + scope.$index + '.address'" :rules="rules.address" class="tableFormItem">
<el-input v-model.trim="scope.row.address" <el-input v-model.trim="scope.row.address" placeholder="例172.1.1.16/24" :disabled="disable" />
placeholder="例172.1.1.16/24" :disabled="disable"/>
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
@ -80,15 +75,17 @@
<el-input v-model="scope.row.term" @change="changeVal(scope.row,scope.$index)"></el-input> <el-input v-model="scope.row.term" @change="changeVal(scope.row,scope.$index)"></el-input>
</template> </template>
</el-table-column> --> </el-table-column> -->
<el-table-column <el-table-column fixed="right" label="操作" width="350">
fixed="right"
label="操作"
width="350"
>
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-button @click="deleteRowsTableData(scope)" v-if="scope.$index < sizeForm.tableData.length-1" type="text" size="small">删除行 <!-- <el-button @click="deleteRowsTableData(scope)" v-if="scope.$index < sizeForm.tableData.length-1" type="text" size="small">删除行
</el-button> --> </el-button> -->
<el-button @click="deleteRowsTableData(scope)" v-if="scope.$index != 0" type="text" size="small" :disabled="disable">删除行 <el-button
@click="deleteRowsTableData(scope)"
v-if="scope.$index != 0"
type="text"
size="small"
:disabled="disable"
>删除行
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -159,8 +156,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-input v-model="scope.row.to" @change="changeValT(scope.row,scope.$index)"></el-input> --> <!-- <el-input v-model="scope.row.to" @change="changeValT(scope.row,scope.$index)"></el-input> -->
<el-form-item :prop="'tableRouter.' + scope.$index + '.to'" :rules="rules.to" class="tableFormItem"> <el-form-item :prop="'tableRouter.' + scope.$index + '.to'" :rules="rules.to" class="tableFormItem">
<el-input v-model.trim="scope.row.to" <el-input v-model.trim="scope.row.to" placeholder="例172.1.1.16/24" :disabled="disable" />
placeholder="例172.1.1.16/24" :disabled="disable" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
@ -168,30 +164,34 @@
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-input v-model="scope.row.via" @change="changeValT(scope.row,scope.$index)"></el-input> --> <!-- <el-input v-model="scope.row.via" @change="changeValT(scope.row,scope.$index)"></el-input> -->
<el-form-item :prop="'tableRouter.' + scope.$index + '.via'" :rules="rules.via" class="tableFormItem"> <el-form-item :prop="'tableRouter.' + scope.$index + '.via'" :rules="rules.via" class="tableFormItem">
<el-input v-model.trim="scope.row.via" <el-input v-model.trim="scope.row.via" placeholder="例172.1.1.16" :disabled="disable" />
placeholder="例172.1.1.16" :disabled="disable"/>
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="metric" label="metric"> <el-table-column prop="metric" label="metric">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-input v-model="scope.row.metric" @change="changeValT(scope.row,scope.$index)"></el-input> --> <!-- <el-input v-model="scope.row.metric" @change="changeValT(scope.row,scope.$index)"></el-input> -->
<el-form-item :prop="'tableRouter.'+ scope.$index + '.metric'" :rules="rules.metric" class="tableFormItem"> <el-form-item
<el-input v-model.trim="scope.row.metric" :prop="'tableRouter.' + scope.$index + '.metric'"
placeholder="例100" :disabled="disable"/> :rules="rules.metric"
class="tableFormItem"
>
<el-input v-model.trim="scope.row.metric" placeholder="例100" :disabled="disable" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column fixed="right" label="操作" width="350">
fixed="right"
label="操作"
width="350"
>
<!-- <template slot-scope="scope" > <!-- <template slot-scope="scope" >
<el-button @click="handleClick(scope.row)" type="primary" :disabled="scope.row.disabled" size="small">确认</el-button> <el-button @click="handleClick(scope.row)" type="primary" :disabled="scope.row.disabled" size="small">确认</el-button>
</template> --> </template> -->
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="deleteRows(scope)" v-if="scope.$index < sizeForm.tableRouter.length" type="text" size="small" :disabled="disable">删除行 <el-button
@click="deleteRows(scope)"
v-if="scope.$index < sizeForm.tableRouter.length"
type="text"
size="small"
:disabled="disable"
>删除行
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -215,23 +215,27 @@
</el-form-item> --> </el-form-item> -->
<el-button type="primary" @click="addRowsDNS()" style="margin-bottom: 10px" v-if="!disable">新增</el-button> <el-button type="primary" @click="addRowsDNS()" style="margin-bottom: 10px" v-if="!disable">新增</el-button>
<el-table :data="sizeForm.tableDataDNS" border style="width: 95%"> <el-table :data="sizeForm.tableDataDNS" border style="width: 95%">
<el-table-column prop="address" label="地址"> <el-table-column prop="address" label="地址">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <el-input v-model="scope.row.address" @change="changeVal(scope.row,scope.$index)"></el-input> --> <!-- <el-input v-model="scope.row.address" @change="changeVal(scope.row,scope.$index)"></el-input> -->
<el-form-item :prop="'tableDataDNS.'+ scope.$index + '.address'" :rules="rules.addressDNS" class="tableFormItem"> <el-form-item
<el-input v-model.trim="scope.row.address" :prop="'tableDataDNS.' + scope.$index + '.address'"
placeholder="例172.1.1.16" :disabled="disable" /> :rules="rules.addressDNS"
class="tableFormItem"
>
<el-input v-model.trim="scope.row.address" placeholder="例172.1.1.16" :disabled="disable" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column fixed="right" label="操作" width="350">
fixed="right"
label="操作"
width="350"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="deleteRowsDNS(scope)" v-if="scope.$index < sizeForm.tableDataDNS.length" type="text" size="small" :disabled="disable">删除行 <el-button
@click="deleteRowsDNS(scope)"
v-if="scope.$index < sizeForm.tableDataDNS.length"
type="text"
size="small"
:disabled="disable"
>删除行
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -239,7 +243,13 @@
</div> </div>
<!-- <el-form-item > <!-- <el-form-item >
<el-col :span="6"> --> <el-col :span="6"> -->
<el-button type="primary" @click="commit(sizeForm.tableRouter,sizeForm.tableData,sizeForm.tableDataDNS,sizeForm)" style="margin-top:10px" v-if="!disable">保存</el-button> <el-button
type="primary"
@click="commit(sizeForm.tableRouter, sizeForm.tableData, sizeForm.tableDataDNS, sizeForm)"
style="margin-top: 10px"
v-if="!disable"
>保存</el-button
>
<!-- </el-col> <!-- </el-col>
</el-form-item> --> </el-form-item> -->
</div> </div>
@ -249,7 +259,6 @@
</template> </template>
<script> <script>
export default { export default {
data() { data() {
let validateIPAddress = (rule, value, callback) => { let validateIPAddress = (rule, value, callback) => {
@ -269,9 +278,9 @@ export default {
if (!isCorrect) { if (!isCorrect) {
callback(new Error('请输入正确的IP地址')); callback(new Error('请输入正确的IP地址'));
} else { } else {
callback() callback();
}
} }
};
let validateIPAddressYes = (rule, value, callback) => { let validateIPAddressYes = (rule, value, callback) => {
if (value == null) { if (value == null) {
return callback(new Error('IP地址不能为空')); return callback(new Error('IP地址不能为空'));
@ -306,10 +315,9 @@ export default {
} }
} }
} }
}
} }
} }
};
let metric = (rule, value, callback) => { let metric = (rule, value, callback) => {
if (!value) { if (!value) {
return callback(new Error('输入不可以为空')); return callback(new Error('输入不可以为空'));
@ -327,7 +335,7 @@ export default {
} }
} }
}, 0); }, 0);
} };
return { return {
dhcp4: false, dhcp4: false,
@ -335,16 +343,31 @@ export default {
columnPropIndex: 0, // columnPropIndex: 0, //
columnData: [], // columnData: [], //
rules: { rules: {
gateway4: [{ required: true, pattern: /^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$/,message: "请输入正确的IP地址", trigger: "blur"}], gateway4: [
via: [{ required: true, pattern: /^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$/,message: "请输入正确的IP地址", trigger: "blur"}], {
required: true,
pattern:
/^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$/,
message: '请输入正确的IP地址',
trigger: 'blur'
}
],
via: [
{
required: true,
pattern:
/^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$/,
message: '请输入正确的IP地址',
trigger: 'blur'
}
],
// via:[{ required: true, validator: validateIPAddress, trigger: "blur" }] // via:[{ required: true, validator: validateIPAddress, trigger: "blur" }]
addressDNS:[{ required: true, validator: validateIPAddress, trigger: "blur" }], addressDNS: [{ required: true, validator: validateIPAddress, trigger: 'blur' }],
address:[{ required: true, validator: validateIPAddressYes, trigger: "blur" }], address: [{ required: true, validator: validateIPAddressYes, trigger: 'blur' }],
to:[{ required: true, validator: validateIPAddressYes, trigger: "blur" }], to: [{ required: true, validator: validateIPAddressYes, trigger: 'blur' }],
metric:[{ required: true, validator: metric, trigger: "blur" }], metric: [{ required: true, validator: metric, trigger: 'blur' }]
}, },
optionsa: [ optionsa: [
{ {
value: '1', value: '1',
@ -430,7 +453,6 @@ export default {
// address: '', // address: '',
// }, // },
// { // {
// id:'', // id:'',
// address: '', // address: '',
// }, // },
@ -448,13 +470,13 @@ export default {
// id:'', // id:'',
// address: '', // address: '',
// } // }
], ]
}, },
options: [ options: [
{ {
value: '', value: '',
label: '' label: ''
}, }
// { // {
// value: 'wlan0', // value: 'wlan0',
// label: 'wlan0' // label: 'wlan0'
@ -516,7 +538,7 @@ export default {
// agreement: 'NO', // agreement: 'NO',
// Range: '1', // Range: '1',
id: '', id: '',
address: '192.168.50.10/24', address: '192.168.50.10/24'
// term: '', // term: '',
// disabled:true // disabled:true
}, },
@ -524,7 +546,7 @@ export default {
// agreement: 'YES', // agreement: 'YES',
// Range: '1', // Range: '1',
id: '', id: '',
address: '192.168.1.5/24', address: '192.168.1.5/24'
// term: '17', // term: '17',
// disabled:true // disabled:true
}, },
@ -532,7 +554,7 @@ export default {
// agreement: 'YES', // agreement: 'YES',
// Range: '1', // Range: '1',
id: '', id: '',
address: '192.168.1.5/24', address: '192.168.1.5/24'
// term: '17', // term: '17',
// disabled:true // disabled:true
} }
@ -542,7 +564,7 @@ export default {
// agreement: 'NO', // agreement: 'NO',
// Range: '1', // Range: '1',
id: '', id: '',
address: '192.168.50.10/24', address: '192.168.50.10/24'
// term: '', // term: '',
// disabled:true // disabled:true
}, },
@ -550,57 +572,55 @@ export default {
// agreement: 'YES', // agreement: 'YES',
// Range: '1', // Range: '1',
id: '', id: '',
address: '192.168.1.5/24', address: '192.168.1.5/24'
// term: '17', // term: '17',
// disabled:true // disabled:true
} }
], ],
tableDataPanduan: [], tableDataPanduan: [],
optionsData: 'eth0', optionsData: 'eth0',
disable:false, // disable: false //
}; };
}, },
watch: { watch: {},
},
created() { created() {
this.createMqtt() this.createMqtt();
setTimeout(() => { setTimeout(() => {
this.publishClient() this.publishClient();
}, 1000 * 3); }, 1000 * 3);
}, },
mounted() { mounted() {
if (localStorage.getItem('roleName') == '系统管理员') { if (localStorage.getItem('roleName') == '系统管理员') {
this.disable = false this.disable = false;
} else { } else {
this.disable = true this.disable = true;
} }
}, },
methods: { methods: {
// //
commit(tableRouter, tableData, tableDataDNS, sizeForm) { commit(tableRouter, tableData, tableDataDNS, sizeForm) {
console.log("tableData",tableData) console.log('tableData', tableData);
console.log("tableDataDNS",tableDataDNS) console.log('tableDataDNS', tableDataDNS);
console.log("sizeForm",sizeForm) console.log('sizeForm', sizeForm);
var tableRouterN = tableRouter.map(value => { var tableRouterN = tableRouter.map((value) => {
return value.to+','+value.via+','+value.metric return value.to + ',' + value.via + ',' + value.metric;
}) });
var tableDataN = tableData.map(item => { var tableDataN = tableData.map((item) => {
return item.address return item.address;
}) });
var tableDataDNSN = tableDataDNS.map(item => { var tableDataDNSN = tableDataDNS.map((item) => {
return item.address return item.address;
}) });
var ner = { var ner = {
type:"netplanSet", type: 'netplanSet',
ethName: sizeForm.name, ethName: sizeForm.name,
dhcp4: this.dhcp4, dhcp4: this.dhcp4,
addresses: tableDataN, // addresses: tableDataN, //
gateway4: sizeForm.gateway4, gateway4: sizeForm.gateway4,
nameservers: tableDataDNSN, //DNS nameservers: tableDataDNSN, //DNS
routes: tableRouterN // routes: tableRouterN //
} };
this.$confirm('此操作将重新设置网络, 是否继续?', '提示', { this.$confirm('此操作将重新设置网络, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -611,7 +631,7 @@ export default {
type: 'success', type: 'success',
message: '设置成功!' message: '设置成功!'
}); });
console.log("JSON.stringify(ner)",JSON.stringify(ner)) console.log('JSON.stringify(ner)', JSON.stringify(ner));
window.publish('Contorl_client', JSON.stringify(ner)); window.publish('Contorl_client', JSON.stringify(ner));
this.sizeForm = { this.sizeForm = {
name: '', name: '',
@ -638,8 +658,8 @@ export default {
speed: '', speed: '',
tableRouter: [], tableRouter: [],
tableData: [], tableData: [],
tableDataDNS: [], tableDataDNS: []
} };
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,
text: 'Loading', text: 'Loading',
@ -648,7 +668,7 @@ export default {
}); });
setTimeout(() => { setTimeout(() => {
loading.close(); loading.close();
this.publishClient() this.publishClient();
}, 5000); }, 5000);
}) })
.catch(() => { .catch(() => {
@ -664,13 +684,15 @@ export default {
const circle = this.sizeForm.tableRouter[0]; // const circle = this.sizeForm.tableRouter[0]; //
if (circle) { if (circle) {
const newObj = {}; const newObj = {};
for (let key in circle) { //newObj for (let key in circle) {
//newObj
newObj[key] = ''; newObj[key] = '';
} }
this.sizeForm.tableRouter.splice(this.sizeForm.tableRouter.length, 0, newObj); this.sizeForm.tableRouter.splice(this.sizeForm.tableRouter.length, 0, newObj);
} else { } else {
const newObj = {}; const newObj = {};
for (let key in circle) { //newObj for (let key in circle) {
//newObj
newObj[key] = ''; newObj[key] = '';
} }
this.sizeForm.tableRouter.splice(this.sizeForm.tableRouter.length, 0, newObj); this.sizeForm.tableRouter.splice(this.sizeForm.tableRouter.length, 0, newObj);
@ -686,7 +708,8 @@ export default {
const circle = this.sizeForm.tableData[0]; // const circle = this.sizeForm.tableData[0]; //
if (circle) { if (circle) {
const newObj = {}; const newObj = {};
for (let key in circle) { //newObj for (let key in circle) {
//newObj
newObj[key] = ''; newObj[key] = '';
} }
// this.sizeForm.tableData.splice(this.sizeForm.tableData.length-1, 0, newObj); // this.sizeForm.tableData.splice(this.sizeForm.tableData.length-1, 0, newObj);
@ -703,13 +726,15 @@ export default {
const circle = this.sizeForm.tableDataDNS[0]; // const circle = this.sizeForm.tableDataDNS[0]; //
if (circle) { if (circle) {
const newObj = {}; const newObj = {};
for (let key in circle) { //newObj for (let key in circle) {
//newObj
newObj[key] = ''; newObj[key] = '';
} }
this.sizeForm.tableDataDNS.splice(this.sizeForm.tableDataDNS.length, 0, newObj); this.sizeForm.tableDataDNS.splice(this.sizeForm.tableDataDNS.length, 0, newObj);
} else { } else {
const newObj = {}; const newObj = {};
for (let key in circle) { //newObj for (let key in circle) {
//newObj
newObj[key] = ''; newObj[key] = '';
} }
this.sizeForm.tableDataDNS.splice(this.sizeForm.tableDataDNS.length, 0, newObj); this.sizeForm.tableDataDNS.splice(this.sizeForm.tableDataDNS.length, 0, newObj);
@ -724,80 +749,75 @@ export default {
// //
var topicSends = ['Contorl_server']; var topicSends = ['Contorl_server'];
window.PubScribe(topicSends, -1, this.realInfo); window.PubScribe(topicSends, -1, this.realInfo);
}, },
publishClient() { publishClient() {
window.publish('Contorl_client',JSON.stringify({"type":"getNet"})); window.publish('Contorl_client', JSON.stringify({ type: 'getNet' }));
}, },
/** 实时数据分类 */ /** 实时数据分类 */
realInfo(topic, message) { realInfo(topic, message) {
// console.log("topic",topic) // console.log("topic",topic)
switch (topic) { switch (topic) {
case "Contorl_server": case 'Contorl_server':
try { try {
const utf8decoder = new TextDecoder() const utf8decoder = new TextDecoder();
const u8arr = new Uint8Array(message) const u8arr = new Uint8Array(message);
const temp = utf8decoder.decode(u8arr) // const temp = utf8decoder.decode(u8arr); //
const msg = JSON.parse(temp) //JSON const msg = JSON.parse(temp); //JSON
if (msg.type == 'getNet') { if (msg.type == 'getNet') {
console.log("msg",msg) console.log('msg', msg);
// const netaddres = JSON.parse(msg.netaddres) // const netaddres = JSON.parse(msg.netaddres)
// console.log("netaddres",netaddres) // console.log("netaddres",netaddres)
// const netstates = JSON.parse(msg.netstates) // const netstates = JSON.parse(msg.netstates)
this.changeNetstates(msg) this.changeNetstates(msg);
}
} catch (error) {
} }
} catch (error) {}
break; break;
} }
}, },
changeNetstates(msg) { changeNetstates(msg) {
console.log("msg",msg) console.log('msg', msg);
// var optionsDataN = this.optionsData // var optionsDataN = this.optionsData
console.log(" msg.netstates[this.optionsData]",this.optionsData) console.log(' msg.netstates[this.optionsData]', this.optionsData);
if (msg.netplan[this.optionsData] != undefined) { if (msg.netplan[this.optionsData] != undefined) {
this.dhcp4 = msg.netplan[this.optionsData].dhcp4||false this.dhcp4 = msg.netplan[this.optionsData].dhcp4 || false;
} }
if (msg.netstates[this.optionsData] != undefined) { if (msg.netstates[this.optionsData] != undefined) {
this.sizeForm.name = this.optionsData this.sizeForm.name = this.optionsData;
this.sizeForm.mtu = msg.netstates[this.optionsData].mtu this.sizeForm.mtu = msg.netstates[this.optionsData].mtu;
var data = msg.netaddres[this.optionsData] var data = msg.netaddres[this.optionsData];
this.sizeForm.speed = msg.netstates[this.optionsData].speed this.sizeForm.speed = msg.netstates[this.optionsData].speed;
this.tableDataPanduan = [] this.tableDataPanduan = [];
var optionN = Object.keys(msg.netplan) var optionN = Object.keys(msg.netplan);
var optionNrr = optionN.map((value, index) => { var optionNrr = optionN.map((value, index) => {
return { return {
value: value, value: value,
label: value label: value
} };
}) });
console.log("optionNrr",optionNrr) console.log('optionNrr', optionNrr);
this.options = optionNrr this.options = optionNrr;
if (msg.netstates[this.optionsData].isup == true) { if (msg.netstates[this.optionsData].isup == true) {
this.sizeForm.status='YES' this.sizeForm.status = 'YES';
} else { } else {
this.sizeForm.status='NO' this.sizeForm.status = 'NO';
} }
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (data[i].family == 17) { if (data[i].family == 17) {
this.sizeForm.mac =data[i].address this.sizeForm.mac = data[i].address;
} else if (data[i].family == 2) { } else if (data[i].family == 2) {
this.tableDataPanduan.push(data[i]) this.tableDataPanduan.push(data[i]);
} }
} }
if (this.tableDataPanduan.length == msg.netplan[this.optionsData].addresses.length) { if (this.tableDataPanduan.length == msg.netplan[this.optionsData].addresses.length) {
for (let i = 0; i < this.tableDataPanduan.length; i++) { for (let i = 0; i < this.tableDataPanduan.length; i++) {
for (let b = 0; b < msg.netplan[this.optionsData].addresses.length; b++) { for (let b = 0; b < msg.netplan[this.optionsData].addresses.length; b++) {
// console.log("str1",netstates.netplan.eth0.addresses[b].substring(0,netstates.netplan.eth0.addresses[b].indexOf("/"))) // console.log("str1",netstates.netplan.eth0.addresses[b].substring(0,netstates.netplan.eth0.addresses[b].indexOf("/")))
var ipos = msg.netplan[this.optionsData].addresses[b].indexOf("/");// var ipos = msg.netplan[this.optionsData].addresses[b].indexOf('/'); //
let str1 = msg.netplan[this.optionsData].addresses[b].substring(0, ipos); let str1 = msg.netplan[this.optionsData].addresses[b].substring(0, ipos);
if (this.tableDataPanduan[i].address == str1) { if (this.tableDataPanduan[i].address == str1) {
} else { } else {
// this.$message({ // this.$message({
// message: '', // message: '',
@ -807,27 +827,30 @@ export default {
} }
} }
} }
var addressesN = msg.netplan[this.optionsData].addresses.map((value, index) => { let addressesN = [];
if (msg.netplan[this.optionsData].addresses && msg.netplan[this.optionsData].addresses.length > 0) {
addressesN = msg.netplan[this.optionsData].addresses.map((value, index) => {
return { return {
address: value, address: value,
id: index id: index
};
});
} }
}) this.sizeForm.tableData = addressesN;
this.sizeForm.tableData = addressesN
// //
var dataJ = msg.netplan[this.optionsData].routes var dataJ = msg.netplan[this.optionsData].routes;
this.sizeForm.tableRouter=[] this.sizeForm.tableRouter = [];
for (let r = 0; r < dataJ.length; r++) { for (let r = 0; r < dataJ.length; r++) {
this.sizeForm.tableRouter.push(dataJ[r]) this.sizeForm.tableRouter.push(dataJ[r]);
} }
this.sizeForm.gateway4 = msg.netplan[this.optionsData].gateway4 this.sizeForm.gateway4 = msg.netplan[this.optionsData].gateway4;
var legend = msg.netplan[this.optionsData].nameservers.addresses.map((value, index) => { var legend = msg.netplan[this.optionsData].nameservers.addresses.map((value, index) => {
return { return {
address: value, address: value,
id: index id: index
} };
}) });
this.sizeForm.tableDataDNS = legend this.sizeForm.tableDataDNS = legend;
} else { } else {
this.sizeForm = { this.sizeForm = {
name: this.optionsData, name: this.optionsData,
@ -843,51 +866,54 @@ export default {
mtu: '', mtu: '',
mac: '', mac: '',
moren: '', moren: '',
speed:'', speed: ''
} };
// //
var dataJ = msg.netplan[this.optionsData].routes var dataJ = msg.netplan[this.optionsData].routes;
this.sizeForm.tableRouter=[] this.sizeForm.tableRouter = [];
for (let r = 0; r < dataJ.length; r++) { for (let r = 0; r < dataJ.length; r++) {
this.sizeForm.tableRouter.push(dataJ[r]) this.sizeForm.tableRouter.push(dataJ[r]);
} }
var addressesN = msg.netplan[this.optionsData].addresses.map((value, index) => { let addressesN = [];
if (msg.netplan[this.optionsData].addresses && msg.netplan[this.optionsData].addresses.length > 0) {
addressesN = msg.netplan[this.optionsData].addresses.map((value, index) => {
return { return {
address: value, address: value,
id: index id: index
};
});
} }
})
this.sizeForm.tableData = addressesN this.sizeForm.tableData = addressesN;
var legend = msg.netplan[this.optionsData].nameservers.addresses.map((value, index) => { var legend = msg.netplan[this.optionsData].nameservers.addresses.map((value, index) => {
return { return {
address: value, address: value,
id: index id: index
};
});
this.sizeForm.tableDataDNS = legend;
} }
})
this.sizeForm.tableDataDNS = legend
}
}, },
changeName(val) { changeName(val) {
console.log("val",val) console.log('val', val);
this.sizeForm.name = val this.sizeForm.name = val;
this.optionsData = val this.optionsData = val;
this.publishClient() this.publishClient();
}, },
gernerateClass(status) { gernerateClass(status) {
console.log("status",status) console.log('status', status);
if (status == 'YES') { if (status == 'YES') {
return 'status' return 'status';
} else { } else {
return 'statusNo' return 'statusNo';
} }
}, },
changeVal(val, e) { changeVal(val, e) {
this.sizeForm.tableData[e].disabled = false this.sizeForm.tableData[e].disabled = false;
}, },
changeValT(val, e) { changeValT(val, e) {
this.sizeForm.tableRouter[e].disabled = false this.sizeForm.tableRouter[e].disabled = false;
}, },
handleClick(scope, e) { handleClick(scope, e) {
console.log(scope, 'scope'); console.log(scope, 'scope');
@ -940,10 +966,16 @@ export default {
} }
} }
.status { .status {
width: 10px; height: 10px; border-radius: 50%; background: green width: 10px;
height: 10px;
border-radius: 50%;
background: green;
} }
.statusNo { .statusNo {
width: 10px; height: 10px; border-radius: 50%; background: red width: 10px;
height: 10px;
border-radius: 50%;
background: red;
} }
</style> </style>