UserManager.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div id="app" style="width: 100%">
  3. <div class="page-header">
  4. <div class="page-title">用户列表</div>
  5. <div class="page-header-btn">
  6. <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addUser">
  7. 添加用户
  8. </el-button>
  9. </div>
  10. </div>
  11. <!--用户列表-->
  12. <el-table :data="userList" style="width: 100%;font-size: 12px;" :height="winHeight"
  13. header-row-class-name="table-header">
  14. <el-table-column prop="username" label="用户名" min-width="160"/>
  15. <el-table-column prop="pushKey" label="pushkey" min-width="160"/>
  16. <el-table-column prop="role.name" label="类型" min-width="160"/>
  17. <el-table-column label="操作" min-width="450" fixed="right">
  18. <template slot-scope="scope">
  19. <el-button size="medium" icon="el-icon-edit" type="text" @click="edit(scope.row)">修改密码</el-button>
  20. <el-divider direction="vertical"></el-divider>
  21. <el-button size="medium" icon="el-icon-edit" type="text" @click="changePushKey(scope.row)">修改pushkey</el-button>
  22. <el-divider direction="vertical"></el-divider>
  23. <el-button size="medium" icon="el-icon-edit" type="text" @click="showUserApiKeyManager(scope.row)">管理ApiKey</el-button>
  24. <el-divider direction="vertical"></el-divider>
  25. <el-button size="medium" icon="el-icon-delete" type="text" @click="deleteUser(scope.row)"
  26. style="color: #f56c6c">删除
  27. </el-button>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. <changePasswordForAdmin ref="changePasswordForAdmin"></changePasswordForAdmin>
  32. <changePushKey ref="changePushKey"></changePushKey>
  33. <addUser ref="addUser"></addUser>
  34. <el-pagination
  35. style="float: right"
  36. @size-change="handleSizeChange"
  37. @current-change="currentChange"
  38. :current-page="currentPage"
  39. :page-size="count"
  40. :page-sizes="[15, 25, 35, 50]"
  41. layout="total, sizes, prev, pager, next"
  42. :total="total">
  43. </el-pagination>
  44. </div>
  45. </template>
  46. <script>
  47. import uiHeader from '../layout/UiHeader.vue'
  48. import changePasswordForAdmin from './dialog/changePasswordForAdmin.vue'
  49. import changePushKey from './dialog/changePushKey.vue'
  50. import addUser from '../components/dialog/addUser.vue'
  51. export default {
  52. name: 'userManager',
  53. components: {
  54. uiHeader,
  55. changePasswordForAdmin,
  56. changePushKey,
  57. addUser
  58. },
  59. data() {
  60. return {
  61. userList: [], //设备列表
  62. currentUser: {}, //当前操作设备对象
  63. videoComponentList: [],
  64. updateLooper: 0, //数据刷新轮训标志
  65. currentUserLenth: 0,
  66. winHeight: window.innerHeight - 200,
  67. currentPage: 1,
  68. count: 15,
  69. total: 0,
  70. getUserListLoading: false
  71. };
  72. },
  73. mounted() {
  74. this.initData();
  75. this.updateLooper = setInterval(this.initData, 10000);
  76. },
  77. destroyed() {
  78. this.$destroy('videojs');
  79. clearTimeout(this.updateLooper);
  80. },
  81. methods: {
  82. initData: function () {
  83. this.getUserList();
  84. },
  85. currentChange: function (val) {
  86. this.currentPage = val;
  87. this.getUserList();
  88. },
  89. handleSizeChange: function (val) {
  90. this.count = val;
  91. this.getUserList();
  92. },
  93. getUserList: function () {
  94. let that = this;
  95. this.getUserListLoading = true;
  96. this.$axios({
  97. method: 'get',
  98. url: `/api/user/users`,
  99. params: {
  100. page: that.currentPage,
  101. count: that.count
  102. }
  103. }).then(function (res) {
  104. if (res.data.code === 0) {
  105. that.total = res.data.data.total;
  106. that.userList = res.data.data.list;
  107. }
  108. that.getUserListLoading = false;
  109. }).catch(function (error) {
  110. that.getUserListLoading = false;
  111. });
  112. },
  113. edit: function (row) {
  114. this.$refs.changePasswordForAdmin.openDialog(row, () => {
  115. this.$refs.changePasswordForAdmin.close();
  116. this.$message({
  117. showClose: true,
  118. message: "密码修改成功",
  119. type: "success",
  120. });
  121. setTimeout(this.getUserList, 200)
  122. })
  123. },
  124. deleteUser: function (row) {
  125. let msg = "确定删除此用户?"
  126. if (row.online !== 0) {
  127. msg = "<strong>确定删除此用户?</strong>"
  128. }
  129. this.$confirm(msg, '提示', {
  130. dangerouslyUseHTMLString: true,
  131. confirmButtonText: '确定',
  132. cancelButtonText: '取消',
  133. center: true,
  134. type: 'warning'
  135. }).then(() => {
  136. this.$axios({
  137. method: 'delete',
  138. url: `/api/user/delete?id=${row.id}`
  139. }).then((res) => {
  140. this.getUserList();
  141. }).catch((error) => {
  142. console.error(error);
  143. });
  144. }).catch(() => {
  145. });
  146. },
  147. changePushKey: function (row) {
  148. this.$refs.changePushKey.openDialog(row, () => {
  149. this.$refs.changePushKey.close();
  150. this.$message({
  151. showClose: true,
  152. message: "pushKey修改成功",
  153. type: "success",
  154. });
  155. setTimeout(this.getUserList, 200)
  156. })
  157. },
  158. addUser: function () {
  159. // this.$refs.addUser.openDialog()
  160. this.$refs.addUser.openDialog( () => {
  161. this.$refs.addUser.close();
  162. this.$message({
  163. showClose: true,
  164. message: "用户添加成功",
  165. type: "success",
  166. });
  167. setTimeout(this.getUserList, 200)
  168. })
  169. },
  170. showUserApiKeyManager: function (row) {
  171. this.$router.push(`/userApiKeyManager/${row.id}`)
  172. },
  173. }
  174. }
  175. </script>
  176. <style>
  177. .videoList {
  178. display: flex;
  179. flex-wrap: wrap;
  180. align-content: flex-start;
  181. }
  182. .video-item {
  183. position: relative;
  184. width: 15rem;
  185. height: 10rem;
  186. margin-right: 1rem;
  187. background-color: #000000;
  188. }
  189. .video-item-img {
  190. position: absolute;
  191. top: 0;
  192. bottom: 0;
  193. left: 0;
  194. right: 0;
  195. margin: auto;
  196. width: 100%;
  197. height: 100%;
  198. }
  199. .video-item-img:after {
  200. content: "";
  201. display: inline-block;
  202. position: absolute;
  203. z-index: 2;
  204. top: 0;
  205. bottom: 0;
  206. left: 0;
  207. right: 0;
  208. margin: auto;
  209. width: 3rem;
  210. height: 3rem;
  211. background-image: url("../assets/loading.png");
  212. background-size: cover;
  213. background-color: #000000;
  214. }
  215. .video-item-title {
  216. position: absolute;
  217. bottom: 0;
  218. color: #000000;
  219. background-color: #ffffff;
  220. line-height: 1.5rem;
  221. padding: 0.3rem;
  222. width: 14.4rem;
  223. }
  224. </style>