Commit e1c4efa7 authored by Bill's avatar Bill

fix: 修改首页bug, 兼容当数据为空时不显示

parent bc1ff7e4
......@@ -26,3 +26,7 @@
margin-top: 12px;
}
}
.empty {
padding: 0;
}
......@@ -22,7 +22,7 @@ const KEY_TITLE = {
}
const MemberCenter: React.FC<Iprops> = () => {
const { loading, responseData, filterEmptyList, isError, ref } = useViewRequest<GetReportMemberHomeGetMemberTallyResponse, any>(PublicApi.getReportMemberHomeGetMemberTally, {})
const { loading, responseData, filterEmptyList, isError, ref, isEmpty } = useViewRequest<GetReportMemberHomeGetMemberTallyResponse, any>(PublicApi.getReportMemberHomeGetMemberTally, {})
return (
<Layout
......@@ -40,6 +40,7 @@ const MemberCenter: React.FC<Iprops> = () => {
}
loading={loading}
isError={isError}
isEmpty={isEmpty}
>
<StaticsDataList title={KEY_TITLE} dataSource={filterEmptyList} />
</Layout>
......
......@@ -6,6 +6,7 @@ import { Link } from 'umi';
import layoutStyles from './center.less';
import Authorize from '../Authorize';
import { BellOutlined, RightOutlined } from '@ant-design/icons';
import cx from 'classnames'
interface LayoutType {
StaticsDataList: typeof StaticsDataList,
......@@ -16,6 +17,10 @@ interface LayoutType {
interface Iprops {
viewRef: any,
/**
* 是否没数据
*/
isEmpty?: boolean,
/**
* 标题
*/
title?: string,
......@@ -41,11 +46,12 @@ interface Iprops {
* 出错是的render方法
*/
customizeErrorRender?: (() => React.ReactElement )| null
onRefresh?: (params: any) => void
onRefresh?: (params: any) => void,
};
const Layout: LayoutType & React.FC<Iprops> = (props) => {
const { title, tips, extra, children, loading, isError, customizeErrorRender, viewRef, onRefresh } = props;
const { title, tips, extra, children, loading, isError, customizeErrorRender, viewRef, onRefresh, isEmpty = false } = props;
const handleRefresh = () => {
onRefresh?.({})
......@@ -68,20 +74,30 @@ const Layout: LayoutType & React.FC<Iprops> = (props) => {
return children;
}
const containerCs = cx(styles.container, {
// [styles.empty]: isEmpty
})
return (
<div className={styles.container} ref={viewRef}>
<div className={styles.header}>
<div className={styles.left}>
<div className={styles.title}>{title}</div>
<div className={styles.tips}>{tips}</div>
</div>
<div className={styles.extra}>
{extra}
</div>
</div>
<div className={styles.body}>
{renderStatus()}
</div>
<div ref={viewRef}>
{
!isEmpty && (
<div className={containerCs} >
<div className={styles.header}>
<div className={styles.left}>
<div className={styles.title}>{title}</div>
<div className={styles.tips}>{tips}</div>
</div>
<div className={styles.extra}>
{extra}
</div>
</div>
<div className={styles.body}>
{renderStatus()}
</div>
</div>
) || null
}
</div>
)
}
......
......@@ -62,17 +62,18 @@ function useViewRequest<T, P>(fn: (postData: P) => Promise<ResponseDataType & {
return result
}
Object.keys(responseData).forEach((_row) => {
// if (responseData[_row] && responseData[_row].length !== 0) {
// result[_row] = responseData[_row];
// }
if (responseData[_row]) {
if (responseData[_row] && responseData[_row].length !== 0) {
result[_row] = responseData[_row];
}
})
console.log("result", result);
return result;
}, [responseData])
return { loading, isError, ref, hasRequest, refresh, responseData, filterEmptyList, inViewPort }
const isEmpty = useMemo(() => {
return filterEmptyList && Object.keys(filterEmptyList).length === 0;
}, [filterEmptyList])
return { loading, isError, ref, hasRequest, refresh, responseData, filterEmptyList, inViewPort, isEmpty }
}
export default useViewRequest
......@@ -196,7 +196,7 @@ export const complaintAddSchema: ISchema = {
]
},
attachments: {
title: '考察要求附件',
title: '事件附件',
type: 'object',
'x-component': 'FormilyUploadFiles',
}
......
......@@ -41,20 +41,9 @@ const columns: ColumnsType<GetMemberInspectPageResponseDetail> = [
render: (text, record) => {
const isFail = +record.score < 60
return (
<StatusTag type={isFail ? 'danger' : 'primary'} title={isFail ? '不合格' : '合格'} />
<StatusTag type={isFail ? 'danger' : 'primary'} title={record.result} />
)
},
filters: [
{
text: '合格',
value: 1,
},
{
text: '不合格',
value: 0,
},
],
onFilter: (_value, record) => _value === 1 ? +record.score >= 60 : +record.score < 60 ,
},
// {
// title: '操作',
......
......@@ -92,7 +92,7 @@ const InspectionDetail: React.FC<Iprops> = (props: Iprops) => {
},
{
title: '考察结果',
value: initialValue?.result === 1 ? '合格' : '不合格'
value: initialValue?.result
}
], [initialValue])
......
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