|
1 | 1 | <template>
|
2 |
| - <ContentWrap> |
3 |
| - <!-- 列表 --> |
4 |
| - <XTable @register="registerTable"> |
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)" |
| 2 | + <content-wrap> |
| 3 | + <!-- 搜索工作栏 --> |
| 4 | + <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true"> |
| 5 | + <el-form-item label="用户编号" prop="userId"> |
| 6 | + <el-input |
| 7 | + v-model="queryParams.userId" |
| 8 | + placeholder="请输入用户编号" |
| 9 | + clearable |
| 10 | + @keyup.enter="handleQuery" |
14 | 11 | />
|
15 |
| - </template> |
16 |
| - </XTable> |
17 |
| - </ContentWrap> |
18 |
| - <XModal v-model="dialogVisible" :title="dialogTitle"> |
19 |
| - <!-- 对话框(详情) --> |
20 |
| - <Descriptions :schema="allSchemas.detailSchema" :data="detailData" /> |
21 |
| - <!-- 操作按钮 --> |
22 |
| - <template #footer> |
23 |
| - <XButton :title="t('dialog.close')" @click="dialogVisible = false" /> |
24 |
| - </template> |
25 |
| - </XModal> |
| 12 | + </el-form-item> |
| 13 | + <el-form-item label="用户类型" prop="userType"> |
| 14 | + <el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable> |
| 15 | + <el-option |
| 16 | + v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)" |
| 17 | + :key="dict.value" |
| 18 | + :label="dict.label" |
| 19 | + :value="dict.value" |
| 20 | + /> |
| 21 | + </el-select> |
| 22 | + </el-form-item> |
| 23 | + <el-form-item label="客户端编号" prop="clientId"> |
| 24 | + <el-input |
| 25 | + v-model="queryParams.clientId" |
| 26 | + placeholder="请输入客户端编号" |
| 27 | + clearable |
| 28 | + @keyup.enter="handleQuery" |
| 29 | + /> |
| 30 | + </el-form-item> |
| 31 | + <el-form-item> |
| 32 | + <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
| 33 | + <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
| 34 | + </el-form-item> |
| 35 | + </el-form> |
| 36 | + </content-wrap> |
| 37 | + |
| 38 | + <!-- 列表 --> |
| 39 | + <content-wrap> |
| 40 | + <el-table v-loading="loading" :data="list"> |
| 41 | + <el-table-column label="访问令牌" align="center" prop="accessToken" width="300" /> |
| 42 | + <el-table-column label="刷新令牌" align="center" prop="refreshToken" width="300" /> |
| 43 | + <el-table-column label="用户编号" align="center" prop="userId" /> |
| 44 | + <el-table-column label="用户类型" align="center" prop="userType"> |
| 45 | + <template #default="scope"> |
| 46 | + <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" /> |
| 47 | + </template> |
| 48 | + </el-table-column> |
| 49 | + <el-table-column |
| 50 | + label="过期时间" |
| 51 | + align="center" |
| 52 | + prop="expiresTime" |
| 53 | + :formatter="dateFormatter" |
| 54 | + width="180" |
| 55 | + /> |
| 56 | + <el-table-column |
| 57 | + label="创建时间" |
| 58 | + align="center" |
| 59 | + prop="createTime" |
| 60 | + :formatter="dateFormatter" |
| 61 | + width="180" |
| 62 | + /> |
| 63 | + <el-table-column label="操作" align="center"> |
| 64 | + <template #default="scope"> |
| 65 | + <el-button |
| 66 | + link |
| 67 | + type="danger" |
| 68 | + @click="handleForceLogout(scope.row.id)" |
| 69 | + v-hasPermi="['system:oauth2-token:delete']" |
| 70 | + > |
| 71 | + 强退 |
| 72 | + </el-button> |
| 73 | + </template> |
| 74 | + </el-table-column> |
| 75 | + </el-table> |
| 76 | + <!-- 分页 --> |
| 77 | + <Pagination |
| 78 | + :total="total" |
| 79 | + v-model:page="queryParams.pageNo" |
| 80 | + v-model:limit="queryParams.pageSize" |
| 81 | + @pagination="getList" |
| 82 | + /> |
| 83 | + </content-wrap> |
26 | 84 | </template>
|
27 |
| -<script setup lang="ts" name="Token"> |
28 |
| -import { allSchemas } from './token.data' |
29 |
| -import * as TokenApi from '@/api/system/oauth2/token' |
30 | 85 |
|
31 |
| -const { t } = useI18n() // 国际化 |
| 86 | +<script setup lang="ts" name="Oauth2AccessToken"> |
| 87 | +import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
| 88 | +import { dateFormatter } from '@/utils/formatTime' |
| 89 | +import * as OAuth2AccessTokenApi from '@/api/system/oauth2/token' |
32 | 90 | const message = useMessage() // 消息弹窗
|
33 |
| -// 列表相关的变量 |
34 |
| -const [registerTable, { reload }] = useXTable({ |
35 |
| - allSchemas: allSchemas, |
36 |
| - topActionSlots: false, |
37 |
| - getListApi: TokenApi.getAccessTokenPageApi |
| 91 | +const { t } = useI18n() // 国际化 |
| 92 | +
|
| 93 | +const loading = ref(true) // 列表的加载中 |
| 94 | +const total = ref(0) // 列表的总页数 |
| 95 | +const list = ref([]) // 列表的数据 |
| 96 | +const queryParams = reactive({ |
| 97 | + pageNo: 1, |
| 98 | + pageSize: 10, |
| 99 | + userId: null, |
| 100 | + userType: null, |
| 101 | + clientId: null |
38 | 102 | })
|
| 103 | +const queryFormRef = ref() // 搜索的表单 |
39 | 104 |
|
40 |
| -// ========== 详情相关 ========== |
41 |
| -const detailData = ref() // 详情 Ref |
42 |
| -const dialogVisible = ref(false) // 是否显示弹出层 |
43 |
| -const dialogTitle = ref(t('action.detail')) // 弹出层标题 |
44 |
| -// 详情 |
45 |
| -const handleDetail = async (row: TokenApi.OAuth2TokenVO) => { |
46 |
| - // 设置数据 |
47 |
| - detailData.value = row |
48 |
| - dialogVisible.value = true |
| 105 | +/** 查询参数列表 */ |
| 106 | +const getList = async () => { |
| 107 | + loading.value = true |
| 108 | + try { |
| 109 | + const data = await OAuth2AccessTokenApi.getAccessTokenPage(queryParams) |
| 110 | + list.value = data.list |
| 111 | + total.value = data.total |
| 112 | + } finally { |
| 113 | + loading.value = false |
| 114 | + } |
49 | 115 | }
|
50 | 116 |
|
51 |
| -// 强退操作 |
52 |
| -const handleForceLogout = (rowId: number) => { |
53 |
| - message |
54 |
| - .confirm('是否要强制退出用户') |
55 |
| - .then(async () => { |
56 |
| - await TokenApi.deleteAccessTokenApi(rowId) |
57 |
| - message.success(t('common.success')) |
58 |
| - }) |
59 |
| - .finally(async () => { |
60 |
| - // 刷新列表 |
61 |
| - await reload() |
62 |
| - }) |
| 117 | +/** 搜索按钮操作 */ |
| 118 | +const handleQuery = () => { |
| 119 | + queryParams.pageNo = 1 |
| 120 | + getList() |
63 | 121 | }
|
| 122 | +
|
| 123 | +/** 重置按钮操作 */ |
| 124 | +const resetQuery = () => { |
| 125 | + queryFormRef.value.resetFields() |
| 126 | + handleQuery() |
| 127 | +} |
| 128 | +
|
| 129 | +/** 强制退出操作 */ |
| 130 | +const handleForceLogout = async (id: number) => { |
| 131 | + try { |
| 132 | + // 删除的二次确认 |
| 133 | + await message.confirm('是否要强制退出用户') |
| 134 | + // 发起删除 |
| 135 | + await OAuth2AccessTokenApi.deleteAccessToken(id) |
| 136 | + message.success(t('common.success')) |
| 137 | + // 刷新列表 |
| 138 | + await getList() |
| 139 | + } catch {} |
| 140 | +} |
| 141 | +
|
| 142 | +/** 初始化 **/ |
| 143 | +onMounted(() => { |
| 144 | + getList() |
| 145 | +}) |
64 | 146 | </script>
|
0 commit comments