index.vue 8.1 KB

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