Files
ipms-sjy/yudao-ui-admin-vue3/src/views/system/oauth2/token/index.vue

72 lines
2.2 KiB
Vue
Raw Normal View History

2022-11-13 14:40:51 +08:00
<template>
<ContentWrap>
<!-- 列表 -->
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
<template #actionbtns_default="{ row }">
<!-- 操作详情 -->
<XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
<!-- 操作删除 -->
<XTextButton
preIcon="ep:delete"
:title="t('action.logout')"
v-hasPermi="['system:oauth2-token:delete']"
@click="handleForceLogout(row.id)"
/>
</template>
</vxe-grid>
</ContentWrap>
2022-11-15 12:25:19 +08:00
<XModal v-model="dialogVisible" :title="dialogTitle">
2022-11-13 14:40:51 +08:00
<!-- 对话框(详情) -->
<Descriptions :schema="allSchemas.detailSchema" :data="detailRef" />
<!-- 操作按钮 -->
<template #footer>
<el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
</template>
2022-11-15 12:25:19 +08:00
</XModal>
2022-11-13 14:40:51 +08:00
</template>
2022-07-18 19:06:37 +08:00
<script setup lang="ts">
2022-11-13 14:40:51 +08:00
import { ref } from 'vue'
2022-07-18 19:06:37 +08:00
import { useI18n } from '@/hooks/web/useI18n'
2022-11-13 14:40:51 +08:00
import { useMessage } from '@/hooks/web/useMessage'
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
import { allSchemas } from './token.data'
2022-07-18 19:06:37 +08:00
import * as TokenApi from '@/api/system/oauth2/token'
2022-11-13 14:40:51 +08:00
2022-07-18 19:06:37 +08:00
const { t } = useI18n() // 国际化
2022-11-13 14:40:51 +08:00
const message = useMessage() // 消息弹窗
// 列表相关的变量
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
const { gridOptions } = useVxeGrid<TokenApi.OAuth2TokenVO>({
allSchemas: allSchemas,
getListApi: TokenApi.getAccessTokenPageApi
2022-07-18 19:06:37 +08:00
})
2022-07-18 19:06:37 +08:00
// ========== 详情相关 ==========
const detailRef = ref() // 详情 Ref
const dialogVisible = ref(false) // 是否显示弹出层
const dialogTitle = ref(t('action.detail')) // 弹出层标题
// 详情
2022-11-13 14:40:51 +08:00
const handleDetail = async (row: TokenApi.OAuth2TokenVO) => {
2022-07-18 19:06:37 +08:00
// 设置数据
detailRef.value = row
dialogVisible.value = true
}
2022-07-18 19:06:37 +08:00
// 强退操作
2022-11-13 14:40:51 +08:00
const handleForceLogout = (rowId: number) => {
message
2022-11-14 13:19:33 +08:00
.confirm('是否要强制退出用户')
2022-11-13 14:40:51 +08:00
.then(async () => {
await TokenApi.deleteAccessTokenApi(rowId)
2022-11-14 13:19:33 +08:00
message.success(t('common.success'))
2022-11-13 14:40:51 +08:00
})
.finally(() => {
// 刷新列表
xGrid.value?.commitProxy('query')
})
2022-07-18 19:06:37 +08:00
}
</script>