index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" 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. icon="el-icon-delete"
  62. size="mini"
  63. :disabled="multiple"
  64. @click="handleDelete"
  65. v-hasPermi="['monitor:logininfor:remove']"
  66. >删除</el-button>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. icon="el-icon-delete"
  72. size="mini"
  73. @click="handleClean"
  74. v-hasPermi="['monitor:logininfor:remove']"
  75. >清空</el-button>
  76. </el-col>
  77. <el-col :span="1.5">
  78. <el-button
  79. type="warning"
  80. icon="el-icon-download"
  81. size="mini"
  82. @click="handleExport"
  83. v-hasPermi="['system:logininfor:export']"
  84. >导出</el-button>
  85. </el-col>
  86. </el-row>
  87. <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
  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" />
  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" />
  94. <el-table-column label="操作系统" align="center" prop="os" />
  95. <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" />
  96. <el-table-column label="操作信息" align="center" prop="msg" />
  97. <el-table-column label="登录日期" align="center" prop="loginTime" width="180">
  98. <template slot-scope="scope">
  99. <span>{{ parseTime(scope.row.loginTime) }}</span>
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <pagination
  104. v-show="total>0"
  105. :total="total"
  106. :page.sync="queryParams.pageNum"
  107. :limit.sync="queryParams.pageSize"
  108. @pagination="getList"
  109. />
  110. </div>
  111. </template>
  112. <script>
  113. import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor";
  114. export default {
  115. name: "Logininfor",
  116. data() {
  117. return {
  118. // 遮罩层
  119. loading: true,
  120. // 选中数组
  121. ids: [],
  122. // 非多个禁用
  123. multiple: true,
  124. // 总条数
  125. total: 0,
  126. // 表格数据
  127. list: [],
  128. // 状态数据字典
  129. statusOptions: [],
  130. // 日期范围
  131. dateRange: [],
  132. // 查询参数
  133. queryParams: {
  134. pageNum: 1,
  135. pageSize: 10,
  136. ipaddr: undefined,
  137. userName: undefined,
  138. status: undefined
  139. }
  140. };
  141. },
  142. created() {
  143. this.getList();
  144. this.getDicts("sys_common_status").then(response => {
  145. this.statusOptions = response.data;
  146. });
  147. },
  148. methods: {
  149. /** 查询登录日志列表 */
  150. getList() {
  151. this.loading = true;
  152. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  153. this.list = response.rows;
  154. this.total = response.total;
  155. this.loading = false;
  156. }
  157. );
  158. },
  159. // 登录状态字典翻译
  160. statusFormat(row, column) {
  161. return this.selectDictLabel(this.statusOptions, row.status);
  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.handleQuery();
  173. },
  174. // 多选框选中数据
  175. handleSelectionChange(selection) {
  176. this.ids = selection.map(item => item.infoId)
  177. this.multiple = !selection.length
  178. },
  179. /** 删除按钮操作 */
  180. handleDelete(row) {
  181. const infoIds = row.infoId || this.ids;
  182. this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", {
  183. confirmButtonText: "确定",
  184. cancelButtonText: "取消",
  185. type: "warning"
  186. }).then(function() {
  187. return delLogininfor(infoIds);
  188. }).then(() => {
  189. this.getList();
  190. this.msgSuccess("删除成功");
  191. }).catch(function() {});
  192. },
  193. /** 清空按钮操作 */
  194. handleClean() {
  195. this.$confirm('是否确认清空所有登录日志数据项?', "警告", {
  196. confirmButtonText: "确定",
  197. cancelButtonText: "取消",
  198. type: "warning"
  199. }).then(function() {
  200. return cleanLogininfor();
  201. }).then(() => {
  202. this.getList();
  203. this.msgSuccess("清空成功");
  204. }).catch(function() {});
  205. },
  206. /** 导出按钮操作 */
  207. handleExport() {
  208. const queryParams = this.queryParams;
  209. this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
  210. confirmButtonText: "确定",
  211. cancelButtonText: "取消",
  212. type: "warning"
  213. }).then(function() {
  214. return exportLogininfor(queryParams);
  215. }).then(response => {
  216. this.download(response.msg);
  217. }).catch(function() {});
  218. }
  219. }
  220. };
  221. </script>