186 lines
5.5 KiB
Vue
Raw Normal View History

<template>
2023-03-26 20:21:31 +08:00
<!-- 搜索 -->
<content-wrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
2023-03-26 20:21:31 +08:00
<el-form-item label="应用名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入应用名"
clearable
@keyup.enter="handleQuery"
2023-04-02 11:05:51 +08:00
class="!w-240px"
2023-03-26 20:21:31 +08:00
/>
</el-form-item>
<el-form-item label="状态" prop="status">
2023-04-02 11:05:51 +08:00
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
2023-03-26 20:21:31 +08:00
<el-option
2023-04-02 11:05:51 +08:00
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
2023-03-26 20:21:31 +08:00
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
2023-04-02 11:05:51 +08:00
<el-button
plain
type="primary"
@click="openForm('create')"
v-hasPermi="['system:oauth2-client:create']"
>
2023-03-26 20:21:31 +08:00
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</el-form-item>
</el-form>
</content-wrap>
<!-- 列表 -->
<content-wrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="客户端编号" align="center" prop="clientId" />
<el-table-column label="客户端密钥" align="center" prop="secret" />
<el-table-column label="应用名" align="center" prop="name" />
<el-table-column label="应用图标" align="center" prop="logo">
<template #default="scope">
<img width="40px" height="40px" :src="scope.row.logo" />
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="访问令牌的有效期" align="center" prop="accessTokenValiditySeconds">
<template #default="scope">{{ scope.row.accessTokenValiditySeconds }} </template>
</el-table-column>
<el-table-column label="刷新令牌的有效期" align="center" prop="refreshTokenValiditySeconds">
<template #default="scope">{{ scope.row.refreshTokenValiditySeconds }} </template>
</el-table-column>
<el-table-column label="授权类型" align="center" prop="authorizedGrantTypes">
<template #default="scope">
<el-tag
:disable-transitions="true"
:key="index"
v-for="(authorizedGrantType, index) in scope.row.authorizedGrantTypes"
:index="index"
>
{{ authorizedGrantType }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
2023-03-26 20:21:31 +08:00
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
2023-04-02 11:05:51 +08:00
@click="openForm('update', scope.row.id)"
v-hasPermi="['system:oauth2-client:update']"
2023-03-26 20:21:31 +08:00
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
2023-04-02 11:05:51 +08:00
v-hasPermi="['system:oauth2-client:delete']"
2023-03-26 20:21:31 +08:00
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</content-wrap>
<!-- 表单弹窗添加/修改 -->
2023-04-02 11:05:51 +08:00
<ClientForm ref="formRef" @success="getList" />
</template>
2023-03-26 20:21:31 +08:00
<script setup lang="ts">
2023-04-02 11:05:51 +08:00
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
2023-03-26 20:21:31 +08:00
import { dateFormatter } from '@/utils/formatTime'
import * as ClientApi from '@/api/system/oauth2/client'
2023-04-02 11:05:51 +08:00
import ClientForm from './ClientForm.vue'
const message = useMessage() // 消息弹窗
2023-03-26 20:21:31 +08:00
const { t } = useI18n() // 国际化
2023-03-26 20:21:31 +08:00
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
status: null
})
2023-03-26 20:21:31 +08:00
const queryFormRef = ref() // 搜索的表单
/** 查询参数列表 */
const getList = async () => {
loading.value = true
try {
2023-04-02 11:05:51 +08:00
const data = await ClientApi.getOAuth2ClientPage(queryParams)
2023-03-26 20:21:31 +08:00
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
2023-03-26 20:21:31 +08:00
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
2023-03-26 20:21:31 +08:00
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
2023-03-26 20:21:31 +08:00
/** 添加/修改操作 */
2023-04-02 11:05:51 +08:00
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
2023-03-26 20:21:31 +08:00
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
2023-04-02 11:05:51 +08:00
await ClientApi.deleteOAuth2Client(id)
2023-03-26 20:21:31 +08:00
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
2023-03-26 20:21:31 +08:00
/** 初始化 **/
onMounted(() => {
getList()
})
</script>