index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <!-- 搜索 -->
  3. <content-wrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="应用名" prop="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入应用名"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="状态" prop="status">
  20. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  21. <el-option
  22. v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
  23. :key="dict.value"
  24. :label="dict.label"
  25. :value="dict.value"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  31. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  32. <el-button type="primary" @click="openModal('create')" v-hasPermi="['infra:config:create']">
  33. <Icon icon="ep:plus" class="mr-5px" /> 新增
  34. </el-button>
  35. </el-form-item>
  36. </el-form>
  37. </content-wrap>
  38. <!-- 列表 -->
  39. <content-wrap>
  40. <el-table v-loading="loading" :data="list">
  41. <el-table-column label="客户端编号" align="center" prop="clientId" />
  42. <el-table-column label="客户端密钥" align="center" prop="secret" />
  43. <el-table-column label="应用名" align="center" prop="name" />
  44. <el-table-column label="应用图标" align="center" prop="logo">
  45. <template #default="scope">
  46. <img width="40px" height="40px" :src="scope.row.logo" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="状态" align="center" prop="status">
  50. <template #default="scope">
  51. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="访问令牌的有效期" align="center" prop="accessTokenValiditySeconds">
  55. <template #default="scope">{{ scope.row.accessTokenValiditySeconds }} 秒</template>
  56. </el-table-column>
  57. <el-table-column label="刷新令牌的有效期" align="center" prop="refreshTokenValiditySeconds">
  58. <template #default="scope">{{ scope.row.refreshTokenValiditySeconds }} 秒</template>
  59. </el-table-column>
  60. <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes">
  61. <template #default="scope">
  62. <el-tag
  63. :disable-transitions="true"
  64. :key="index"
  65. v-for="(authorizedGrantType, index) in scope.row.authorizedGrantTypes"
  66. :index="index"
  67. >
  68. {{ authorizedGrantType }}
  69. </el-tag>
  70. </template>
  71. </el-table-column>
  72. <el-table-column
  73. label="创建时间"
  74. align="center"
  75. prop="createTime"
  76. width="180"
  77. :formatter="dateFormatter"
  78. />
  79. <el-table-column label="操作" align="center">
  80. <template #default="scope">
  81. <el-button
  82. link
  83. type="primary"
  84. @click="openModal('update', scope.row.id)"
  85. v-hasPermi="['infra:config:update']"
  86. >
  87. 编辑
  88. </el-button>
  89. <el-button
  90. link
  91. type="danger"
  92. @click="handleDelete(scope.row.id)"
  93. v-hasPermi="['infra:config:delete']"
  94. >
  95. 删除
  96. </el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <!-- 分页 -->
  101. <Pagination
  102. :total="total"
  103. v-model:page="queryParams.pageNo"
  104. v-model:limit="queryParams.pageSize"
  105. @pagination="getList"
  106. />
  107. </content-wrap>
  108. <!-- 表单弹窗:添加/修改 -->
  109. <ClientForm ref="modalRef" @success="getList" />
  110. </template>
  111. <script setup lang="ts">
  112. import { DICT_TYPE, getDictOptions } from '@/utils/dict'
  113. import { dateFormatter } from '@/utils/formatTime'
  114. import * as ClientApi from '@/api/system/oauth2/client'
  115. import ClientForm from './form.vue'
  116. const message = useMessage() // 消息弹窗
  117. const { t } = useI18n() // 国际化
  118. const loading = ref(true) // 列表的加载中
  119. const total = ref(0) // 列表的总页数
  120. const list = ref([]) // 列表的数据
  121. const queryParams = reactive({
  122. pageNo: 1,
  123. pageSize: 10,
  124. name: null,
  125. status: null
  126. })
  127. const queryFormRef = ref() // 搜索的表单
  128. /** 查询参数列表 */
  129. const getList = async () => {
  130. loading.value = true
  131. try {
  132. const data = await ClientApi.getOAuth2ClientPageApi(queryParams)
  133. list.value = data.list
  134. total.value = data.total
  135. } finally {
  136. loading.value = false
  137. }
  138. }
  139. /** 搜索按钮操作 */
  140. const handleQuery = () => {
  141. queryParams.pageNo = 1
  142. getList()
  143. }
  144. /** 重置按钮操作 */
  145. const resetQuery = () => {
  146. queryFormRef.value.resetFields()
  147. handleQuery()
  148. }
  149. /** 添加/修改操作 */
  150. const modalRef = ref()
  151. const openModal = (type: string, id?: number) => {
  152. modalRef.value.openModal(type, id)
  153. }
  154. /** 删除按钮操作 */
  155. const handleDelete = async (id: number) => {
  156. try {
  157. // 删除的二次确认
  158. await message.delConfirm()
  159. // 发起删除
  160. await ClientApi.deleteOAuth2ClientApi(id)
  161. message.success(t('common.delSuccess'))
  162. // 刷新列表
  163. await getList()
  164. } catch {}
  165. }
  166. /** 初始化 **/
  167. onMounted(() => {
  168. getList()
  169. })
  170. </script>