Plat Admin

adminUser.vue 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="app-container">
  3. <div class="box-container">
  4. <div class="contain-title">平台后台用户管理列表</div>
  5. <div class="contian-operate">
  6. <el-button type="primary" @click="handleADD">添加</el-button>
  7. </div>
  8. </div>
  9. <div class="content-container">
  10. <div class="contain-select">
  11. <span>用户分类:</span>
  12. <el-select
  13. v-model="selectMode"
  14. @change="selectChange">
  15. <el-option label="正常账号" value="1" selected></el-option>
  16. <el-option label="停用账号" value="2"></el-option>
  17. </el-select>
  18. </div>
  19. <el-table
  20. :data="tableData"
  21. height="630"
  22. border>
  23. <el-table-column
  24. v-for="item in tableItem"
  25. :key="item.index"
  26. :prop="item.prop ? item.prop : ''"
  27. :label="item.tit ? item.tit : ''"
  28. :width="item.width ? item.width : ''"
  29. align="center">
  30. <template slot-scope="scope">
  31. <div v-if="scope.row[item.prop]">
  32. {{scope.row[item.prop]}}
  33. </div>
  34. <div v-if="item.operate && typeof scope.row === 'object'">
  35. <div class="normal" v-if="scope.row.active">
  36. <el-button
  37. size="mini"
  38. type="primary"
  39. @click="handleEdit(scope.row)">修改</el-button>
  40. <el-button
  41. size="mini"
  42. type="primary"
  43. @click="handleResetpw(scope.row)">重置密码</el-button>
  44. <el-button
  45. size="mini"
  46. type="primary"
  47. @click="handleRight(scope.row)">分配权限</el-button>
  48. <el-button
  49. size="mini"
  50. type="danger"
  51. @click="handleDelete(scope.$index, scope.row)">停用</el-button>
  52. </div>
  53. <div class="forbidden" v-else>
  54. <el-button
  55. size="mini"
  56. type="primary"
  57. @click="handleEdit(scope.$index, scope.row)">恢复</el-button>
  58. </div>
  59. </div>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <div class="pagination-container">
  64. <el-pagination
  65. background
  66. @current-change="handleCurrentChange"
  67. :current-page.sync="pageNo"
  68. :page-size="pageSize"
  69. layout="prev, pager, next, jumper"
  70. :total="total">
  71. </el-pagination>
  72. </div>
  73. </div>
  74. <editUser ref="userInfoDialog"></editUser>
  75. </div>
  76. </template>
  77. <script>
  78. import request from '@/utils/request'
  79. import { parseTime } from '@/utils'
  80. import comTable from '@/utils/comTable'
  81. import {
  82. pageQueryUser,
  83. // addUser,
  84. resetPw
  85. // updateUser,
  86. // updatePermission,
  87. // banUser
  88. } from '@/api/sysSetting'
  89. import editUser from './editUser'
  90. export default {
  91. data() {
  92. return {
  93. searchText: '',
  94. selectMode: '1',
  95. pageSize: 10,
  96. pageNo: 1,
  97. total: 0,
  98. tableData: [],
  99. tableItem: [
  100. {
  101. prop: 'account',
  102. tit: '账号'
  103. },
  104. {
  105. prop: 'id',
  106. tit: '用户名'
  107. },
  108. {
  109. prop: 'job',
  110. tit: '职位',
  111. width: '160'
  112. },
  113. {
  114. prop: 'comp',
  115. tit: '所在部门',
  116. width: '160'
  117. },
  118. {
  119. prop: 'dep',
  120. tit: '所在机构'
  121. },
  122. {
  123. prop: 'phone',
  124. tit: '联系电话',
  125. width: '160'
  126. },
  127. {
  128. prop: 'email',
  129. tit: '联系邮箱',
  130. width: '160'
  131. },
  132. {
  133. prop: 'createTime',
  134. tit: '创建时间',
  135. width: '160'
  136. },
  137. {
  138. operate: true,
  139. width: '200'
  140. }
  141. ]
  142. }
  143. },
  144. components: {
  145. editUser
  146. },
  147. created() {
  148. this.pageQueryUser()
  149. },
  150. methods: {
  151. pageQueryUser() {
  152. var that = this
  153. request.get(pageQueryUser, {
  154. active: that.selectMode,
  155. pageSize: that.pageSize,
  156. pageNo: that.pageNo
  157. }, function(res) {
  158. if (res.data.success && res.data.data) {
  159. const obj = res.data.data
  160. for (let i = 0; i < obj.length; ++i) {
  161. if (obj[i].createTime) {
  162. obj[i].createTime = parseTime(obj[i].createTime)
  163. }
  164. }
  165. that.total = res.data.total
  166. that.tableData = obj
  167. }
  168. })
  169. comTable.gapFilling(that.tableData)
  170. },
  171. handleADD() {
  172. // this.$refs.BInfoDialog02.queryServerList()
  173. this.$refs.userInfoDialog.userDialogVisible = true
  174. },
  175. handleCurrentChange(val) {
  176. this.pageNo = val
  177. this.pageQueryUser()
  178. },
  179. selectChange(val) {
  180. this.selectMode = val
  181. this.pageQueryUser()
  182. },
  183. handleEdit(row) {
  184. var that = this
  185. request.get(resetPw, {
  186. id: row.id
  187. }, function(res) {
  188. that.$message({
  189. type: 'success',
  190. message: '删除成功!'
  191. })
  192. })
  193. },
  194. handleResetpw(row) {
  195. var that = this
  196. that.$confirm(`确定重置用户${row.name}的密码`, '提示', {
  197. confirmButtonText: '确定',
  198. cancelButtonText: '取消',
  199. type: 'warning',
  200. center: true
  201. }).then(() => {
  202. request.get(resetPw, {
  203. id: row.id
  204. }, function(res) {
  205. that.$message({
  206. type: 'success',
  207. message: '该用户密码重置成功!'
  208. })
  209. })
  210. })
  211. },
  212. handleRight(row) {
  213. // var that = this
  214. // request.get(updatePermission + row.id, {
  215. // }, function(res) {
  216. // that.$message({
  217. // type: 'success',
  218. // message: '删除成功!'
  219. // })
  220. // })
  221. }
  222. }
  223. }
  224. </script>