index.vue 5.5 KB

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