// 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'; import { Input } from 'antd';

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', renderFormItem: (text, { record, rowIndex }, form) => { const isFirstRow = rowIndex === 0; const shouldMerge = record.title === 'BUG分析'; return ( <ProForm.Item name={['data', rowIndex, 'title']} style={{ margin: 0 }} rules={[ { required: true, message: '请输入BUG等级', }, ]} > {isFirstRow && shouldMerge ? ( <div style={{ textAlign: 'center' }}>{record.title}

) : ( )} </ProForm.Item> ); }, }, { 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 ( <ContentCard title={'BUG分析'} className="bug-list"> <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 []; }, }} />

</ContentCard>

); }); export default BugAnalysis;

BUG分析 - 可编辑表格展示BUG数量和等级

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

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