import React, { useEffect, useState } from 'react'; import ContentCard from '@/components/ContentCard'; import PageContainer from '@/components/PageContainer'; import ProCardComponent from '@/components/ProCard'; import ProCard from '@ant-design/pro-card'; import ProTable, { ProColumns } from '@ant-design/pro-table'; import { Button, Typography } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import { history, useModel } from 'umi'; import TaskModal from './TaskModal'; import { getBudgetByProjectId, getWeeklyData } from '@/services/project/kanban'; import moment from 'moment'; const { Link } = Typography; import './index.less'; import { projectList, WeeklyList } from '../../Kanban/WeeklyReports/type';

const WeeklyReport: React.FC = () => { const [depBugModal, setDepBugModal] = useState({ visible: false, projectTask: {} }); const { current, changeCurrent } = useModel('operation'); const [budgetKey, setBudgetKey] = useState(''); const [WeeklyData, setWeeklyData] = useState([]); const [loading, setLoading] = useState(false); const getWeeklyDatas = async () => { setLoading(true); try { const { data } = await getWeeklyData({ bpProjectId: budgetKey, projectId: current, }); setLoading(false); const tableData = data.map((item: WeeklyList, index2: number) => { const len = item?.projectList?.length; return item.projectList.map((ite: projectList, index: number) => { return { serial: index2 + 1, weeklyName: item.weeklyName, creator: item.creator, projectName: ite.projectName, projectId: ite.projectId, spm: ite.spm, task: item.task, weeklyTime: item.weeklyTime, unFinishedTask: item.unFinishedTask, finishedTask: item.finishedTask, createTime: item.createTime ? moment(item.createTime).format('YYYY-MM-DD') : '', span: index === 0 ? len : 0, key: index2 * len + index, }; }); }).flat();

  setWeeklyData(tableData);
} catch (error) {
  return { success: false };
}

}; const getBudgetByProjectIds = async (id: string) => { try { const { data } = await getBudgetByProjectId({ projectId: id }); const bugValue = data.bpProjectId; setBudgetKey(bugValue); } catch (error) { return { success: false }; } };

useEffect(() => { if (current) { getBudgetByProjectIds(current); } }, [current]); useEffect(() => { if (budgetKey && current) { getWeeklyDatas(); } }, [budgetKey, current]);

const columns: ProColumns[] = [ { title: '序号', width: 20, dataIndex: 'serial', align: 'center', render: (value, row) => { return { children: value, props: { rowSpan: row.span }, }; }, }, { title: '周报', dataIndex: 'weeklyName', align: 'left', hideInSearch: true, width: 60, render: (text, record) => { return ( <Link onClick={() => { history.push( /project/operation/projectDocuments/reportDetails?weeklyName=${record.weeklyName}&weeklyTime=${record.weeklyTime}&creator=${record.creator}, ); }} > {record.weeklyName} ); }, onCell: (row) => { return { rowSpan: row.span }; }, }, { title: 'SPM', dataIndex: 'spm', align: 'center', hideInSearch: true, width: 30, }, { title: '创建时间', dataIndex: 'createTime', align: 'center', hideInSearch: true, width: 45, render: (value, row) => { return { children: value, props: { rowSpan: row.span }, }; }, }, { title: '创建人', dataIndex: 'creator', align: 'center', hideInSearch: true, width: 40, render: (value, row) => { return { children: value, props: { rowSpan: row.span }, }; }, }, { title: '任务总数', dataIndex: 'task', align: 'center', hideInSearch: true, width: 40, render: (, record) => { return ( <span onClick={() => setDepBugModal({ visible: true, projectTask: record.task })} style={{ cursor: 'pointer', color: '#1890FF' }} > {record.task?.length || '0'} ); }, onCell: (row) => { return { rowSpan: row.span }; }, }, { title: '本周完成任务', dataIndex: 'finishedTask', align: 'center', hideInSearch: true, width: 45, render: (, record) => { return ( <span onClick={() => setDepBugModal({ visible: true, projectTask: record.finishedTask })} style={{ cursor: 'pointer', color: '#1890FF' }} > {record.finishedTask?.length || '0'} ); }, onCell: (row) => { return { rowSpan: row.span }; }, }, { title: '待完成任务', dataIndex: 'unFinishedTask', align: 'center', hideInSearch: true, width: 40, render: (, record) => { return ( <span onClick={() => setDepBugModal({ visible: true, projectTask: record.unFinishedTask })} style={{ cursor: 'pointer', color: '#1890FF' }} > {record.unFinishedTask?.length || '0'} ); }, onCell: (row) => { return { rowSpan: row.span }; }, }, { title: '周报合并项目(共预算项目)', dataIndex: 'projectName', align: 'center', hideInSearch: true, width: 100, render: (, record: any) => { return ( <div style={{ textAlign: 'left' }}> <Link onClick={() => { changeCurrent(record.projectId); history.push(/project/operation/home?projectId=${record.projectId}); }} > {record.projectName}

); }, }, ];

return ( {/* /} <ProCard colSpan={{ lg: 24, xl: 16 }} bodyStyle={{ padding: '0' }}> <ProTable className="tablePlan" rowKey={'key'} scroll={{ y: 400 }} columns={columns} dataSource={WeeklyData} bordered search={false} options={false} pagination={false} loading={loading} headerTitle={ <Button icon={} type="primary" onClick={() => { history.push('/project/operation/projectDocuments/newReport'); }} > 新建周报 } /> <TaskModal {...depBugModal} onCancel={() => setDepBugModal((val) => ({ ...val, visible: false }))} /> {/ */} ); }; export default WeeklyReport;

项目周报 - 项目管理系统

原文地址: https://www.cveoy.top/t/topic/pZbo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录