Commit 6653e889 by zhaochengxiang

bug fix

parent bb46a3ba
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.12", "@types/react-dom": "^17.0.12",
"ahooks": "^3.1.7", "ahooks": "^3.1.7",
"antd": "^4.18.2", "antd": "4.18.2",
"axios": "^0.19.0", "axios": "^0.19.0",
"copy-to-clipboard": "^3.3.1", "copy-to-clipboard": "^3.3.1",
"core-js": "^3.4.2", "core-js": "^3.4.2",
......
...@@ -46,7 +46,7 @@ const AssetManageTree = (props) => { ...@@ -46,7 +46,7 @@ const AssetManageTree = (props) => {
id: MENU_ID, id: MENU_ID,
}); });
const { checkable = false, onSelect, className, onCheck, tableId, reference=AssetManageReference, onDirectoryChange, centerId, metadataIds } = props; const { checkable = false, onSelect, className, onCheck, tableId, reference=AssetManageReference, onDirectoryChange, centerId, metadataIds, onTemplateChange } = props;
const [ keyword, setKeyword ] = useState(''); const [ keyword, setKeyword ] = useState('');
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
const [ treeData, setTreeData ] = useState([]); const [ treeData, setTreeData ] = useState([]);
...@@ -139,17 +139,16 @@ const AssetManageTree = (props) => { ...@@ -139,17 +139,16 @@ const AssetManageTree = (props) => {
setLoadingTemplates(false) setLoadingTemplates(false)
setTemplates(data) setTemplates(data)
if ((data??[]).length > 0) { if ((data??[]).length > 0) {
const _templateType = getQueryParam(AnchorTemplateType, props?.location?.search); const _templateType = getQueryParam(AnchorTemplateType, props?.location?.search) || data[0].type;
console.log('_templateType', _templateType)
if (_templateType) {
setTemplateType(_templateType) setTemplateType(_templateType)
LocalStorage.set(`templateType-${appId}`, _templateType) LocalStorage.set(`templateType-${appId}`, _templateType)
} else {
setTemplateType(data[0].type) const index = (templates??[]).findIndex(item => item.type === _templateType)
LocalStorage.set(`templateType-${appId}`, data[0].type) if (index !== -1) {
onTemplateChange?.(templates[index])
} }
listSubject.next({ msg: 'templateChange' })
onSelect?.('', '', null, false) onSelect?.('', '', null, false)
getAllDirectoryAsTree(false) getAllDirectoryAsTree(false)
} }
...@@ -787,7 +786,11 @@ const AssetManageTree = (props) => { ...@@ -787,7 +786,11 @@ const AssetManageTree = (props) => {
onChange={(val) => { onChange={(val) => {
setTemplateType(val) setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
listSubject.next({ msg: 'templateChange' })
const index = (templates??[]).findIndex(item => item.type === val)
if (index !== -1) {
onTemplateChange?.(templates[index])
}
setCurrentDirId(); setCurrentDirId();
onSelect?.(null, null, null, false); onSelect?.(null, null, null, false);
......
...@@ -92,7 +92,7 @@ export const listSubject = new Subject(); ...@@ -92,7 +92,7 @@ export const listSubject = new Subject();
const AssetTable = (props) => { const AssetTable = (props) => {
const { className, nodeId, nodeType, nodeLevel, nodeAllowdLoadDataAsset, elementsChanged, assetActionChanged, onSelect, onCountChange, reference = AssetManageReference, onFullScreenChange } = props; const { className, nodeId, nodeType, nodeLevel, nodeAllowdLoadDataAsset, elementsChanged, assetActionChanged, onSelect, onCountChange, reference = AssetManageReference, onFullScreenChange, template } = props;
const MENU_ID = 'asset-table'; const MENU_ID = 'asset-table';
...@@ -129,8 +129,6 @@ const AssetTable = (props) => { ...@@ -129,8 +129,6 @@ const AssetTable = (props) => {
ids: undefined ids: undefined
}) })
const [loadingTemplates, setLoadingTemplates] = useState(false) const [loadingTemplates, setLoadingTemplates] = useState(false)
const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState()
const [loadingElements, setLoadingElements] = useState(false) const [loadingElements, setLoadingElements] = useState(false)
const [elements, setElements] = useState() const [elements, setElements] = useState()
const [currentElementId, setCurrentElementId] = useState() const [currentElementId, setCurrentElementId] = useState()
...@@ -170,13 +168,13 @@ const AssetTable = (props) => { ...@@ -170,13 +168,13 @@ const AssetTable = (props) => {
return ( return (
<Space size={5} split={<Divider type='vertical' style={{margin:0}} />}> <Space size={5} split={<Divider type='vertical' style={{margin:0}} />}>
{ {
(reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && !isPostAsset(currentTemplateType) && <a onClick={(e) => { (reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
handleItemClick('authorization', record); handleItemClick('authorization', record);
}}>授权</a> }}>授权</a>
} }
{ {
((reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && currentTemplateType!=='mdg') && <a onClick={(e) => { (reference===AssetManageReference||(reference===AssetBrowseReference&&record.hasPermission)) && <a onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
setAssetMountParam({ setAssetMountParam({
visible: true, visible: true,
...@@ -193,15 +191,11 @@ const AssetTable = (props) => { ...@@ -193,15 +191,11 @@ const AssetTable = (props) => {
getAdmin(); getAdmin();
judgeDataKeyUser(); judgeDataKeyUser();
getUsers(); getUsers();
if (reference === AssetRecycleReference) {
getTemplates()
}
const $list = listSubject.subscribe((val) => { const $list = listSubject.subscribe((val) => {
if (val.msg === 'templateChange') { if (val.msg === 'templateChange') {
setCurrentElementId(); setCurrentElementId();
getElements(); getElements();
setTemplateType(LocalStorage.get(`templateType-${appId}`))
} }
}); });
window?.addEventListener("storage", storageChange); window?.addEventListener("storage", storageChange);
...@@ -318,25 +312,6 @@ const AssetTable = (props) => { ...@@ -318,25 +312,6 @@ const AssetTable = (props) => {
}) })
} }
const getTemplates = () => {
setLoadingTemplates(true)
dispatch({
type: 'assetmanage.getTemplates',
callback: data => {
setLoadingTemplates(false)
setTemplates(data)
if ((data??[]).length > 0) {
setTemplateType(data[0].type)
LocalStorage.set(`templateType-${appId}`, data[0].type)
getFilterElementsGroupThenGetDataAssets();
}
},
error: () => {
setLoadingTemplates(false)
}
})
}
const getUsers = () => { const getUsers = () => {
dispatch({ dispatch({
type: 'pds.getOwners', type: 'pds.getOwners',
...@@ -991,13 +966,11 @@ const AssetTable = (props) => { ...@@ -991,13 +966,11 @@ const AssetTable = (props) => {
{ {
(reference===AssetManageReference || reference===AssetRecycleReference) && <React.Fragment> (reference===AssetManageReference || reference===AssetRecycleReference) && <React.Fragment>
{ <Menu.Item disabled={(checkedKeys||[]).length===0}>
currentTemplateType!=='mdg' && <Menu.Item disabled={(checkedKeys||[]).length===0}>
<div className='text-center' onClick={onBatchCatalogChangeBtnClick}> <div className='text-center' onClick={onBatchCatalogChangeBtnClick}>
{(reference===AssetRecycleReference)?'挂载':'变更目录'} {(reference===AssetRecycleReference)?'挂载':'变更目录'}
</div> </div>
</Menu.Item> </Menu.Item>
}
{ {
isAdmin && <Menu.Item disabled={(checkedKeys||[]).length===0}> isAdmin && <Menu.Item disabled={(checkedKeys||[]).length===0}>
<div className='text-center' onClick={deleteAssets}> <div className='text-center' onClick={deleteAssets}>
...@@ -1057,24 +1030,7 @@ const AssetTable = (props) => { ...@@ -1057,24 +1030,7 @@ const AssetTable = (props) => {
> >
<Space size={15}> <Space size={15}>
{ {
((reference===AssetManageReference||isDataKeyUser) && isPostAsset(getTemplateType()) && nodeAllowdLoadDataAsset) && <Button onClick={addAsset}>新增</Button> ((reference===AssetManageReference||isDataKeyUser) && template && !template?.structured) && <Button onClick={addAsset}>新增</Button>
}
{
reference === AssetRecycleReference && <Select
loading={loadingTemplates}
value={currentTemplateType}
onChange={(val) => {
setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val);
setPagination({ ...pagination, pageNum: 1 });
}}
style={{ width: 85 }}
>
{
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
}
</Select>
} }
{ {
...@@ -1114,11 +1070,9 @@ const AssetTable = (props) => { ...@@ -1114,11 +1070,9 @@ const AssetTable = (props) => {
{ {
(reference===AssetManageReference || reference===AssetRecycleReference) && <React.Fragment> (reference===AssetManageReference || reference===AssetRecycleReference) && <React.Fragment>
{ <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
currentTemplateType && currentTemplateType!=='mdg' && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={onBatchCatalogChangeBtnClick} disabled={(checkedKeys||[]).length===0} >{(reference===AssetRecycleReference)?'挂载':'变更目录'}</Button> <Button onClick={onBatchCatalogChangeBtnClick} disabled={(checkedKeys||[]).length===0} >{(reference===AssetRecycleReference)?'挂载':'变更目录'}</Button>
</Tooltip> </Tooltip>
}
{ {
(reference===AssetRecycleReference) && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}> (reference===AssetRecycleReference) && <Tooltip title={(checkedKeys||[]).length===0?'请先选择资产目录':''}>
<Button onClick={recoveryAssets} disabled={(checkedKeys||[]).length===0} >恢复</Button> <Button onClick={recoveryAssets} disabled={(checkedKeys||[]).length===0} >恢复</Button>
......
...@@ -28,6 +28,7 @@ const AssetManage = (props) => { ...@@ -28,6 +28,7 @@ const AssetManage = (props) => {
const [ directoryChanged, setDirectoryChanged ] = useState(false); const [ directoryChanged, setDirectoryChanged ] = useState(false);
const [ elementsChanged, setElementsChanged ] = useState(false); const [ elementsChanged, setElementsChanged ] = useState(false);
const [ assetActionChanged, setAssetActionChanged ] = useState(false); const [ assetActionChanged, setAssetActionChanged ] = useState(false);
const [template, setTemplate] = useState();
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
const { assetId, assetDirId } = assetParams; const { assetId, assetDirId } = assetParams;
...@@ -55,6 +56,10 @@ const AssetManage = (props) => { ...@@ -55,6 +56,10 @@ const AssetManage = (props) => {
setDirectoryChanged(!directoryChanged); setDirectoryChanged(!directoryChanged);
} }
const onTemplateChange = (val) => {
setTemplate(val)
}
const onAssetActionChange = () => { const onAssetActionChange = () => {
setAssetActionChanged(!assetActionChanged); setAssetActionChanged(!assetActionChanged);
} }
...@@ -84,7 +89,7 @@ const AssetManage = (props) => { ...@@ -84,7 +89,7 @@ const AssetManage = (props) => {
axis='x' axis='x'
minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]} minConstraints={[230, Infinity]} maxConstraints={[Infinity, Infinity]}
> >
<AssetTree onSelect={onTreeSelect} onDirectoryChange={onDirectoryChange} {...props} /> <AssetTree onSelect={onTreeSelect} onDirectoryChange={onDirectoryChange} onTemplateChange={onTemplateChange} {...props} />
</ResizableBox> </ResizableBox>
{ {
expandTree && <Separate width={15} /> expandTree && <Separate width={15} />
...@@ -92,7 +97,7 @@ const AssetManage = (props) => { ...@@ -92,7 +97,7 @@ const AssetManage = (props) => {
<div className={middleClasses}> <div className={middleClasses}>
{/* <AssetDirectory id={nodeId} assetCount={assetCount} directoryChanged={directoryChanged} onElementsChange={onElementsChange} /> {/* <AssetDirectory id={nodeId} assetCount={assetCount} directoryChanged={directoryChanged} onElementsChange={onElementsChange} />
<Separate height={15} /> */} <Separate height={15} /> */}
<AssetTable nodeId={nodeId} nodeType={nodeType} nodeLevel={nodeLevel} nodeAllowdLoadDataAsset={nodeAllowdLoadDataAsset} reference={AssetManageReference} elementsChanged={elementsChanged} assetActionChanged={assetActionChanged} onSelect={onTableSelect} onCountChange={onAssetCountChange} onFullScreenChange={onFullScreenChange} {...props} /> <AssetTable template={template} nodeId={nodeId} nodeType={nodeType} nodeLevel={nodeLevel} nodeAllowdLoadDataAsset={nodeAllowdLoadDataAsset} reference={AssetManageReference} elementsChanged={elementsChanged} assetActionChanged={assetActionChanged} onSelect={onTableSelect} onCountChange={onAssetCountChange} onFullScreenChange={onFullScreenChange} {...props} />
<div className='tree-toggle' onClick={treeToggleClick}> <div className='tree-toggle' onClick={treeToggleClick}>
{ expandTree ? <CaretLeftOutlined /> : <CaretRightOutlined /> } { expandTree ? <CaretLeftOutlined /> : <CaretRightOutlined /> }
</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