update 系统功能列表全部加上列宽
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Alert, Button, Card, Descriptions, Form, Popconfirm, Input, message as Message, Select, DatePicker } from 'antd'
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Popconfirm,
|
||||
Input,
|
||||
message as Message,
|
||||
Select,
|
||||
DatePicker,
|
||||
} from 'antd'
|
||||
import { Auth, Container, QueryTable } from 'components'
|
||||
import { api } from 'common/api'
|
||||
import { toCamelCase } from 'util/format'
|
||||
@@ -7,17 +18,17 @@ import { isEqual } from 'lodash'
|
||||
import getDictData from 'util/dic'
|
||||
import moment from 'moment'
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { RangePicker } = DatePicker
|
||||
|
||||
const apiAction = {
|
||||
page: api.sysVisLogPage,
|
||||
delete: api.sysVisLogDelete
|
||||
delete: api.sysVisLogDelete,
|
||||
}
|
||||
export default class index extends Component {
|
||||
state = {
|
||||
codes: {
|
||||
visType: []
|
||||
}
|
||||
visType: [],
|
||||
},
|
||||
}
|
||||
// 表格实例
|
||||
table = React.createRef()
|
||||
@@ -26,38 +37,54 @@ export default class index extends Component {
|
||||
{
|
||||
title: '日志名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: '访问类型',
|
||||
dataIndex: 'visType',
|
||||
render: text => (<>{this.bindCodeValue(text, 'vis_type')}</>),
|
||||
width: 120,
|
||||
render: text => <>{this.bindCodeValue(text, 'vis_type')}</>,
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: '是否成功',
|
||||
dataIndex: 'success',
|
||||
render: text => (<> {text ? '是' : '否'}</>),
|
||||
width: 120,
|
||||
render: text => (
|
||||
<>
|
||||
{text ? (
|
||||
<span className="text-success">是</span>
|
||||
) : (
|
||||
<span className="text-error">否</span>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: 'ip',
|
||||
dataIndex: 'ip',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: '浏览器',
|
||||
dataIndex: 'browser',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: '访问时间',
|
||||
dataIndex: 'visTime',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
defaultSortOrder: 'descend',
|
||||
},
|
||||
{
|
||||
title: '访问人',
|
||||
dataIndex: 'account',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
},
|
||||
]
|
||||
@@ -66,9 +93,9 @@ export default class index extends Component {
|
||||
* 阻止外部组件引发的渲染,提升性能
|
||||
* 可自行添加渲染条件
|
||||
* [必要]
|
||||
* @param {*} props
|
||||
* @param {*} state
|
||||
* @returns
|
||||
* @param {*} props
|
||||
* @param {*} state
|
||||
* @returns
|
||||
*/
|
||||
shouldComponentUpdate(props, state) {
|
||||
return !isEqual(this.state, state)
|
||||
@@ -81,26 +108,29 @@ export default class index extends Component {
|
||||
componentDidMount() {
|
||||
this.table.current.onLoading()
|
||||
getDictData('vis_type').then(res => {
|
||||
this.setState({
|
||||
codes: res
|
||||
}, () => {
|
||||
this.table.current.onLoadData()
|
||||
})
|
||||
this.setState(
|
||||
{
|
||||
codes: res,
|
||||
},
|
||||
() => {
|
||||
this.table.current.onLoadData()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用加载数据接口,可在调用前对query进行处理
|
||||
* [异步,必要]
|
||||
* @param {*} params
|
||||
* @param {*} query
|
||||
* @returns
|
||||
* @param {*} params
|
||||
* @param {*} query
|
||||
* @returns
|
||||
*/
|
||||
loadData = async (params, query) => {
|
||||
if (query.dates && query.dates.length) {
|
||||
query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss');
|
||||
query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss');
|
||||
delete query.dates;
|
||||
query.searchBeginTime = moment(query.dates[0]).format('YYYY-MM-DD HH:mm:ss')
|
||||
query.searchEndTime = moment(query.dates[1]).format('YYYY-MM-DD HH:mm:ss')
|
||||
delete query.dates
|
||||
}
|
||||
const { data } = await apiAction.page({
|
||||
...params,
|
||||
@@ -109,16 +139,16 @@ export default class index extends Component {
|
||||
return data
|
||||
}
|
||||
/**
|
||||
* 绑定字典数据
|
||||
* @param {*} code
|
||||
* @param {*} name
|
||||
* @returns
|
||||
*/
|
||||
* 绑定字典数据
|
||||
* @param {*} code
|
||||
* @param {*} name
|
||||
* @returns
|
||||
*/
|
||||
bindCodeValue(code, name) {
|
||||
name = toCamelCase(name)
|
||||
const codes = this.state.codes[name]
|
||||
if (codes) {
|
||||
const c = codes.find((p) => +p.code === code)
|
||||
const c = codes.find(p => +p.code === code)
|
||||
if (c) {
|
||||
return c.value
|
||||
}
|
||||
@@ -129,8 +159,8 @@ export default class index extends Component {
|
||||
/**
|
||||
* 对表格上的操作进行统一处理
|
||||
* [异步]
|
||||
* @param {*} action
|
||||
* @param {*} successMessage
|
||||
* @param {*} action
|
||||
* @param {*} successMessage
|
||||
*/
|
||||
async onAction(action, successMessage) {
|
||||
this.table.current.onLoading()
|
||||
@@ -144,17 +174,18 @@ export default class index extends Component {
|
||||
}
|
||||
|
||||
onVisLogClear() {
|
||||
this.onAction(
|
||||
apiAction.delete(),
|
||||
'清空成功'
|
||||
)
|
||||
this.onAction(apiAction.delete(), '清空成功')
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Container mode="fluid">
|
||||
<br />
|
||||
<Alert closable type="error" message="页面刷新的时候也会有保存登录日志,但是没有ip显示" />
|
||||
<Alert
|
||||
closable
|
||||
type="error"
|
||||
message="页面刷新的时候也会有保存登录日志,但是没有ip显示"
|
||||
/>
|
||||
<br />
|
||||
<Card bordered={false}>
|
||||
<QueryTable
|
||||
@@ -168,43 +199,37 @@ export default class index extends Component {
|
||||
<Input autoComplete="off" placeholder="请输入日志名称" />
|
||||
</Form.Item>
|
||||
<Form.Item label="访问类型" name="visType">
|
||||
<Select placeholder="请选择访问类型"
|
||||
<Select
|
||||
placeholder="请选择访问类型"
|
||||
allow-clear
|
||||
style={{ width: '170px' }}
|
||||
>
|
||||
{
|
||||
this.state.codes.visType.map(item => {
|
||||
return <Select.Option
|
||||
key={item.code}
|
||||
value={+item.code}
|
||||
>{item.value}</Select.Option>
|
||||
})
|
||||
}
|
||||
{this.state.codes.visType.map(item => {
|
||||
return (
|
||||
<Select.Option key={item.code} value={+item.code}>
|
||||
{item.value}
|
||||
</Select.Option>
|
||||
)
|
||||
})}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="是否成功" name="success">
|
||||
<Select placeholder="请选择是否成功" style={{ width: '170px' }}>
|
||||
<Select.Option
|
||||
key='true'
|
||||
>
|
||||
是</Select.Option>
|
||||
<Select.Option
|
||||
key='false'
|
||||
>
|
||||
否</Select.Option>
|
||||
<Select.Option key="true">是</Select.Option>
|
||||
<Select.Option key="false">否</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="访问时间" name="dates">
|
||||
<RangePicker
|
||||
showTime={
|
||||
{
|
||||
hideDisabledOptions: true,
|
||||
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')]
|
||||
}
|
||||
}
|
||||
showTime={{
|
||||
hideDisabledOptions: true,
|
||||
defaultValue: [
|
||||
moment('00:00:00', 'HH:mm:ss'),
|
||||
moment('23:59:59', 'HH:mm:ss'),
|
||||
],
|
||||
}}
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
>
|
||||
</RangePicker>
|
||||
></RangePicker>
|
||||
</Form.Item>
|
||||
</Auth>
|
||||
}
|
||||
@@ -220,16 +245,22 @@ export default class index extends Component {
|
||||
</Auth>
|
||||
}
|
||||
expandable={{
|
||||
expandedRowRender: record =>
|
||||
<Descriptions bordered size="small">
|
||||
<Descriptions.Item span="3" label="具体消息">
|
||||
expandedRowRender: record => (
|
||||
<Descriptions
|
||||
bordered
|
||||
size="small"
|
||||
columns={1}
|
||||
labelStyle={{ width: '150px' }}
|
||||
>
|
||||
<Descriptions.Item label="具体消息">
|
||||
{record.message}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user