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