Commit 5c8f0919 by zhaochengxiang

增加资产路径

parent 3f549c0d
//全文检索 //全文检索
export const AnchorId = 'id'; export const AnchorId = 'id';
export const AnchorTimestamp = 'timestamp'; export const AnchorTimestamp = 'timestamp';
export const AnchorDirId = 'did';
//编辑模型 //编辑模型
export const Action = 'action'; export const Action = 'action';
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Spin, Input, Descriptions, Space, Button } from 'antd'; import { Form, Spin, Input, Descriptions, Space, Button } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, UpOutlined } from '@ant-design/icons';
import Tag from '../../Tag'; import LocalStorage from 'local-storage';
import MetadataInfo from './MetadataInfo'; import MetadataInfo from './MetadataInfo';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { highlightSearchContentByTerms, showMessage } from '../../../../util'; import { highlightSearchContentByTerms, showMessage } from '../../../../util';
import { unfoldedElements } from '../util'; import { unfoldedElements } from '../util';
import { AppContext } from '../../../../App'; import { AppContext } from '../../../../App';
import Tag from '../../Tag';
const AssetAction = (props) => { const AssetAction = (props) => {
...@@ -77,7 +78,8 @@ const AssetAction = (props) => { ...@@ -77,7 +78,8 @@ const AssetAction = (props) => {
dispatch({ dispatch({
type: 'assetmanage.getDataAssetDetail', type: 'assetmanage.getDataAssetDetail',
payload: { payload: {
dataAssetId: id dataAssetId: id,
dirId: dirId,
}, },
callback: data => { callback: data => {
setLoading(false); setLoading(false);
...@@ -120,6 +122,16 @@ const AssetAction = (props) => { ...@@ -120,6 +122,16 @@ const AssetAction = (props) => {
} }
} }
const jumpToPath = () => {
setFullScreen(false);
LocalStorage.set('assetDirChange', !(LocalStorage.get('assetDirChange')||false));
let event = new Event('storage');
event.key = 'assetDirChange';
event.dirId = (assets?.dirIds||[]).length>0?assets.dirIds[0]:'';
window?.dispatchEvent(event);
}
const onOk = async() => { const onOk = async() => {
try { try {
const row = await form.validateFields(); const row = await form.validateFields();
...@@ -243,6 +255,13 @@ const AssetAction = (props) => { ...@@ -243,6 +255,13 @@ const AssetAction = (props) => {
<div style={{ padding: 10 }}> <div style={{ padding: 10 }}>
<Descriptions column={1}> <Descriptions column={1}>
{
(assets.currentPath||'')!=='' && <Descriptions.Item label='路径' style={{ paddingBottom: 10 }}>
<a onClick={()=>{jumpToPath();}}>
{assets.currentPath||''}
</a>
</Descriptions.Item>
}
<Descriptions.Item label='标签' style={{ paddingBottom: 0 }}> <Descriptions.Item label='标签' style={{ paddingBottom: 0 }}>
{ {
(currentAction==='add'||currentAction==='edit')?<Tag styleType='complex' id={id} />:<Tag id={id} /> (currentAction==='add'||currentAction==='edit')?<Tag styleType='complex' id={id} />:<Tag id={id} />
......
...@@ -52,7 +52,8 @@ const AssetTable = (props) => { ...@@ -52,7 +52,8 @@ const AssetTable = (props) => {
const [ columns, setColumns ] = useState([]); const [ columns, setColumns ] = useState([]);
const [ assets, setAssets ] = useState([]); const [ assets, setAssets ] = useState([]);
const [ total, setTotal ] = useState(0); const [ total, setTotal ] = useState(0);
const [ selectKey, setSelectKey ] = useState(''); const [ selectItem, setSelectItem ] = useState({});
const [ checkedKeys, setCheckedKeys ] = useState([]); const [ checkedKeys, setCheckedKeys ] = useState([]);
const [ importAssetVisible, setImportAssetVisible ] = useState(false); const [ importAssetVisible, setImportAssetVisible ] = useState(false);
const [ filterElementVisible, setFilterElementVisible ] = useState(false); const [ filterElementVisible, setFilterElementVisible ] = useState(false);
...@@ -78,7 +79,7 @@ const AssetTable = (props) => { ...@@ -78,7 +79,7 @@ const AssetTable = (props) => {
useEffect(() => { useEffect(() => {
if ((nodeId||'') !== '' ) { if ((nodeId||'') !== '' ) {
setKeyword(''); setKeyword('');
setSelectKey(''); setSelectItem({});
setCheckedKeys([]); setCheckedKeys([]);
if (shouldScrollRef.current === true) { if (shouldScrollRef.current === true) {
...@@ -296,16 +297,16 @@ const AssetTable = (props) => { ...@@ -296,16 +297,16 @@ const AssetTable = (props) => {
setAssets(_assets); setAssets(_assets);
if (reference === AssetManageReference) { if (reference === AssetManageReference) {
if ((selectKey||'') !=='') { if ((selectItem?.id||'') !=='') {
const index = _assets.findIndex((asset) => asset.id === selectKey); const index = _assets.findIndex((asset) => asset.id === selectItem?.id);
if (index === -1) { if (index === -1) {
setSelectKey(_assets.length>0?_assets[0].id:''); setSelectItem(_assets.length>0?_assets[0]:{});
onSelect && onSelect(_assets.length>0?_assets[0].id:''); onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:'');
} }
} else { } else {
setSelectKey(_assets.length>0?_assets[0].id:''); setSelectItem(_assets.length>0?_assets[0]:{});
onSelect && onSelect(_assets.length>0?_assets[0].id:''); onSelect && onSelect(_assets.length>0?_assets[0].id:'', _assets.length>0?_assets[0].dirId:'');
} }
} }
...@@ -526,8 +527,8 @@ const AssetTable = (props) => { ...@@ -526,8 +527,8 @@ const AssetTable = (props) => {
return { return {
id: `data-asset-${record?.id}`, id: `data-asset-${record?.id}`,
onClick: (e) => { onClick: (e) => {
setSelectKey(record?.id); setSelectItem(record);
onSelect && onSelect(record?.id); onSelect && onSelect(record?.id, record?.dirId);
if (reference !== AssetManageReference) { if (reference !== AssetManageReference) {
setAssetDetailDrawerVisible(true); setAssetDetailDrawerVisible(true);
...@@ -536,7 +537,7 @@ const AssetTable = (props) => { ...@@ -536,7 +537,7 @@ const AssetTable = (props) => {
} }
}} }}
rowClassName={(record, index) => { rowClassName={(record, index) => {
if (record?.id===anchorId || record?.id===selectKey) { if (record?.id===anchorId || record?.id===selectItem?.id) {
return 'highlight-row'; return 'highlight-row';
} }
...@@ -600,8 +601,8 @@ const AssetTable = (props) => { ...@@ -600,8 +601,8 @@ const AssetTable = (props) => {
onCancel={ onFilterElementModalCancel} onCancel={ onFilterElementModalCancel}
/> />
<AssetDetailDrawer <AssetDetailDrawer
id={selectKey} id={selectItem?.id}
dirId={nodeId} dirId={selectItem?.dirId}
visible={assetDetailDrawerVisible} visible={assetDetailDrawerVisible}
onCancel={onAssetDetailDrawerCancel} onCancel={onAssetDetailDrawerCancel}
/> />
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useMount } from 'ahooks';
import {Card, Spin, Tooltip, Tree, Input, Dropdown, Menu, Modal} from 'antd'; import {Card, Spin, Tooltip, Tree, Input, Dropdown, Menu, Modal} from 'antd';
import { PlusOutlined, ImportOutlined,EditOutlined,DeleteOutlined,ExportOutlined,ReloadOutlined, SettingOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; import { PlusOutlined, ImportOutlined,EditOutlined,DeleteOutlined,ExportOutlined,ReloadOutlined, SettingOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
import classNames from 'classnames'; import classNames from 'classnames';
...@@ -8,7 +9,7 @@ import ImportDirectory from './ImportDirectory'; ...@@ -8,7 +9,7 @@ import ImportDirectory from './ImportDirectory';
import UpdateDirectoryModal from './UpdateDirectoryModal'; import UpdateDirectoryModal from './UpdateDirectoryModal';
import CustomDirectoryModal from './CustomDirectoryModal'; import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util'; import { showMessage, getQueryParam } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetMountReference } from '../../../../util/constant'; import { AnchorTimestamp, AnchorId, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetMountReference, AnchorDirId } from '../../../../util/constant';
import './AssetTree.less'; import './AssetTree.less';
const AssetTree = (props) => { const AssetTree = (props) => {
...@@ -35,6 +36,14 @@ const AssetTree = (props) => { ...@@ -35,6 +36,14 @@ const AssetTree = (props) => {
const timestamp = getQueryParam(AnchorTimestamp, props?.location?.search); const timestamp = getQueryParam(AnchorTimestamp, props?.location?.search);
const id = getQueryParam(AnchorId, props?.location?.search); const id = getQueryParam(AnchorId, props?.location?.search);
useMount(() => {
window?.addEventListener("storage", storageChange);
return () => {
window?.removeEventListener("storage", storageChange);
}
})
useEffect(() => { useEffect(() => {
if ((id||'') !== '') { if ((id||'') !== '') {
getDataAssetLocationThenGetTreeData(); getDataAssetLocationThenGetTreeData();
...@@ -53,11 +62,19 @@ const AssetTree = (props) => { ...@@ -53,11 +62,19 @@ const AssetTree = (props) => {
useEffect(() => { useEffect(() => {
if ((centerId||'') !== '') { if ((centerId||'') !== '') {
centerIdChanged(); treeDirectoryChanged(centerId);
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [centerId]) }, [centerId])
const storageChange = (e) => {
if (e.key === 'assetDirChange') {
if ((e.dirId||'') !== '') {
treeDirectoryChanged(e.dirId);
}
}
}
const getDataAssetLocationThenGetTreeData = () => { const getDataAssetLocationThenGetTreeData = () => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
...@@ -177,7 +194,7 @@ const AssetTree = (props) => { ...@@ -177,7 +194,7 @@ const AssetTree = (props) => {
}); });
} }
const centerIdChanged = () => { const treeDirectoryChanged = (did) => {
let defaultItem = null; let defaultItem = null;
...@@ -187,7 +204,7 @@ const AssetTree = (props) => { ...@@ -187,7 +204,7 @@ const AssetTree = (props) => {
(subCatalogs||[]).forEach(catalog=> { (subCatalogs||[]).forEach(catalog=> {
if (catalog.nodeId === centerId) { if (catalog.nodeId === did) {
defaultItem = catalog; defaultItem = catalog;
} }
...@@ -195,14 +212,14 @@ const AssetTree = (props) => { ...@@ -195,14 +212,14 @@ const AssetTree = (props) => {
}) })
} }
if ((centerId||'') !== '') { if ((did||'') !== '') {
recursion(treeData); recursion(treeData);
} }
if (defaultItem) { if (defaultItem) {
const expandedKeys = (dataList||[]) const expandedKeys = (dataList||[])
.map(item => { .map(item => {
if (item.key.indexOf(centerId) > -1) { if (item.key.indexOf(did) > -1) {
return getParentKey(item.key, treeData); return getParentKey(item.key, treeData);
} }
return null; return null;
...@@ -214,6 +231,7 @@ const AssetTree = (props) => { ...@@ -214,6 +231,7 @@ const AssetTree = (props) => {
setCurrentDirId(defaultItem.nodeId); setCurrentDirId(defaultItem.nodeId);
setCurrentDirType(defaultItem.type||''); setCurrentDirType(defaultItem.type||'');
onSelect && onSelect(defaultItem.nodeId);
} }
} }
......
...@@ -15,7 +15,7 @@ import './index.less'; ...@@ -15,7 +15,7 @@ import './index.less';
const AssetManage = (props) => { const AssetManage = (props) => {
const [ nodeId, setNodeId ] = useState(''); const [ nodeId, setNodeId ] = useState('');
const [ assetId, setAssetId ] = useState(''); const [ assetParams, setAssetParams ] = useState({ assetId: '', assetDirId: '' })
const [ expandTree, setExpandTree ] = useState(true); const [ expandTree, setExpandTree ] = useState(true);
const [ assetCount, setAssetCount ] = useState(0); const [ assetCount, setAssetCount ] = useState(0);
...@@ -23,13 +23,15 @@ const AssetManage = (props) => { ...@@ -23,13 +23,15 @@ const AssetManage = (props) => {
const [ elementsChanged, setElementsChanged ] = useState(false); const [ elementsChanged, setElementsChanged ] = useState(false);
const [ assetActionChanged, setAssetActionChanged ] = useState(false); const [ assetActionChanged, setAssetActionChanged ] = useState(false);
const { assetId, assetDirId } = assetParams;
const onTreeSelect = (value, type) => { const onTreeSelect = (value, type) => {
setNodeId(value||''); setNodeId(value||'');
} }
const onTableSelect = (value) => { const onTableSelect = (id, did) => {
setAssetId(value); setAssetParams({ assetId: id, assetDirId: did });
} }
const treeToggleClick = () => { const treeToggleClick = () => {
...@@ -72,9 +74,8 @@ const AssetManage = (props) => { ...@@ -72,9 +74,8 @@ const AssetManage = (props) => {
<AssetTable nodeId={nodeId} reference={AssetManageReference} elementsChanged={elementsChanged} assetActionChanged={assetActionChanged} onSelect={onTableSelect} onCountChange={onAssetCountChange} {...props} /> <AssetTable nodeId={nodeId} reference={AssetManageReference} elementsChanged={elementsChanged} assetActionChanged={assetActionChanged} onSelect={onTableSelect} onCountChange={onAssetCountChange} {...props} />
</div> </div>
<div className='right'> <div className='right'>
<AssetAction id={assetId} dirId={nodeId} action='detail' onChange={onAssetActionChange} /> <AssetAction id={assetId} dirId={assetDirId} action='detail' onChange={onAssetActionChange} />
</div> </div>
</div> </div>
) )
} }
......
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { Tooltip, Modal, Pagination, Table, Popover } from 'antd'; import { Tooltip, Modal, Pagination, Table } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, UpOutlined } from '@ant-design/icons';
import SmoothScroll from 'smooth-scroll'; import SmoothScroll from 'smooth-scroll';
import classnames from 'classnames'; import classnames from 'classnames';
......
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