You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/views/system/userManagement.vue

170 lines
4.7 KiB
Vue

2 years ago
<template>
2 years ago
<div class="camerChannel">
<div class="deviceBox">
<div class="deviceBtnGroup">
<el-button
type="primary"
icon="el-icon-plus"
@click.native.stop="handleAdddevice()"
>新增</el-button
>
</div>
<div class="deviceTable">
<el-table
ref="multipleTable"
:data="deviceTableData"
stripe
tooltip-effect="dark"
style="width: 100%"
height="calc(100% - 40px)"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
>
<!-- <el-table-column type="index" width="55"> </el-table-column>
<el-table-column type="selection" width="55"> </el-table-column> -->
<el-table-column label="用户名" show-overflow-tooltip prop="userName" ></el-table-column>
<el-table-column label="角色" show-overflow-tooltip prop="role" >
<template slot-scope="scope">{{ scope.row.role == 1 ? '管理员' : '用户' }}</template>
</el-table-column>
<el-table-column label="创建时间" show-overflow-tooltip prop="createTime" >
<template slot-scope="scope">{{ $moment(scope.row.createTime).format("yy-MM-DD HH:mm:ss") }}</template>
</el-table-column>
2 years ago
<el-table-column fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button
@click.native.stop="handleResive(scope.row)"
type="text"
2 years ago
>修改</el-button>
2 years ago
<el-button type="text" class="deleteText" @click.native.stop="handleDelete(scope.row)" >删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pageNation">
<el-pagination
@current-change="handleCurrentChange"
:current-page="page"
:page-size="pageSize"
layout=" prev, pager, next, jumper,total"
:total="total"
background
>
</el-pagination>
</div>
</div>
</div>
<!-- 新增 -->
2 years ago
<addUser :title="title" ref="adduserref"></addUser>
</div>
2 years ago
</template>
2 years ago
<script>
import addUser from "./components/addUser.vue";
import { getUserList, delUserApi } from "@/utils/api/index";
2 years ago
export default {
components: {
addUser
},
data() {
return {
title: "", //弹窗标题
deviceTableData: [],
//multipleSelection: [], //获取当前选中
page: 1, // 当前页数
pageSize: 10, // 每页数量
total: 0, //总条数
};
},
created() {
this.deviceList();
},
methods: {
//获取线路列表数据
deviceList() {
getUserList({
2 years ago
pageindex: this.page,
pagesize: this.pageSize,
})
.then((res) => {
this.deviceTableData = res.data.list;
this.total = res.data.total;
})
.catch((err) => {});
},
//点击行选中
handleRowClick(row, column, event) {
this.$refs.multipleTable.toggleRowSelection(row);
},
//获取选中的行
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 新建
handleAdddevice() {
this.title = "新增";
this.$refs.adduserref.display();
this.$refs.adduserref.getdataform(null);
},
2 years ago
2 years ago
//修改
handleResive(data) {
this.title = "修改";
this.$refs.adduserref.display();
this.$refs.adduserref.getdataform(data);
},
2 years ago
2 years ago
//删除数据
handleDelete(data) {
this.$confirm("确定要删除记录吗,同时删除关联关系?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
delUserApi({ uid: data.userId }).then((res) => {
if (res.code == 200) {
this.$message.success("删除成功");
this.deviceList(); //刷新
} else {
this.$message.error(res.msg);
}
2 years ago
});
})
.catch(() => {
this.$message({ type: "info", message: "已取消删除" });
});
},
//点击分页
handleCurrentChange(val) {
this.page = val;
this.deviceList();
},
},
};
</script>
2 years ago
<style lang="less">
2 years ago
.camerChannel {
width: calc(100% - 32px);
height: calc(100% - 32px);
padding: 16px 16px;
background: @color-white;
.deviceBox {
border: 1px solid #dddddd;
height: calc(100% - 32px);
padding: 16px;
border-radius: 4px;
}
.deviceBtnGroup {
display: flex;
justify-content: flex-end;
}
.deviceTable {
margin-top: 16px;
height: calc(100% - 48px);
//background: #fcc;
}
2 years ago
}
</style>