|
@@ -1,21 +1,71 @@
|
|
|
|
+import PageContent from '@/components/PageContent';
|
|
|
|
+import PageTitle from '@/components/PageTitle';
|
|
|
|
+import {
|
|
|
|
+ MandateClass,
|
|
|
|
+ MandateStatus,
|
|
|
|
+ MandateType,
|
|
|
|
+} from '@/pages/TaskManage/constent';
|
|
import styles from '@/pages/TaskManage/index.less';
|
|
import styles from '@/pages/TaskManage/index.less';
|
|
-import { PropTypes } from '@/pages/TaskManage/index.types';
|
|
|
|
-import { List } from 'antd';
|
|
|
|
-import React, { useEffect } from 'react';
|
|
|
|
|
|
+import { PropTypes, mandateType } from '@/pages/TaskManage/index.types';
|
|
|
|
+import { getMandateList } from '@/services/TaskManage';
|
|
|
|
+import { RightOutlined } from '@ant-design/icons';
|
|
|
|
+import { useParams, useRequest } from '@umijs/max';
|
|
|
|
+import { List, Spin } from 'antd';
|
|
|
|
+import React, { useEffect, useState } from 'react';
|
|
|
|
+import { useNavigate } from 'umi';
|
|
|
|
|
|
const TaskManage: React.FC<PropTypes> = (props) => {
|
|
const TaskManage: React.FC<PropTypes> = (props) => {
|
|
- const { projectID } = props;
|
|
|
|
|
|
+ const { projectID } = useParams();
|
|
|
|
+ console.log(projectID);
|
|
const project_id = Number(projectID === '' ? '0' : projectID);
|
|
const project_id = Number(projectID === '' ? '0' : projectID);
|
|
- const arr = [];
|
|
|
|
- for (let i = 0; i < 20; i++) {
|
|
|
|
- arr.push({
|
|
|
|
- title: '任务标题',
|
|
|
|
- desc: '任务详情任务详情任务详情任务详情任务详情任务详情任务详情任务详情任务详情',
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
|
|
- const goToDetail = (item: number) => {
|
|
|
|
- console.log(item);
|
|
|
|
|
|
+ const navigate = useNavigate();
|
|
|
|
+
|
|
|
|
+ const [pagination, setPagination] = useState({
|
|
|
|
+ total: 0,
|
|
|
|
+ pageSize: 5,
|
|
|
|
+ current: 1,
|
|
|
|
+ });
|
|
|
|
+ const [mandateList, setMandateList] = useState<mandateType[]>([]);
|
|
|
|
+
|
|
|
|
+ const {
|
|
|
|
+ run: runGetMandateList,
|
|
|
|
+ loading,
|
|
|
|
+ refresh: refreshMandateList,
|
|
|
|
+ } = useRequest(getMandateList, {
|
|
|
|
+ defaultParams: [
|
|
|
|
+ {
|
|
|
|
+ project_id,
|
|
|
|
+ pageSize: pagination.pageSize,
|
|
|
|
+ currentPage: pagination.current,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ onSuccess: () => {},
|
|
|
|
+ formatResult: (result) => {
|
|
|
|
+ const mandates = result.data.list;
|
|
|
|
+ mandates.forEach((mandate: mandateType) => {
|
|
|
|
+ mandate.Status =
|
|
|
|
+ MandateStatus.find((status) => status.value === mandate.Status) || 0;
|
|
|
|
+ mandate.MandateClass =
|
|
|
|
+ MandateClass.find(
|
|
|
|
+ (classItem) => classItem.value === mandate.MandateClass,
|
|
|
|
+ ) || 0;
|
|
|
|
+ mandate.MandateType =
|
|
|
|
+ MandateType.find((type) => type.value === mandate.MandateType) || 0;
|
|
|
|
+ });
|
|
|
|
+ setMandateList(result.data.list);
|
|
|
|
+ setPagination(result.data.pagination);
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ const goToDetail = (item: mandateType) => {
|
|
|
|
+ navigate(
|
|
|
|
+ `/task-manage/detail?project_id=${project_id}&mandate_id=${item.Id}`,
|
|
|
|
+ );
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const onPageChange = (page: number, pageSize: number) => {
|
|
|
|
+ runGetMandateList({ project_id, currentPage: page, pageSize });
|
|
};
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -26,7 +76,7 @@ const TaskManage: React.FC<PropTypes> = (props) => {
|
|
};
|
|
};
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
- const makeList = (item: any, index: number) => {
|
|
|
|
|
|
+ const makeList = (item: mandateType, index: number) => {
|
|
return (
|
|
return (
|
|
<List.Item
|
|
<List.Item
|
|
className={styles.listItem}
|
|
className={styles.listItem}
|
|
@@ -34,34 +84,46 @@ const TaskManage: React.FC<PropTypes> = (props) => {
|
|
goToDetail(item);
|
|
goToDetail(item);
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- <List.Item.Meta title={item.title} description={item.desc} />
|
|
|
|
|
|
+ <List.Item.Meta
|
|
|
|
+ title={
|
|
|
|
+ typeof item.MandateType === 'number' ? '' : item.MandateType.label
|
|
|
|
+ }
|
|
|
|
+ description={item.Detail}
|
|
|
|
+ />
|
|
<div className={styles.itemCount}>
|
|
<div className={styles.itemCount}>
|
|
<div className={styles.countNumber}>10</div>
|
|
<div className={styles.countNumber}>10</div>
|
|
<div>任务数量</div>
|
|
<div>任务数量</div>
|
|
</div>
|
|
</div>
|
|
- <div style={{ fontSize: '48px', color: 'gray', fontWeight: '200' }}>
|
|
|
|
- {'>'}
|
|
|
|
- </div>
|
|
|
|
|
|
+ <RightOutlined />
|
|
</List.Item>
|
|
</List.Item>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|
|
return (
|
|
return (
|
|
- <div className={styles.backgroundImage}>
|
|
|
|
- <div className={styles.container}>
|
|
|
|
- <div className={styles.title}>
|
|
|
|
- <span className={styles.delimiter}></span>
|
|
|
|
- 任务管理
|
|
|
|
- </div>
|
|
|
|
|
|
+ <PageContent>
|
|
|
|
+ <PageTitle>任务管理</PageTitle>
|
|
|
|
+ <Spin spinning={loading}>
|
|
<List
|
|
<List
|
|
className={styles.taskList}
|
|
className={styles.taskList}
|
|
bordered
|
|
bordered
|
|
itemLayout="horizontal"
|
|
itemLayout="horizontal"
|
|
- dataSource={arr}
|
|
|
|
|
|
+ dataSource={mandateList}
|
|
renderItem={makeList}
|
|
renderItem={makeList}
|
|
|
|
+ pagination={
|
|
|
|
+ mandateList.length
|
|
|
|
+ ? {
|
|
|
|
+ position: 'bottom',
|
|
|
|
+ align: 'end',
|
|
|
|
+ simple: true,
|
|
|
|
+ showSizeChanger: false,
|
|
|
|
+ onChange: onPageChange,
|
|
|
|
+ ...pagination,
|
|
|
|
+ }
|
|
|
|
+ : false
|
|
|
|
+ }
|
|
/>
|
|
/>
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </Spin>
|
|
|
|
+ </PageContent>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|