index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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="['system: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="['system: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="['system: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="status">
  93. <template slot-scope="scope">
  94. <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="描述" align="center" prop="msg" />
  98. <el-table-column label="访问时间" align="center" prop="accessTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  99. <template slot-scope="scope">
  100. <span>{{ parseTime(scope.row.accessTime) }}</span>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination
  105. v-show="total>0"
  106. :total="total"
  107. :page.sync="queryParams.pageNum"
  108. :limit.sync="queryParams.pageSize"
  109. @pagination="getList"
  110. />
  111. </div>
  112. </template>
  113. <script>
  114. import { list, delLogininfor, cleanLogininfor } from "@/api/system/logininfor";
  115. export default {
  116. name: "Logininfor",
  117. dicts: ['sys_common_status'],
  118. data() {
  119. return {
  120. // 遮罩层
  121. loading: true,
  122. // 选中数组
  123. ids: [],
  124. // 非多个禁用
  125. multiple: true,
  126. // 显示搜索条件
  127. showSearch: true,
  128. // 总条数
  129. total: 0,
  130. // 表格数据
  131. list: [],
  132. // 日期范围
  133. dateRange: [],
  134. // 默认排序
  135. defaultSort: {prop: 'loginTime', order: 'descending'},
  136. // 查询参数
  137. queryParams: {
  138. pageNum: 1,
  139. pageSize: 10,
  140. ipaddr: undefined,
  141. userName: undefined,
  142. status: undefined
  143. }
  144. };
  145. },
  146. created() {
  147. this.getList();
  148. },
  149. methods: {
  150. /** 查询登录日志列表 */
  151. getList() {
  152. this.loading = true;
  153. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  154. this.list = response.rows;
  155. this.total = response.total;
  156. this.loading = false;
  157. }
  158. );
  159. },
  160. /** 搜索按钮操作 */
  161. handleQuery() {
  162. this.queryParams.pageNum = 1;
  163. this.getList();
  164. },
  165. /** 重置按钮操作 */
  166. resetQuery() {
  167. this.dateRange = [];
  168. this.resetForm("queryForm");
  169. this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
  170. this.handleQuery();
  171. },
  172. /** 多选框选中数据 */
  173. handleSelectionChange(selection) {
  174. this.ids = selection.map(item => item.infoId)
  175. this.multiple = !selection.length
  176. },
  177. /** 排序触发事件 */
  178. handleSortChange(column, prop, order) {
  179. this.queryParams.orderByColumn = column.prop;
  180. this.queryParams.isAsc = column.order;
  181. this.getList();
  182. },
  183. /** 删除按钮操作 */
  184. handleDelete(row) {
  185. const infoIds = row.infoId || this.ids;
  186. this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() {
  187. return delLogininfor(infoIds);
  188. }).then(() => {
  189. this.getList();
  190. this.$modal.msgSuccess("删除成功");
  191. }).catch(() => {});
  192. },
  193. /** 清空按钮操作 */
  194. handleClean() {
  195. this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() {
  196. return cleanLogininfor();
  197. }).then(() => {
  198. this.getList();
  199. this.$modal.msgSuccess("清空成功");
  200. }).catch(() => {});
  201. },
  202. /** 导出按钮操作 */
  203. handleExport() {
  204. this.download('system/logininfor/export', {
  205. ...this.queryParams
  206. }, `logininfor_${new Date().getTime()}.xlsx`)
  207. }
  208. }
  209. };
  210. </script>