| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <div class="app-container">
- <el-row class="action-bar-container" type="flex" justify="end">
- <el-button v-permission="['oauth.user.find']" type="primary" size="small" @click.native="$refs.dialogForm.open({})">新建</el-button>
- </el-row>
- <el-table
- v-loading="isLoading"
- :data="pageData.data"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- >
- <el-table-column align="center" label="ID" width="150">
- <template slot-scope="scope">
- {{ scope.row.id }}
- </template>
- </el-table-column>
- <el-table-column label="昵称">
- <template slot-scope="scope">
- {{ scope.row.nickName }}
- </template>
- </el-table-column>
- <el-table-column label="手机号">
- <template slot-scope="scope">
- {{ scope.row.mp }}
- </template>
- </el-table-column>
- <el-table-column label="邮箱">
- <template slot-scope="scope">
- {{ scope.row.email }}
- </template>
- </el-table-column>
- <el-table-column label="性别">
- <template slot-scope="scope">
- {{ scope.row.gender.text }}
- </template>
- </el-table-column>
- <el-table-column label="状态">
- <template slot-scope="scope">
- <el-tag>{{ scope.row.state.text }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="注册时间" width="160">
- <template slot-scope="scope">
- {{ scope.row.registerTime }}
- </template>
- </el-table-column>
- <el-table-column label="角色">
- <template slot-scope="scope">
- <el-tag v-for="role in scope.row.listRoles" :key="role.id">{{ role.name }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="70" fixed="right">
- <template slot-scope="scope">
- <el-dropdown>
- <el-button type="text">
- 操作<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item @click.native="$refs.dialogForm.open(scope.row)">编辑</el-dropdown-item>
- <el-dropdown-item @click.native="enabledByIds([scope.row.id])">启用</el-dropdown-item>
- <el-dropdown-item @click.native="disableByIds([scope.row.id])">禁用</el-dropdown-item>
- <el-dropdown-item @click.native="resetLoginPasswordByIds([scope.row.id])">重置登录密码</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- class="pagination-container"
- background
- layout="prev, pager, next"
- :total="pageData.total"
- :page-size="pageData.pageSize"
- @current-change="handleCurrentChange"
- />
- <dialog-form ref="dialogForm" @ok="fetchData"/>
- </div>
- </template>
- <script>
- import { findPage, enabledByIds, disableByIds, resetLoginPasswordByIds } from '@/api/userInfo'
- import DialogForm from './DialogForm'
- export default {
- components: { DialogForm },
- data() {
- return {
- isLoading: true,
- pageData: {},
- currentPage: 1
- }
- },
- created() {
- this.fetchData()
- },
- methods: {
- handleCurrentChange(val) {
- console.log(`当前页: ${val}`)
- this.currentPage = val
- this.fetchData()
- },
- enabledByIds(ids) {
- console.log(`当前页: ${ids}`)
- this.$confirm('确认要启用吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- enabledByIds(ids).then(() => {
- this.fetchData()
- })
- })
- },
- disableByIds(ids) {
- console.log(`当前页: ${ids}`)
- this.$confirm('确认要禁用吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- disableByIds(ids).then(() => {
- this.fetchData()
- })
- })
- },
- resetLoginPasswordByIds(ids) {
- this.$confirm('确认要重置吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- resetLoginPasswordByIds(ids).then((newPasswd) => {
- this.$alert('新的登录密码为:' + newPasswd + ',请妥善保管', '登录密码重置成功', {
- confirmButtonText: '确定'
- })
- })
- })
- },
- fetchData() {
- this.isLoading = true
- findPage({ current: this.currentPage })
- .then((response) => {
- this.pageData = response
- })
- .finally(() => (this.isLoading = false))
- }
- }
- }
- </script>
|