Commit c61bc3c6 by zhaochengxiang

目录视角

parent cfdcdc53
...@@ -78,6 +78,6 @@ ...@@ -78,6 +78,6 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"proxy": "http://139.198.127.28:18221", "proxy": "http://139.198.127.54:18099",
"homepage": "http://myhost/data-govern" "homepage": "http://myhost/data-govern"
} }
...@@ -104,6 +104,9 @@ export function* existDataAsset(payload) { ...@@ -104,6 +104,9 @@ export function* existDataAsset(payload) {
export function* queryAllDirectoryAsTree() { export function* queryAllDirectoryAsTree() {
return yield call(service.queryAllDirectoryAsTree); return yield call(service.queryAllDirectoryAsTree);
} }
export function* queryCustomTypeRootDirectory() {
return yield call(service.queryCustomTypeRootDirectory);
}
export function* refreshDirectoryTree() { export function* refreshDirectoryTree() {
return yield call(service.refreshDirectoryTree); return yield call(service.refreshDirectoryTree);
} }
......
...@@ -140,6 +140,10 @@ export function queryAllDirectoryAsTree() { ...@@ -140,6 +140,10 @@ export function queryAllDirectoryAsTree() {
return GetJSON("/dataassetmanager/directoryApi/queryAllDirectoryAsTree"); return GetJSON("/dataassetmanager/directoryApi/queryAllDirectoryAsTree");
} }
export function queryCustomTypeRootDirectory() {
return GetJSON("/dataassetmanager/directoryApi/queryCustomTypeRootDirectory");
}
export function refreshDirectoryTree() { export function refreshDirectoryTree() {
return GetJSON("/dataassetmanager/directoryApi/refreshDirectoryTree"); return GetJSON("/dataassetmanager/directoryApi/refreshDirectoryTree");
} }
......
...@@ -144,7 +144,8 @@ const AssetAction = (props) => { ...@@ -144,7 +144,8 @@ const AssetAction = (props) => {
payload: { payload: {
dataAssetId: id, dataAssetId: id,
dirId: dirId, dirId: dirId,
checkPermission: readOnly checkPermission: readOnly,
countVisitTime: readOnly,
}, },
callback: data => { callback: data => {
setLoading(false); setLoading(false);
...@@ -485,6 +486,11 @@ const AssetAction = (props) => { ...@@ -485,6 +486,11 @@ const AssetAction = (props) => {
} }
</AppContext.Consumer> </AppContext.Consumer>
</Descriptions.Item> </Descriptions.Item>
{
readOnly && <Descriptions.Item label={<div className='title-text' style={{ textAlign: 'right', width: 60 }}>浏览量</div>} style={{ paddingBottom: 15 }}>
<div>{ assets?.visitCount }</div>
</Descriptions.Item>
}
{/* <Descriptions.Item {/* <Descriptions.Item
label={<div className='title-text' style={{ textAlign: 'right', width: 60 }}>关联关系</div>} label={<div className='title-text' style={{ textAlign: 'right', width: 60 }}>关联关系</div>}
style={{ paddingBottom: 0 }} style={{ paddingBottom: 0 }}
......
import React, { useEffect, useState, useRef, useContext } from 'react'; import React, { useEffect, useState, useRef, useContext } from 'react';
import {Card, Spin, Tooltip, Tree, Dropdown, Menu, Modal, AutoComplete} from 'antd'; import {Card, Spin, Tooltip, Tree, Dropdown, Menu, Modal, AutoComplete} from 'antd';
import { PlusOutlined, ImportOutlined,ExportOutlined,ReloadOutlined, SettingOutlined } from '@ant-design/icons'; import { PlusOutlined, ImportOutlined,ExportOutlined,ReloadOutlined, SettingOutlined, UnorderedListOutlined } from '@ant-design/icons';
import classNames from 'classnames'; import classNames from 'classnames';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify"; import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import LocalStorage from 'local-storage'; import LocalStorage from 'local-storage';
...@@ -19,6 +19,17 @@ import 'react-contexify/dist/ReactContexify.css'; ...@@ -19,6 +19,17 @@ import 'react-contexify/dist/ReactContexify.css';
const { Option } = AutoComplete; const { Option } = AutoComplete;
const viewModes = [
{
key: 'dir',
name: '目录视角'
},
{
key: 'custom',
name: '自定义目录视角'
}
];
function updateTreeData(list, key, children) { function updateTreeData(list, key, children) {
return list.map((node) => { return list.map((node) => {
if (node.nodeId === key) { if (node.nodeId === key) {
...@@ -64,6 +75,7 @@ const AssetManageTree = (props) => { ...@@ -64,6 +75,7 @@ const AssetManageTree = (props) => {
const [ customDirectoryAction, setCustomDirectoryAction ] = useState(''); const [ customDirectoryAction, setCustomDirectoryAction ] = useState('');
const [options, setOptions] = useState([]); const [options, setOptions] = useState([]);
const [ loadedKeys, setLoadedKeys ] = useState([]); const [ loadedKeys, setLoadedKeys ] = useState([]);
const [ viewSelectedKey, setViewSelectedKey ] = useState(viewModes[0].key);
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
...@@ -75,6 +87,7 @@ const AssetManageTree = (props) => { ...@@ -75,6 +87,7 @@ const AssetManageTree = (props) => {
const treeDataRef = useRef([]); const treeDataRef = useRef([]);
const dataListRef = useRef([]); const dataListRef = useRef([]);
const viewSelectedKeyRef = useRef(viewModes[0].key)
useEffect(() => { useEffect(() => {
window?.addEventListener("storage", storageChange); window?.addEventListener("storage", storageChange);
...@@ -161,13 +174,21 @@ const AssetManageTree = (props) => { ...@@ -161,13 +174,21 @@ const AssetManageTree = (props) => {
} }
let url = refresh ? 'assetmanage.refreshDirectoryTree' : 'assetmanage.queryAllDirectoryAsTree'; let url = refresh ? 'assetmanage.refreshDirectoryTree' : 'assetmanage.queryAllDirectoryAsTree';
if (viewSelectedKeyRef.current === 'custom') {
url = 'assetmanage.queryCustomTypeRootDirectory';
}
dispatch({ dispatch({
type: url, type: url,
callback: data => { callback: data => {
setLoading(false); setLoading(false);
let newData = [...data]; let newData;
if (viewSelectedKeyRef.current==='dir') {
newData = [...data];
} else {
newData = [{...data, ...{text: data.name, nodeId: data.id}}];
}
if (reference === AssetMountReference) { if (reference === AssetMountReference) {
newData = newData.filter(item => item.resourceType!=='custom'); newData = newData.filter(item => item.resourceType!=='custom');
...@@ -215,6 +236,7 @@ const AssetManageTree = (props) => { ...@@ -215,6 +236,7 @@ const AssetManageTree = (props) => {
} }
if (resetCurrentDirId) { if (resetCurrentDirId) {
if (viewSelectedKeyRef.current==='custom') { defaultItem = newData[0]; }
if (defaultItem) { if (defaultItem) {
const expandedKeys = _dataList const expandedKeys = _dataList
...@@ -661,6 +683,16 @@ const AssetManageTree = (props) => { ...@@ -661,6 +683,16 @@ const AssetManageTree = (props) => {
}); });
}); });
const onViewClick = ({ key }) => {
if (viewSelectedKey && viewSelectedKey===key ) return;
viewSelectedKeyRef.current = key;
setViewSelectedKey(key);
getAllDirectoryAsTree();
}
const exportMenu = ( const exportMenu = (
<Menu> <Menu>
<Menu.Item> <Menu.Item>
...@@ -676,6 +708,22 @@ const AssetManageTree = (props) => { ...@@ -676,6 +708,22 @@ const AssetManageTree = (props) => {
</Menu> </Menu>
); );
const viewMenus = (
<Menu selectedKeys={[viewSelectedKey]} onClick={onViewClick}>
{
viewModes && viewModes.map(item => {
return (
<Menu.Item key={item.key} value={item.key} >
<div style={{ textAlign: 'center' }}>
{item.name}
</div>
</Menu.Item>
)
})
}
</Menu>
);
const loop = (data, rootResourceType = null) => const loop = (data, rootResourceType = null) =>
data.map(item => { data.map(item => {
...@@ -747,29 +795,46 @@ const AssetManageTree = (props) => { ...@@ -747,29 +795,46 @@ const AssetManageTree = (props) => {
justifyContent: 'space-around', justifyContent: 'space-around',
}} }}
> >
<Tooltip title={addTip}> <Dropdown overlay={viewMenus} placement="bottomLeft">
<PlusOutlined className={!addAble?'disable': 'default'} onClick={() => { <Tooltip title="视角">
if (addAble) { <UnorderedListOutlined className='default' style={{ fontSize:16,cursor:'pointer' }} />
addDir(); </Tooltip>
} </Dropdown>
}} style={{ fontSize:16,cursor: !addAble?'not-allowed':'pointer' }}/> {
</Tooltip> viewSelectedKey==='dir' && <Tooltip title={addTip}>
<PlusOutlined className={!addAble?'disable': 'default'} onClick={() => {
if (addAble) {
addDir();
}
}} style={{ fontSize:16,cursor: !addAble?'not-allowed':'pointer' }}/>
</Tooltip>
}
<Tooltip title="刷新目录"> <Tooltip title="刷新目录">
<ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer' }} /> <ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip> </Tooltip>
{ {
importCatalogAbility(app?.dataRoles) && <Tooltip title="导入目录"> importCatalogAbility(app?.dataRoles) && viewSelectedKey==='dir' && <Tooltip title="导入目录">
<ImportOutlined className={(currentDirType==='custom')?'disable': 'default'} onClick={importDir} style={{ fontSize:16,cursor:(currentDirType==='custom')?'not-allowed':'pointer' }} /> <ImportOutlined className={(currentDirType==='custom')?'disable': 'default'} onClick={importDir} style={{ fontSize:16,cursor:(currentDirType==='custom')?'not-allowed':'pointer' }} />
</Tooltip> </Tooltip>
} }
<Dropdown overlay={exportMenu} placement="bottomCenter" > {
<Tooltip title="导出目录"> viewSelectedKey==='dir' && <Dropdown overlay={exportMenu} placement="bottomCenter" >
<ExportOutlined className='default' style={{ fontSize:16,cursor:'pointer' }} /> <Tooltip title="导出目录">
<ExportOutlined className='default' style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip>
</Dropdown>
}
{
viewSelectedKey==='custom' && <Tooltip title="自定义目录">
<SettingOutlined className='default' onClick={customDir} style={{ fontSize:16,cursor:'pointer' }} />
</Tooltip> </Tooltip>
</Dropdown> }
<Tooltip title="自定义目录"> {
<SettingOutlined className='default' onClick={customDir} style={{ fontSize:16,cursor:'pointer' }} /> viewSelectedKey==='custom' && <div></div>
</Tooltip> }
{
viewSelectedKey==='custom' && <div></div>
}
</div> </div>
)} )}
bordered={false} bordered={false}
...@@ -778,26 +843,28 @@ const AssetManageTree = (props) => { ...@@ -778,26 +843,28 @@ const AssetManageTree = (props) => {
style={{ width: '100%' }} style={{ width: '100%' }}
> >
<Spin spinning={loading}> <Spin spinning={loading}>
<AutoComplete
allowClear
value={keyword}
style={{ marginBottom: 10, width: '100%' }}
onSelect={onAutoCompleteSelect}
onSearch={onAutoCompleteSearch}
onClear={() => { setKeyword(''); }}
>
{ {
(options||[]).map((item, index) => { viewSelectedKeyRef.current==='dir' && <AutoComplete
return ( allowClear
<Option key={item.key} value={item.value}> value={keyword}
<div style={{ whiteSpace: 'normal' }}> style={{ marginBottom: 10, width: '100%' }}
{highlightSearchContentByTerms(item.value, [keyword])} onSelect={onAutoCompleteSelect}
</div> onSearch={onAutoCompleteSearch}
</Option> onClear={() => { setKeyword(''); }}
); >
}) {
(options||[]).map((item, index) => {
return (
<Option key={item.key} value={item.value}>
<div style={{ whiteSpace: 'normal' }}>
{highlightSearchContentByTerms(item.value, [keyword])}
</div>
</Option>
);
})
}
</AutoComplete>
} }
</AutoComplete>
<Tree <Tree
checkable={checkable} checkable={checkable}
showLine={true} showLine={true}
......
...@@ -535,9 +535,9 @@ const AssetTree = (props) => { ...@@ -535,9 +535,9 @@ const AssetTree = (props) => {
<Tooltip title="刷新目录"> <Tooltip title="刷新目录">
<ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer',flex:1}} /> <ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer',flex:1}} />
</Tooltip> </Tooltip>
<Tooltip title="自定义目录"> {/* <Tooltip title="自定义目录">
<SettingOutlined className='default' onClick={customDir} style={{ fontSize:16,cursor:'pointer',flex:1}} /> <SettingOutlined className='default' onClick={customDir} style={{ fontSize:16,cursor:'pointer',flex:1}} />
</Tooltip> </Tooltip> */}
<div style={{ flex: 3 }}></div> <div style={{ flex: 3 }}></div>
</div> </div>
} }
......
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