Commit c61bc3c6 by zhaochengxiang

目录视角

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