index.vue 7.0 KB

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