|
@ -4,10 +4,11 @@ import { connect } from 'react-redux'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
import moment from 'moment'; |
|
|
import moment from 'moment'; |
|
|
import MemberModal from '../components/memberModal'; |
|
|
import MemberModal from '../components/memberModal'; |
|
|
|
|
|
import ResetPasswordModal from '../components/resetPassword'; |
|
|
import { useFsRequest, ApiTable } from '$utils'; |
|
|
import { useFsRequest, ApiTable } from '$utils'; |
|
|
import './style.less'; |
|
|
import './style.less'; |
|
|
function Member(props) { |
|
|
function Member(props) { |
|
|
const { loading, clientHeight, actions, dispatch, dataSources, adapters } = props; |
|
|
const { loading, clientHeight, actions, dispatch, member } = props; |
|
|
const [pageSize, setPageSize] = useState(10); |
|
|
const [pageSize, setPageSize] = useState(10); |
|
|
const [currentPage, setCurrentPage] = useState(1); |
|
|
const [currentPage, setCurrentPage] = useState(1); |
|
|
const [searchValue, setSearchValue] = useState('') |
|
|
const [searchValue, setSearchValue] = useState('') |
|
@ -19,10 +20,11 @@ function Member(props) { |
|
|
const query = { |
|
|
const query = { |
|
|
limit: search ? 10 : pageSize || 10, |
|
|
limit: search ? 10 : pageSize || 10, |
|
|
page: search ? 1 : currentPage || 1, |
|
|
page: search ? 1 : currentPage || 1, |
|
|
name: searchValue |
|
|
name: searchValue, |
|
|
|
|
|
role: searchRole |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dispatch(actions.metadataAcquisition.getDataSources(query)); |
|
|
dispatch(actions.memberManagement.getUserList(query)); |
|
|
} |
|
|
} |
|
|
const { data: treeData = [] } = useFsRequest({ |
|
|
const { data: treeData = [] } = useFsRequest({ |
|
|
url: ApiTable.getResourceCatalog, |
|
|
url: ApiTable.getResourceCatalog, |
|
@ -30,16 +32,9 @@ function Member(props) { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
dispatch(actions.metadataAcquisition.getAdapters()) |
|
|
|
|
|
queryData(); |
|
|
queryData(); |
|
|
}, [pageSize, currentPage]); |
|
|
}, [pageSize, currentPage]); |
|
|
|
|
|
|
|
|
const handleDelete = (id) => { |
|
|
|
|
|
dispatch(actions.metadataAcquisition.deleteDataSource(id)).then(() => { |
|
|
|
|
|
queryData(); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
const columns = [ |
|
|
{ |
|
|
{ |
|
|
title: '序号', |
|
|
title: '序号', |
|
@ -61,6 +56,9 @@ function Member(props) { |
|
|
{ |
|
|
{ |
|
|
title: '状态', |
|
|
title: '状态', |
|
|
dataIndex: 'enabled', |
|
|
dataIndex: 'enabled', |
|
|
|
|
|
render: (text, record) => { |
|
|
|
|
|
return <span style={{ color: record?.enabled ? '#87d068' : '#f50' }}>● {record?.enabled ? '正常' : '禁用'}</span> |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '操作', |
|
|
title: '操作', |
|
@ -69,65 +67,71 @@ function Member(props) { |
|
|
valueType: 'option', |
|
|
valueType: 'option', |
|
|
render: (text, record) => { |
|
|
render: (text, record) => { |
|
|
const options = []; |
|
|
const options = []; |
|
|
options.push(<a onClick={() => { |
|
|
options.push(<MemberModal |
|
|
setVisible(true) |
|
|
editData={record} |
|
|
setEditData(record) |
|
|
triggerRender={<a>编辑</a>} |
|
|
}} style={{ marginRight: 8 }}>编辑</a>) |
|
|
title="编辑用户" |
|
|
|
|
|
onFinish={onFinish} |
|
|
|
|
|
key="editUser" |
|
|
|
|
|
/>) |
|
|
options.push( |
|
|
options.push( |
|
|
<Popconfirm |
|
|
<Popconfirm |
|
|
key="del" |
|
|
key="del" |
|
|
placement="top" |
|
|
placement="top" |
|
|
title={<><div>是否确认删除该数据源?</div> |
|
|
title={<><div>是否确认删除该用户?</div> |
|
|
<div>(将同步删除数据源下的元数据)</div></>} |
|
|
</>} |
|
|
onConfirm={() => handleDelete(record.id)} |
|
|
onConfirm={() => handleDelete(record.id)} |
|
|
okText="是" |
|
|
okText="是" |
|
|
cancelText="否" |
|
|
cancelText="否" |
|
|
> |
|
|
> |
|
|
<a>删除</a> |
|
|
<a>删除</a> |
|
|
</Popconfirm>) |
|
|
</Popconfirm>) |
|
|
|
|
|
options.push(<ResetPasswordModal |
|
|
|
|
|
editData={record} |
|
|
|
|
|
triggerRender={<a>重置密码</a>} |
|
|
|
|
|
title="重置密码" |
|
|
|
|
|
onFinish={onFinish} |
|
|
|
|
|
key="resetPassword" |
|
|
|
|
|
/>) |
|
|
|
|
|
|
|
|
return options; |
|
|
return options; |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const onFinish = (values) => { |
|
|
const handleDelete = (id) => { |
|
|
const { stepOneValues, stepTwoValues, } = values; |
|
|
dispatch(actions.memberManagement.deleteUser(id)).then(() => { |
|
|
const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName) |
|
|
queryData(); |
|
|
if (adapterInfo) { |
|
|
}); |
|
|
const dataToSave = { |
|
|
}; |
|
|
name: stepOneValues?.name, |
|
|
|
|
|
audited: true, |
|
|
const onFinish = async (values, editData) => { |
|
|
adapterId: adapterInfo?.id, |
|
|
if (editData) { |
|
|
mountPath: stepOneValues?.mountPath, |
|
|
const dataToSave = { ...values } |
|
|
catalogKey: stepOneValues?.catalogKey, |
|
|
return dispatch( |
|
|
description: stepOneValues?.description, |
|
|
actions.memberManagement.modifyUser(editData.id, dataToSave, values?.msg || ''), |
|
|
config: stepTwoValues, |
|
|
).then((res) => { |
|
|
time: moment() |
|
|
if (res.success) { |
|
|
} |
|
|
queryData(); |
|
|
if (editData) { |
|
|
return true; |
|
|
dispatch(actions.metadataAcquisition.modifyDataSource(editData?.id, dataToSave)).then(res => { |
|
|
} else { |
|
|
if (res.success) { |
|
|
return false; |
|
|
setVisible(false); |
|
|
} |
|
|
setEditData(null); |
|
|
}); |
|
|
queryData(); |
|
|
} |
|
|
} |
|
|
|
|
|
}) |
|
|
return dispatch(actions.memberManagement.addUser({ |
|
|
|
|
|
...values, |
|
|
|
|
|
})).then(res => { |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
queryData(); |
|
|
|
|
|
return true; |
|
|
} else { |
|
|
} else { |
|
|
dispatch(actions.metadataAcquisition.addDataSource(dataToSave)).then(res => { |
|
|
return false; |
|
|
if (res.success) { |
|
|
|
|
|
setVisible(false); |
|
|
|
|
|
setEditData(null); |
|
|
|
|
|
queryData(); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
} |
|
|
}; |
|
|
const refresh = () => { |
|
|
|
|
|
// queryData();
|
|
|
|
|
|
setRefreshTree(refreshTree + 1) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return <Spin spinning={loading}> |
|
|
return <Spin spinning={loading}> |
|
|
<Row className='protable-title'> |
|
|
<Row className='protable-title'> |
|
@ -145,6 +149,7 @@ function Member(props) { |
|
|
style={{ width: 220, marginRight: 15 }} placeholder="请输入" /> |
|
|
style={{ width: 220, marginRight: 15 }} placeholder="请输入" /> |
|
|
|
|
|
|
|
|
<span>角色: </span> <Select |
|
|
<span>角色: </span> <Select |
|
|
|
|
|
allowClear |
|
|
value={searchRole} onChange={e => { setSearchRole(e) }} |
|
|
value={searchRole} onChange={e => { setSearchRole(e) }} |
|
|
style={{ width: 220, marginRight: 15 }} placeholder="请选择" > |
|
|
style={{ width: 220, marginRight: 15 }} placeholder="请选择" > |
|
|
<Select.Option value={'系统管理员'}>系统管理员</Select.Option> |
|
|
<Select.Option value={'系统管理员'}>系统管理员</Select.Option> |
|
@ -171,7 +176,7 @@ function Member(props) { |
|
|
//1490 2256
|
|
|
//1490 2256
|
|
|
pagination={{ |
|
|
pagination={{ |
|
|
size: 'large', |
|
|
size: 'large', |
|
|
total: dataSources?.count, |
|
|
total: member?.count, |
|
|
showSizeChanger: true, |
|
|
showSizeChanger: true, |
|
|
showQuickJumper: true, |
|
|
showQuickJumper: true, |
|
|
current: currentPage, |
|
|
current: currentPage, |
|
@ -192,7 +197,7 @@ function Member(props) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}} |
|
|
}} |
|
|
dataSource={dataSources?.rows || []} |
|
|
dataSource={member?.rows || []} |
|
|
options={false} |
|
|
options={false} |
|
|
/> |
|
|
/> |
|
|
</Spin> |
|
|
</Spin> |
|
@ -201,14 +206,13 @@ function Member(props) { |
|
|
|
|
|
|
|
|
function mapStateToProps(state) { |
|
|
function mapStateToProps(state) { |
|
|
const { |
|
|
const { |
|
|
auth, global, datasources, adapters |
|
|
auth, global, datasources, member |
|
|
} = state; |
|
|
} = state; |
|
|
return { |
|
|
return { |
|
|
loading: datasources.isRequesting || adapters?.isRequesting, |
|
|
loading: datasources.isRequesting, |
|
|
clientHeight: global.clientHeight, |
|
|
clientHeight: global.clientHeight, |
|
|
actions: global.actions, |
|
|
actions: global.actions, |
|
|
dataSources: datasources?.data || {}, |
|
|
member: member?.data || {}, |
|
|
adapters: adapters?.data || [] |
|
|
|
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|