// import { ProFormInstance } from '@ant-design/pro-form'; 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 | undefined; };

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 BugAnalysis: React.FC = forwardRef(() => { const actionRef = useRef(); const [data, setData] = useState([]); const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);

const columns: ProColumns[] = [ { title: 'BUG等级', dataIndex: 'title', align: 'center', mergeCells: true, }, { 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(() => { setEditableRowKeys(datas?.map((item: any) => item.id)); setData([...datas]); }, []); return ( <EditableProTable rowKey="id" recordCreatorProps={false} actionRef={actionRef} columns={columns} value={data} bordered editable={{ type: 'multiple', editableKeys, onChange: setEditableRowKeys, onValuesChange: (_, values) => { setData(values); }, actionRender: (row, config, defaultDoms) => { return []; }, }} mergeCells={true} mergedCells={(dataSource: any[]) => { const mergedCells: { [key: string]: [number, number, number, number] } = {}; let prevTitle: string | null = null; let startIndex = 0; let endIndex = 0; dataSource.forEach((record, index) => { const { title } = record; if (prevTitle !== title) { if (prevTitle !== null) { mergedCells[${startIndex}-${endIndex}-0-0] = [startIndex, endIndex, 0, 0]; } prevTitle = title; startIndex = index; } endIndex = index; }); if (prevTitle !== null && endIndex > startIndex) { mergedCells[${startIndex}-${endIndex}-0-0] = [startIndex, endIndex, 0, 0]; } return mergedCells; }} />

</ContentCard>

); }); export default BugAnalysis;

BUG分析表格

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

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