Commit 3ef9f302 by zhaochengxiang

资产人员列表

parent 9fdfdc4c
......@@ -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 [options, setOptions] = React.useState()
......@@ -1308,9 +1308,11 @@ const UserItem = ({ loading, users, value, onChange, readonly=false, terms = [],
return (
<React.Fragment>
{
readonly ? <Typography.Text>
readonly ? <Tooltip title={showTooltip?userInfo:''}>
<Typography.Text ellipsis={true}>
{highlightSearchContentByTerms(userInfo, terms)}
</Typography.Text> : <Select loading={loading} showSearch allowClear
</Typography.Text>
</Tooltip> : <Select loading={loading} showSearch allowClear
placeholder='请选择用户'
mode={multiple?'multiple':null}
value={currentValue}
......
......@@ -141,6 +141,10 @@ const AssetManageTree = (props) => {
if ((data??[]).length > 0) {
setTemplateType(data[0].type)
LocalStorage.set(`templateType-${appId}`, data[0].type)
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
getAllDirectoryAsTree(true)
}
},
......@@ -781,6 +785,10 @@ const AssetManageTree = (props) => {
onChange={(val) => {
setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setCurrentDirId();
onSelect?.(null, null);
setTimeout(() => {
......
......@@ -22,6 +22,7 @@ import StartFlowModal from "./StartFlow";
import "./AssetTable.less";
import 'react-contexify/dist/ReactContexify.css';
import { getTemplateType } from "../../../../util/axios";
import { UserItem } from "./AssetAction";
const { Text } = Typography;
const { Search } = Input;
......@@ -170,6 +171,7 @@ const AssetTable = (props) => {
const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState()
const [sorter, setSorter] = useState()
const [elements, setElements] = useState()
const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search);
......@@ -214,22 +216,34 @@ const AssetTable = (props) => {
}
useEffect(() => {
if (TableWidth>0 && columns.length>0) {
if (TableWidth>0 && columns.length>0 && (elements??[]).length>0) {
const newColumns = [...columns??[]];
const currentWidth = (newColumns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 32.0;
if (currentWidth < TableWidth) {
newColumns.forEach(column => {
if (currentWidth < TableWidth) {
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' />]);
} else {
setRealColumns([]);
}
}, [columns, TableWidth])
}, [columns, TableWidth, elements, users])
useEffect(() => {
getUsers();
......@@ -294,31 +308,6 @@ const AssetTable = (props) => {
//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) {
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) => {
if (e.key === 'assetRelationOnClickEvent') {
remoteRelationRef.current = e.relation;
......@@ -329,6 +318,8 @@ const AssetTable = (props) => {
dirId: e.dirId
};
shouldScrollRef.current = true;
} else if (e.key === 'assetTemplateChange') {
getElements()
}
}
......@@ -342,6 +333,10 @@ const AssetTable = (props) => {
if ((data??[]).length > 0) {
setTemplateType(data[0].type)
LocalStorage.set(`templateType-${appId}`, data[0].type)
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
getFilterElementsGroupThenGetDataAssets();
}
},
......@@ -351,9 +346,18 @@ const AssetTable = (props) => {
})
}
const getElements = () => {
dispatch({
type: 'assetmanage.listElements',
callback: data => {
setElements(data)
}
})
}
const getUsers = () => {
dispatch({
type: 'pds.getOwners',
type: 'user.getMcclUsers',
callback: (data) => {
setUsers(data);
}
......@@ -1045,6 +1049,10 @@ const AssetTable = (props) => {
onChange={(val) => {
setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setPagination({ ...pagination, pageNum: 1 });
}}
style={{ width: 100 }}
......@@ -1196,7 +1204,7 @@ const AssetTable = (props) => {
})
}
rowKey='id'
dataSource={realAssets}
dataSource={assets}
pagination={false}
size='default'
scroll={{ y: scrollY }}
......
......@@ -131,6 +131,10 @@ const AssetTree = (props) => {
LocalStorage.set(`templateType-${appId}`, data[0].type)
}
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
if (_dirId) {
getAllDirectoryAsTree(true, _dirId)
} else {
......@@ -580,6 +584,10 @@ const AssetTree = (props) => {
onChange={(val) => {
setTemplateType(val)
LocalStorage.set(`templateType-${appId}`, val);
let event = new Event('storage');
event.key = 'assetTemplateChange';
window?.dispatchEvent(event);
setCurrentDirId();
onSelect?.(null, null);
setTimeout(() => {
......@@ -587,7 +595,7 @@ const AssetTree = (props) => {
getAllDirectoryAsTree(true)
}, 100)
}}
style={{ width: 80 }}
style={{ width: 100 }}
>
{
(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