BUG分析表格:可编辑的BUG分析数据展示
import React, { ForwardedRef, forwardRef, useEffect, useRef, useState } from 'react'; import ContentCard from '@/components/ContentCard'; import { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; import ProForm, { ProFormTextArea } from '@ant-design/pro-form'; import './index.less';
export type BugFormRef = {
getApplicationFormValue?: () => any;
validateApplicationForm: () => Promise
interface Props {
ref?: ForwardedRef
const datas = [ { key: 0, title: '新增BUG总数', totals: 1, s: 0, a: 1, b: 0, c: 0, }, { key: 1, title: 'PEN BUG总数', totals: 0, s: 0, a: 0, b: 0, c: 0, }, ];
const mergeRows = (data: any[]) => { const mergedData = []; for (let i = 0; i < data.length; i += 2) { const row1 = data[i]; const row2 = data[i + 1]; if (row2) { const mergedRow = { ...row1, totals: row1.totals + row2.totals, s: row1.s + row2.s, a: row1.a + row2.a, b: row1.b + row2.b, c: row1.c + row2.c, }; mergedData.push(mergedRow); } else { mergedData.push(row1); } } return mergedData; };
const BugAnalysis: React.FC
const columns: ProColumns[] = [ { title: 'BUG等级', dataIndex: 'title', align: 'center', }, { title: '总数', dataIndex: 'totals', align: 'center', readonly: true, }, { title: 'S', dataIndex: 's', align: 'center', readonly: true, }, { title: 'A', dataIndex: 'a', align: 'center', readonly: true, }, { title: 'B', dataIndex: 'b', align: 'center', readonly: true, }, { title: 'C', dataIndex: 'c', align: 'center', readonly: true, }, { title: 'BUG分析', dataIndex: 'bug', align: 'center', readonly: true, }, ];
useEffect(() => { const mergedData = mergeRows(datas); setData([...mergedData]); }, []);
return ( <ContentCard title={'BUG分析'} className="bug-list"> <EditableProTable rowKey="id" recordCreatorProps={false} actionRef={actionRef} columns={columns} value={data} bordered editable={{ type: 'multiple', actionRender: (row, config, defaultDoms) => { return []; }, }} /> ); });
export default BugAnalysis;
原文地址: https://www.cveoy.top/t/topic/qm6U 著作权归作者所有。请勿转载和采集!