春风项目四线(合箱线、总装线)
wujian
2024-01-31 c74dcb8dca7b9e3eded0d20299f19a26a6b70974
提交 | 用户 | 时间
fd2207 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 HH:mm:ss"
42           type="daterange"
43           range-separator="-"
44           start-placeholder="开始日期"
45           end-placeholder="结束日期"
46           :default-time="['00:00:00', '23:59:59']"
47         ></el-date-picker>
48       </el-form-item>
49       <el-form-item>
50         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
51         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
52       </el-form-item>
53     </el-form>
54
55     <el-row :gutter="10" class="mb8">
56       <el-col :span="1.5">
57         <el-button
58           type="danger"
59           plain
60           icon="el-icon-delete"
61           size="mini"
62           :disabled="multiple"
63           @click="handleDelete"
64           v-hasPermi="['monitor:logininfor:remove']"
65         >删除</el-button>
66       </el-col>
67       <el-col :span="1.5">
68         <el-button
69           type="danger"
70           plain
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="primary"
80           plain
81           icon="el-icon-unlock"
82           size="mini"
83           :disabled="single"
84           @click="handleUnlock"
85           v-hasPermi="['monitor:logininfor:unlock']"
86         >解锁</el-button>
87       </el-col>
88       <el-col :span="1.5">
89         <el-button
90           type="warning"
91           plain
92           icon="el-icon-download"
93           size="mini"
94           @click="handleExport"
95           v-hasPermi="['monitor:logininfor:export']"
96         >导出</el-button>
97       </el-col>
98       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
99     </el-row>
100
101     <el-table ref="tables" v-loading="loading" :data="list" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="handleSortChange">
102       <el-table-column type="selection" width="55" align="center" />
103       <el-table-column label="访问编号" align="center" prop="infoId" />
104       <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" sortable="custom" :sort-orders="['descending', 'ascending']" />
105       <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
106       <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
107       <el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" />
108       <el-table-column label="操作系统" align="center" prop="os" />
109       <el-table-column label="登录状态" align="center" prop="status">
110         <template slot-scope="scope">
111           <dict-tag :options="dict.type.sys_common_status" :value="scope.row.status"/>
112         </template>
113       </el-table-column>
114       <el-table-column label="操作信息" align="center" prop="msg" :show-overflow-tooltip="true" />
115       <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
116         <template slot-scope="scope">
117           <span>{{ parseTime(scope.row.loginTime) }}</span>
118         </template>
119       </el-table-column>
120     </el-table>
121
122     <pagination
123       v-show="total>0"
124       :total="total"
125       :page.sync="queryParams.pageNum"
126       :limit.sync="queryParams.pageSize"
127       @pagination="getList"
128     />
129   </div>
130 </template>
131
132 <script>
133 import { list, delLogininfor, cleanLogininfor, unlockLogininfor } from "@/api/monitor/logininfor";
134
135 export default {
136   name: "Logininfor",
137   dicts: ['sys_common_status'],
138   data() {
139     return {
140       // 遮罩层
141       loading: true,
142       // 选中数组
143       ids: [],
144       // 非单个禁用
145       single: true,
146       // 非多个禁用
147       multiple: true,
148       // 选择用户名
149       selectName: "",
150       // 显示搜索条件
151       showSearch: true,
152       // 总条数
153       total: 0,
154       // 表格数据
155       list: [],
156       // 日期范围
157       dateRange: [],
158       // 默认排序
159       defaultSort: {prop: 'loginTime', order: 'descending'},
160       // 查询参数
161       queryParams: {
162         pageNum: 1,
163         pageSize: 10,
164         ipaddr: undefined,
165         userName: undefined,
166         status: undefined
167       }
168     };
169   },
170   created() {
171     this.getList();
172   },
173   methods: {
174     /** 查询登录日志列表 */
175     getList() {
176       this.loading = true;
177       list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
178           this.list = response.rows;
179           this.total = response.total;
180           this.loading = false;
181         }
182       );
183     },
184     /** 搜索按钮操作 */
185     handleQuery() {
186       this.queryParams.pageNum = 1;
187       this.getList();
188     },
189     /** 重置按钮操作 */
190     resetQuery() {
191       this.dateRange = [];
192       this.resetForm("queryForm");
193       this.queryParams.pageNum = 1;
194       this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
195     },
196     /** 多选框选中数据 */
197     handleSelectionChange(selection) {
198       this.ids = selection.map(item => item.infoId)
199       this.single = selection.length!=1
200       this.multiple = !selection.length
201       this.selectName = selection.map(item => item.userName);
202     },
203     /** 排序触发事件 */
204     handleSortChange(column, prop, order) {
205       this.queryParams.orderByColumn = column.prop;
206       this.queryParams.isAsc = column.order;
207       this.getList();
208     },
209     /** 删除按钮操作 */
210     handleDelete(row) {
211       const infoIds = row.infoId || this.ids;
212       this.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?').then(function() {
213         return delLogininfor(infoIds);
214       }).then(() => {
215         this.getList();
216         this.$modal.msgSuccess("删除成功");
217       }).catch(() => {});
218     },
219     /** 清空按钮操作 */
220     handleClean() {
221       this.$modal.confirm('是否确认清空所有登录日志数据项?').then(function() {
222         return cleanLogininfor();
223       }).then(() => {
224         this.getList();
225         this.$modal.msgSuccess("清空成功");
226       }).catch(() => {});
227     },
228     /** 解锁按钮操作 */
229     handleUnlock() {
230       const username = this.selectName;
231       this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function() {
232         return unlockLogininfor(username);
233       }).then(() => {
234         this.$modal.msgSuccess("用户" + username + "解锁成功");
235       }).catch(() => {});
236     },
237     /** 导出按钮操作 */
238     handleExport() {
239       this.download('monitor/logininfor/export', {
240         ...this.queryParams
241       }, `logininfor_${new Date().getTime()}.xlsx`)
242     }
243   }
244 };
245 </script>
246