|
@@ -3,8 +3,9 @@ import { FilterTable } from 'wptpc-design'
|
|
|
import { connect } from 'dva'
|
|
|
import { thanos } from '@/conf/config'
|
|
|
import { message, Popconfirm, Button } from 'antd'
|
|
|
-import { delItem, addIP } from './service.js'
|
|
|
-import Edit from './components/Edit';
|
|
|
+import { delItem, addIP, batchAddNameList } from './service.js'
|
|
|
+import Edit from './components/Edit'
|
|
|
+import BatchEdit from '../commoncomponents/Edit'
|
|
|
|
|
|
const apiUrl = `${thanos}/thanos-admin/api/v1/nameList/blackIpList`
|
|
|
|
|
@@ -19,12 +20,18 @@ class BlackIpList extends React.PureComponent {
|
|
|
showModal: false,
|
|
|
selectedItem: {},
|
|
|
showEditModal: false,
|
|
|
- params: {}
|
|
|
+ params: {},
|
|
|
+
|
|
|
+ showBatchModal: false,
|
|
|
+ selectedBatchItem: {},
|
|
|
+ showBatchEditModal: false,
|
|
|
+ batchParams: {},
|
|
|
+ batchRemark:"文件内包含名单字段 ip "
|
|
|
}
|
|
|
}
|
|
|
|
|
|
filterSetting = {
|
|
|
- rfBtnsJsx: <Button type="primary" onClick={() => this.addItem()}>添加IP</Button>,
|
|
|
+ rfBtnsJsx:<div> <Button type="primary" onClick={() =>this.addBatchItem()}>批量导入</Button> <Button type="primary" onClick={() => this.addItem()}>添加IP</Button></div>,
|
|
|
isClearSearch: true,
|
|
|
formFields: [
|
|
|
{
|
|
@@ -34,10 +41,6 @@ class BlackIpList extends React.PureComponent {
|
|
|
placeholder: 'IP查询'
|
|
|
}
|
|
|
]
|
|
|
- // 在接口请求前,可以修改给接口的入参
|
|
|
- // beforeSearchFunc: params => {
|
|
|
- // params.pageNum = params.pageNum
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
// filtertable的列表配置
|
|
@@ -103,11 +106,21 @@ class BlackIpList extends React.PureComponent {
|
|
|
addItem = () => {
|
|
|
this.setState({ showEditModal: true, params: {} });
|
|
|
}
|
|
|
+
|
|
|
+ addBatchItem = () => {
|
|
|
+ this.setState({ showBatchEditModal: true, batchParams: {} });
|
|
|
+ }
|
|
|
+
|
|
|
onParamsChange = (key, value) => {
|
|
|
const params = { ...this.state.params };
|
|
|
params[key] = value;
|
|
|
this.setState({ params });
|
|
|
}
|
|
|
+ onBatchParamsChange = (key, value) => {
|
|
|
+ const batchParams = { ...this.state.batchParams };
|
|
|
+ batchParams[key] = value;
|
|
|
+ this.setState({ batchParams });
|
|
|
+ }
|
|
|
onEditOk = () => {
|
|
|
const { params } = this.state;
|
|
|
|
|
@@ -120,16 +133,37 @@ class BlackIpList extends React.PureComponent {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ onBatchEditOk = () => {
|
|
|
+ const { csvFile, valid } = this.state.batchParams;
|
|
|
+ const params = new FormData()
|
|
|
+ params.append("csvFile", csvFile)
|
|
|
+ params.append("model", "BlackIp")
|
|
|
+ params.append("valid", valid)
|
|
|
+ batchAddNameList(params).then(res => {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ message.success('批量导入成功')
|
|
|
+ this.refresh()// 刷新列表
|
|
|
+ this.onBatchEditCancel()//关闭弹窗
|
|
|
+ }else {
|
|
|
+ message.error('批量导入失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
onEditCancel = () => {
|
|
|
this.setState({ showEditModal: false })
|
|
|
}
|
|
|
+ onBatchEditCancel = () => {
|
|
|
+ this.setState({ showBatchEditModal: false })
|
|
|
+ }
|
|
|
render() {
|
|
|
- const { showModal, selectedItem, showEditModal, params } = this.state;
|
|
|
+ const { showModal, selectedItem, showEditModal, params, showBatchEditModal, batchParams, batchRemark} = this.state;
|
|
|
return (
|
|
|
<div>
|
|
|
<FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl}
|
|
|
/>
|
|
|
<Edit showModal={showEditModal} params={params} onChange={this.onParamsChange} onOk={this.onEditOk} onCancel={this.onEditCancel} />
|
|
|
+ <BatchEdit showModal={showBatchEditModal} params={batchParams} onChange={this.onBatchParamsChange} onOk={this.onBatchEditOk} onCancel={this.onBatchEditCancel} batchRemark={batchRemark} />
|
|
|
</div>
|
|
|
)
|
|
|
}
|