index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. >删除
  68. </el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="danger"
  73. plain
  74. icon="el-icon-delete"
  75. size="mini"
  76. @click="handleClean"
  77. v-hasPermi="['monitor:logininfor:remove']"
  78. >清空
  79. </el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="warning"
  84. plain
  85. icon="el-icon-download"
  86. size="mini"
  87. :loading="exportLoading"
  88. @click="handleExport"
  89. v-hasPermi="['monitor:logininfor:export']"
  90. >导出
  91. </el-button>
  92. </el-col>
  93. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  94. </el-row>
  95. <el-table ref="tables" :header-cell-style="{ background: 'linear-gradient(white, #ccebf9)'}" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  96. <el-table-column type="selection" width="55" align="center"/>
  97. <el-table-column label="访问编号" align="center" prop="infoId"/>
  98. <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']"/>
  99. <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true"/>
  100. <!-- <el-table-column label="登录地点" align="center" prop="loginLocation" :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="os"/>
  103. <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat"/>
  104. <el-table-column label="操作信息" align="center" prop="msg"/>
  105. <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  106. <template slot-scope="scope">
  107. <span>{{ parseTime(scope.row.loginTime) }}</span>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <pagination
  112. v-show="total>0"
  113. :total="total"
  114. :page.sync="queryParams.pageNum"
  115. :limit.sync="queryParams.pageSize"
  116. @pagination="getList"
  117. />
  118. </div>
  119. </template>
  120. <script>
  121. import {cleanLogininfor, delLogininfor, exportLogininfor, list} from "@/api/monitor/logininfor";
  122. export default {
  123. name: "Logininfor",
  124. data() {
  125. return {
  126. // 遮罩层
  127. loading: true,
  128. // 导出遮罩层
  129. exportLoading: false,
  130. // 选中数组
  131. ids: [],
  132. // 非多个禁用
  133. multiple: true,
  134. // 显示搜索条件
  135. showSearch: true,
  136. // 总条数
  137. total: 0,
  138. // 表格数据
  139. list: [],
  140. // 状态数据字典
  141. statusOptions: [],
  142. // 日期范围
  143. dateRange: [],
  144. // 默认排序
  145. defaultSort: {prop: 'loginTime', order: 'descending'},
  146. // 查询参数
  147. queryParams: {
  148. pageNum: 1,
  149. pageSize: 10,
  150. ipaddr: undefined,
  151. userName: undefined,
  152. status: undefined
  153. }
  154. };
  155. },
  156. created() {
  157. this.getList();
  158. this.getDicts("sys_common_status").then(response => {
  159. this.statusOptions = response.data;
  160. });
  161. },
  162. methods: {
  163. /** 查询登录日志列表 */
  164. getList() {
  165. this.loading = true;
  166. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  167. this.list = response.rows;
  168. this.total = response.total;
  169. this.loading = false;
  170. }
  171. );
  172. },
  173. // 登录状态字典翻译
  174. statusFormat(row, column) {
  175. return this.selectDictLabel(this.statusOptions, row.status);
  176. },
  177. /** 搜索按钮操作 */
  178. handleQuery() {
  179. this.queryParams.pageNum = 1;
  180. this.getList();
  181. },
  182. /** 重置按钮操作 */
  183. resetQuery() {
  184. this.dateRange = [];
  185. this.resetForm("queryForm");
  186. this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
  187. this.handleQuery();
  188. },
  189. /** 多选框选中数据 */
  190. handleSelectionChange(selection) {
  191. this.ids = selection.map(item => item.infoId)
  192. this.multiple = !selection.length
  193. },
  194. /** 排序触发事件 */
  195. handleSortChange(column, prop, order) {
  196. this.queryParams.orderByColumn = column.prop;
  197. this.queryParams.isAsc = column.order;
  198. this.getList();
  199. },
  200. /** 删除按钮操作 */
  201. handleDelete(row) {
  202. const infoIds = row.infoId || this.ids;
  203. this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", {
  204. confirmButtonText: "确定",
  205. cancelButtonText: "取消",
  206. type: "warning"
  207. }).then(function () {
  208. return delLogininfor(infoIds);
  209. }).then(() => {
  210. this.getList();
  211. this.msgSuccess("删除成功");
  212. }).catch(() => {
  213. });
  214. },
  215. /** 清空按钮操作 */
  216. handleClean() {
  217. this.$confirm('是否确认清空所有登录日志数据项?', "警告", {
  218. confirmButtonText: "确定",
  219. cancelButtonText: "取消",
  220. type: "warning"
  221. }).then(function () {
  222. return cleanLogininfor();
  223. }).then(() => {
  224. this.getList();
  225. this.msgSuccess("清空成功");
  226. }).catch(() => {
  227. });
  228. },
  229. /** 导出按钮操作 */
  230. handleExport() {
  231. const queryParams = this.queryParams;
  232. this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
  233. confirmButtonText: "确定",
  234. cancelButtonText: "取消",
  235. type: "warning"
  236. }).then(() => {
  237. this.exportLoading = true;
  238. return exportLogininfor(queryParams);
  239. }).then(response => {
  240. this.download(response.msg);
  241. this.exportLoading = false;
  242. }).catch(() => {
  243. });
  244. }
  245. }
  246. };
  247. </script>