Commit 31169abf by zhaochengxiang

主题域

parent 5bd92c73
import React, { useEffect, useState, useContext } from 'react'; import React, { useEffect, useState, useContext, useMemo } from 'react';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select } from 'antd'; import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, UpOutlined } from '@ant-design/icons';
...@@ -37,12 +37,16 @@ const AssetAction = (props) => { ...@@ -37,12 +37,16 @@ const AssetAction = (props) => {
const [ loadingUsers, setLoadingUsers ] = useState(false); const [ loadingUsers, setLoadingUsers ] = useState(false);
const [ departments, setDepartments ] = useState([]); const [ departments, setDepartments ] = useState([]);
const [ loadingDepartments, setLoadingDepartments ] = useState(false); const [ loadingDepartments, setLoadingDepartments ] = useState(false);
const [ treeData, setTreeData ] = useState([]);
const [ treeDataMap, setTreeDataMap ] = useState(undefined);
const [currentDomainGroup, setCurrentDomainGroup] = useState(undefined);
const app = useContext(AppContext); const app = useContext(AppContext);
useEffect(() => { useEffect(() => {
getSystems(); getSystems();
getUsers(); getUsers();
getTreeData();
getDepartments(); getDepartments();
if (action === 'add') { if (action === 'add') {
getElements(); getElements();
...@@ -63,6 +67,14 @@ const AssetAction = (props) => { ...@@ -63,6 +67,14 @@ const AssetAction = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [id, dirId]) }, [id, dirId])
const domains = useMemo(() => {
if (currentDomainGroup && treeDataMap) {
return treeDataMap[currentDomainGroup];
}
return [];
}, [currentDomainGroup, treeDataMap])
const getAssetPaths = () => { const getAssetPaths = () => {
dispatch({ dispatch({
type: 'assetmanage.getAssetPaths', type: 'assetmanage.getAssetPaths',
...@@ -106,6 +118,21 @@ const AssetAction = (props) => { ...@@ -106,6 +118,21 @@ const AssetAction = (props) => {
}) })
} }
const getTreeData = () => {
dispatch({
type: 'assetmanage.queryAllDirectoryAsTree',
callback: (data) => {
setTreeData(data);
const newTreeDataMap = {};
data?.forEach(item => {
newTreeDataMap[item.text] = item.children;
})
setTreeDataMap(newTreeDataMap);
}
})
}
const getDepartments = () => { const getDepartments = () => {
setLoadingDepartments(true); setLoadingDepartments(true);
dispatch({ dispatch({
...@@ -245,6 +272,9 @@ const AssetAction = (props) => { ...@@ -245,6 +272,9 @@ const AssetAction = (props) => {
let _fieldsValue = {}; let _fieldsValue = {};
(data.elements||[]).forEach(element => { (data.elements||[]).forEach(element => {
_fieldsValue[element.name] = element.value||''; _fieldsValue[element.name] = element.value||'';
if (element.name === '主题域分组') {
setCurrentDomainGroup(element.value);
}
}) })
form?.setFieldsValue(_fieldsValue); form?.setFieldsValue(_fieldsValue);
...@@ -467,6 +497,40 @@ const AssetAction = (props) => { ...@@ -467,6 +497,40 @@ const AssetAction = (props) => {
/> />
} }
if (element.name === '主题域分组') {
return (
<Select
allowClear
disabled={element.manualMaintain==='否'}
>
{
treeData?.map((item, index) => {
return <Select.Option key={index} value={item.text}>
{item.text}
</Select.Option>
})
}
</Select>
)
}
if (element.name === '主题域') {
return (
<Select
allowClear
disabled={element.manualMaintain==='否'}
>
{
domains?.map((item, index) => {
return <Select.Option key={index} value={item.text}>
{item.text}
</Select.Option>
})
}
</Select>
)
}
if (element.selectMode==='单选') { if (element.selectMode==='单选') {
return ( return (
<Select <Select
...@@ -509,6 +573,13 @@ const AssetAction = (props) => { ...@@ -509,6 +573,13 @@ const AssetAction = (props) => {
return <span className='text-color'>{highlightSearchContentByTerms(item.value||'', terms)}</span>; return <span className='text-color'>{highlightSearchContentByTerms(item.value||'', terms)}</span>;
} }
const onValuesChange = (changedValues, allValues) => {
if (changedValues.hasOwnProperty('主题域分组')) {
setCurrentDomainGroup(changedValues['主题域分组']);
form.setFieldsValue({'主题域': ''});
}
}
return ( return (
<div <div
className='flex' className='flex'
...@@ -703,7 +774,7 @@ const AssetAction = (props) => { ...@@ -703,7 +774,7 @@ const AssetAction = (props) => {
}); });
return ( return (
<Form {...formItemLayout} form={form} labelWrap> <Form {...formItemLayout} form={form} labelWrap onValuesChange={onValuesChange}>
{ {
(sameAttributeElements||[]).map((element, _index) => { (sameAttributeElements||[]).map((element, _index) => {
return ( return (
......
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