index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5. <template #actionbtns_default="{ row }">
  6. <!-- 操作:详情 -->
  7. <XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
  8. <!-- 操作:删除 -->
  9. <XTextButton
  10. preIcon="ep:delete"
  11. :title="t('action.logout')"
  12. v-hasPermi="['system:oauth2-token:delete']"
  13. @click="handleForceLogout(row.id)"
  14. />
  15. </template>
  16. </vxe-grid>
  17. </ContentWrap>
  18. <XModal v-model="dialogVisible" :title="dialogTitle">
  19. <!-- 对话框(详情) -->
  20. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef" />
  21. <!-- 操作按钮 -->
  22. <template #footer>
  23. <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
  24. </template>
  25. </XModal>
  26. </template>
  27. <script setup lang="ts">
  28. import { ref } from 'vue'
  29. import { useI18n } from '@/hooks/web/useI18n'
  30. import { useMessage } from '@/hooks/web/useMessage'
  31. import { useVxeGrid } from '@/hooks/web/useVxeGrid'
  32. import { VxeGridInstance } from 'vxe-table'
  33. import { allSchemas } from './token.data'
  34. import * as TokenApi from '@/api/system/oauth2/token'
  35. const { t } = useI18n() // 国际化
  36. const message = useMessage() // 消息弹窗
  37. // 列表相关的变量
  38. const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  39. const { gridOptions, reloadList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
  40. allSchemas: allSchemas,
  41. getListApi: TokenApi.getAccessTokenPageApi
  42. })
  43. // ========== 详情相关 ==========
  44. const detailRef = ref() // 详情 Ref
  45. const dialogVisible = ref(false) // 是否显示弹出层
  46. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  47. // 详情
  48. const handleDetail = async (row: TokenApi.OAuth2TokenVO) => {
  49. // 设置数据
  50. detailRef.value = row
  51. dialogVisible.value = true
  52. }
  53. // 强退操作
  54. const handleForceLogout = (rowId: number) => {
  55. message
  56. .confirm('是否要强制退出用户')
  57. .then(async () => {
  58. await TokenApi.deleteAccessTokenApi(rowId)
  59. message.success(t('common.success'))
  60. })
  61. .finally(() => {
  62. // 刷新列表
  63. reloadList(xGrid)
  64. })
  65. }
  66. </script>