index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <content-wrap>
  3. <!-- 搜索工作栏 -->
  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="username">
  12. <el-input
  13. v-model="queryParams.username"
  14. placeholder="请输入用户名称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="登录地址" prop="userIp">
  21. <el-input
  22. v-model="queryParams.userIp"
  23. placeholder="请输入登录地址"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item label="登录日期" prop="createTime">
  30. <el-date-picker
  31. v-model="queryParams.createTime"
  32. value-format="YYYY-MM-DD HH:mm:ss"
  33. type="daterange"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  37. class="!w-240px"
  38. />
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  42. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  43. <el-button
  44. type="success"
  45. plain
  46. @click="handleExport"
  47. :loading="exportLoading"
  48. v-hasPermi="['infra:config:export']"
  49. >
  50. <Icon icon="ep:download" class="mr-5px" /> 导出
  51. </el-button>
  52. </el-form-item>
  53. </el-form>
  54. </content-wrap>
  55. <!-- 列表 -->
  56. <content-wrap>
  57. <el-table class="yudao-table" v-loading="loading" :data="list">
  58. <el-table-column label="日志编号" align="center" prop="id" />
  59. <el-table-column label="操作类型" align="center" prop="logType">
  60. <template #default="scope">
  61. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="scope.row.logType" />
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="用户名称" align="center" prop="username" width="180" />
  65. <el-table-column label="登录地址" align="center" prop="userIp" width="180" />
  66. <el-table-column label="浏览器" align="center" prop="userAgent" />
  67. <el-table-column label="登陆结果" align="center" prop="result">
  68. <template #default="scope">
  69. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="scope.row.result" />
  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(scope.row)"
  85. v-hasPermi="['infra:config:query']"
  86. >
  87. 详情
  88. </el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <!-- 分页 -->
  93. <Pagination
  94. :total="total"
  95. v-model:page="queryParams.pageNo"
  96. v-model:limit="queryParams.pageSize"
  97. @pagination="getList"
  98. />
  99. </content-wrap>
  100. <!-- 表单弹窗:详情 -->
  101. <login-log-detail ref="modalRef" />
  102. </template>
  103. <script setup lang="ts" name="LoginLog">
  104. import { DICT_TYPE } from '@/utils/dict'
  105. import { dateFormatter } from '@/utils/formatTime'
  106. import download from '@/utils/download'
  107. import * as LoginLogApi from '@/api/system/loginLog'
  108. import LoginLogDetail from './detail.vue'
  109. const message = useMessage() // 消息弹窗
  110. const loading = ref(true) // 列表的加载中
  111. const total = ref(0) // 列表的总页数
  112. const list = ref([]) // 列表的数据
  113. const queryParams = reactive({
  114. pageNo: 1,
  115. pageSize: 10,
  116. username: undefined,
  117. userIp: undefined,
  118. createTime: []
  119. })
  120. const queryFormRef = ref() // 搜索的表单
  121. const exportLoading = ref(false) // 导出的加载中
  122. /** 查询参数列表 */
  123. const getList = async () => {
  124. loading.value = true
  125. try {
  126. const data = await LoginLogApi.getLoginLogPage(queryParams)
  127. list.value = data.list
  128. total.value = data.total
  129. } finally {
  130. loading.value = false
  131. }
  132. }
  133. /** 搜索按钮操作 */
  134. const handleQuery = () => {
  135. queryParams.pageNo = 1
  136. getList()
  137. }
  138. /** 重置按钮操作 */
  139. const resetQuery = () => {
  140. queryFormRef.value.resetFields()
  141. handleQuery()
  142. }
  143. /** 详情操作 */
  144. const modalRef = ref()
  145. const openModal = (data: LoginLogApi.LoginLogVO) => {
  146. modalRef.value.openModal(data)
  147. }
  148. /** 导出按钮操作 */
  149. const handleExport = async () => {
  150. try {
  151. // 导出的二次确认
  152. await message.exportConfirm()
  153. // 发起导出
  154. exportLoading.value = true
  155. const data = await LoginLogApi.exportLoginLog(queryParams)
  156. download.excel(data, '登录日志.xls')
  157. } catch {
  158. } finally {
  159. exportLoading.value = false
  160. }
  161. }
  162. /** 初始化 **/
  163. onMounted(() => {
  164. getList()
  165. })
  166. </script>