<<供电所技术台帐>>第二周完成进度

星期一:

本周开始做报表,具体思路是对于复杂的显示结果,就在数据库中建一个表,用存储过程将要求的数据填到表中,然后在查询到本地,简单的就直接用SQL查询出来!报表用quickrep来做,但是做一个保存为excel的功能

星期二:

在实际的操作过程中两个clientdataset实现主从关系的报表没有实现,没有办法,就用query直接代替!希望在本周能够解决!如果是一个表的就用clientdataset实现了。

const ElectricityWarningChart:React.FC = () => { const style: React.CSSProperties = {marginBottom: '10px', display: 'flex', justifyContent: 'center'} let dateStr: string= dayjs().format('YYYY-MM') const disabledDate = (current: any) => { return current > dayjs(); } const onChange: DatePickerProps['onChange'] = (date, dateString) => { dateStr = dateString }; return ( <> <ProCard className=" " title="电费管理-预警情况" headerBordered bordered extra={<Space direction="vertical"> <DatePicker onChange={onChange} picker="month" disabledDate={disabledDate} defaultValue={dayjs()} /> </Space>} style={{height: "380px", width: "28%"}}> <ProCard> <Row gutter={8}> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="无需缴费" value={2833} /> </div> </Col> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="运营商缴费" value={2519} /> </div> </Col> </Row> <Row gutter={8}> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="暂缓缴费" value={1222} /> </div> </Col> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="直供电" value={6699} /> </div> </Col> </Row> <Row gutter={8}> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="转供电当期" value={4080} /> </div> </Col> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="缴费逾期" value={436} /> </div> </Col> </Row> <Row gutter={8}> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="总站址数" value={4080} /> </div> </Col> <Col className="gutter-row" span={12}> <div style={style}> <Statistic title="缴费及时率" value={436} /> </div> </Col> </Row> </ProCard> </ProCard> </> ); }; export default ElectricityWarningChart; 这个代码可以如何优化
07-11
这段代码可以进行一些优化,包括代码结构和性能方面的改进。 1. 提取常量和变量:将样式和日期字符串提取为常量或变量,可以提高代码的可读性和维护性。 ```tsx const style: React.CSSProperties = { marginBottom: '10px', display: 'flex', justifyContent: 'center' }; const currentDate = dayjs().format('YYYY-MM'); ``` 2. 使用 useState 代替直接修改变量:使用 useState 声明 dateStr 变量,并使用 setDateStr 函数来更新它。这样可以确保 React 组件的状态正确更新。 ```tsx const [dateStr, setDateStr] = useState(currentDate); const onChange: DatePickerProps['onChange'] = (date, dateString) => { setDateStr(dateString); }; ``` 3. 使用 useMemo 缓存函数:使用 useMemo 缓存 disabledDate 函数,避免在每次渲染时重新创建函数实例。 ```tsx const disabledDate = useMemo(() => (current: any) => { return current > dayjs(); }, []); ``` 4. 提取组件:将相似的代码块提取为独立的组件,以减少重复代码。例如,可以将 `Statistic` 组件提取为一个单独的组件,并通过 props 传递标题和值。 ```tsx interface StatisticProps { title: string; value: number; } const StatisticCard: React.FC<StatisticProps> = ({ title, value }) => { return ( <div style={style}> <Statistic title={title} value={value} /> </div> ); }; ``` 然后在主组件中使用 `StatisticCard` 组件: ```tsx <Row gutter={8}> <Col className="gutter-row" span={12}> <StatisticCard title="无需缴费" value={2833} /> </Col> <Col className="gutter-row" span={12}> <StatisticCard title="运营商缴费" value={2519} /> </Col> </Row> // 其他相似的代码块也可以使用 StatisticCard 组件 ``` 这样可以减少代码冗余并提高可维护性。 以上是对这段代码的一些优化建议。当然,具体的优化方案还取决于你的项目需求和具体情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值