Commit 3ef9f302 by zhaochengxiang

资产人员列表

parent 9fdfdc4c
...@@ -1255,7 +1255,7 @@ const DepartmentItem = ({ loading, departments, value, onChange, multiple = fals ...@@ -1255,7 +1255,7 @@ const DepartmentItem = ({ loading, departments, value, onChange, multiple = fals
) )
} }
const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [], multiple = false }) => { export const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [], multiple = false, showTooltip = false }) => {
const [searchValue, setSearchValue] = React.useState() const [searchValue, setSearchValue] = React.useState()
const [options, setOptions] = React.useState() const [options, setOptions] = React.useState()
...@@ -1308,9 +1308,11 @@ const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [], ...@@ -1308,9 +1308,11 @@ const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [],
return ( return (
<React.Fragment> <React.Fragment>
{ {
readonly ? <Typography.Text> readonly ? <Tooltip title={showTooltip?userInfo:''}>
<Typography.Text ellipsis={true}>
{highlightSearchContentByTerms(userInfo, terms)} {highlightSearchContentByTerms(userInfo, terms)}
</Typography.Text> : <Select loading={loading} showSearch allowClear </Typography.Text>
</Tooltip> : <Select loading={loading} showSearch allowClear
placeholder='请选择用户' placeholder='请选择用户'
mode={multiple?'multiple':null} mode={multiple?'multiple':null}
value={currentValue} value={currentValue}
......
...@@ -141,6 +141,10 @@ const AssetManageTree = (props) => { ...@@ -141,6 +141,10 @@ 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)
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
getAllDirectoryAsTree(true) getAllDirectoryAsTree(true)
} }
}, },
...@@ -781,6 +785,10 @@ const AssetManageTree = (props) => { ...@@ -781,6 +785,10 @@ const AssetManageTree = (props) => {
onChange={(val) => { onChange={(val) => {
setTemplateType(val) setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setCurrentDirId(); setCurrentDirId();
onSelect?.(null, null); onSelect?.(null, null);
setTimeout(() => { setTimeout(() => {
......
...@@ -22,6 +22,7 @@ import StartFlowModal from "./StartFlow"; ...@@ -22,6 +22,7 @@ import StartFlowModal from "./StartFlow";
import "./AssetTable.less"; import "./AssetTable.less";
import 'react-contexify/dist/ReactContexify.css'; import 'react-contexify/dist/ReactContexify.css';
import { getTemplateType } from "../../../../util/axios"; import { getTemplateType } from "../../../../util/axios";
import { UserItem } from "./AssetAction";
const { Text } = Typography; const { Text } = Typography;
const { Search } = Input; const { Search } = Input;
...@@ -170,6 +171,7 @@ const AssetTable = (props) => { ...@@ -170,6 +171,7 @@ const AssetTable = (props) => {
const [templates, setTemplates] = useState() const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState() const [currentTemplateType, setTemplateType] = useState()
const [sorter, setSorter] = useState() const [sorter, setSorter] = useState()
const [elements, setElements] = 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);
...@@ -214,22 +216,34 @@ const AssetTable = (props) => { ...@@ -214,22 +216,34 @@ const AssetTable = (props) => {
} }
useEffect(() => { useEffect(() => {
if (TableWidth>0 && columns.length>0) { if (TableWidth>0 && columns.length>0 && (elements??[]).length>0) {
const newColumns = [...columns??[]]; const newColumns = [...columns??[]];
const currentWidth = (newColumns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 32.0; const currentWidth = (newColumns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 32.0;
if (currentWidth < TableWidth) {
newColumns.forEach(column => { newColumns.forEach(column => {
if (currentWidth < TableWidth) {
column.width = (TableWidth - 32.0)/newColumns.length; column.width = (TableWidth - 32.0)/newColumns.length;
})
} }
const index = (elements??[]).findIndex(item => item.name === column.title)
if (index !== -1) {
const tmp = (elements[index].optional??'').split(',')
if ((tmp??[]).indexOf('用户列表')!==-1) {
column.render = (text, record) => {
return <UserItem readonly={true} value={text||''} users={users} multiple={elements[index].selectMode==='多选'} showTooltip={true} />
}
}
}
})
setRealColumns([...newColumns, <Column key='auto' />]); setRealColumns([...newColumns, <Column key='auto' />]);
} else { } else {
setRealColumns([]); setRealColumns([]);
} }
}, [columns, TableWidth]) }, [columns, TableWidth, elements, users])
useEffect(() => { useEffect(() => {
getUsers(); getUsers();
...@@ -294,31 +308,6 @@ const AssetTable = (props) => { ...@@ -294,31 +308,6 @@ const AssetTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ keyword, pagination, elementsChanged ]) }, [ keyword, pagination, elementsChanged ])
const realAssets = useMemo(() => {
const newAssets = [...assets];
if (users?.length > 0 && assets?.length > 0 && columns?.length > 0) {
const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人'];
const indexArray = [];
columns.forEach((item, index) => {
if (specialCol.indexOf(item.title?.toLowerCase()) !== -1) {
indexArray.push(index);
}
});
newAssets?.forEach((item) => {
indexArray?.forEach(index => {
const user = users?.filter((user)=>(user.pernr===item[`element${index+1}`]));
if (user && user.length > 0) {
item[`element${index+1}`] = user[0].nachn?`${user[0].nachn}(${user[0].pernr})`:user[0].pernr;
}
})
})
}
return newAssets;
}, [users, assets, columns])
const storageChange = (e) => { const storageChange = (e) => {
if (e.key === 'assetRelationOnClickEvent') { if (e.key === 'assetRelationOnClickEvent') {
remoteRelationRef.current = e.relation; remoteRelationRef.current = e.relation;
...@@ -329,6 +318,8 @@ const AssetTable = (props) => { ...@@ -329,6 +318,8 @@ const AssetTable = (props) => {
dirId: e.dirId dirId: e.dirId
}; };
shouldScrollRef.current = true; shouldScrollRef.current = true;
} else if (e.key === 'assetTemplateChange') {
getElements()
} }
} }
...@@ -342,6 +333,10 @@ const AssetTable = (props) => { ...@@ -342,6 +333,10 @@ const AssetTable = (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)
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
getFilterElementsGroupThenGetDataAssets(); getFilterElementsGroupThenGetDataAssets();
} }
}, },
...@@ -351,9 +346,18 @@ const AssetTable = (props) => { ...@@ -351,9 +346,18 @@ const AssetTable = (props) => {
}) })
} }
const getElements = () => {
dispatch({
type: 'assetmanage.listElements',
callback: data => {
setElements(data)
}
})
}
const getUsers = () => { const getUsers = () => {
dispatch({ dispatch({
type: 'pds.getOwners', type: 'user.getMcclUsers',
callback: (data) => { callback: (data) => {
setUsers(data); setUsers(data);
} }
...@@ -1045,6 +1049,10 @@ const AssetTable = (props) => { ...@@ -1045,6 +1049,10 @@ const AssetTable = (props) => {
onChange={(val) => { onChange={(val) => {
setTemplateType(val) setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setPagination({ ...pagination, pageNum: 1 }); setPagination({ ...pagination, pageNum: 1 });
}} }}
style={{ width: 100 }} style={{ width: 100 }}
...@@ -1196,7 +1204,7 @@ const AssetTable = (props) => { ...@@ -1196,7 +1204,7 @@ const AssetTable = (props) => {
}) })
} }
rowKey='id' rowKey='id'
dataSource={realAssets} dataSource={assets}
pagination={false} pagination={false}
size='default' size='default'
scroll={{ y: scrollY }} scroll={{ y: scrollY }}
......
...@@ -131,6 +131,10 @@ const AssetTree = (props) => { ...@@ -131,6 +131,10 @@ const AssetTree = (props) => {
LocalStorage.set(`templateType-${appId}`, data[0].type) LocalStorage.set(`templateType-${appId}`, data[0].type)
} }
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
if (_dirId) { if (_dirId) {
getAllDirectoryAsTree(true, _dirId) getAllDirectoryAsTree(true, _dirId)
} else { } else {
...@@ -580,6 +584,10 @@ const AssetTree = (props) => { ...@@ -580,6 +584,10 @@ const AssetTree = (props) => {
onChange={(val) => { onChange={(val) => {
setTemplateType(val) setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setCurrentDirId(); setCurrentDirId();
onSelect?.(null, null); onSelect?.(null, null);
setTimeout(() => { setTimeout(() => {
...@@ -587,7 +595,7 @@ const AssetTree = (props) => { ...@@ -587,7 +595,7 @@ const AssetTree = (props) => {
getAllDirectoryAsTree(true) getAllDirectoryAsTree(true)
}, 100) }, 100)
}} }}
style={{ width: 80 }} style={{ width: 100 }}
> >
{ {
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>) (templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
......
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