index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <!-- 搜索 -->
  3. <ContentWrap>
  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.APPLICATION_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. </ContentWrap>
  44. <!-- 列表 -->
  45. <ContentWrap>
  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="code" />
  51. <el-table-column label="图片" align="center" prop="logo">
  52. <template #default="scope">
  53. <img width="40px" height="40px" :src="scope.row.logo" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="跳转地址" align="center" prop="loginUrl" />
  57. <el-table-column label="状态" align="center" prop="status">
  58. <template #default="scope">
  59. <dict-tag :type="DICT_TYPE.APPLICATION_STATUS" :value="scope.row.status" />
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="排序" align="center" prop="sort" />
  63. <!-- <el-table-column label="访问令牌的有效期" align="center" prop="accessTokenValiditySeconds">-->
  64. <!-- <template #default="scope">{{ scope.row.accessTokenValiditySeconds }} 秒</template>-->
  65. <!-- </el-table-column>-->
  66. <!-- <el-table-column label="刷新令牌的有效期" align="center" prop="refreshTokenValiditySeconds">-->
  67. <!-- <template #default="scope">{{ scope.row.refreshTokenValiditySeconds }} 秒</template>-->
  68. <!-- </el-table-column>-->
  69. <!-- <el-table-column label="授权类型" align="center" prop="authorizedGrantTypes">-->
  70. <!-- <template #default="scope">-->
  71. <!-- <el-tag-->
  72. <!-- :disable-transitions="true"-->
  73. <!-- :key="index"-->
  74. <!-- v-for="(authorizedGrantType, index) in scope.row.authorizedGrantTypes"-->
  75. <!-- :index="index"-->
  76. <!-- class="mr-5px"-->
  77. <!-- >-->
  78. <!-- {{ authorizedGrantType }}-->
  79. <!-- </el-tag>-->
  80. <!-- </template>-->
  81. <!-- </el-table-column>-->
  82. <el-table-column
  83. label="创建时间"
  84. align="center"
  85. prop="createTime"
  86. width="180"
  87. :formatter="dateFormatter"
  88. />
  89. <el-table-column label="操作" align="center">
  90. <template #default="scope">
  91. <el-button
  92. link
  93. type="primary"
  94. @click="openForm('update', scope.row.id)"
  95. v-hasPermi="['system:oauth2-client:update']"
  96. >
  97. 编辑
  98. </el-button>
  99. <!-- <el-button-->
  100. <!-- link-->
  101. <!-- type="danger"-->
  102. <!-- @click="handleDelete(scope.row.id)"-->
  103. <!-- v-hasPermi="['system:oauth2-client:delete']"-->
  104. <!-- >-->
  105. <!-- 删除-->
  106. <!-- </el-button>-->
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <!-- 分页 -->
  111. <Pagination
  112. :total="total"
  113. v-model:page="queryParams.pageNo"
  114. v-model:limit="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. </ContentWrap>
  118. <!-- 表单弹窗:添加/修改 -->
  119. <ClientForm ref="formRef" @success="getList" />
  120. </template>
  121. <script lang="ts" setup>
  122. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  123. import { dateFormatter } from '@/utils/formatTime'
  124. import * as ClientApi from '@/api/system/oauth2/client'
  125. import ClientForm from './ClientForm.vue'
  126. defineOptions({ name: 'SystemOAuth2Client' })
  127. const message = useMessage() // 消息弹窗
  128. const { t } = useI18n() // 国际化
  129. const loading = ref(true) // 列表的加载中
  130. const total = ref(0) // 列表的总页数
  131. const list = ref([]) // 列表的数据
  132. const queryParams = reactive({
  133. pageNo: 1,
  134. pageSize: 10,
  135. name: null,
  136. status: undefined
  137. })
  138. const queryFormRef = ref() // 搜索的表单
  139. /** 查询列表 */
  140. const getList = async () => {
  141. loading.value = true
  142. try {
  143. const data = await ClientApi.getOAuth2ClientPage(queryParams)
  144. list.value = data.list
  145. total.value = data.total
  146. } finally {
  147. loading.value = false
  148. }
  149. }
  150. /** 搜索按钮操作 */
  151. const handleQuery = () => {
  152. queryParams.pageNo = 1
  153. getList()
  154. }
  155. /** 重置按钮操作 */
  156. const resetQuery = () => {
  157. queryFormRef.value.resetFields()
  158. handleQuery()
  159. }
  160. /** 添加/修改操作 */
  161. const formRef = ref()
  162. const openForm = (type: string, id?: number) => {
  163. formRef.value.open(type, id)
  164. }
  165. /** 删除按钮操作 */
  166. const handleDelete = async (id: number) => {
  167. try {
  168. // 删除的二次确认
  169. await message.delConfirm()
  170. // 发起删除
  171. await ClientApi.deleteOAuth2Client(id)
  172. message.success(t('common.delSuccess'))
  173. // 刷新列表
  174. await getList()
  175. } catch {}
  176. }
  177. /** 初始化 **/
  178. onMounted(() => {
  179. getList()
  180. })
  181. </script>