Commit a612c784 authored by XieZhiXiong's avatar XieZhiXiong

chore: 完善没有数据时的展示

parent f28a2ef4
......@@ -49,6 +49,7 @@
&-content {
margin-left: -@margin-md;
min-height: 184px;
}
&-group {
......@@ -91,5 +92,10 @@
background-color: rgba(37,45,55,0.08);;
}
}
&-noData {
margin-top: 20px;
color: @text-color-secondary;
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Description 欢迎卡片
*/
import React, { useState, useEffect } from 'react';
import { message, Spin } from 'antd';
import { message, Spin, Empty } from 'antd';
import classNames from 'classnames';
import { history } from 'umi';
import { SRM_HOME_TODO } from '@/constants/home';
......@@ -19,6 +19,7 @@ import {
getReportMemberHomeGetSettleAccountTally,
} from '@/services/ReportV2Api';
import MellowCard from '@/components/MellowCard';
import NODATA_IMG from '@/assets/imgs/im_noData.png';
import styles from './index.less';
type Apikeys = keyof typeof SRM_HOME_TODO
......@@ -130,11 +131,14 @@ const normalizeTodoList = (dataSource: TallyReseponseType): TodoType[][] => {
const todos: TallyType[] = dataSource[item];
if (todos) {
todos.forEach((todo, todoIndex) => {
group.push({
name: todo.name,
url: todo.link,
total: todo.count,
});
// 待办数大于 0 才展示
if (todo.count > 0) {
group.push({
name: todo.name,
url: todo.link,
total: todo.count,
});
}
if (group.length === GROUP_MAX_LEN) {
ret.push(group);
group = [];
......@@ -194,6 +198,11 @@ const TodoCard: React.FC = () => {
history.push(url);
};
console.log('todoList', todoList)
const noTodoItem = todoList.every((item) => !item.length);
console.log('noTodoItem', noTodoItem)
return (
<MellowCard title={(<div className={styles['todo-title']}>今日待办</div>)}>
<ul className={styles['todo-tag-list']}>
......@@ -215,7 +224,7 @@ const TodoCard: React.FC = () => {
<Spin spinning={listLoading}>
<div className={styles['todo-list']}>
<div className={styles['todo-list-content']}>
{todoList.map((group, index) => (
{todoList.map((group, index) => group.length ? (
<div key={index} className={styles['todo-list-group']}>
{group.map((item, groupItemIndex) => (
<div
......@@ -232,7 +241,10 @@ const TodoCard: React.FC = () => {
</div>
))}
</div>
))}
) : null)}
{noTodoItem ? (
<Empty image={NODATA_IMG} description={<div className={styles['todo-list-noData']}>暂无待办</div>} />
) : null}
</div>
</div>
</Spin>
......
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