index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="primary"
  78. plain
  79. icon="el-icon-unlock"
  80. size="mini"
  81. :disabled="single"
  82. @click="handleUnlock"
  83. v-hasPermi="['system:logininfor:unlock']"
  84. >解锁</el-button>
  85. </el-col>
  86. <el-col :span="1.5">
  87. <el-button
  88. type="warning"
  89. plain
  90. icon="el-icon-download"
  91. size="mini"
  92. @click="handleExport"
  93. v-hasPermi="['system:logininfor:export']"
  94. >导出</el-button>
  95. </el-col>
  96. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  97. </el-row>
  98. <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
  99. <el-table-column type="selection" width="55" align="center" />
  100. <el-table-column label="访问编号" align="center" prop="infoId" />
  101. <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
  102. <el-table-column label="地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
  103. <el-table-column label="登录状态" align="center" prop="status">
  104. <template slot-scope="scope">
  105. <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="描述" align="center" prop="msg" />
  109. <el-table-column label="访问时间" align="center" prop="accessTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
  110. <template slot-scope="scope">
  111. <span>{{ parseTime(scope.row.accessTime) }}</span>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. v-show="total>0"
  117. :total="total"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. </div>
  123. </template>
  124. <script>
  125. import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/system/logininfor";
  126. export default {
  127. name: "Logininfor",
  128. dicts: ['sys_common_status'],
  129. data() {
  130. return {
  131. // 遮罩层
  132. loading: true,
  133. // 选中数组
  134. ids: [],
  135. // 非单个禁用
  136. single: true,
  137. // 非多个禁用
  138. multiple: true,
  139. // 选择用户名
  140. selectName: "",
  141. // 显示搜索条件
  142. showSearch: true,
  143. // 总条数
  144. total: 0,
  145. // 表格数据
  146. list: [],
  147. // 日期范围
  148. dateRange: [],
  149. // 默认排序
  150. defaultSort: {prop: 'loginTime', order: 'descending'},
  151. // 查询参数
  152. queryParams: {
  153. pageNum: 1,
  154. pageSize: 10,
  155. ipaddr: undefined,
  156. userName: undefined,
  157. status: undefined
  158. }
  159. };
  160. },
  161. created() {
  162. this.getList();
  163. },
  164. methods: {
  165. /** 查询登录日志列表 */
  166. getList() {
  167. this.loading = true;
  168. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  169. this.list = response.rows;
  170. this.total = response.total;
  171. this.loading = false;
  172. }
  173. );
  174. },
  175. /** 搜索按钮操作 */
  176. handleQuery() {
  177. this.queryParams.pageNum = 1;
  178. this.getList();
  179. },
  180. /** 重置按钮操作 */
  181. resetQuery() {
  182. this.dateRange = [];
  183. this.resetForm("queryForm");
  184. this.queryParams.pageNum = 1;
  185. this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
  186. },
  187. /** 多选框选中数据 */
  188. handleSelectionChange(selection) {
  189. this.ids = selection.map(item => item.infoId)
  190. this.single = selection.length!=1
  191. this.multiple = !selection.length
  192. this.selectName = selection.map(item => item.userName);
  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.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() {
  204. return delLogininfor(infoIds);
  205. }).then(() => {
  206. this.getList();
  207. this.$modal.msgSuccess("删除成功");
  208. }).catch(() => {});
  209. },
  210. /** 清空按钮操作 */
  211. handleClean() {
  212. this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() {
  213. return cleanLogininfor();
  214. }).then(() => {
  215. this.getList();
  216. this.$modal.msgSuccess("清空成功");
  217. }).catch(() => {});
  218. },
  219. /** 解锁按钮操作 */
  220. handleUnlock() {
  221. const username = this.selectName;
  222. this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function() {
  223. return unlockLogininfor(username);
  224. }).then(() => {
  225. this.$modal.msgSuccess("用户" + username + "解锁成功");
  226. }).catch(() => {});
  227. },
  228. /** 导出按钮操作 */
  229. handleExport() {
  230. this.download('system/logininfor/export', {
  231. ...this.queryParams
  232. }, `logininfor_${new Date().getTime()}.xlsx`)
  233. }
  234. }
  235. };
  236. </script>