Commit e1c4efa7 authored by Bill's avatar Bill

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

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