index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { useRole } from "./hook";
  4. import { getPickerShortcuts } from "../../utils";
  5. import { PureTableBar } from "@/components/RePureTableBar";
  6. import { useRenderIcon } from "@/components/ReIcon/src/hooks";
  7. import Delete from "@iconify-icons/ep/delete";
  8. import Refresh from "@iconify-icons/ep/refresh";
  9. defineOptions({
  10. name: "LoginLog"
  11. });
  12. const formRef = ref();
  13. const tableRef = ref();
  14. const {
  15. form,
  16. loading,
  17. columns,
  18. dataList,
  19. pagination,
  20. selectedNum,
  21. onSearch,
  22. clearAll,
  23. resetForm,
  24. onbatchDel,
  25. handleSizeChange,
  26. onSelectionCancel,
  27. handleCurrentChange,
  28. handleSelectionChange
  29. } = useRole(tableRef);
  30. </script>
  31. <template>
  32. <div class="main">
  33. <el-form
  34. ref="formRef"
  35. :inline="true"
  36. :model="form"
  37. class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]"
  38. >
  39. <el-form-item label="用户名" prop="username">
  40. <el-input
  41. v-model="form.username"
  42. placeholder="请输入用户名"
  43. clearable
  44. class="!w-[180px]"
  45. />
  46. </el-form-item>
  47. <el-form-item label="登录时间" prop="loginTime">
  48. <el-date-picker
  49. v-model="form.loginTime"
  50. :shortcuts="getPickerShortcuts()"
  51. type="datetimerange"
  52. range-separator="至"
  53. start-placeholder="开始日期时间"
  54. end-placeholder="结束日期时间"
  55. />
  56. </el-form-item>
  57. <el-form-item>
  58. <el-button
  59. type="primary"
  60. :icon="useRenderIcon('ri:search-line')"
  61. :loading="loading"
  62. @click="onSearch"
  63. >
  64. 搜索
  65. </el-button>
  66. <el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
  67. 重置
  68. </el-button>
  69. </el-form-item>
  70. </el-form>
  71. <PureTableBar
  72. title="登录日志(仅演示,操作后不生效)"
  73. :columns="columns"
  74. @refresh="onSearch"
  75. >
  76. <template #buttons>
  77. <el-popconfirm title="确定要删除所有日志数据吗?" @confirm="clearAll">
  78. <template #reference>
  79. <el-button type="danger" :icon="useRenderIcon(Delete)">
  80. 清空日志
  81. </el-button>
  82. </template>
  83. </el-popconfirm>
  84. </template>
  85. <template v-slot="{ size, dynamicColumns }">
  86. <div
  87. v-if="selectedNum > 0"
  88. v-motion-fade
  89. class="bg-[var(--el-fill-color-light)] w-full h-[46px] mb-2 pl-4 flex items-center"
  90. >
  91. <div class="flex-auto">
  92. <span
  93. style="font-size: var(--el-font-size-base)"
  94. class="text-[rgba(42,46,54,0.5)] dark:text-[rgba(220,220,242,0.5)]"
  95. >
  96. 已选 {{ selectedNum }} 项
  97. </span>
  98. <el-button type="primary" text @click="onSelectionCancel">
  99. 取消选择
  100. </el-button>
  101. </div>
  102. <el-popconfirm title="是否确认删除?" @confirm="onbatchDel">
  103. <template #reference>
  104. <el-button type="danger" text class="mr-1"> 批量删除 </el-button>
  105. </template>
  106. </el-popconfirm>
  107. </div>
  108. <pure-table
  109. ref="tableRef"
  110. row-key="id"
  111. align-whole="center"
  112. table-layout="auto"
  113. :loading="loading"
  114. :size="size"
  115. adaptive
  116. :adaptiveConfig="{ offsetBottom: 108 }"
  117. :data="dataList"
  118. :columns="dynamicColumns"
  119. :pagination="pagination"
  120. :paginationSmall="size === 'small' ? true : false"
  121. :header-cell-style="{
  122. background: 'var(--el-fill-color-light)',
  123. color: 'var(--el-text-color-primary)'
  124. }"
  125. @selection-change="handleSelectionChange"
  126. @page-size-change="handleSizeChange"
  127. @page-current-change="handleCurrentChange"
  128. />
  129. </template>
  130. </PureTableBar>
  131. </div>
  132. </template>
  133. <style scoped lang="scss">
  134. :deep(.el-dropdown-menu__item i) {
  135. margin: 0;
  136. }
  137. .main-content {
  138. margin: 24px 24px 0 !important;
  139. }
  140. .search-form {
  141. :deep(.el-form-item) {
  142. margin-bottom: 12px;
  143. }
  144. }
  145. </style>