index.vue 8.0 KB

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