{{ item.val }}
@@ -92,7 +97,7 @@
+ min-width="180">
{{ item.action }} => {{ item.val }} : {{ item.port }}
@@ -186,9 +191,9 @@
-
-
- BYTE/S
+
+
+ Mbps
@@ -266,7 +271,7 @@
-
+
@@ -435,6 +440,7 @@ export default {
},
ruleForm: {
bandwidth: 0,
+ bandwidth_format: '0',
status: 1,
allow_lan: true,
client_dns: [{val: '114.114.114.114'}],
@@ -463,9 +469,9 @@ export default {
{required: true, message: '请输入组名', trigger: 'blur'},
{max: 30, message: '长度小于 30 个字符', trigger: 'blur'}
],
- bandwidth: [
+ bandwidth_format: [
{required: true, message: '请输入带宽限制', trigger: 'blur'},
- {type: 'number', message: '带宽限制必须为数字值'}
+ {type: 'string', message: '带宽限制必须为数字值'}
],
status: [
{required: true}
@@ -493,7 +499,7 @@ export default {
],
"auth.ldap.search_attr": [
{required: true, message: '请输入用户唯一ID', trigger: 'blur'}
- ],
+ ],
},
}
},
@@ -536,7 +542,8 @@ export default {
id: row.id,
}
}).then(resp => {
- this.ruleForm = resp.data.data;
+ resp.data.data.bandwidth_format = this.convertBandwidth(resp.data.data.bandwidth, 'BYTE', 'Mbps').toString();
+ this.ruleForm = resp.data.data;
this.setAuthData(resp.data.data);
}).catch(error => {
this.$message.error('哦,请求出错');
@@ -582,6 +589,7 @@ export default {
console.log('error submit!!');
return false;
}
+ this.ruleForm.bandwidth = this.convertBandwidth(this.ruleForm.bandwidth_format, 'Mbps', 'BYTE');
axios.post('/group/set', this.ruleForm).then(resp => {
const rdata = resp.data;
if (rdata.code === 0) {
@@ -666,6 +674,18 @@ export default {
closeDialog() {
this.user_edit_dialog = false;
this.activeTab = "general";
+ },
+ convertBandwidth(bandwidth, fromUnit, toUnit) {
+ const units = {
+ bps: 1,
+ Kbps: 1000,
+ Mbps: 1000000,
+ Gbps: 1000000000,
+ BYTE: 8,
+ };
+ const result = bandwidth * units[fromUnit] / units[toUnit];
+ const fixedResult = result.toFixed(2);
+ return parseFloat(fixedResult);
}
},
}