index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. @click="handleExport"
  86. v-hasPermi="['system:logininfor:export']"
  87. >导出</el-button>
  88. </el-col>
  89. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  90. </el-row>
  91. <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
  92. <el-table-column type="selection" width="55" align="center" />
  93. <el-table-column label="访问编号" align="center" prop="infoId" />
  94. <el-table-column label="用户名称" align="center" prop="userName" />
  95. <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
  96. <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
  97. <el-table-column label="浏览器" align="center" prop="browser" />
  98. <el-table-column label="操作系统" align="center" prop="os" />
  99. <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" />
  100. <el-table-column label="操作信息" align="center" prop="msg" />
  101. <el-table-column label="登录日期" align="center" prop="loginTime" 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, exportLogininfor } from "@/api/monitor/logininfor";
  118. export default {
  119. name: "Logininfor",
  120. data() {
  121. return {
  122. // 遮罩层
  123. loading: true,
  124. // 选中数组
  125. ids: [],
  126. // 非多个禁用
  127. multiple: true,
  128. // 显示搜索条件
  129. showSearch: true,
  130. // 总条数
  131. total: 0,
  132. // 表格数据
  133. list: [],
  134. // 状态数据字典
  135. statusOptions: [],
  136. // 日期范围
  137. dateRange: [],
  138. // 查询参数
  139. queryParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. ipaddr: undefined,
  143. userName: undefined,
  144. status: undefined
  145. }
  146. };
  147. },
  148. created() {
  149. this.getList();
  150. this.getDicts("sys_common_status").then(response => {
  151. this.statusOptions = response.data;
  152. });
  153. },
  154. methods: {
  155. /** 查询登录日志列表 */
  156. getList() {
  157. this.loading = true;
  158. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  159. this.list = response.rows;
  160. this.total = response.total;
  161. this.loading = false;
  162. }
  163. );
  164. },
  165. // 登录状态字典翻译
  166. statusFormat(row, column) {
  167. return this.selectDictLabel(this.statusOptions, row.status);
  168. },
  169. /** 搜索按钮操作 */
  170. handleQuery() {
  171. this.queryParams.pageNum = 1;
  172. this.getList();
  173. },
  174. /** 重置按钮操作 */
  175. resetQuery() {
  176. this.dateRange = [];
  177. this.resetForm("queryForm");
  178. this.handleQuery();
  179. },
  180. // 多选框选中数据
  181. handleSelectionChange(selection) {
  182. this.ids = selection.map(item => item.infoId)
  183. this.multiple = !selection.length
  184. },
  185. /** 删除按钮操作 */
  186. handleDelete(row) {
  187. const infoIds = row.infoId || this.ids;
  188. this.$confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?', "警告", {
  189. confirmButtonText: "确定",
  190. cancelButtonText: "取消",
  191. type: "warning"
  192. }).then(function() {
  193. return delLogininfor(infoIds);
  194. }).then(() => {
  195. this.getList();
  196. this.msgSuccess("删除成功");
  197. })
  198. },
  199. /** 清空按钮操作 */
  200. handleClean() {
  201. this.$confirm('是否确认清空所有登录日志数据项?', "警告", {
  202. confirmButtonText: "确定",
  203. cancelButtonText: "取消",
  204. type: "warning"
  205. }).then(function() {
  206. return cleanLogininfor();
  207. }).then(() => {
  208. this.getList();
  209. this.msgSuccess("清空成功");
  210. })
  211. },
  212. /** 导出按钮操作 */
  213. handleExport() {
  214. const queryParams = this.queryParams;
  215. this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning"
  219. }).then(function() {
  220. return exportLogininfor(queryParams);
  221. }).then(response => {
  222. this.download(response.msg);
  223. })
  224. }
  225. }
  226. };
  227. </script>