Commit 17ff7421 by zhaochengxiang

资产增加要素搜索

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