login-log.vue 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div style="padding: 0px 0px 8px 8px">
  3. <el-card shadow="never" :body-style="{ paddingBottom: '0' }" style="margin-top: 8px">
  4. <el-form :model="state.filterModel" :inline="true" @submit.stop.prevent>
  5. <el-form-item prop="name">
  6. <el-input v-model="state.filterModel.createdUserName" placeholder="登录账户" @keyup.enter="onQuery" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  10. </el-form-item>
  11. </el-form>
  12. </el-card>
  13. <el-card shadow="never" style="margin-top: 8px">
  14. <el-table v-loading="state.loading" :data="state.loginLogListData" row-key="id" style="width: 100%">
  15. <el-table-column prop="createdUserName" label="操作账号" width="100">
  16. <template #default="{ row }"> {{ row.createdUserName }}<br />{{ row.nickName }} </template>
  17. </el-table-column>
  18. <el-table-column prop="ip" label="IP地址" width="130" />
  19. <el-table-column prop="browser" label="浏览器" width="100" />
  20. <el-table-column prop="os" label="操作系统" width="100" />
  21. <el-table-column prop="elapsedMilliseconds" label="耗时(毫秒)" width="100" />
  22. <el-table-column prop="status" label="登录状态" width="80">
  23. <template #default="{ row }">
  24. <el-tag :type="row.status ? 'success' : 'danger'" disable-transitions>{{ row.status ? '成功' : '失败' }}</el-tag>
  25. </template>
  26. </el-table-column>
  27. <el-table-column prop="createdTime" label="登录时间" :formatter="formatterTime" width="160" />
  28. <el-table-column prop="msg" label="登录消息" width="" />
  29. </el-table>
  30. <div class="my-flex my-flex-end" style="margin-top: 20px">
  31. <el-pagination
  32. v-model:currentPage="state.pageInput.currentPage"
  33. v-model:page-size="state.pageInput.pageSize"
  34. :total="state.total"
  35. :page-sizes="[10, 20, 50, 100]"
  36. small
  37. background
  38. @size-change="onSizeChange"
  39. @current-change="onCurrentChange"
  40. layout="total, sizes, prev, pager, next, jumper"
  41. />
  42. </div>
  43. </el-card>
  44. </div>
  45. </template>
  46. <script lang="ts" setup name="admin/loginLog">
  47. import { reactive, onMounted } from 'vue'
  48. import { LoginLogListOutput, PageInputLogGetPageDto } from '/@/api/admin/data-contracts'
  49. import { LoginLogApi } from '/@/api/admin/LoginLog'
  50. import dayjs from 'dayjs'
  51. const state = reactive({
  52. loading: false,
  53. loginLogFormTitle: '',
  54. filterModel: {
  55. createdUserName: '',
  56. },
  57. total: 0,
  58. pageInput: {
  59. currentPage: 1,
  60. pageSize: 20,
  61. } as PageInputLogGetPageDto,
  62. loginLogListData: [] as Array<LoginLogListOutput>,
  63. loginLogLogsTitle: '',
  64. })
  65. onMounted(() => {
  66. onQuery()
  67. })
  68. const formatterTime = (row: any, column: any, cellValue: any) => {
  69. return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
  70. }
  71. const onQuery = async () => {
  72. state.loading = true
  73. state.pageInput.filter = state.filterModel
  74. const res = await new LoginLogApi().getPage(state.pageInput)
  75. state.loginLogListData = res?.data?.list ?? []
  76. state.total = res.data?.total ?? 0
  77. state.loading = false
  78. }
  79. const onSizeChange = (val: number) => {
  80. state.pageInput.pageSize = val
  81. onQuery()
  82. }
  83. const onCurrentChange = (val: number) => {
  84. state.pageInput.currentPage = val
  85. onQuery()
  86. }
  87. </script>
  88. <style scoped lang="scss"></style>