UserList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <el-row>
  3. <el-row>
  4. <el-form :inline="true" :model="searchForm" class="demo-form-inline">
  5. <el-form-item>
  6. <el-select v-model="searchForm.type" placeholder="查询类型">
  7. <el-option label="用户名" value="1" />
  8. <el-option label="用户 ID" value="2" />
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-input v-model="searchForm.content" placeholder="" />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button size="mini" type="warning" @click="search">查询</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-table
  19. :data="dataList"
  20. border
  21. style="width: 100%"
  22. >
  23. <el-table-column
  24. fixed="left"
  25. label="No"
  26. type="index"
  27. />
  28. <el-table-column
  29. prop="avatarUrl"
  30. label="头像"
  31. width="90"
  32. >
  33. <template slot-scope="scope">
  34. <el-image :src="scope.row.avatarUrl" min-width="30" height="20" />
  35. </template>
  36. </el-table-column>
  37. <el-table-column
  38. prop="screenName"
  39. label="用户名"
  40. >
  41. <template slot-scope="scope">
  42. <router-link style="text-decoration-line: none" target="_blank" :to="`/user/${scope.row.userId}`">
  43. <span>{{ scope.row.screenName }}</span>
  44. </router-link>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. prop="gender"
  49. label="性别"
  50. >
  51. <template slot-scope="scope">
  52. <span v-if="scope.row.gender === 0">女</span>
  53. <span v-else-if="scope.row.gender === 1">男</span>
  54. <span v-else>未知</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="signature"
  59. label="签名"
  60. >
  61. <template slot-scope="scope">
  62. <el-tooltip
  63. v-if="scope.row.signature"
  64. :content="scope.row.signature"
  65. raw-content
  66. placement="top-start"
  67. >
  68. <span v-if="scope.row.signature.length <= 15">
  69. {{ scope.row.signature }}
  70. </span>
  71. <span v-else>
  72. {{ scope.row.signature.substr(0, 15) + "..." }}
  73. </span>
  74. </el-tooltip>
  75. <span v-else>-</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="following"
  80. label="关注数"
  81. />
  82. <el-table-column
  83. prop="follower"
  84. label="粉丝数"
  85. />
  86. <el-table-column
  87. prop="userId"
  88. label="帐号状态"
  89. width="120"
  90. >
  91. <template slot-scope="scope">
  92. <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
  93. 正常
  94. </el-tag>
  95. <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
  96. 禁言
  97. </el-tag>
  98. <el-tag v-else-if="scope.row.status === 3" :type="'danger'" disable-transitions>
  99. 封禁
  100. </el-tag>
  101. <el-tag v-else :type="'danger'" disable-transitions>
  102. 注销
  103. </el-tag>
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. fixed="right"
  108. label="操作"
  109. >
  110. <template slot-scope="scope">
  111. <el-button
  112. size="mini"
  113. @click="handleEdit(scope.$index, scope.row)"
  114. >编辑</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <!-- 修改修改帐号状态对话框 -->
  119. <el-dialog
  120. append-to-body
  121. :visible.sync="showEditScopeDialog"
  122. width="30%"
  123. center
  124. >
  125. <el-card class="box-card">
  126. <div slot="header" class="clearfix">
  127. <span>修改帐号状态</span>
  128. <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateStatus">更新</el-button>
  129. </div>
  130. <div class="text item">
  131. <el-select v-model="form.scope" placeholder="设置帐号状态">
  132. <el-option label="正常" value="1" />
  133. <el-option label="禁言" value="2" />
  134. <el-option label="封禁" value="3" />
  135. </el-select>
  136. </div>
  137. </el-card>
  138. </el-dialog>
  139. </el-row>
  140. <el-row>
  141. <el-pagination
  142. background
  143. :small="screenWidth <= 768"
  144. layout="prev, pager, next"
  145. :page-size="pageSize"
  146. :current-page="currentPage"
  147. :total="totalSize"
  148. @current-change="handleCurrentChange"
  149. @prev-click="handleCurrentChange"
  150. @next-click="handleCurrentChange"
  151. />
  152. </el-row>
  153. </el-row>
  154. </template>
  155. <script>
  156. import { getUserList } from '@/api/admin'
  157. export default {
  158. name: 'UserList',
  159. data() {
  160. return {
  161. // 屏幕宽度, 为了控制分页条的大小
  162. screenWidth: document.body.clientWidth,
  163. currentPage: 1,
  164. pageSize: 100,
  165. totalSize: 0,
  166. dataList: [],
  167. // **********************************************************************
  168. showEditScopeDialog: false,
  169. form: {
  170. videoId: null,
  171. scope: '1'
  172. },
  173. searchForm: {
  174. page: 1,
  175. type: '1',
  176. content: null
  177. }
  178. }
  179. },
  180. created() {
  181. document.title = '用户列表'
  182. this.getData(this.searchForm)
  183. },
  184. methods: {
  185. handleCurrentChange(pageNumber) {
  186. this.currentPage = pageNumber
  187. this.searchForm.page = this.currentPage
  188. this.getData(this.searchForm)
  189. // 回到顶部
  190. scrollTo(0, 0)
  191. },
  192. getData(searchForm) {
  193. this.dataList = []
  194. getUserList(searchForm).then(resp => {
  195. if (resp.code === 0) {
  196. this.dataList = resp.data.list
  197. this.totalSize = resp.data.totalSize
  198. } else {
  199. this.$notify({
  200. title: '提示',
  201. message: resp.msg,
  202. type: 'warning',
  203. duration: 3000
  204. })
  205. }
  206. }).catch(error => {
  207. this.$notify({
  208. title: '提示',
  209. message: error.message,
  210. type: 'error',
  211. duration: 3000
  212. })
  213. })
  214. },
  215. handleScope(index, row) {
  216. this.form.videoId = row.videoId
  217. this.form.scope = '' + row.scope
  218. this.showEditScopeDialog = true
  219. },
  220. handleEdit(index, row) {
  221. this.showEditScopeDialog = true
  222. },
  223. onUpdateStatus() {
  224. this.showEditScopeDialog = false
  225. this.$notify({
  226. message: '接口未实现',
  227. type: 'warning',
  228. duration: 3000
  229. })
  230. },
  231. search() {
  232. this.currentPage = 1
  233. this.searchForm.page = this.currentPage
  234. this.getData(this.searchForm)
  235. }
  236. }
  237. }
  238. </script>
  239. <style>
  240. </style>