From 61b79fb0a1a0ee7c6692c0d1c1e16fe9c08a3242 Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Sun, 27 Apr 2025 10:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B3=B0=E8=B0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/report/components/Card.tsx | 2 +- src/pages/report/index.tsx | 406 +++++++++++++++++---------- 2 files changed, 260 insertions(+), 148 deletions(-) diff --git a/src/pages/report/components/Card.tsx b/src/pages/report/components/Card.tsx index ec03395..9107d37 100644 --- a/src/pages/report/components/Card.tsx +++ b/src/pages/report/components/Card.tsx @@ -1,7 +1,7 @@ import 'twin.macro' export default function(props) { - return
diff --git a/src/pages/report/index.tsx b/src/pages/report/index.tsx index 9eb3d22..11bb94d 100644 --- a/src/pages/report/index.tsx +++ b/src/pages/report/index.tsx @@ -16,26 +16,18 @@ import TopContent from './components/TopContent'; // 核心代码 import { useSearchParams } from 'react-router-dom' import {getRoundNumber} from "@/utils"; +import 'twin.macro'; +import {Meter04KvType} from "@/shared/model-park"; -function getAmount(amount: string, loss: string, refund: string, price: string): string { - return `${ - getRoundNumber( - Number( - getRoundNumber( - Number( - (Number( - (Number(amount) + Number(loss) - ) - ) - - Number(refund) - ) - ) - ) - ) * Number(price) - )}` +function getNestAmount(arr: string[] = []): string { + if (!arr.length) { + return "0" + } + return arr?.reduce((prev, next) => { + return getRoundNumber(Number(prev || 0) + Number(next || 0)) + }) } - export const UserReport: FC = () => { const [searchParams] = useSearchParams() const tid = searchParams.get("tenement"); @@ -83,23 +75,165 @@ export const UserReport: FC = () => { const renderTable = useCallback(() => { return data?.meters?.map((item, index) => { - const finalAmount = Number(item?.overall?.amount || 0) + Number(item?.loss?.amount || 0) + Number(item?.publicAmount || 0) + // const finalAmount = Number(item?.overall?.amount || 0) + Number(item?.loss?.amount || 0) + Number(item?.publicAmount || 0) return ( - {item?.meterNo} {item?.address} - {outputWithPrecision(item?.startNumber, 2, '-')} - {outputWithPrecision(item?.endNumber, 2, '-')} - {outputWithPrecision(item?.displayRatio, 2, '-')} - {outputWithPrecision(item?.overall?.amount, 2, '-')} + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(item?.startNumber, 2, '-')} : + +
尖:{item?.startSharp}
+
峰:{item?.startPeak}
+
平:{item?.startFlat}
+
谷:{item?.startValley}
+ + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(item?.endNumber, 2, '-')} : + +
尖:{item?.endSharp}
+
峰:{item?.endPeak}
+
平:{item?.endFlat}
+
谷:{item?.endValley}
+ + } + + {outputWithPrecision(item?.ratio, 2, '-')} + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {item?.refundAmount} : + +
尖:{item?.refundSharp}
+
峰:{item?.refundPeak}
+
平:{item?.refundFlat}
+
谷:{item?.refundValley}
+ + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {item?.nestOverall} : + +
尖:{item?.nestSharp}
+
峰:{item?.nestPeak}
+
平:{item?.nestFlat}
+
谷:{item?.nestValley}
+ + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(item?.overall?.amount, 2, '-')} : + +
尖:{item?.critical?.amount}
+
峰:{item?.peak?.amount}
+
平:{item?.flat?.amount}
+
谷:{item?.valley?.amount}
+ + } + {/* {outputWithPrecision(item?.finalTotal ? (1 / (1 - Number(item?.loss?.amount) / Number(item?.finalTotal)) - 1) * 100 : undefined, 2, '-')} % */} - {outputWithPrecision(item?.loss?.amount, 2, '-')} - {outputWithPrecision(item?.publicAmount, 2, '-')} - {outputWithPrecision(finalAmount, 2, '-')} + { + data?.tenement?.feeType === 3 ? null : ( + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(item?.loss?.amount, 2, '-')} : + +
尖:{item?.lossSharp}
+
峰:{item?.lossPeak}
+
平:{item?.lossFlat}
+
谷:{item?.lossValley}
+ + + ) + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(item?.publicAmount, 2, '-')} : + +
尖:{item?.poolSharp || 0}
+
峰:{item?.poolPeak || 0}
+
平:{item?.poolFlat || 0}
+
谷:{item?.poolValley || 0}
+ + } + + + {outputWithPrecision(item?.finalAmount, 2, '-')} - ) + ) }) - }, [data?.meters]) + }, [data?.meters, data?.park?.meter04kvType]) + + const renderTableSum = useCallback(() => { + if (data?.meters?.length < 2) { + return null; + } + return + 总计 + - + - + - + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {data?.comprehensive?.refundOverall} : + +
尖:{data?.comprehensive?.refundSharp}
+
峰:{data?.comprehensive?.refundPeak}
+
平:{data?.comprehensive?.refundFlat}
+
谷:{data?.comprehensive?.refundValley}
+ + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {getNestAmount(data?.meters?.map(item => item?.nestOverall))} : + +
尖:{getNestAmount(data?.meters?.map(item => item?.nestSharp))}
+
峰:{getNestAmount(data?.meters?.map(item => item?.nestPeak))}
+
平:{getNestAmount(data?.meters?.map(item => item?.nestFlat))}
+
谷:{getNestAmount(data?.meters?.map(item => item?.nestValley))}
+ + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(data?.comprehensive?.consumption, 2, '-')} : + +
尖:{data?.comprehensive?.sharpAmount}
+
峰:{data?.comprehensive?.peakAmount}
+
平:{data?.comprehensive?.flatAmount}
+
谷:{data?.comprehensive?.valleyAmount}
+ + } + + {/* {outputWithPrecision(item?.finalTotal ? (1 / (1 - Number(item?.loss?.amount) / Number(item?.finalTotal)) - 1) * 100 : undefined, 2, '-')} % */} + { + data?.tenement?.feeType === 3 ? null : ( + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(data?.comprehensive?.lossAmount, 2, '-')} : + +
尖:{data?.comprehensive?.lossSharp}
+
峰:{data?.comprehensive?.lossPeak}
+
平:{data?.comprehensive?.lossFlat}
+
谷:{data?.comprehensive?.lossValley}
+ + + ) + } + { + data?.park?.meter04kvType === Meter04KvType.DisableValley ? + {outputWithPrecision(data?.comprehensive?.publicAmount, 2, '-')} : + +
尖:{data?.comprehensive?.poolSharp || 0}
+
峰:{data?.comprehensive?.poolPeak || 0}
+
平:{data?.comprehensive?.poolFlat || 0}
+
谷:{data?.comprehensive?.poolValley || 0}
+ + } + + + {outputWithPrecision( + `${(data?.park?.meter04kvType === 0 ? amount?.current : data?.comprehensive?.finalAmount) || 0}`, 2, '-')} + + }, [data?.meters, data?.park?.meter04kvType, data?.comprehensive]) return ( <> @@ -109,16 +243,20 @@ export const UserReport: FC = () => { td { padding: 0.2cm } - tr td:nth-child(1) { - width: 3.5cm; + ${ + data?.park?.meter04kvType === Meter04KvType.DisableValley ? ` tr td:nth-child(1) { + + width: 4.5cm; + }` : ` tr td:nth-child(1) { + width: 2cm; + + }` + } + + tr td:nth-child(2), tr td:nth-child(3), tr td:nth-child(4) { + width: 1.5cm; } - tr td:nth-child(2) { - width: 4.5cm; - } - tr td:nth-child(3), tr td:nth-child(4), tr td:nth-child(5) { - width: 1.8cm; - } - tr td:nth-child(6), tr td:nth-child(7), tr td:nth-child(8), tr td:nth-child(9) { + tr td:nth-child(5), tr td:nth-child(6), tr td:nth-child(7), tr td:nth-child(8), tr td:nth-child(9), tr td:nth-child(10) { width: 2cm; } #content, .ant-col { @@ -215,9 +353,13 @@ export const UserReport: FC = () => {

合计电量:

{ outputWithPrecision( - `${Number(amount.current || 0)}`, 2, '-')}   千瓦时 + `${Number((data?.park?.meter04kvType === 0 ? amount?.current : data?.comprehensive?.finalAmount) || 0)}`, 2, '-')}   千瓦时
+ +

合计电费:

+
{outputWithPrecision(data?.comprehensive?.total, 2, '-')} 元   
+
电费构成 @@ -253,11 +395,11 @@ export const UserReport: FC = () => {

公摊电量:

{outputWithPrecision(data?.comprehensive?.publicAmount, 2, '-')}   千瓦时
- - - -

退补电量:

-
{outputWithPrecision(data?.comprehensive?.publicAmount, 2, '-')}   千瓦时
-
+ {/* - */} + {/**/} + {/*

退补电量:

*/} + {/*
{outputWithPrecision(data?.comprehensive?.publicAmount, 2, '-')}   千瓦时
*/} + {/*
*/} *

电度单价:

@@ -266,19 +408,19 @@ export const UserReport: FC = () => { +

基本电费:

-
{outputWithPrecision(data?.comprehensive?.basicPooled, 2, '-')}
-
- + - -

调整电费:

-
{outputWithPrecision(data?.comprehensive?.adjustPooled, 2, '-')}
+
{outputWithPrecision(data?.comprehensive?.basicPooled, 2, '-')} 元
+ {/* + */} + {/**/} + {/*

调整电费:

*/} + {/*
{outputWithPrecision(data?.comprehensive?.adjustPooled, 2, '-')} 元
*/} + {/*
*/}
= -

本期总电费(元):

-
{outputWithPrecision(data?.comprehensive?.total, 2, '-')}
+

本期总电费:

+
{outputWithPrecision(data?.comprehensive?.total, 2, '-')} 元
@@ -291,7 +433,7 @@ export const UserReport: FC = () => {
-

尖电量:

+

电度电量(尖):

{outputWithPrecision(data?.comprehensive?.sharpAmount, 2, '-')}   千瓦时
{ @@ -299,7 +441,7 @@ export const UserReport: FC = () => { <> + -

尖线损电量:

+

线损电量(尖):

{outputWithPrecision(data?.comprehensive?.lossSharp, 2, '-')}   千瓦时
@@ -308,34 +450,29 @@ export const UserReport: FC = () => { + -

尖公摊电量:

+

公摊电量(尖):

{outputWithPrecision(data?.comprehensive?.poolSharp || '0', 2, '-')}   千瓦时
- - - -

尖退补电量:

-
{outputWithPrecision(data?.comprehensive?.refundSharp, 2, '-')}   千瓦时
-
+ {/* - */} + {/**/} + {/*

退补电量(尖):

*/} + {/*
{outputWithPrecision(data?.comprehensive?.refundSharp, 2, '-')}   千瓦时
*/} + {/*
*/} * -

尖用电单价:

+

电度单价(尖):

{outputWithPrecision(data?.comprehensive?.priceSharp, 6, '-')}   千瓦时/元
= -

尖电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.sharpAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossSharp || "0"), - data?.comprehensive?.refundSharp || "0", - data?.comprehensive?.priceSharp || "0", - ), 2, '-')}   
+

电费(尖):

+
{outputWithPrecision(data?.comprehensive?.finalSharpFee, 2, '-')} 元  
-

峰电量:

+

电度电量(峰):

{outputWithPrecision(data?.comprehensive?.peakAmount, 2, '-')}   千瓦时
{ @@ -343,7 +480,7 @@ export const UserReport: FC = () => { <> + -

峰线损电量:

+

线损电量(峰):

{outputWithPrecision(data?.comprehensive?.lossPeak, 2, '-')}   千瓦时
@@ -352,34 +489,29 @@ export const UserReport: FC = () => { + -

峰公摊电量:

+

公摊电量(峰):

{outputWithPrecision(data?.comprehensive?.poolPeak, 2, '-')}   千瓦时
- - - -

峰退补电量:

-
{outputWithPrecision(data?.comprehensive?.refundPeak, 2, '-')}   千瓦时
-
+ {/* - */} + {/**/} + {/*

退补电量(峰):

*/} + {/*
{outputWithPrecision(data?.comprehensive?.refundPeak, 2, '-')}   千瓦时
*/} + {/*
*/} * -

峰用电单价:

+

用电单价(峰):

{outputWithPrecision(data?.comprehensive?.pricePeak, 6, '-')}   千瓦时/元
= -

峰电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.peakAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossPeak || "0"), - data?.comprehensive?.refundPeak || "0", - data?.comprehensive?.pricePeak || "0", - ), 2, '-')}   
+

电费(峰):

+
{outputWithPrecision(data?.comprehensive?.finalPeakFee, 2, '-')} 元  
-

平电量:

+

电度电量(平):

{outputWithPrecision(data?.comprehensive?.flatAmount, 2, '-')}   千瓦时
{ @@ -387,7 +519,7 @@ export const UserReport: FC = () => { <> + -

平线损电量:

+

线损电量(平):

{outputWithPrecision(data?.comprehensive?.lossFlat, 2, '-')}   千瓦时
@@ -396,34 +528,29 @@ export const UserReport: FC = () => { + -

平公摊电量:

+

公摊电量(平):

{outputWithPrecision(data?.comprehensive?.poolFlat, 2, '-')}   千瓦时
- - - -

平退补电量:

-
{outputWithPrecision(data?.comprehensive?.refundFlat, 2, '-')}   千瓦时
-
+ {/* - */} + {/**/} + {/*

退补电量(平):

*/} + {/*
{outputWithPrecision(data?.comprehensive?.refundFlat, 2, '-')}   千瓦时
*/} + {/*
*/} * -

平用电单价:

+

用电单价(平):

{outputWithPrecision(data?.comprehensive?.priceFlat, 6, '-')}   千瓦时/元
= -

平电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.flatAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossFlat || "0"), - data?.comprehensive?.refundFlat || "0", - data?.comprehensive?.priceFlat || "0", - ), 2, '-')}   
+

电费(平):

+
{outputWithPrecision(data?.comprehensive?.finalFlatFee, 2, '-')} 元   
-

谷电量:

+

电度电量(谷):

{outputWithPrecision(data?.comprehensive?.valleyAmount, 2, '-')}   千瓦时
{ @@ -431,7 +558,7 @@ export const UserReport: FC = () => { <> + -

谷线损电量:

+

线损电量(谷):

{outputWithPrecision(data?.comprehensive?.lossValley, 2, '-')}   千瓦时
@@ -440,74 +567,53 @@ export const UserReport: FC = () => { + -

谷公摊电量:

+

公摊电量(谷):

{outputWithPrecision(data?.comprehensive?.poolValley, 2, '-')}   千瓦时
- - - -

谷退补电量:

-
{outputWithPrecision(data?.comprehensive?.refundValley, 2, '-')}   千瓦时
-
+ {/* - */} + {/**/} + {/*

退补电量(谷):

*/} + {/*
{outputWithPrecision(data?.comprehensive?.refundValley, 2, '-')}   千瓦时
*/} + {/*
*/} * -

谷用电单价:

+

用电单价(谷):

{outputWithPrecision(data?.comprehensive?.priceValley, 6, '-')}   千瓦时/元
= -

谷电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.valleyAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossValley || "0"), - data?.comprehensive?.refundValley || "0", - data?.comprehensive?.priceValley || "0", - ), 2, '-')}   
+

电费(谷):

+
{outputWithPrecision(data?.comprehensive?.finalValleyFee, 2, '-')} 元   
-

尖电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.sharpAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossSharp || "0"), - data?.comprehensive?.refundSharp || "0", - data?.comprehensive?.priceSharp || "0", - ), 2, '-')}
+

