mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-09-21 10:59:22 +08:00
更改目录结构
This commit is contained in:
273
web/src/pages/user/IpMap.vue
Normal file
273
web/src/pages/user/IpMap.vue
Normal file
@@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
|
||||
<el-form :inline="true">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="handleEdit('')">添加
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
border>
|
||||
|
||||
<el-table-column
|
||||
sortable="true"
|
||||
prop="id"
|
||||
label="ID"
|
||||
width="60">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="ip_addr"
|
||||
label="IP地址">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="mac_addr"
|
||||
label="MAC地址">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="username"
|
||||
label="用户名">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="keep"
|
||||
label="IP保留">
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-tag v-if="scope.row.keep" type="success">保留</el-tag>-->
|
||||
<el-switch
|
||||
disabled
|
||||
v-model="scope.row.keep"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="note"
|
||||
label="备注">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="last_login"
|
||||
label="最后登陆时间"
|
||||
:formatter="tableDateFormat">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="操作"
|
||||
width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="handleEdit(scope.row)">编辑
|
||||
</el-button>
|
||||
|
||||
<el-popconfirm
|
||||
class="m-left-10"
|
||||
@onConfirm="handleDel(scope.row)"
|
||||
title="确定要删除IP映射吗?">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="mini"
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row)">删除
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="sh-20"></div>
|
||||
|
||||
<el-pagination
|
||||
background
|
||||
layout="prev, pager, next"
|
||||
:pager-count="11"
|
||||
@current-change="pageChange"
|
||||
:total="count">
|
||||
</el-pagination>
|
||||
|
||||
</el-card>
|
||||
|
||||
<!--新增、修改弹出框-->
|
||||
<el-dialog
|
||||
title="提示"
|
||||
:close-on-click-modal="false"
|
||||
:visible="user_edit_dialog"
|
||||
@close="disVisible"
|
||||
width="600px"
|
||||
center>
|
||||
|
||||
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="ruleForm">
|
||||
<el-form-item label="ID" prop="id">
|
||||
<el-input v-model="ruleForm.id" disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="IP地址" prop="ip_addr">
|
||||
<el-input v-model="ruleForm.ip_addr"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="MAC地址" prop="mac_addr">
|
||||
<el-input v-model="ruleForm.mac_addr"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="ruleForm.username"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="note">
|
||||
<el-input v-model="ruleForm.note"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="IP保留" prop="keep">
|
||||
<el-switch
|
||||
v-model="ruleForm.keep"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
|
||||
<el-button @click="disVisible">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
name: "IpMap",
|
||||
components: {},
|
||||
mixins:[],
|
||||
created() {
|
||||
this.$emit('update:route_path', this.$route.path)
|
||||
this.$emit('update:route_name', ['用户信息', 'IP映射'])
|
||||
},
|
||||
mounted() {
|
||||
this.getData(1)
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
count: 10,
|
||||
nowIndex: 0,
|
||||
ruleForm: {
|
||||
status: 1,
|
||||
groups: [],
|
||||
},
|
||||
rules: {
|
||||
username: [
|
||||
{required: false, message: '请输入用户名', trigger: 'blur'},
|
||||
{max: 50, message: '长度小于 50 个字符', trigger: 'blur'}
|
||||
],
|
||||
mac_addr: [
|
||||
{required: true, message: '请输入mac地址', trigger: 'blur'}
|
||||
],
|
||||
ip_addr: [
|
||||
{required: true, message: '请输入ip地址', trigger: 'blur'}
|
||||
],
|
||||
|
||||
status: [
|
||||
{required: true}
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getData(p) {
|
||||
axios.get('/user/ip_map/list', {
|
||||
params: {
|
||||
page: p,
|
||||
}
|
||||
}).then(resp => {
|
||||
var data = resp.data.data
|
||||
console.log(data);
|
||||
this.tableData = data.datas;
|
||||
this.count = data.count
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
pageChange(p) {
|
||||
this.getData(p)
|
||||
},
|
||||
handleEdit(row) {
|
||||
!this.$refs['ruleForm'] || this.$refs['ruleForm'].resetFields();
|
||||
console.log(row)
|
||||
this.user_edit_dialog = true
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.get('/user/ip_map/detail', {
|
||||
params: {
|
||||
id: row.id,
|
||||
}
|
||||
}).then(resp => {
|
||||
this.ruleForm = resp.data.data
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleDel(row) {
|
||||
axios.post('/user/ip_map/del?id=' + row.id).then(resp => {
|
||||
var rdata = resp.data
|
||||
if (rdata.code === 0) {
|
||||
this.$message.success(rdata.msg);
|
||||
this.getData(1);
|
||||
} else {
|
||||
this.$message.error(rdata.msg);
|
||||
}
|
||||
console.log(rdata);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (!valid) {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
|
||||
// alert('submit!');
|
||||
axios.post('/user/ip_map/set', this.ruleForm).then(resp => {
|
||||
var rdata = resp.data
|
||||
if (rdata.code === 0) {
|
||||
this.$message.success(rdata.msg);
|
||||
this.getData(1);
|
||||
} else {
|
||||
this.$message.error(rdata.msg);
|
||||
}
|
||||
console.log(rdata);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
410
web/src/pages/user/List.vue
Normal file
410
web/src/pages/user/List.vue
Normal file
@@ -0,0 +1,410 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
<el-form :inline="true">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="handleEdit('')">添加
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="用户名:">
|
||||
<el-input size="small" v-model="searchData" placeholder="请输入内容"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleSearch()">搜索
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
icon="el-icon-refresh"
|
||||
@click="searchData=''">重置搜索
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
border>
|
||||
|
||||
<el-table-column
|
||||
sortable="true"
|
||||
prop="id"
|
||||
label="ID"
|
||||
width="60">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="username"
|
||||
label="用户名"
|
||||
width="150">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="nickname"
|
||||
label="姓名"
|
||||
width="100">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="email"
|
||||
label="邮箱">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="otp_secret"
|
||||
label="OTP密钥"
|
||||
width="110">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="!scope.row.disable_otp"
|
||||
type="text"
|
||||
icon="el-icon-view"
|
||||
@click="getOtpImg(scope.row)">
|
||||
{{ scope.row.otp_secret.substring(0, 6) }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="groups"
|
||||
label="用户组">
|
||||
<template slot-scope="scope">
|
||||
<el-row v-for="item in scope.row.groups" :key="item">{{ item }}</el-row>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="status"
|
||||
label="状态"
|
||||
width="70">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.status === 1" type="success">可用</el-tag>
|
||||
<el-tag v-else type="danger">停用</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="updated_at"
|
||||
label="更新时间"
|
||||
:formatter="tableDateFormat">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="操作"
|
||||
width="210">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="handleEdit(scope.row)">编辑
|
||||
</el-button>
|
||||
|
||||
<!-- <el-popconfirm
|
||||
class="m-left-10"
|
||||
@onConfirm="handleClick('reset',scope.row)"
|
||||
title="确定要重置用户密码和密钥吗?">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="mini"
|
||||
type="warning">重置
|
||||
</el-button>
|
||||
</el-popconfirm>-->
|
||||
|
||||
<el-popconfirm
|
||||
class="m-left-10"
|
||||
@onConfirm="handleDel(scope.row)"
|
||||
title="确定要删除用户吗?">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="mini"
|
||||
type="danger">删除
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="sh-20"></div>
|
||||
|
||||
<el-pagination
|
||||
background
|
||||
layout="prev, pager, next"
|
||||
:pager-count="11"
|
||||
@current-change="pageChange"
|
||||
:current-page="page"
|
||||
:total="count">
|
||||
</el-pagination>
|
||||
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
title="OTP密钥"
|
||||
:visible.sync="otpImgData.visible"
|
||||
width="350px"
|
||||
center>
|
||||
<div style="text-align: center">{{ otpImgData.username }} : {{ otpImgData.nickname }}</div>
|
||||
<img :src="otpImgData.base64Img" alt="otp-img"/>
|
||||
</el-dialog>
|
||||
|
||||
<!--新增、修改弹出框-->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
title="用户"
|
||||
:visible="user_edit_dialog"
|
||||
@close="disVisible"
|
||||
width="650px"
|
||||
center>
|
||||
|
||||
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="ruleForm">
|
||||
<el-form-item label="用户ID" prop="id">
|
||||
<el-input v-model="ruleForm.id" disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="ruleForm.username" :disabled="ruleForm.id > 0"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="nickname">
|
||||
<el-input v-model="ruleForm.nickname"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="ruleForm.email"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="PIN码" prop="pin_code">
|
||||
<el-input v-model="ruleForm.pin_code" placeholder="不填由系统自动生成"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="禁用OTP" prop="disable_otp">
|
||||
<el-switch
|
||||
v-model="ruleForm.disable_otp">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="OTP密钥" prop="otp_secret" v-if="!ruleForm.disable_otp">
|
||||
<el-input v-model="ruleForm.otp_secret" placeholder="不填由系统自动生成"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="用户组" prop="groups">
|
||||
<el-checkbox-group v-model="ruleForm.groups">
|
||||
<el-checkbox v-for="(item) in grouNames" :key="item" :label="item" :name="item"></el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="发送邮件" prop="send_email">
|
||||
<el-switch
|
||||
v-model="ruleForm.send_email">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="ruleForm.status">
|
||||
<el-radio :label="1" border>启用</el-radio>
|
||||
<el-radio :label="0" border>停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
|
||||
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button>-->
|
||||
<el-button @click="disVisible">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
name: "List",
|
||||
components: {},
|
||||
mixins: [],
|
||||
created() {
|
||||
this.$emit('update:route_path', this.$route.path)
|
||||
this.$emit('update:route_name', ['用户信息', '用户列表'])
|
||||
},
|
||||
mounted() {
|
||||
this.getGroups();
|
||||
this.getData(1)
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
grouNames: [],
|
||||
tableData: [],
|
||||
count: 10,
|
||||
searchData: '',
|
||||
otpImgData: {visible: false, username: '', nickname: '', base64Img: ''},
|
||||
ruleForm: {
|
||||
send_email: true,
|
||||
status: 1,
|
||||
groups: [],
|
||||
},
|
||||
rules: {
|
||||
username: [
|
||||
{required: true, message: '请输入用户名', trigger: 'blur'},
|
||||
{max: 50, message: '长度小于 50 个字符', trigger: 'blur'}
|
||||
],
|
||||
nickname: [
|
||||
{required: true, message: '请输入用户姓名', trigger: 'blur'}
|
||||
],
|
||||
email: [
|
||||
{required: true, message: '请输入用户邮箱', trigger: 'blur'},
|
||||
{type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change']}
|
||||
],
|
||||
|
||||
password: [
|
||||
{min: 6, message: '长度大于 6 个字符', trigger: 'blur'}
|
||||
],
|
||||
pin_code: [
|
||||
{min: 6, message: 'PIN码大于 6 个字符', trigger: 'blur'}
|
||||
],
|
||||
date1: [
|
||||
{type: 'date', required: true, message: '请选择日期', trigger: 'change'}
|
||||
],
|
||||
groups: [
|
||||
{type: 'array', required: true, message: '请至少选择一个组', trigger: 'change'}
|
||||
],
|
||||
status: [
|
||||
{required: true}
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
getOtpImg(row) {
|
||||
// this.base64Img = Buffer.from(data).toString('base64');
|
||||
this.otpImgData.visible = true
|
||||
axios.get('/user/otp_qr', {
|
||||
params: {
|
||||
id: row.id,
|
||||
b64: '1',
|
||||
}
|
||||
}).then(resp => {
|
||||
var rdata = resp.data;
|
||||
// console.log(resp);
|
||||
this.otpImgData.username = row.username;
|
||||
this.otpImgData.nickname = row.nickname;
|
||||
this.otpImgData.base64Img = 'data:image/png;base64,' + rdata
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleDel(row) {
|
||||
axios.post('/user/del?id=' + row.id).then(resp => {
|
||||
var rdata = resp.data
|
||||
if (rdata.code === 0) {
|
||||
this.$message.success(rdata.msg);
|
||||
this.getData(1);
|
||||
} else {
|
||||
this.$message.error(rdata.msg);
|
||||
}
|
||||
console.log(rdata);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleEdit(row) {
|
||||
!this.$refs['ruleForm'] || this.$refs['ruleForm'].resetFields();
|
||||
console.log(row)
|
||||
this.user_edit_dialog = true
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.get('/user/detail', {
|
||||
params: {
|
||||
id: row.id,
|
||||
}
|
||||
}).then(resp => {
|
||||
var data = resp.data.data
|
||||
// 修改默认不发送邮件
|
||||
data.send_email = false
|
||||
this.ruleForm = data
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
handleSearch() {
|
||||
console.log(this.searchData)
|
||||
this.getData(1, this.searchData)
|
||||
},
|
||||
pageChange(p) {
|
||||
this.getData(p)
|
||||
},
|
||||
getData(page, prefix) {
|
||||
this.page = page
|
||||
axios.get('/user/list', {
|
||||
params: {
|
||||
page: page,
|
||||
prefix: prefix || '',
|
||||
}
|
||||
}).then(resp => {
|
||||
var data = resp.data.data
|
||||
console.log(data);
|
||||
this.tableData = data.datas;
|
||||
this.count = data.count
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
getGroups() {
|
||||
axios.get('/group/names', {}).then(resp => {
|
||||
var data = resp.data.data
|
||||
console.log(data.datas);
|
||||
this.grouNames = data.datas;
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (!valid) {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
|
||||
// alert('submit!');
|
||||
axios.post('/user/set', this.ruleForm).then(resp => {
|
||||
var data = resp.data
|
||||
if (data.code === 0) {
|
||||
this.$message.success(data.msg);
|
||||
this.getData(1);
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
console.log(data);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
196
web/src/pages/user/Online.vue
Normal file
196
web/src/pages/user/Online.vue
Normal file
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card>
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
border>
|
||||
|
||||
<el-table-column
|
||||
sortable="true"
|
||||
type="index"
|
||||
label="序号"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="username"
|
||||
label="用户名">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="group"
|
||||
label="登陆组">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="mac_addr"
|
||||
label="MAC地址">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="ip"
|
||||
label="IP地址"
|
||||
width="140">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="remote_addr"
|
||||
label="远端地址">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="tun_name"
|
||||
label="虚拟网卡">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="mtu"
|
||||
label="MTU">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="is_mobile"
|
||||
label="客户端">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.client === 'mobile'" class="el-icon-mobile-phone" style="font-size: 20px;color: red"></i>
|
||||
<i v-else class="el-icon-s-platform" style="font-size: 20px;color: blue"></i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="status"
|
||||
label="实时 上行/下行"
|
||||
width="220">
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="success">{{ scope.row.bandwidth_up }}</el-tag>
|
||||
<el-tag class="m-left-10">{{ scope.row.bandwidth_down }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="status"
|
||||
label="总量 上行/下行"
|
||||
width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-tag effect="dark" type="success">{{ scope.row.bandwidth_up_all }}</el-tag>
|
||||
<el-tag class="m-left-10" effect="dark">{{ scope.row.bandwidth_down_all }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="last_login"
|
||||
label="登陆时间"
|
||||
:formatter="tableDateFormat">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="操作"
|
||||
width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="handleReline(scope.row)">重连
|
||||
</el-button>
|
||||
|
||||
<el-popconfirm
|
||||
class="m-left-10"
|
||||
@onConfirm="handleOffline(scope.row)"
|
||||
title="确定要下线用户吗?">
|
||||
<el-button
|
||||
slot="reference"
|
||||
size="mini"
|
||||
type="danger">下线
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
name: "Online",
|
||||
components: {},
|
||||
mixins: [],
|
||||
created() {
|
||||
this.$emit('update:route_path', this.$route.path)
|
||||
this.$emit('update:route_name', ['用户信息', '在线用户'])
|
||||
},
|
||||
mounted() {
|
||||
this.getData();
|
||||
|
||||
const chatTimer = setInterval(() => {
|
||||
this.getData();
|
||||
}, 2000);
|
||||
|
||||
this.$once('hook:beforeDestroy', () => {
|
||||
clearInterval(chatTimer);
|
||||
})
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleOffline(row) {
|
||||
axios.post('/user/offline?token=' + row.token).then(resp => {
|
||||
var data = resp.data
|
||||
if (data.code === 0) {
|
||||
this.$message.success(data.msg);
|
||||
this.getData();
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
console.log(data);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleReline(row) {
|
||||
axios.post('/user/reline?token=' + row.token).then(resp => {
|
||||
var data = resp.data
|
||||
if (data.code === 0) {
|
||||
this.$message.success(data.msg);
|
||||
this.getData();
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
console.log(data);
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleEdit(a, row) {
|
||||
console.log(a, row)
|
||||
},
|
||||
getData() {
|
||||
axios.get('/user/online').then(resp => {
|
||||
var data = resp.data.data
|
||||
console.log(data);
|
||||
this.tableData = data.datas;
|
||||
this.count = data.count
|
||||
}).catch(error => {
|
||||
this.$message.error('哦,请求出错');
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user