index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="登录地址" prop="ipaddr">
  5. <el-input
  6. v-model="queryParams.ipaddr"
  7. placeholder="请输入登录地址"
  8. clearable
  9. style="width: 240px;"
  10. @keyup.enter="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="用户名称" prop="userName">
  14. <el-input
  15. v-model="queryParams.userName"
  16. placeholder="请输入用户名称"
  17. clearable
  18. style="width: 240px;"
  19. @keyup.enter="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="status">
  23. <el-select
  24. v-model="queryParams.status"
  25. placeholder="登录状态"
  26. clearable
  27. style="width: 240px"
  28. >
  29. <el-option
  30. v-for="dict in sys_common_status"
  31. :key="dict.value"
  32. :label="dict.label"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="登录时间" style="width: 308px">
  38. <el-date-picker
  39. v-model="dateRange"
  40. value-format="YYYY-MM-DD"
  41. type="daterange"
  42. range-separator="-"
  43. start-placeholder="开始日期"
  44. end-placeholder="结束日期"
  45. ></el-date-picker>
  46. </el-form-item>
  47. <el-form-item>
  48. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  49. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  50. </el-form-item>
  51. </el-form>
  52. <el-row :gutter="10" class="mb8">
  53. <el-col :span="1.5">
  54. <el-button
  55. type="danger"
  56. plain
  57. icon="Delete"
  58. :disabled="multiple"
  59. @click="handleDelete"
  60. v-hasPermi="['monitor:logininfor:remove']"
  61. >删除</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="danger"
  66. plain
  67. icon="Delete"
  68. @click="handleClean"
  69. v-hasPermi="['monitor:logininfor:remove']"
  70. >清空</el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="primary"
  75. plain
  76. icon="Unlock"
  77. :disabled="single"
  78. @click="handleUnlock"
  79. v-hasPermi="['monitor:logininfor:unlock']"
  80. >解锁</el-button>
  81. </el-col>
  82. <el-col :span="1.5">
  83. <el-button
  84. type="warning"
  85. plain
  86. icon="Download"
  87. @click="handleExport"
  88. v-hasPermi="['monitor:logininfor:export']"
  89. >导出</el-button>
  90. </el-col>
  91. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  92. </el-row>
  93. <el-table ref="logininforRef" v-loading="loading" :data="logininforList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  94. <el-table-column type="selection" width="55" align="center" />
  95. <el-table-column label="访问编号" align="center" prop="infoId" />
  96. <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
  97. <el-table-column label="地址" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
  98. <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
  99. <el-table-column label="操作系统" align="center" prop="os" :show-overflow-tooltip="true" />
  100. <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" />
  101. <el-table-column label="登录状态" align="center" prop="status">
  102. <template #default="scope">
  103. <dict-tag :options="sys_common_status" :value="scope.row.status" />
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="描述" align="center" prop="msg" />
  107. <el-table-column label="访问时间" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  108. <template #default="scope">
  109. <span>{{ parseTime(scope.row.loginTime) }}</span>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <pagination
  114. v-show="total > 0"
  115. :total="total"
  116. v-model:page="queryParams.pageNum"
  117. v-model:limit="queryParams.pageSize"
  118. @pagination="getList"
  119. />
  120. </div>
  121. </template>
  122. <script setup name="Logininfor">
  123. import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor";
  124. const { proxy } = getCurrentInstance();
  125. const { sys_common_status } = proxy.useDict("sys_common_status");
  126. const logininforList = ref([]);
  127. const loading = ref(true);
  128. const showSearch = ref(true);
  129. const ids = ref([]);
  130. const single = ref(true);
  131. const multiple = ref(true);
  132. const selectName = ref("");
  133. const total = ref(0);
  134. const dateRange = ref([]);
  135. const defaultSort = ref({ prop: "loginTime", order: "descending" });
  136. // 查询参数
  137. const queryParams = ref({
  138. pageNum: 1,
  139. pageSize: 10,
  140. ipaddr: undefined,
  141. userName: undefined,
  142. status: undefined,
  143. orderByColumn: undefined,
  144. isAsc: undefined
  145. });
  146. /** 查询登录日志列表 */
  147. function getList() {
  148. loading.value = true;
  149. list(proxy.addDateRange(queryParams.value, dateRange.value)).then(response => {
  150. logininforList.value = response.rows;
  151. total.value = response.total;
  152. loading.value = false;
  153. });
  154. }
  155. /** 搜索按钮操作 */
  156. function handleQuery() {
  157. queryParams.value.pageNum = 1;
  158. getList();
  159. }
  160. /** 重置按钮操作 */
  161. function resetQuery() {
  162. dateRange.value = [];
  163. proxy.resetForm("queryRef");
  164. proxy.$refs["logininforRef"].sort(defaultSort.value.prop, defaultSort.value.order);
  165. handleQuery();
  166. }
  167. /** 多选框选中数据 */
  168. function handleSelectionChange(selection) {
  169. ids.value = selection.map(item => item.infoId);
  170. multiple.value = !selection.length;
  171. single.value = selection.length != 1;
  172. selectName.value = selection.map(item => item.userName);
  173. }
  174. /** 排序触发事件 */
  175. function handleSortChange(column, prop, order) {
  176. queryParams.value.orderByColumn = column.prop;
  177. queryParams.value.isAsc = column.order;
  178. getList();
  179. }
  180. /** 删除按钮操作 */
  181. function handleDelete(row) {
  182. const infoIds = row.infoId || ids.value;
  183. proxy.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function () {
  184. return delLogininfor(infoIds);
  185. }).then(() => {
  186. getList();
  187. proxy.$modal.msgSuccess("删除成功");
  188. }).catch(() => {});
  189. }
  190. /** 清空按钮操作 */
  191. function handleClean() {
  192. proxy.$modal.confirm("是否确认清空所有登录日志数据项?").then(function () {
  193. return cleanLogininfor();
  194. }).then(() => {
  195. getList();
  196. proxy.$modal.msgSuccess("清空成功");
  197. }).catch(() => {});
  198. }
  199. /** 解锁按钮操作 */
  200. function handleUnlock() {
  201. const username = selectName.value;
  202. proxy.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function () {
  203. return unlockLogininfor(username);
  204. }).then(() => {
  205. proxy.$modal.msgSuccess("用户" + username + "解锁成功");
  206. }).catch(() => {});
  207. }
  208. /** 导出按钮操作 */
  209. function handleExport() {
  210. proxy.download("monitor/logininfor/export", {
  211. ...queryParams.value,
  212. }, `config_${new Date().getTime()}.xlsx`);
  213. }
  214. getList();
  215. </script>