完善用户&用户组列表资产授权页面

This commit is contained in:
dushixiang 2021-02-20 17:14:13 +08:00
parent 11d3dc167b
commit fe5b0a3f45
2 changed files with 138 additions and 32 deletions

View File

@ -25,6 +25,8 @@ import {message} from "antd/es";
import {DeleteOutlined, ExclamationCircleOutlined, PlusOutlined, SyncOutlined, UndoOutlined} from '@ant-design/icons'; import {DeleteOutlined, ExclamationCircleOutlined, PlusOutlined, SyncOutlined, UndoOutlined} from '@ant-design/icons';
import {PROTOCOL_COLORS} from "../../common/constants"; import {PROTOCOL_COLORS} from "../../common/constants";
import UserShareSelectedAsset from "./UserShareSelectedAsset"; import UserShareSelectedAsset from "./UserShareSelectedAsset";
import {isEmpty} from "../../utils/utils";
import dayjs from "dayjs";
const confirm = Modal.confirm; const confirm = Modal.confirm;
const {Search} = Input; const {Search} = Input;
@ -34,6 +36,7 @@ const {Title, Text} = Typography;
class UserShareAsset extends Component { class UserShareAsset extends Component {
inputRefOfName = React.createRef(); inputRefOfName = React.createRef();
inputRefOfIp = React.createRef();
changeOwnerFormRef = React.createRef(); changeOwnerFormRef = React.createRef();
state = { state = {
@ -132,6 +135,17 @@ class UserShareAsset extends Component {
this.loadTableData(query); this.loadTableData(query);
}; };
handleSearchByIp = ip => {
let query = {
...this.state.queryParams,
'pageIndex': 1,
'pageSize': this.state.queryParams.pageSize,
'ip': ip,
}
this.loadTableData(query);
};
handleTagsChange = tags => { handleTagsChange = tags => {
let query = { let query = {
...this.state.queryParams, ...this.state.queryParams,
@ -177,31 +191,53 @@ class UserShareAsset extends Component {
</Tooltip> </Tooltip>
); );
} }
}, {
title: '网络',
dataIndex: 'ip',
key: 'ip',
render: (text, record) => {
return record['ip'] + ':' + record['port'];
}
}, { }, {
title: '连接协议', title: '连接协议',
dataIndex: 'protocol', dataIndex: 'protocol',
key: 'protocol', key: 'protocol',
render: (text, record) => { render: (text, record) => {
const title = `${record['ip'] + ':' + record['port']}`
return (<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>); return (
<Tooltip title={title}>
<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>
</Tooltip>
)
}
}, {
title: '标签',
dataIndex: 'tags',
key: 'tags',
render: tags => {
if (!isEmpty(tags)) {
let tagDocuments = []
let tagArr = tags.split(',');
for (let i = 0; i < tagArr.length; i++) {
if (tags[i] === '-') {
continue;
}
tagDocuments.push(<Tag>{tagArr[i]}</Tag>)
}
return tagDocuments;
}
} }
}, { }, {
title: '状态', title: '状态',
dataIndex: 'active', dataIndex: 'active',
key: 'active', key: 'active',
render: text => { render: text => {
if (text) { if (text) {
return (<Badge status="processing" text="运行中"/>); return (
<Tooltip title='运行中'>
<Badge status="processing"/>
</Tooltip>
)
} else { } else {
return (<Badge status="error" text="不可用"/>); return (
<Tooltip title='不可用'>
<Badge status="error"/>
</Tooltip>
)
} }
} }
}, { }, {
@ -211,8 +247,15 @@ class UserShareAsset extends Component {
}, { }, {
title: '创建日期', title: '创建日期',
dataIndex: 'created', dataIndex: 'created',
key: 'created' key: 'created',
} render: (text, record) => {
return (
<Tooltip title={text}>
{dayjs(text).fromNow()}
</Tooltip>
)
}
},
]; ];
const selectedRowKeys = this.state.selectedRowKeys; const selectedRowKeys = this.state.selectedRowKeys;
@ -229,10 +272,10 @@ class UserShareAsset extends Component {
<Content key='page-content' className="site-layout-background"> <Content key='page-content' className="site-layout-background">
<div style={{marginBottom: 20}}> <div style={{marginBottom: 20}}>
<Row justify="space-around" align="middle" gutter={24}> <Row justify="space-around" align="middle" gutter={24}>
<Col span={8} key={1}> <Col span={4} key={1}>
<Title level={3}>授权资产列表</Title> <Title level={3}>授权资产列表</Title>
</Col> </Col>
<Col span={16} key={2} style={{textAlign: 'right'}}> <Col span={20} key={2} style={{textAlign: 'right'}}>
<Space> <Space>
<Search <Search
@ -240,6 +283,15 @@ class UserShareAsset extends Component {
placeholder="资产名称" placeholder="资产名称"
allowClear allowClear
onSearch={this.handleSearchByName} onSearch={this.handleSearchByName}
style={{width: 200}}
/>
<Search
ref={this.inputRefOfIp}
placeholder="资产IP"
allowClear
onSearch={this.handleSearchByIp}
style={{width: 200}}
/> />
<Select mode="multiple" <Select mode="multiple"
@ -268,6 +320,7 @@ class UserShareAsset extends Component {
<Button icon={<UndoOutlined/>} onClick={() => { <Button icon={<UndoOutlined/>} onClick={() => {
this.inputRefOfName.current.setValue(''); this.inputRefOfName.current.setValue('');
this.inputRefOfIp.current.setValue('');
this.loadTableData({ this.loadTableData({
...this.state.queryParams, ...this.state.queryParams,
pageIndex: 1, pageIndex: 1,

View File

@ -8,6 +8,8 @@ import {message} from "antd/es";
import {PlusOutlined, SyncOutlined, UndoOutlined} from '@ant-design/icons'; import {PlusOutlined, SyncOutlined, UndoOutlined} from '@ant-design/icons';
import {PROTOCOL_COLORS} from "../../common/constants"; import {PROTOCOL_COLORS} from "../../common/constants";
import {isEmpty} from "../../utils/utils";
import dayjs from "dayjs";
const {Search} = Input; const {Search} = Input;
const {Content} = Layout; const {Content} = Layout;
@ -16,6 +18,7 @@ const {Title} = Typography;
class UserShareSelectedAsset extends Component { class UserShareSelectedAsset extends Component {
inputRefOfName = React.createRef(); inputRefOfName = React.createRef();
inputRefOfIp = React.createRef();
changeOwnerFormRef = React.createRef(); changeOwnerFormRef = React.createRef();
state = { state = {
@ -150,6 +153,17 @@ class UserShareSelectedAsset extends Component {
this.loadTableData(query); this.loadTableData(query);
}; };
handleSearchByIp = ip => {
let query = {
...this.state.queryParams,
'pageIndex': 1,
'pageSize': this.state.queryParams.pageSize,
'ip': ip,
}
this.loadTableData(query);
};
handleTagsChange = tags => { handleTagsChange = tags => {
console.log(tags) console.log(tags)
// this.setState({ // this.setState({
@ -222,31 +236,53 @@ class UserShareSelectedAsset extends Component {
</Tooltip> </Tooltip>
); );
} }
}, {
title: '网络',
dataIndex: 'ip',
key: 'ip',
render: (text, record) => {
return record['ip'] + ':' + record['port'];
}
}, { }, {
title: '连接协议', title: '连接协议',
dataIndex: 'protocol', dataIndex: 'protocol',
key: 'protocol', key: 'protocol',
render: (text, record) => { render: (text, record) => {
const title = `${record['ip'] + ':' + record['port']}`
return (<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>); return (
<Tooltip title={title}>
<Tag color={PROTOCOL_COLORS[text]}>{text}</Tag>
</Tooltip>
)
}
}, {
title: '标签',
dataIndex: 'tags',
key: 'tags',
render: tags => {
if (!isEmpty(tags)) {
let tagDocuments = []
let tagArr = tags.split(',');
for (let i = 0; i < tagArr.length; i++) {
if (tags[i] === '-') {
continue;
}
tagDocuments.push(<Tag>{tagArr[i]}</Tag>)
}
return tagDocuments;
}
} }
}, { }, {
title: '状态', title: '状态',
dataIndex: 'active', dataIndex: 'active',
key: 'active', key: 'active',
render: text => { render: text => {
if (text) { if (text) {
return (<Badge status="processing" text="运行中"/>); return (
<Tooltip title='运行中'>
<Badge status="processing"/>
</Tooltip>
)
} else { } else {
return (<Badge status="error" text="不可用"/>); return (
<Tooltip title='不可用'>
<Badge status="error"/>
</Tooltip>
)
} }
} }
}, { }, {
@ -256,8 +292,15 @@ class UserShareSelectedAsset extends Component {
}, { }, {
title: '创建日期', title: '创建日期',
dataIndex: 'created', dataIndex: 'created',
key: 'created' key: 'created',
} render: (text, record) => {
return (
<Tooltip title={text}>
{dayjs(text).fromNow()}
</Tooltip>
)
}
},
]; ];
const selectedRowKeys = this.state.selectedRowKeys; const selectedRowKeys = this.state.selectedRowKeys;
@ -300,10 +343,10 @@ class UserShareSelectedAsset extends Component {
<Content key='page-content' className="site-layout-background"> <Content key='page-content' className="site-layout-background">
<div style={{marginBottom: 20}}> <div style={{marginBottom: 20}}>
<Row justify="space-around" align="middle" gutter={24}> <Row justify="space-around" align="middle" gutter={24}>
<Col span={8} key={1}> <Col span={4} key={1}>
<Title level={3}>全部资产列表</Title> <Title level={3}>全部资产列表</Title>
</Col> </Col>
<Col span={16} key={2} style={{textAlign: 'right'}}> <Col span={20} key={2} style={{textAlign: 'right'}}>
<Space> <Space>
<Search <Search
@ -311,6 +354,15 @@ class UserShareSelectedAsset extends Component {
placeholder="资产名称" placeholder="资产名称"
allowClear allowClear
onSearch={this.handleSearchByName} onSearch={this.handleSearchByName}
style={{width: 200}}
/>
<Search
ref={this.inputRefOfIp}
placeholder="资产IP"
allowClear
onSearch={this.handleSearchByIp}
style={{width: 200}}
/> />
<Select mode="multiple" <Select mode="multiple"
@ -339,6 +391,7 @@ class UserShareSelectedAsset extends Component {
<Button icon={<UndoOutlined/>} onClick={() => { <Button icon={<UndoOutlined/>} onClick={() => {
this.inputRefOfName.current.setValue(''); this.inputRefOfName.current.setValue('');
this.inputRefOfIp.current.setValue('');
this.loadTableData({ this.loadTableData({
...this.state.queryParams, ...this.state.queryParams,
pageIndex: 1, pageIndex: 1,