Commit 17ff7421 by zhaochengxiang

资产增加要素搜索

parent 5eec17ef
...@@ -12,6 +12,7 @@ import CustomDirectoryModal from './CustomDirectoryModal'; ...@@ -12,6 +12,7 @@ import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util'; import { showMessage, getQueryParam } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetMountReference, AnchorDirId } from '../../../../util/constant'; import { AnchorTimestamp, AnchorId, AssetManageReference, AssetBrowseReference, ResourceBrowseReference, AssetMountReference, AnchorDirId } from '../../../../util/constant';
import { highlightSearchContentByTerms } from '../../../../util'; import { highlightSearchContentByTerms } from '../../../../util';
import { listSubject } from './AssetTable';
import './AssetManageTree.less'; import './AssetManageTree.less';
import 'react-contexify/dist/ReactContexify.css'; import 'react-contexify/dist/ReactContexify.css';
...@@ -139,6 +140,7 @@ const AssetManageTree = (props) => { ...@@ -139,6 +140,7 @@ const AssetManageTree = (props) => {
if ((data??[]).length > 0) { if ((data??[]).length > 0) {
setTemplateType(data[0].type) setTemplateType(data[0].type)
LocalStorage.set(`templateType-${appId}`, data[0].type) LocalStorage.set(`templateType-${appId}`, data[0].type)
listSubject.next({ msg: 'templateChange' })
onSelect?.('', '') onSelect?.('', '')
getAllDirectoryAsTree(false) getAllDirectoryAsTree(false)
} }
...@@ -782,6 +784,8 @@ const AssetManageTree = (props) => { ...@@ -782,6 +784,8 @@ 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' })
setCurrentDirId(); setCurrentDirId();
onSelect?.(null, null); onSelect?.(null, null);
setTimeout(() => { setTimeout(() => {
......
...@@ -5,6 +5,7 @@ import { Resizable } from 'react-resizable'; ...@@ -5,6 +5,7 @@ import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer'; import ResizeObserver from 'rc-resize-observer';
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';
import { Subject } from "rxjs";
import FilterElementModal from './FilterElementModal'; import FilterElementModal from './FilterElementModal';
import AssetMount from '../../AssetRecycle/Component/AssetMount'; import AssetMount from '../../AssetRecycle/Component/AssetMount';
...@@ -116,6 +117,8 @@ const ResizeableHeaderCell = props => { ...@@ -116,6 +117,8 @@ const ResizeableHeaderCell = props => {
); );
}; };
export const listSubject = new Subject();
const AssetTable = (props) => { const AssetTable = (props) => {
const { className, nodeId, nodeType, nodeLevel, elementsChanged, assetActionChanged, onSelect, onCountChange, reference = AssetManageReference, onFullScreenChange } = props; const { className, nodeId, nodeType, nodeLevel, elementsChanged, assetActionChanged, onSelect, onCountChange, reference = AssetManageReference, onFullScreenChange } = props;
...@@ -158,6 +161,9 @@ const AssetTable = (props) => { ...@@ -158,6 +161,9 @@ const AssetTable = (props) => {
const [loadingTemplates, setLoadingTemplates] = useState(false) const [loadingTemplates, setLoadingTemplates] = useState(false)
const [templates, setTemplates] = useState() const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState() const [currentTemplateType, setTemplateType] = useState()
const [loadingElements, setLoadingElements] = useState(false)
const [elements, setElements] = useState()
const [currentElementId, setCurrentElementId] = useState()
const [ modal, contextHolder ] = Modal.useModal(); const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search); const anchorId = getQueryParam(AnchorId, props?.location?.search);
...@@ -225,9 +231,16 @@ const AssetTable = (props) => { ...@@ -225,9 +231,16 @@ const AssetTable = (props) => {
getTemplates() getTemplates()
} }
const $list = listSubject.subscribe((val) => {
if (val.msg === 'templateChange') {
setCurrentElementId();
getElements();
}
});
window?.addEventListener("storage", storageChange); window?.addEventListener("storage", storageChange);
return () => { return () => {
$list.unsubscribe()
window?.removeEventListener("storage", storageChange); window?.removeEventListener("storage", storageChange);
} }
...@@ -267,7 +280,7 @@ const AssetTable = (props) => { ...@@ -267,7 +280,7 @@ const AssetTable = (props) => {
getFilterElementsGroupThenGetDataAssets(); getFilterElementsGroupThenGetDataAssets();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword, pagination, elementsChanged, assetActionChanged, recursive, fullSearch ]) }, [ keyword, pagination, elementsChanged, assetActionChanged, recursive, fullSearch, currentElementId ])
useEffect(() => { useEffect(() => {
if (reference === AssetRecycleReference) { if (reference === AssetRecycleReference) {
...@@ -348,6 +361,20 @@ const AssetTable = (props) => { ...@@ -348,6 +361,20 @@ const AssetTable = (props) => {
}) })
} }
const getElements = () => {
setLoadingElements(true);
dispatch({
type: 'assetmanage.listElements',
callback: (data) => {
setLoadingElements(false);
setElements(data);
},
error: () => {
setLoadingElements(false);
}
})
}
const getDataAssetLocationByRelation = () => { const getDataAssetLocationByRelation = () => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
...@@ -495,6 +522,7 @@ const AssetTable = (props) => { ...@@ -495,6 +522,7 @@ const AssetTable = (props) => {
setLoading(true); setLoading(true);
let params = { let params = {
queryElementId: currentElementId,
dirId: nodeId, dirId: nodeId,
pageNum, pageNum,
pageSize, pageSize,
...@@ -1097,6 +1125,21 @@ const AssetTable = (props) => { ...@@ -1097,6 +1125,21 @@ const AssetTable = (props) => {
{/* { {/* {
(reference!==AssetRecycleReference) && <Checkbox onChange={onFullSearchChange} checked={fullSearch}>全部数据</Checkbox> (reference!==AssetRecycleReference) && <Checkbox onChange={onFullSearchChange} checked={fullSearch}>全部数据</Checkbox>
} */} } */}
<Select allowClear
loading={loadingElements}
value={currentElementId}
placeholder='请选择搜索属性'
onChange={(val) => {
setCurrentElementId(val)
}}
style={{ width: 160 }}
>
{
(elements??[]).map((item, index) => (
<Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
))
}
</Select>
<Search <Search
placeholder="请输入资产目录要素值" placeholder="请输入资产目录要素值"
allowClear allowClear
......
...@@ -13,6 +13,7 @@ import { highlightSearchContentByTerms } from '../../../../util'; ...@@ -13,6 +13,7 @@ import { highlightSearchContentByTerms } from '../../../../util';
import './AssetTree.less'; import './AssetTree.less';
import 'react-contexify/dist/ReactContexify.css'; import 'react-contexify/dist/ReactContexify.css';
import { appId } from '../../../../App'; import { appId } from '../../../../App';
import { listSubject } from './AssetTable';
const { Option } = AutoComplete; const { Option } = AutoComplete;
...@@ -127,8 +128,10 @@ const AssetTree = (props) => { ...@@ -127,8 +128,10 @@ const AssetTree = (props) => {
if (_templateType) { if (_templateType) {
LocalStorage.set(`templateType-${appId}`, _templateType) LocalStorage.set(`templateType-${appId}`, _templateType)
listSubject.next({ msg: 'templateChange' })
} else { } else {
LocalStorage.set(`templateType-${appId}`, data[0].type) LocalStorage.set(`templateType-${appId}`, data[0].type)
listSubject.next({ msg: 'templateChange' })
} }
if (_dirId) { if (_dirId) {
...@@ -580,6 +583,7 @@ const AssetTree = (props) => { ...@@ -580,6 +583,7 @@ const AssetTree = (props) => {
onChange={(val) => { onChange={(val) => {
setTemplateType(val) setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
listSubject.next({ msg: 'templateChange' });
setCurrentDirId(); setCurrentDirId();
onSelect?.(null, null); onSelect?.(null, null);
setTimeout(() => { setTimeout(() => {
......
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