| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <div class="template">
- <div class="top">
- <div class="location">数据管理 / <span>用户管理</span></div>
- </div>
- <div class="conten">
- <div class="search">
- <div class="txt">筛选查询</div>
- <div class="row">
- <span>用户名:</span>
- <el-input v-model="form.searchKey" placeholder="请输入"></el-input>
- </div>
- <div class="btn" @click="search">搜 索</div>
- </div>
- <!-- 表格 -->
- <div class="table">
- <div class="title">
- <div class="txt">用户列表</div>
- <div class="addBtn" @click="addUser">+ 新增</div>
- </div>
- <el-table
- :header-cell-style="{ background: '#e3e6e9' }"
- :data="tableData"
- stripe
- style="width: 100%"
- >
- <el-table-column label="序号" width="80">
- <template slot-scope="scope">
- {{ scope.$index + (form.pageNum - 1) * form.pageSize + 1 }}
- </template>
- </el-table-column>
- <el-table-column prop="realName" label="用户名"></el-table-column>
- <el-table-column prop="roleName" label="用户角色"></el-table-column>
- <el-table-column prop="dept" label="部门"> </el-table-column>
- <el-table-column prop="createTime" label="创建时间"> </el-table-column>
- <el-table-column prop="remark" label="备注"> </el-table-column>
- <el-table-column label="操作">
- <template #default='{row}'>
- <el-button type="text" @click="editUser(row.id)">编 辑</el-button>
- <el-button type="text" @click="delUserById(row.id)" v-if="row.roleId!==1">删 除</el-button>
- <el-button type="text" @click="resetPass(row.id)" v-if="row.roleId!==1">重置密码</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页 -->
- <div class="paging">
- <el-pagination layout="prev, pager, next,sizes,jumper"
- :total="total"
- :current-page='form.pageNum'
- @current-change="currentChange"
- @size-change="sizeChange"
- >
- </el-pagination>
- </div>
- </div>
- <!-- 点击新增的弹窗 -->
- <Tab4Add :isShow.sync="isShow" @update='getUserList(form)' ref="myUser"/>
- </div>
- </template>
- <script>
- import Tab4Add from './tab4_add.vue'
- import { getUserList, delUserById, resetPass } from '@/apis/tab4'
- export default {
- name: 'tab3',
- components: { Tab4Add },
- data () {
- // 这里存放数据
- return {
- isShow: false,
- total: 0,
- form: {
- pageNum: 1,
- pageSize: 10,
- searchKey: ''
- },
- tableData: []
- }
- },
- // 监听属性 类似于data概念
- computed: {},
- // 监控data中的数据变化
- watch: {},
- // 方法集合
- methods: {
- // 点击搜索
- search () {
- this.form.pageNum = 1
- this.getUserList(this.form)
- },
- // 点击重置密码
- resetPass (id) {
- this.$confirm('确定重置密码吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- const res = await resetPass(id)
- if (res.code === 0) {
- this.getUserList(this.form)
- this.$message.success('重置密码成功!')
- }
- console.log(999, res)
- })
- .catch(() => {
- this.$message.info('已取消重置!')
- })
- },
- // 点击删除
- delUserById (id) {
- this.$confirm('确定删除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- const res = await delUserById(id)
- if (res.code === 0) {
- this.getUserList(this.form)
- this.$message.success('删除成功!')
- }
- console.log(999, res)
- })
- .catch(() => {
- this.$message.info('已取消删除!')
- })
- },
- // 点击编辑
- editUser (id) {
- this.$refs.myUser.getUserDetailById(id)
- this.isShow = true
- },
- // 点击新增
- addUser () {
- this.isShow = true
- },
- // 封装获取文物列表方法
- async getUserList (data) {
- const res = await getUserList(data)
- this.tableData = res.data.list
- this.total = res.data.total
- },
- // 分页器方法
- currentChange (val) {
- // console.log('当前页改变了', val)
- this.form.pageNum = val
- this.getUserList(this.form)
- },
- sizeChange (val) {
- // console.log('条数改变了', val)
- this.form.pageNum = 1
- this.form.pageSize = val
- this.getUserList(this.form)
- }
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created () {
- this.getUserList(this.form)
- },
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted () {},
- beforeCreate () {}, // 生命周期 - 创建之前
- beforeMount () {}, // 生命周期 - 挂载之前
- beforeUpdate () {}, // 生命周期 - 更新之前
- updated () {}, // 生命周期 - 更新之后
- beforeDestroy () {}, // 生命周期 - 销毁之前
- destroyed () {}, // 生命周期 - 销毁完成
- activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
- }
- </script>
- <style lang='less' scoped>
- .template {
- /deep/.el-table__body-wrapper {
- max-height: 450px;
- overflow-y: auto;
- }
- /deep/.cell {
- padding-left: 20px !important;
- }
- /deep/.el-table__row .el-table__cell {
- padding: 0 !important;
- }
- /deep/.el-pager li {
- background: transparent !important;
- }
- /deep/.btn-prev {
- background: transparent !important;
- }
- /deep/.btn-next {
- background: transparent !important;
- }
- padding: 0px 30px;
- .top {
- display: flex;
- align-items: center;
- height: 58px;
- width: 100%;
- .location {
- font-size: 22px;
- color: #999;
- & > span {
- color: black;
- }
- }
- }
- .conten {
- position: relative;
- width: 100%;
- height: 780px;
- .txt {
- font-weight: 700;
- height: 40px;
- border-bottom: 2px solid #A3A2A9 ;
- }
- .search {
- position: relative;
- padding: 15px 20px 0;
- border-radius: 5px;
- box-shadow: 0px 0px 5px 0px;
- height: 130px;
- background-color: #d8dadc;
- .row {
- width: 100%;
- margin-top: 20px;
- display: flex;
- align-items: center;
- & > div {
- margin-right: 50px;
- width: 20%;
- display: flex;
- align-items: center;
- }
- }
- .btn {
- border-radius: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #fff;
- cursor: pointer;
- width: 170px;
- height: 40px;
- background-color: #dc3545;
- position: absolute;
- right: 50px;
- top: 75px;
- }
- }
- .table {
- margin-top: 25px;
- .title {
- position: relative;
- padding: 15px 20px 0;
- background-color: #e3e6e9;
- .addBtn {
- cursor: pointer;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #fff;
- width: 80px;
- height: 30px;
- background-color: #dc3545;
- border-radius: 12px;
- z-index: 999;
- position: absolute;
- right: 56px;
- top: 62px;
- }
- }
- }
- .paging {
- position: absolute;
- bottom: 15px;
- right: 50px;
- }
- }
- }
- </style>
|