AdminUserList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <el-container>
  3. <el-header height="220">
  4. <el-row style="margin-top: 10px">
  5. <el-select
  6. v-model="queryInfo.scope"
  7. clearable
  8. placeholder="查询条件"
  9. style="margin-left: 5px"
  10. @change="onSelectChange"
  11. />
  12. <el-button type="plain" icon="el-icon-refresh" style="margin-left: 5px" @click="onRefresh">刷新</el-button>
  13. </el-row>
  14. </el-header>
  15. <el-main>
  16. <el-table
  17. :data="dataList"
  18. border
  19. height="480"
  20. style="width: 100%"
  21. >
  22. <el-table-column
  23. fixed="left"
  24. label="No"
  25. type="index"
  26. />
  27. <el-table-column
  28. prop="avatarUrl"
  29. label="头像"
  30. width="90"
  31. >
  32. <template slot-scope="scope">
  33. <el-image :src="scope.row.avatarUrl" min-width="30" height="20" />
  34. </template>
  35. </el-table-column>
  36. <el-table-column
  37. prop="userId"
  38. label="用户 ID"
  39. >
  40. </el-table-column>
  41. <el-table-column
  42. prop="username"
  43. label="用户名"
  44. />
  45. <el-table-column
  46. prop="screenName"
  47. label="显示名"
  48. >
  49. <template slot-scope="scope">
  50. <router-link target="_blank" :to="`/user/${scope.row.userId}`">
  51. <span>{{ scope.row.screenName }}</span>
  52. </router-link>
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. prop="signature"
  57. label="签名"
  58. :show-overflow-tooltip="true"
  59. >
  60. <template slot-scope="scope">
  61. <el-tooltip
  62. v-if="scope.row.signature"
  63. :content="scope.row.signature"
  64. raw-content
  65. placement="top-start"
  66. >
  67. <span v-if="scope.row.signature && scope.row.signature.length <= 15">
  68. {{ scope.row.signature }}
  69. </span>
  70. <span v-if="scope.row.signature && scope.row.signature.length > 15">
  71. {{ scope.row.signature.substr(0, 15) + "..." }}
  72. </span>
  73. </el-tooltip>
  74. <span v-else-if="scope.row.signature === null">-</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. prop="pubDate"
  79. label="注册时间"
  80. />
  81. <el-table-column
  82. prop="scope"
  83. label="帐号状态"
  84. >
  85. <template slot-scope="scope">
  86. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  87. 正常
  88. </el-tag>
  89. <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
  90. 封禁中
  91. </el-tag>
  92. <el-tag v-else :type="'danger'" disable-transitions>
  93. 已注销
  94. </el-tag>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. prop="status"
  99. label="当前会话"
  100. >
  101. <template slot-scope="scope">
  102. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  103. 正常
  104. </el-tag>
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. prop="status"
  109. label="拥有的角色"
  110. >
  111. <template slot-scope="scope">
  112. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  113. 正常
  114. </el-tag>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. fixed="right"
  119. label="操作"
  120. width="180"
  121. >
  122. <template slot-scope="scope">
  123. <el-button
  124. size="mini"
  125. @click="handleEdit(scope.$index, scope.row)"
  126. >编辑</el-button>
  127. <el-button
  128. size="mini"
  129. type="danger"
  130. @click="handleDelete(scope.$index, scope.row)"
  131. >删除</el-button>
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. <el-pagination
  136. background
  137. :small="screenWidth <= 768"
  138. layout="prev, pager, next"
  139. :page-size="pageSize"
  140. :current-page="currentPage"
  141. :total="totalSize"
  142. @current-change="handleCurrentChange"
  143. @prev-click="handleCurrentChange"
  144. @next-click="handleCurrentChange"
  145. />
  146. </el-main>
  147. </el-container>
  148. </template>
  149. <script>
  150. import { getUserList } from '@/api/admin'
  151. export default {
  152. name: 'AdminUserList',
  153. data() {
  154. return {
  155. queryInfo: {
  156. scope: null,
  157. pn: 1
  158. },
  159. // 屏幕宽度, 为了控制分页条的大小
  160. screenWidth: document.body.clientWidth,
  161. currentPage: 1,
  162. pageSize: 12,
  163. totalSize: 0,
  164. dataList: [],
  165. nextId: 0,
  166. // **********************************************************************
  167. showEditScopeDialog: false,
  168. form: {
  169. videoId: null,
  170. scope: 1
  171. }
  172. }
  173. },
  174. created() {
  175. document.title = 'AdminUserList'
  176. this.getData()
  177. },
  178. methods: {
  179. getData() {
  180. this.dataList = []
  181. getUserList(this.nextId).then(resp => {
  182. if (resp.code === 0) {
  183. const respData = resp.data
  184. this.dataList = respData.list
  185. this.totalSize = respData.data.totalSize
  186. } else {
  187. this.$message.error(resp.msg)
  188. }
  189. })
  190. },
  191. onRefresh() {
  192. this.getData()
  193. },
  194. handleCurrentChange(pageNumber) {
  195. this.currentPage = pageNumber
  196. this.getData()
  197. // 回到顶部
  198. scrollTo(0, 0)
  199. },
  200. handleEdit(index, row) {
  201. this.$message.info('handleEdit')
  202. },
  203. handleDelete(index, row) {
  204. this.$confirm('确定要删除 ' + row.title + '?', '提示', {
  205. confirmButtonText: '确定',
  206. cancelButtonText: '取消',
  207. type: 'warning'
  208. }).then(() => {
  209. this.$message.info('handleDelete')
  210. }).catch(() => {
  211. this.$message({
  212. type: 'info',
  213. message: '已取消'
  214. })
  215. })
  216. },
  217. onUpdateScope() {
  218. this.showEditScopeDialog = false
  219. },
  220. onSelectChange() {
  221. this.$message.info(this.queryInfo)
  222. },
  223. handleClose() {
  224. }
  225. }
  226. }
  227. </script>
  228. <style>
  229. </style>