Commit 02a9c759 authored by 张烨's avatar 张烨

fix: upload callback url to string

parent 7b1a217c
......@@ -26,7 +26,9 @@ const ListCardItem = props => {
useEffect(() => {
if (isGroup) {
const keys = item.children
.map(child => checkChildrenByCondition(child, c => getId(c), 'map'))
.map(child =>
checkChildrenByCondition(child, c => getId(c), true, 'map'),
)
.flat(Infinity);
setChildrenKeys(keys);
} else {
......
......@@ -10,14 +10,21 @@ export const getId = item =>
item.userID || item.roleID || item.stationID || item.id;
export const checkIsGroup = node =>
['widgetGroup'].includes(node?.type || node) && node.children?.length > 0;
export const checkChildrenByCondition = (item, fn, tag = 'every') => {
// 递归遍历节点的方法
export const checkChildrenByCondition = (
item,
fn,
withGroup = true,
method = 'every',
) => {
if (!checkIsGroup(item)) {
return fn(item);
}
return [
getId(item),
...item.children[tag](t => checkChildrenByCondition(t, fn, tag)),
];
const childrenResults = item.children[method](t =>
checkChildrenByCondition(t, fn, method),
);
return withGroup ? [fn(item), ...childrenResults] : [...childrenResults];
};
const ListCard = props => {
......
......@@ -90,10 +90,10 @@ class PicturesWall extends React.Component<PicturesWallType> {
uid: uuid(8, 16),
name: '熊猫运维中台系统',
status: 'done',
url: this.getImageUrl(this.state.curSelectedImg),
url: this.state.curSelectedImg,
},
];
this.props.onChange && this.props.onChange(fileList);
this.props.onChange && this.props.onChange(this.props.maxLen === 1 ? fileList[0].url : fileList.map(f => f.url));
this.setState({ fileList, wallModalVisible: false });
};
......
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