index.vue 7.9 KB

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