index.vue 8.0 KB

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