Files
bbq/src/app/routes/sys-setting/components/user-logs/user-logs.component.ts
Taric Xin b7d054ab18 edit
2021-12-28 10:02:41 +08:00

129 lines
3.2 KiB
TypeScript

import { Component, OnInit, ViewChild } from '@angular/core';
import { STComponent, STColumn, STChange, STRequestOptions } from '@delon/abc/st';
import { SFComponent, SFDateWidgetSchema, SFSchema } from '@delon/form';
import { dateTimePickerUtil } from '@delon/util';
import { NzModalService } from 'ng-zorro-antd/modal';
import { SFItemDateWidget } from 'src/app/shared/widget/sl-form-item-date/sl-form-item-date.widget';
import { SystemService } from '../../services/system.service';
@Component({
selector: 'app-user-logs',
templateUrl: './user-logs.component.html',
styleUrls: ['./user-logs.component.less']
})
export class UserLogsComponent implements OnInit {
@ViewChild('st', { static: true })
st!: STComponent;
@ViewChild('sf', { static: false })
sf!: SFComponent;
url = `/rule?_allow_anonymous=true`;
searchSchema: SFSchema = {
properties: {
expand: {
type: 'boolean',
ui: {
hidden: true
}
},
roleName: {
type: 'string',
title: '登录端口',
ui: { placeholder: '请输入' }
},
loginType: {
type: 'string',
title: '登录方式',
enum: [
{ label: '全部', value: null },
{ label: 'PC', value: '1' },
{ label: 'APP', value: '2' },
{ label: '小程序', value: '3' }
],
ui: {
widget: 'select',
placeholder: '请选择'
},
default: null
},
address: {
type: 'string',
title: '位置',
ui: {
placeholder: '请输入'
}
},
terminalIp: {
type: 'string',
title: 'ip',
ui: {
placeholder: '请输入',
visibleIf: {
expand: (value: boolean) => value
}
}
},
time: {
title: '登录时间',
type: 'string',
ui: {
widget: 'sl-from-to-search',
format: 'yyyy-MM-dd HH:mm:ss',
placeholder: '请选择',
nzShowTime: true,
visibleIf: {
expand: (value: boolean) => value
}
} as SFDateWidgetSchema
}
}
};
columns: STColumn[] = [
{ title: '登录时间', index: 'createTime', type: 'date' },
{ title: '登录端口', index: 'roleName' },
{ title: '姓名', index: 'userName' },
{ title: '登录方式', index: 'loginType', enum: { '1': 'PC', '2': 'APP', '3': '小程序' }, type: 'enum' },
{ title: '位置', index: 'address' },
{ title: 'ip', index: 'terminalIp' }
];
_$expand = false;
constructor(public service: SystemService) {}
ngOnInit(): void {}
beforeReq = (requestOptions: STRequestOptions) => {
if (this.sf) {
Object.assign(requestOptions.body, {
...this.sf.value,
time: {
start: this.sf.value.time?.[0] || null,
end: this.sf.value.time?.[1] || null
}
});
}
return requestOptions;
};
roleAction(item?: any) {}
/**
* 重置表单
*/
resetSF() {
this.sf.reset();
this._$expand = false;
}
/**
* 伸缩查询条件
*/
expandToggle() {
this._$expand = !this._$expand;
this.sf?.setValue('/expand', this._$expand);
}
}