import React, { useEffect, useState } from 'react'; import { Table, Typography, Tag, Popover, Button, Switch } from '@douyinfe/semi-ui'; import { cloneDeep } from 'lodash'; import { ColumnProps } from 'table/interface'; export default function App() { const [count, setCount] = useState(100); const [data, setData] = useState([]); const handleSwitchChange = (options: { checked; record; index }) => { const { checked, index } = options; const newData = cloneDeep(data); newData[index].completeStatus = checked; setData(newData); }; const src = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg'; const shouldCellUpdate: ColumnProps['shouldCellUpdate'] = (props, prevProps) => { return props.record !== prevProps.record; }; const columns: ColumnProps[] = [ { title: '需求标题', dataIndex: 'featureTitle', render: (text, record, index) => ( {text} ), filterIcon:
test
, shouldCellUpdate }, { title: '文档', dataIndex: 'doc', width: 150, render: (text, record, index) => ( {text} ), shouldCellUpdate }, { title: '需求状态', dataIndex: 'featureStatus', width: 100, render: (text, record, index) => ( {text} ), shouldCellUpdate }, { title: '优先级', dataIndex: 'priority', render: (text, record, index) => {text}, shouldCellUpdate }, { title: 'PM', dataIndex: 'pm', render: (text, record, index) => ( Hi ByteDancer, this is a popover.
We have 2 lines. } key={index} > {text}
), shouldCellUpdate }, { title: '产品线', dataIndex: 'productLine', render: (text, record, index) => ( {text} ), shouldCellUpdate }, { title: '前端', dataIndex: 'fe', render: (text, record, index) => ( Hi ByteDancer, this is a popover.
We have 2 lines. } key={index} > {text}
), shouldCellUpdate }, { title: '服务端', dataIndex: 'server', render: (text, record, index) => ( Hi ByteDancer, this is a popover.
We have 2 lines. } key={index} > {text}
), shouldCellUpdate }, { title: '创建时间', dataIndex: 'createTime', render: (text, record, index) => ( { console.log('click createTime', record); }} > {text} ), shouldCellUpdate }, { title: '完成时间', dataIndex: 'completeTime', render: (text, record, index) => ( { console.log('click completeTime', record); }} > {text} ), shouldCellUpdate }, { title: '完成状态', dataIndex: 'completeStatus', render: (text, record, index) => ( handleSwitchChange({ checked, record, index })} > ), shouldCellUpdate }, ]; useEffect(() => { const getData = () => { const data = Array.from( { length: count, }, (_, key) => { const rowRandom = Math.round(Math.random() * 1000); const prioritySet = ['P0', 'P1', 'P2']; const priority = prioritySet[Math.round(Math.random() * 2)]; const featureStatusSet = ['待埋点', '开始', '待需详评', '测试', '已完成']; const featureStatus = featureStatusSet[Math.round(Math.random() * 4)]; const doc = 'https://semi.design'; const createTime = new Date().valueOf(); return { key, featureTitle: `需求-${rowRandom}`, doc, featureStatus, priority, pm: 'Li', productLine: 'Hotsoon', fe: '姜鹏志', server: 'ZhuYi', createTime, completeTime: createTime + rowRandom, completeStatus: false, }; } ); return data; }; const newData = getData(); setData(newData); }, [count]); const scroll = { y: 500 }; return ( <>
); }