index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="app-container">
  3. <el-row class="action-bar-container" type="flex" justify="end">
  4. <el-button v-permission="['oauth.user.find']" type="primary" size="small" @click.native="$refs.dialogForm.open({})">新建</el-button>
  5. </el-row>
  6. <el-table
  7. v-loading="isLoading"
  8. :data="pageData.data"
  9. element-loading-text="Loading"
  10. border
  11. fit
  12. highlight-current-row
  13. >
  14. <el-table-column align="center" label="ID" width="150">
  15. <template slot-scope="scope">
  16. {{ scope.row.id }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="昵称">
  20. <template slot-scope="scope">
  21. {{ scope.row.nickName }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="手机号">
  25. <template slot-scope="scope">
  26. {{ scope.row.mp }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="邮箱">
  30. <template slot-scope="scope">
  31. {{ scope.row.email }}
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="性别">
  35. <template slot-scope="scope">
  36. {{ scope.row.gender.text }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="状态">
  40. <template slot-scope="scope">
  41. <el-tag>{{ scope.row.state.text }}</el-tag>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="注册时间" width="160">
  45. <template slot-scope="scope">
  46. {{ scope.row.registerTime }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="角色">
  50. <template slot-scope="scope">
  51. <el-tag v-for="role in scope.row.listRoles" :key="role.id">{{ role.name }}</el-tag>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="操作" width="70" fixed="right">
  55. <template slot-scope="scope">
  56. <el-dropdown>
  57. <el-button type="text">
  58. 操作<i class="el-icon-arrow-down el-icon--right"></i>
  59. </el-button>
  60. <el-dropdown-menu slot="dropdown">
  61. <el-dropdown-item @click.native="$refs.dialogForm.open(scope.row)">编辑</el-dropdown-item>
  62. <el-dropdown-item @click.native="enabledByIds([scope.row.id])">启用</el-dropdown-item>
  63. <el-dropdown-item @click.native="disableByIds([scope.row.id])">禁用</el-dropdown-item>
  64. <el-dropdown-item @click.native="resetLoginPasswordByIds([scope.row.id])">重置登录密码</el-dropdown-item>
  65. </el-dropdown-menu>
  66. </el-dropdown>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <el-pagination
  71. class="pagination-container"
  72. background
  73. layout="prev, pager, next"
  74. :total="pageData.total"
  75. :page-size="pageData.pageSize"
  76. @current-change="handleCurrentChange"
  77. />
  78. <dialog-form ref="dialogForm" @ok="fetchData"/>
  79. </div>
  80. </template>
  81. <script>
  82. import { findPage, enabledByIds, disableByIds, resetLoginPasswordByIds } from '@/api/userInfo'
  83. import DialogForm from './DialogForm'
  84. export default {
  85. components: { DialogForm },
  86. data() {
  87. return {
  88. isLoading: true,
  89. pageData: {},
  90. currentPage: 1
  91. }
  92. },
  93. created() {
  94. this.fetchData()
  95. },
  96. methods: {
  97. handleCurrentChange(val) {
  98. console.log(`当前页: ${val}`)
  99. this.currentPage = val
  100. this.fetchData()
  101. },
  102. enabledByIds(ids) {
  103. console.log(`当前页: ${ids}`)
  104. this.$confirm('确认要启用吗?', '提示', {
  105. confirmButtonText: '确定',
  106. cancelButtonText: '取消',
  107. type: 'warning'
  108. }).then(() => {
  109. enabledByIds(ids).then(() => {
  110. this.fetchData()
  111. })
  112. })
  113. },
  114. disableByIds(ids) {
  115. console.log(`当前页: ${ids}`)
  116. this.$confirm('确认要禁用吗?', '提示', {
  117. confirmButtonText: '确定',
  118. cancelButtonText: '取消',
  119. type: 'warning'
  120. }).then(() => {
  121. disableByIds(ids).then(() => {
  122. this.fetchData()
  123. })
  124. })
  125. },
  126. resetLoginPasswordByIds(ids) {
  127. this.$confirm('确认要重置吗?', '提示', {
  128. confirmButtonText: '确定',
  129. cancelButtonText: '取消',
  130. type: 'warning'
  131. }).then(() => {
  132. resetLoginPasswordByIds(ids).then((newPasswd) => {
  133. this.$alert('新的登录密码为:' + newPasswd + ',请妥善保管', '登录密码重置成功', {
  134. confirmButtonText: '确定'
  135. })
  136. })
  137. })
  138. },
  139. fetchData() {
  140. this.isLoading = true
  141. findPage({ current: this.currentPage })
  142. .then((response) => {
  143. this.pageData = response
  144. })
  145. .finally(() => (this.isLoading = false))
  146. }
  147. }
  148. }
  149. </script>