Commit ceec2e3c by zhaochengxiang

历史版本

parent 6322bf75
...@@ -36,6 +36,10 @@ const { Text } = Typography; ...@@ -36,6 +36,10 @@ const { Text } = Typography;
const { Search } = Input; const { Search } = Input;
const { Column } = Table; const { Column } = Table;
const operationMap = {
historyVersion: '历史版本',
}
//资产项 //资产项
export const AssetItem = (props) => { export const AssetItem = (props) => {
const { metadata, terms } = props; const { metadata, terms } = props;
...@@ -218,8 +222,12 @@ const AssetTable = (props) => { ...@@ -218,8 +222,12 @@ const AssetTable = (props) => {
{ {
(reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => { (reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
handleItemClick('authorization', record); if (record.metadata?.metadataTableId) {
}}>授权</a> app?.setGlobalState && app?.setGlobalState({
message: 'data-govern-assets-admit',
data: record
})
}}}>授权</a>
} }
{ {
// (reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => { // (reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => {
...@@ -402,6 +410,16 @@ const AssetTable = (props) => { ...@@ -402,6 +410,16 @@ const AssetTable = (props) => {
return newAssets; return newAssets;
}, [users, assets, columns]) }, [users, assets, columns])
const menuData = React.useMemo(() => {
const newMenuData = []
for (const key of contextMenuItem?.allowButtons??[]) {
if (operationMap[key]) {
newMenuData.push(operationMap[key])
}
}
return newMenuData
}, [contextMenuItem])
const storageChange = (e) => { const storageChange = (e) => {
if (e.key === 'assetRelationOnClickEvent') { if (e.key === 'assetRelationOnClickEvent') {
remoteRelationRef.current = e.relation; remoteRelationRef.current = e.relation;
...@@ -1009,7 +1027,7 @@ const AssetTable = (props) => { ...@@ -1009,7 +1027,7 @@ const AssetTable = (props) => {
const handleItemClick = ({ event, props, data, triggerEvent }) => { const handleItemClick = ({ event, props, data, triggerEvent }) => {
const key = event.currentTarget.id; const key = event.currentTarget.id;
if (key === 'history') { if (key === '历史版本') {
setHistoryAndVersionParams({ setHistoryAndVersionParams({
visible: true, visible: true,
id: contextMenuItem?.id id: contextMenuItem?.id
...@@ -1258,9 +1276,20 @@ const AssetTable = (props) => { ...@@ -1258,9 +1276,20 @@ const AssetTable = (props) => {
}, },
onContextMenu: event => { onContextMenu: event => {
if (reference===AssetManageReference) { if (reference===AssetManageReference) {
let allowContextMenu = false
for (const key of (record.allowButtons??[])) {
if (operationMap[key]) {
allowContextMenu = true
break
}
}
if (allowContextMenu) {
setContextMenuItem(record); setContextMenuItem(record);
displayMenu(event); displayMenu(event);
} }
}
}, },
} }
}} }}
...@@ -1277,7 +1306,8 @@ const AssetTable = (props) => { ...@@ -1277,7 +1306,8 @@ const AssetTable = (props) => {
return classNames.join(' '); return classNames.join(' ');
}} }}
loading={loading} loading={loading}
columns={reference===AssetManageReference?[indexCol, ...columns, tagCol, actionCol]:[indexCol, ...columns, actionCol]} columns={reference===AssetManageReference?[indexCol, ...columns, tagCol]:[indexCol, ...columns]}
// columns={reference===AssetManageReference?[indexCol, ...columns, tagCol, actionCol]:[indexCol, ...columns, actionCol]}
rowKey='id' rowKey='id'
dataSource={realAssets} dataSource={realAssets}
pagination={false} pagination={false}
...@@ -1406,9 +1436,13 @@ const AssetTable = (props) => { ...@@ -1406,9 +1436,13 @@ const AssetTable = (props) => {
/> />
<RcMenu id={MENU_ID}> <RcMenu id={MENU_ID}>
<RcItem id="history" onClick={handleItemClick}> {
历史版本 menuData?.map(item => (
<RcItem id={item} onClick={handleItemClick}>
{item}
</RcItem> </RcItem>
))
}
</RcMenu> </RcMenu>
{contextHolder} {contextHolder}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment