index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :table-loading="tableLoading"
  25. :option="tableOption"
  26. :permission="permissionList"
  27. @on-load="getList"
  28. @refresh-change="refreshChange"
  29. @row-del="handleDel"/>
  30. </basic-container>
  31. </div>
  32. </template>
  33. <script>
  34. import { delObj, fetchList } from '@/api/admin/token'
  35. import { tableOption } from '@/const/crud/admin/token'
  36. import { mapGetters } from 'vuex'
  37. export default {
  38. name: 'Token',
  39. data() {
  40. return {
  41. tableData: [],
  42. page: {
  43. total: 0, // 总页数
  44. currentPage: 1, // 当前页数
  45. pageSize: 20 // 每页显示多少条
  46. },
  47. tableLoading: false,
  48. tableOption: tableOption
  49. }
  50. },
  51. created() {
  52. },
  53. mounted: function() {
  54. },
  55. computed: {
  56. ...mapGetters(['permissions']),
  57. permissionList() {
  58. return {
  59. delBtn: this.vaildData(this.permissions.sys_token_del, false)
  60. }
  61. }
  62. },
  63. methods: {
  64. getList(page, params) {
  65. this.tableLoading = true
  66. fetchList(Object.assign({
  67. current: page.currentPage,
  68. size: page.pageSize
  69. }, params)).then(response => {
  70. this.tableData = response.data.data.records
  71. this.page.total = response.data.data.total
  72. this.tableLoading = false
  73. })
  74. },
  75. handleDel: function(row, index) {
  76. var _this = this
  77. this.$confirm('是否强制' + row.username + '下线?', '提示', {
  78. confirmButtonText: '确定',
  79. cancelButtonText: '取消',
  80. type: 'warning'
  81. }).then(function() {
  82. return delObj(row.access_token)
  83. }).then(() => {
  84. _this.tableData.splice(index, 1)
  85. _this.$message({
  86. showClose: true,
  87. message: '强制下线成功',
  88. type: 'success'
  89. })
  90. }).catch(function() {
  91. })
  92. },
  93. /**
  94. * 刷新回调
  95. */
  96. refreshChange() {
  97. this.getList(this.page)
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. </style>