|
@ -8,10 +8,12 @@ import MetadataTab from './metadataTab'; |
|
|
import MetadataDetails from './metadataDetails'; |
|
|
import MetadataDetails from './metadataDetails'; |
|
|
let expandedKeysData = []; |
|
|
let expandedKeysData = []; |
|
|
let allTreeNodeKeys = []; |
|
|
let allTreeNodeKeys = []; |
|
|
|
|
|
let resourceCatalogRawData = []; |
|
|
|
|
|
|
|
|
const LatestMetadata = (props) => { |
|
|
const LatestMetadata = (props) => { |
|
|
const { user, dispatch, actions, history, clientHeight, resourceCatalog, isRequesting, location, match, organization } = props; |
|
|
const { user, dispatch, actions, history, clientHeight, resourceCatalog, isRequesting, location, match, organization } = props; |
|
|
const { metadataManagement } = actions; |
|
|
const { metadataManagement } = actions; |
|
|
|
|
|
const [isAdmin, setIsAdmin] = useState(false); |
|
|
const [resourceCatalogData, setResourceCatalogData] = useState([]); |
|
|
const [resourceCatalogData, setResourceCatalogData] = useState([]); |
|
|
const [selectedKeys, setSelectedKeys] = useState([]); |
|
|
const [selectedKeys, setSelectedKeys] = useState([]); |
|
|
const [expandedKeys, setExpandedKeys] = useState([]); |
|
|
const [expandedKeys, setExpandedKeys] = useState([]); |
|
@ -36,6 +38,7 @@ const LatestMetadata = (props) => { |
|
|
dispatch(metadataManagement.getResourceCatalog()).then(res => { |
|
|
dispatch(metadataManagement.getResourceCatalog()).then(res => { |
|
|
const { data } = res.payload; |
|
|
const { data } = res.payload; |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
|
|
|
resourceCatalogRawData = data; |
|
|
allTreeNodeKeys = [] |
|
|
allTreeNodeKeys = [] |
|
|
const resourceCatalogData = getTreeNodeData(data, null, 'rc', [], null); |
|
|
const resourceCatalogData = getTreeNodeData(data, null, 'rc', [], null); |
|
|
setResourceCatalogData(resourceCatalogData); |
|
|
setResourceCatalogData(resourceCatalogData); |
|
@ -47,6 +50,8 @@ const LatestMetadata = (props) => { |
|
|
params?.catalogKey ? setSelectedKeys([params?.catalogKey]) : setSelectedKeys(expandedKeysData); |
|
|
params?.catalogKey ? setSelectedKeys([params?.catalogKey]) : setSelectedKeys(expandedKeysData); |
|
|
params?.catalogKey ? setExpandedKeys(getExpandKeys([params?.catalogKey])) : setExpandedKeys(expandedKeys); |
|
|
params?.catalogKey ? setExpandedKeys(getExpandKeys([params?.catalogKey])) : setExpandedKeys(expandedKeys); |
|
|
params?.treeId && setResourceCatalogId(params?.treeId); |
|
|
params?.treeId && setResourceCatalogId(params?.treeId); |
|
|
|
|
|
params?.treeId && params?.treeId && setIsAdmin(user?.username === 'SuperAdmin' |
|
|
|
|
|
|| (user?.role === '系统管理员' && user?.orgId == resourceCatalogRawData.find(a => a.id == params?.treeId)?.orgId)); |
|
|
expandedKeysData = []; |
|
|
expandedKeysData = []; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -60,7 +65,10 @@ const LatestMetadata = (props) => { |
|
|
const keyArr = selectedData[0].split('-'); |
|
|
const keyArr = selectedData[0].split('-'); |
|
|
keyArr.shift();//['rc-2-5']->返回'rc';keyArr:['2','5']
|
|
|
keyArr.shift();//['rc-2-5']->返回'rc';keyArr:['2','5']
|
|
|
const allExpandedKeys = allTreeNodeKeys.filter(k => keyArr.includes(k.id.toString())); |
|
|
const allExpandedKeys = allTreeNodeKeys.filter(k => keyArr.includes(k.id.toString())); |
|
|
!params?.treeId && setResourceCatalogId(keyArr.pop()); |
|
|
const resourceCatalogId = keyArr.pop(); |
|
|
|
|
|
!params?.treeId && setResourceCatalogId(resourceCatalogId); |
|
|
|
|
|
!params?.treeId && setIsAdmin(user?.username === 'SuperAdmin' |
|
|
|
|
|
|| (user?.role === '系统管理员' && user?.orgId == resourceCatalogRawData.find(a => a.id == resourceCatalogId)?.orgId)); |
|
|
setResourceCatalogKey(selectedData[0]); |
|
|
setResourceCatalogKey(selectedData[0]); |
|
|
const resourceCatalogPath = allExpandedKeys.map(a => a.name); |
|
|
const resourceCatalogPath = allExpandedKeys.map(a => a.name); |
|
|
setResourceCatalogPath(resourceCatalogPath); |
|
|
setResourceCatalogPath(resourceCatalogPath); |
|
@ -104,27 +112,29 @@ const LatestMetadata = (props) => { |
|
|
const renderTreeNode = (ds, dataSource) => { |
|
|
const renderTreeNode = (ds, dataSource) => { |
|
|
return <div className={theStyle.icon} style={{ width: 180 }}> |
|
|
return <div className={theStyle.icon} style={{ width: 180 }}> |
|
|
{setTreeNodeTitle(ds.name)} |
|
|
{setTreeNodeTitle(ds.name)} |
|
|
<EditOutlined title='修改' className={theStyle.tip} onClick={() => { |
|
|
{(user?.username === 'SuperAdmin' || (user?.role === '系统管理员' && user?.orgId == ds?.orgId)) && <> |
|
|
let record = JSON.parse(JSON.stringify(ds)); |
|
|
<EditOutlined title='修改' className={theStyle.tip} onClick={() => { |
|
|
let parentData = dataSource.filter(rc => rc.id === record.parent); |
|
|
let record = JSON.parse(JSON.stringify(ds)); |
|
|
record.parentName = parentData.length ? parentData[0].name : ''; |
|
|
let parentData = dataSource.filter(rc => rc.id === record.parent); |
|
|
setEditData({ record: record, title: '修改子类', child: ds.parent ? true : false, }); |
|
|
record.parentName = parentData.length ? parentData[0].name : ''; |
|
|
setModalVisible(true); |
|
|
setEditData({ record: record, title: '修改子类', child: ds.parent ? true : false, }); |
|
|
}} /> |
|
|
setModalVisible(true); |
|
|
<Popconfirm placement="top" title={'确定删除该资源目录吗?'} onConfirm={() => { |
|
|
}} /> |
|
|
dispatch(metadataManagement.delResourceCatalog(ds.id)).then((res) => { |
|
|
<Popconfirm placement="top" title={'确定删除该资源目录吗?'} onConfirm={() => { |
|
|
if (res.success) { |
|
|
dispatch(metadataManagement.delResourceCatalog(ds.id)).then((res) => { |
|
|
expandedKeysData = []; initData(true); |
|
|
if (res.success) { |
|
|
} |
|
|
expandedKeysData = []; initData(true); |
|
|
setModalVisible(false); |
|
|
} |
|
|
}); |
|
|
setModalVisible(false); |
|
|
}} okText="确定" cancelText="取消"> |
|
|
}); |
|
|
<MinusCircleOutlined title='删除' className={theStyle.tip} /> |
|
|
}} okText="确定" cancelText="取消"> |
|
|
</Popconfirm> |
|
|
<MinusCircleOutlined title='删除' className={theStyle.tip} /> |
|
|
<PlusCircleOutlined title='新建' className={theStyle.tip} onClick={() => { |
|
|
</Popconfirm> |
|
|
setEditData({ record: { parent: ds.id, parentName: ds.name }, title: '新建子类', child: true, add: true }); |
|
|
<PlusCircleOutlined title='新建' className={theStyle.tip} onClick={() => { |
|
|
setModalVisible(true); |
|
|
setEditData({ record: { parent: ds.id, parentName: ds.name, orgId: ds?.orgId }, title: '新建子类', child: true, add: true }); |
|
|
}} /> |
|
|
setModalVisible(true); |
|
|
|
|
|
}} /> |
|
|
|
|
|
</>} |
|
|
</div > |
|
|
</div > |
|
|
}; |
|
|
}; |
|
|
//新建、修改
|
|
|
//新建、修改
|
|
@ -194,7 +204,7 @@ const LatestMetadata = (props) => { |
|
|
allowClear onChange={onChangeSearch} |
|
|
allowClear onChange={onChangeSearch} |
|
|
onKeyPress={onChangeSearch} /> |
|
|
onKeyPress={onChangeSearch} /> |
|
|
{user?.role == '系统管理员' && <Button type='primary' style={{ marginBottom: 16 }} onClick={() => { |
|
|
{user?.role == '系统管理员' && <Button type='primary' style={{ marginBottom: 16 }} onClick={() => { |
|
|
setEditData({ title: '新建资源目录', add: true }); |
|
|
setEditData({ title: '新建资源目录', add: true, record: { orgId: user?.orgId } }); |
|
|
setModalVisible(true); |
|
|
setModalVisible(true); |
|
|
}}>新建资源目录</Button>} |
|
|
}}>新建资源目录</Button>} |
|
|
<Tree |
|
|
<Tree |
|
@ -222,11 +232,13 @@ const LatestMetadata = (props) => { |
|
|
<MetadataDetails resourceCatalogId={resourceCatalogId} |
|
|
<MetadataDetails resourceCatalogId={resourceCatalogId} |
|
|
resourceCatalogKey={resourceCatalogKey} |
|
|
resourceCatalogKey={resourceCatalogKey} |
|
|
resourceCatalogPath={resourceCatalogPath} |
|
|
resourceCatalogPath={resourceCatalogPath} |
|
|
match={match} /> : |
|
|
match={match} |
|
|
|
|
|
isAdmin={isAdmin} /> : |
|
|
<MetadataTab resourceCatalogId={resourceCatalogId} |
|
|
<MetadataTab resourceCatalogId={resourceCatalogId} |
|
|
resourceCatalogKey={resourceCatalogKey} |
|
|
resourceCatalogKey={resourceCatalogKey} |
|
|
resourceCatalogPath={resourceCatalogPath} |
|
|
resourceCatalogPath={resourceCatalogPath} |
|
|
params={params} |
|
|
params={params} |
|
|
|
|
|
isAdmin={isAdmin} |
|
|
/> |
|
|
/> |
|
|
// <MetadataTab resourceCatalogId={params?.treeId}
|
|
|
// <MetadataTab resourceCatalogId={params?.treeId}
|
|
|
// resourceCatalogKey={params?.catalogKey}
|
|
|
// resourceCatalogKey={params?.catalogKey}
|
|
|