Commit 07f204fd by zhaochengxiang

未挂载资产多模版

parent caaf76c8
......@@ -750,6 +750,7 @@ const AssetManageTree = (props) => {
}}
>
<Select
loading={loadingTemplates}
size='small'
value={currentTemplateType}
onChange={(val) => {
......
import React,{ useState, useEffect, useRef, useContext, useMemo } from "react";
import { Button, Pagination, Space, Modal, Input, Table, Tooltip, Checkbox, Typography, Dropdown, Menu, Divider } from "antd";
import { Button, Pagination, Space, Modal, Input, Table, Tooltip, Checkbox, Typography, Dropdown, Menu, Divider, Select } from "antd";
import classNames from 'classnames';
import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer';
......@@ -16,7 +16,7 @@ import { showMessage, showNotifaction, getQueryParam, inputWidth, isSzseEnv } fr
import { AnchorId, AnchorDirId, AnchorTimestamp, AssetBrowseReference, AssetManageReference, AssetRecycleReference, ResourceBrowseReference } from '../../../../util/constant';
import { FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import AssetDeleteModal from './AssetDeleteModal';
import { AppContext } from "../../../../App";
import { AppContext, appId } from "../../../../App";
import StartFlowModal from "./StartFlow";
import "./AssetTable.less";
......@@ -154,6 +154,9 @@ const AssetTable = (props) => {
visible: false,
ids: undefined
})
const [loadingTemplates, setLoadingTemplates] = useState(false)
const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState()
const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search);
......@@ -164,6 +167,8 @@ const AssetTable = (props) => {
const metadataIndexRef = useRef('');
const remoteRelationRef = useRef(null);
const mountRef = useRef(true)
const app = useContext(AppContext)
const actionCol = {
......@@ -215,6 +220,10 @@ const AssetTable = (props) => {
useEffect(() => {
getUsers();
if (reference === AssetRecycleReference) {
getTemplates()
}
window?.addEventListener("storage", storageChange);
return () => {
......@@ -225,7 +234,7 @@ const AssetTable = (props) => {
}, [])
useEffect(() => {
if (nodeId !== null) {
if (nodeId !== null && nodeId !== undefined) {
setSelectItem({});
setCheckedKeys([]);
......@@ -253,12 +262,25 @@ const AssetTable = (props) => {
}, [timestamp])
useEffect(() => {
if (nodeId!==null || reference===AssetRecycleReference) {
if (reference !== AssetRecycleReference && nodeId !== null) {
getFilterElementsGroupThenGetDataAssets();
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword, pagination, elementsChanged, assetActionChanged, recursive, fullSearch ])
useEffect(() => {
if (reference === AssetRecycleReference) {
if (!mountRef.current) {
getFilterElementsGroupThenGetDataAssets()
}
if (mountRef.current) {
mountRef.current = false
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword, pagination, elementsChanged ])
const realAssets = useMemo(() => {
const newAssets = [...assets];
if (users?.length > 0 && assets?.length > 0 && columns?.length > 0) {
......@@ -297,6 +319,25 @@ 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 = () => {
dispatch({
type: 'pds.getOwners',
......@@ -973,6 +1014,23 @@ const AssetTable = (props) => {
// (reference===AssetManageReference && nodeLevel!==1 && nodeType!=='custom') && <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: 80 }}
>
{
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
}
</Select>
}
{
(reference===AssetManageReference && nodeType!=='custom') && <Button onClick={importAsset}>导入</Button>
}
......
......@@ -575,6 +575,7 @@ const AssetTree = (props) => {
>
<Select
size='small'
loading={loadingTemplates}
value={currentTemplateType}
onChange={(val) => {
setTemplateType(val)
......
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