电费(尖):

+
{outputWithPrecision(data?.comprehensive?.finalSharpFee, 2, '-')} 元 +
+ -

峰电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.peakAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossPeak || "0"), - data?.comprehensive?.refundPeak || "0", - data?.comprehensive?.pricePeak || "0", - ), 2, '-')}
+

电费(峰):

+
{outputWithPrecision(data?.comprehensive?.finalPeakFee, 2, '-')} 元 +
+ -

平电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.flatAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossFlat || "0"), - data?.comprehensive?.refundFlat || "0", - data?.comprehensive?.priceFlat || "0", - ), 2, '-')}
+

电费(平):

+
{outputWithPrecision(data?.comprehensive?.finalFlatFee, 2, '-')} 元 +
+ -

谷电费:

-
{outputWithPrecision(getAmount( - data?.comprehensive?.valleyAmount || "0", - data?.tenement?.feeType === 3 ? "0" : (data?.comprehensive?.lossValley || "0"), - data?.comprehensive?.refundValley || "0", - data?.comprehensive?.priceValley || "0", - ), 2, '-')}
+

电费(谷):

+
{outputWithPrecision(data?.comprehensive?.finalValleyFee, 2, '-')} 元 +
=

本期总电费:

-
{outputWithPrecision(data?.comprehensive?.total, 2, '-')}   
+
{outputWithPrecision(data?.comprehensive?.total, 2, '-')} 元   
{/*
*/} @@ -524,17 +630,24 @@ export const UserReport: FC = () => {
用电明细 + + ( + 电度电量=(止码-起码)*倍率-退补电量-从表电量, + 合计电量=电度电量+线损电量+公摊电量 + ) +
- + + {/* */} { @@ -542,13 +655,13 @@ export const UserReport: FC = () => { ) } - {renderTable()} + {renderTableSum()}
电表编号 电表地址 起码 止码 表倍率退补电量从表电量 电度电量线损占比线损电量退补电量 公摊电量 合计电量
@@ -560,7 +673,6 @@ export const UserReport: FC = () => {
- );