|
@@ -3,9 +3,11 @@ import { FilterTable } from 'wptpc-design'
|
|
|
import { connect } from 'dva'
|
|
|
import { thanos } from '@/conf/config'
|
|
|
import { message, Popconfirm, Button } from 'antd'
|
|
|
-import { delItem, addUserId, batchAddNameList } from './service.js'
|
|
|
+import { delItem, updateUserId, addUserId, batchAddNameList } from './service.js'
|
|
|
import Edit from './components/Edit'
|
|
|
-import BatchEdit from '../commoncomponents/Edit'
|
|
|
+import BatchEdit from '../commoncomponents/BatchUserEdit'
|
|
|
+import Update from './components/Update'
|
|
|
+import moment from 'moment';
|
|
|
|
|
|
const apiUrl = `${thanos}/thanos-admin/api/v1/nameList/whiteUserList`
|
|
|
|
|
@@ -21,7 +23,7 @@ class BlackIpList extends React.PureComponent {
|
|
|
selectedItem: {},
|
|
|
showEditModal: false,
|
|
|
params: {},
|
|
|
-
|
|
|
+ showUpdate: false,
|
|
|
showBatchModal: false,
|
|
|
selectedBatchItem: {},
|
|
|
showBatchEditModal: false,
|
|
@@ -35,11 +37,30 @@ class BlackIpList extends React.PureComponent {
|
|
|
isClearSearch: true,
|
|
|
formFields: [
|
|
|
{
|
|
|
- label: '',
|
|
|
+ label: '用户id:',
|
|
|
type: 'input',
|
|
|
- key: 'queryName',
|
|
|
- placeholder: '用户Id查询'
|
|
|
- }
|
|
|
+ key: 'users',
|
|
|
+ placeholder: '多个用半角逗号分割'
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // label: '是否启用:',
|
|
|
+ // type: 'select',
|
|
|
+ // options: [
|
|
|
+ // { value: '0', label: '禁用' },
|
|
|
+ // { value: '1', label: '启用' }
|
|
|
+ // ],
|
|
|
+ // key: 'valid'
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ label: '是否启用:',
|
|
|
+ type: 'select',
|
|
|
+ option: [
|
|
|
+ { value: '', label: '不限' },
|
|
|
+ { value: '0', label: '禁用' },
|
|
|
+ { value: '1', label: '启用' }
|
|
|
+ ],
|
|
|
+ key: 'valid'
|
|
|
+ },
|
|
|
]
|
|
|
// 在接口请求前,可以修改给接口的入参
|
|
|
// beforeSearchFunc: params => {
|
|
@@ -67,10 +88,33 @@ class BlackIpList extends React.PureComponent {
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
- title: '是否有效',
|
|
|
+ title: '是否启用',
|
|
|
dataIndex: 'valid',
|
|
|
render: (text) => text === 1 ? '是' : '否'
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '作用域',
|
|
|
+ dataIndex: 'scope',
|
|
|
+ render: (text) => {
|
|
|
+ if (text === 100) return '全局'
|
|
|
+ else if (text === 10) return '业务大类'
|
|
|
+ else if (text === 1) return '具体决策'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '作用域key',
|
|
|
+ dataIndex: 'scopekey',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '生效时间',
|
|
|
+ dataIndex: 'starttime',
|
|
|
+ render: (text) => text.substring(0,10),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '失效时间',
|
|
|
+ dataIndex: 'endtime',
|
|
|
+ render: (text) => text.substring(0,10),
|
|
|
+ },
|
|
|
{
|
|
|
title: '更新时间',
|
|
|
dataIndex: 'updateTime'
|
|
@@ -81,13 +125,7 @@ class BlackIpList extends React.PureComponent {
|
|
|
// 所有需要弹窗操作的都可以用编辑的逻辑;所有不需要弹窗的操作,比如上架、发布等,都可以用”删除“的逻辑
|
|
|
render: (text, record) => (
|
|
|
<span>
|
|
|
- <Popconfirm
|
|
|
- title="启用/禁用"
|
|
|
- onConfirm={() => this.delItem(record)}>
|
|
|
- <a>{
|
|
|
- record.valid === 1 ? '禁用' : '启用'
|
|
|
- }</a>
|
|
|
- </Popconfirm>
|
|
|
+ <a onClick={() => this.update(record)}>编辑</a>
|
|
|
</span>)
|
|
|
}
|
|
|
],
|
|
@@ -126,7 +164,9 @@ class BlackIpList extends React.PureComponent {
|
|
|
const { params } = this.state;
|
|
|
|
|
|
const payload = { ...params };
|
|
|
- addUserId({ userId: payload.userId, valid: payload.valid, type:2, createUser: this.props.currentUser.name, updateUser: this.props.currentUser.name }).then(res => {
|
|
|
+ addUserId({ userId: payload.userId, valid: payload.valid, type:2,
|
|
|
+ scope: payload.scope, scopekey: payload.scopekey,starttime: payload.starttime.format('YYYY-MM-DD')
|
|
|
+ ,endtime: payload.endtime.format('YYYY-MM-DD'), operator:this.props.currentUser.name, createUser: this.props.currentUser.name, updateUser: this.props.currentUser.name }).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
message.success('添加成功')
|
|
|
this.refresh()//刷新列表
|
|
@@ -136,11 +176,18 @@ class BlackIpList extends React.PureComponent {
|
|
|
}
|
|
|
|
|
|
onBatchEditOk = () => {
|
|
|
- const { csvFile, valid } = this.state.batchParams;
|
|
|
+ const { csvFile, valid, scope, scopekey, starttime, endtime} = this.state.batchParams;
|
|
|
const params = new FormData()
|
|
|
params.append("csvFile", csvFile)
|
|
|
params.append("model", "WhiteUser")
|
|
|
params.append("valid", valid)
|
|
|
+ params.append("scope", scope)
|
|
|
+ if(scopekey){
|
|
|
+ params.append("scopekey", scopekey)
|
|
|
+ }
|
|
|
+ params.append("starttime", starttime.format('YYYY-MM-DD'))
|
|
|
+ params.append("endtime", endtime.format('YYYY-MM-DD'))
|
|
|
+ params.append("operator", this.props.currentUser.name)
|
|
|
batchAddNameList(params).then(res => {
|
|
|
if (res.data.code === 0) {
|
|
|
message.success('批量导入成功')
|
|
@@ -158,12 +205,45 @@ class BlackIpList extends React.PureComponent {
|
|
|
onBatchEditCancel = () => {
|
|
|
this.setState({ showBatchEditModal: false })
|
|
|
}
|
|
|
+
|
|
|
+ onUpdateCancel = () => {
|
|
|
+ this.setState({ showUpdate: false })
|
|
|
+ }
|
|
|
+
|
|
|
+ onUpdateOk = () => {
|
|
|
+ const params = Object.assign({}, this.state.params)
|
|
|
+ if(!params.starttime || !params.endtime){
|
|
|
+ message.error('请选择相应的日期未选择')
|
|
|
+ }
|
|
|
+ params.starttime = params?.starttime?.format('YYYY-MM-DD')
|
|
|
+ params.endtime = params?.endtime?.format('YYYY-MM-DD')
|
|
|
+ updateUserId(params).then(res => {
|
|
|
+ console.log(JSON.stringify(res))
|
|
|
+ if (res.code === 0) {
|
|
|
+ message.success('修改成功')
|
|
|
+ console.info(this.state)
|
|
|
+ this.refresh()
|
|
|
+ this.onUpdateCancel()
|
|
|
+ }else {
|
|
|
+ message.error('修改失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ update = (record) => {
|
|
|
+ const params = Object.assign({}, record)
|
|
|
+ params.starttime = moment(params.starttime, 'YYYY-MM-DD')
|
|
|
+ params.endtime = moment(params.endtime, 'YYYY-MM-DD')
|
|
|
+ this.setState({ showUpdate: true, params: params })
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
- const { showModal, selectedItem, showEditModal, params,showBatchEditModal, batchParams, batchRemark} = this.state;
|
|
|
+ const { showModal, selectedItem, showUpdate, showEditModal, params,showBatchEditModal, batchParams, batchRemark} = this.state;
|
|
|
return (
|
|
|
<div>
|
|
|
<FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl}
|
|
|
/>
|
|
|
+ <Update showModal={showUpdate} params={params} onChange={this.onParamsChange} onOk={this.onUpdateOk} onCancel={this.onUpdateCancel} />
|
|
|
<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>
|