import { Component, OnInit } from '@angular/core'; import { HttpClientService } from '../../../services/http-client.service'; import { Router } from '@angular/router'; import { NzMessageService } from 'ng-zorro-antd'; @Component({ selector: 'app-operation-logs', templateUrl: './operation-logs.component.html', styleUrls: ['./operation-logs.component.scss'] }) export class OperationLogsComponent implements OnInit { collectionSize: any; public tableData: any = []; statusParamsTable: any = { //获取用户列表接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据 status: 1, } public search: any = { page_index: '1', page_size: '10', date_start: '', date_end: '', keyword: '', orgId: '', } logType: any = { 'LOGIN': '登录', 'LOGOUT': '退出', 'USER_UI_SET': '修改用户设置', 'USER_INFO_OPT': '增删改用户信息', }; optType: any = { 'ADD': '新增', 'UPDATE': '修改', 'DELETE': '删除', }; endOpen: boolean = false; startValue: Date = null; endValue: Date = null; constructor( private http: HttpClientService, ) { } ngOnInit() { this.queryTable(); } disabledStartDate = (startValue: Date): boolean => { if (!startValue || !this.endValue) { return false; } return startValue.getTime() >= this.endValue.getTime(); }; disabledEndDate = (endValue: Date): boolean => { if (!endValue || !this.startValue) { return false; } return endValue.getTime() <= this.startValue.getTime(); }; onStartChange(date: Date): void { this.startValue = date; this.search.date_start = this.changeDate(date) } onEndChange(date: Date): void { this.endValue = date; this.search.date_end = this.changeDate(date) } handleStartOpenChange(open: boolean): void { if (!open && this.startValue) { this.endOpen = true; } } handleEndOpenChange(open: boolean): void { this.endOpen = open; } //日期时间处理 changeDate(time) { var date = new Date(time); var Y = date.getFullYear() + ''; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + ''; var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ''; var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ''; var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ''; var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() + ''; return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s; } //重置,重置搜索条件 reset() { this.search.page_index = 1; this.search.page_size = 10; this.search.keyword = ''; this.search.date_start = ''; this.startValue = null; this.search.date_end = ''; this.endValue = null; } //获取列表 queryTable(): void { this.statusParamsTable.status = 1; this.tableData = []; this.http.get('/sysapi/oplog/list', this.search).subscribe((json) => { if (json.is_success) { this.tableData = json.body.recordList; this.collectionSize = json.body.recordCount; if (json.body.recordList && json.body.recordList.length > 0) { this.statusParamsTable.status = 3; } else { this.statusParamsTable.status = 4; } } else { this.statusParamsTable.status = 0; } }) } //翻页 pageChange(event) { this.search.page_index = event; this.queryTable(); } }