Commit 24d321bc1682c54856d909f33d1755ea471f162d
1 parent
ba311679
feat: update
Showing
4 changed files
with
145 additions
and
37 deletions
src/pages/OrderReport/components/OrderStatisticCard.tsx
1 | -import Icon, { CheckCircleTwoTone, EditTwoTone } from '@ant-design/icons'; | 1 | +import { RESPONSE_CODE } from '@/constants/enum'; |
2 | +import { postServiceOrderUpdateReportFormsTarget } from '@/services'; | ||
3 | +import Icon, { | ||
4 | + CheckCircleTwoTone, | ||
5 | + CloseCircleTwoTone, | ||
6 | + EditTwoTone, | ||
7 | +} from '@ant-design/icons'; | ||
2 | import { ProCard } from '@ant-design/pro-components'; | 8 | import { ProCard } from '@ant-design/pro-components'; |
3 | -import { Flex, InputNumber } from 'antd'; | ||
4 | -import { useState } from 'react'; | 9 | +import { Flex, InputNumber, message } from 'antd'; |
10 | +import { useEffect, useState } from 'react'; | ||
5 | 11 | ||
6 | -export default ({ data }) => { | 12 | +export default ({ data, statisticsMethod, reFreshData }) => { |
7 | const [edit, setEdit] = useState(false); | 13 | const [edit, setEdit] = useState(false); |
8 | 14 | ||
9 | const UpBig = () => ( | 15 | const UpBig = () => ( |
@@ -51,13 +57,20 @@ export default ({ data }) => { | @@ -51,13 +57,20 @@ export default ({ data }) => { | ||
51 | sameMonthPercentageChange = -1000, | 57 | sameMonthPercentageChange = -1000, |
52 | editable = false, | 58 | editable = false, |
53 | }) => { | 59 | }) => { |
60 | + const [targetValue, setTargetValue] = useState(0); | ||
61 | + useEffect(() => { | ||
62 | + setTargetValue(content); | ||
63 | + }, [content]); | ||
54 | let trendIcon; | 64 | let trendIcon; |
55 | let trendPercentage; | 65 | let trendPercentage; |
56 | if (sameMonthPercentageChange > 0) { | 66 | if (sameMonthPercentageChange > 0) { |
57 | trendIcon = <Icon component={UpBig} />; | 67 | trendIcon = <Icon component={UpBig} />; |
58 | trendPercentage = ( | 68 | trendPercentage = ( |
59 | - <div> | ||
60 | - <span className="text-xs text-stone-500">同比上个月</span> | 69 | + <div style={{ minWidth: '130px' }}> |
70 | + <span className="text-xs text-stone-500"> | ||
71 | + 同比上 | ||
72 | + {statisticsMethod === 'MONTH_STATISTICS' ? '个月' : '年'} | ||
73 | + </span> | ||
61 | <Icon component={UpSmall} /> | 74 | <Icon component={UpSmall} /> |
62 | <span className="text-[#d81e06]">+{sameMonthPercentageChange}%</span> | 75 | <span className="text-[#d81e06]">+{sameMonthPercentageChange}%</span> |
63 | </div> | 76 | </div> |
@@ -67,8 +80,11 @@ export default ({ data }) => { | @@ -67,8 +80,11 @@ export default ({ data }) => { | ||
67 | if (sameMonthPercentageChange < 0) { | 80 | if (sameMonthPercentageChange < 0) { |
68 | trendIcon = <Icon component={DownBig} />; | 81 | trendIcon = <Icon component={DownBig} />; |
69 | trendPercentage = ( | 82 | trendPercentage = ( |
70 | - <div> | ||
71 | - <span className="text-xs text-stone-500">同比上个月</span> | 83 | + <div style={{ minWidth: '130px' }}> |
84 | + <span className="text-xs text-stone-500"> | ||
85 | + 同比上 | ||
86 | + {statisticsMethod === 'MONTH_STATISTICS' ? '个月' : '年'} | ||
87 | + </span> | ||
72 | <Icon component={DownSmall} /> | 88 | <Icon component={DownSmall} /> |
73 | <span className="text-[#1DB302]">{sameMonthPercentageChange}%</span> | 89 | <span className="text-[#1DB302]">{sameMonthPercentageChange}%</span> |
74 | </div> | 90 | </div> |
@@ -85,13 +101,17 @@ export default ({ data }) => { | @@ -85,13 +101,17 @@ export default ({ data }) => { | ||
85 | <Flex> | 101 | <Flex> |
86 | <Flex align="center"> | 102 | <Flex align="center"> |
87 | <span className="text-base pr-1">{unit}</span> | 103 | <span className="text-base pr-1">{unit}</span> |
88 | - <div className={editable ? 'w-[120px]' : ''}> | 104 | + <div style={{ width: 'max-content', display: 'flex' }}> |
89 | {editable ? ( | 105 | {editable ? ( |
90 | edit ? ( | 106 | edit ? ( |
91 | <InputNumber | 107 | <InputNumber |
92 | placeholder="请输入指标(¥)" | 108 | placeholder="请输入指标(¥)" |
93 | width={200} | 109 | width={200} |
110 | + value={targetValue} | ||
94 | max={100000000} | 111 | max={100000000} |
112 | + onChange={(value) => { | ||
113 | + setTargetValue(value); | ||
114 | + }} | ||
95 | /> | 115 | /> |
96 | ) : ( | 116 | ) : ( |
97 | <span className="text-2xl"> | 117 | <span className="text-2xl"> |
@@ -114,12 +134,33 @@ export default ({ data }) => { | @@ -114,12 +134,33 @@ export default ({ data }) => { | ||
114 | 134 | ||
115 | {editable ? ( | 135 | {editable ? ( |
116 | edit ? ( | 136 | edit ? ( |
117 | - <CheckCircleTwoTone | ||
118 | - style={{ fontSize: '20px', paddingLeft: '5px' }} | ||
119 | - onClick={() => { | ||
120 | - setEdit(false); | ||
121 | - }} | ||
122 | - /> | 137 | + [ |
138 | + <CheckCircleTwoTone | ||
139 | + key="confirm" | ||
140 | + style={{ fontSize: '20px', paddingLeft: '5px' }} | ||
141 | + onClick={async () => { | ||
142 | + let body = { | ||
143 | + statisticsMethod: statisticsMethod, | ||
144 | + target: targetValue, | ||
145 | + }; | ||
146 | + let res = await postServiceOrderUpdateReportFormsTarget( | ||
147 | + { data: body }, | ||
148 | + ); | ||
149 | + if (res.result === RESPONSE_CODE.SUCCESS) { | ||
150 | + message.success(res.message); | ||
151 | + setEdit(false); | ||
152 | + reFreshData(); | ||
153 | + } | ||
154 | + }} | ||
155 | + />, | ||
156 | + <CloseCircleTwoTone | ||
157 | + key="cancel" | ||
158 | + style={{ fontSize: '20px', paddingLeft: '5px' }} | ||
159 | + onClick={async () => { | ||
160 | + setEdit(false); | ||
161 | + }} | ||
162 | + />, | ||
163 | + ] | ||
123 | ) : ( | 164 | ) : ( |
124 | <EditTwoTone | 165 | <EditTwoTone |
125 | style={{ fontSize: '20px' }} | 166 | style={{ fontSize: '20px' }} |
@@ -151,7 +192,7 @@ export default ({ data }) => { | @@ -151,7 +192,7 @@ export default ({ data }) => { | ||
151 | <CardContent | 192 | <CardContent |
152 | unit="¥" | 193 | unit="¥" |
153 | content={data.totalPayment} | 194 | content={data.totalPayment} |
154 | - sameMonthPercentageChange={20} | 195 | + sameMonthPercentageChange={data.totalPaymentTrend} |
155 | /> | 196 | /> |
156 | </ProCard> | 197 | </ProCard> |
157 | <ProCard | 198 | <ProCard |
@@ -169,7 +210,7 @@ export default ({ data }) => { | @@ -169,7 +210,7 @@ export default ({ data }) => { | ||
169 | <CardContent | 210 | <CardContent |
170 | unit="单" | 211 | unit="单" |
171 | content={data.totalOrderNumber} | 212 | content={data.totalOrderNumber} |
172 | - sameMonthPercentageChange={-15} | 213 | + sameMonthPercentageChange={data.totalOrderNumberTrend} |
173 | /> | 214 | /> |
174 | </ProCard> | 215 | </ProCard> |
175 | <ProCard | 216 | <ProCard |
src/pages/OrderReport/index.tsx
@@ -38,8 +38,9 @@ const OrderReportPage = () => { | @@ -38,8 +38,9 @@ const OrderReportPage = () => { | ||
38 | }>(); | 38 | }>(); |
39 | const [statisticData, setStatisticData] = useState([]); | 39 | const [statisticData, setStatisticData] = useState([]); |
40 | const [loading, setLoading] = useState(false); | 40 | const [loading, setLoading] = useState(false); |
41 | + const [statisticsMethod, setStatisticsMethod] = useState('MONTH_STATISTICS'); | ||
41 | const onChange = (key: string) => { | 42 | const onChange = (key: string) => { |
42 | - console.log(key); | 43 | + setStatisticsMethod(key); |
43 | }; | 44 | }; |
44 | 45 | ||
45 | /** | 46 | /** |
@@ -59,16 +60,23 @@ const OrderReportPage = () => { | @@ -59,16 +60,23 @@ const OrderReportPage = () => { | ||
59 | // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]), | 60 | // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]), |
60 | // body.endTime=formatDate(form.getFieldValue("dateRange")[1]) | 61 | // body.endTime=formatDate(form.getFieldValue("dateRange")[1]) |
61 | // } | 62 | // } |
62 | - body.statisticsMethod = 'MONTH_STATISTICS'; | 63 | + body.statisticsMethod = statisticsMethod; |
63 | const { data } = await postServiceOrderQueryReportFormsInformation({ | 64 | const { data } = await postServiceOrderQueryReportFormsInformation({ |
64 | data: body, | 65 | data: body, |
65 | }); | 66 | }); |
66 | - setStatisticData(data); | 67 | + if (data !== undefined) { |
68 | + setStatisticData(data); | ||
69 | + } | ||
70 | + | ||
67 | setLoading(false); | 71 | setLoading(false); |
68 | }; | 72 | }; |
69 | 73 | ||
70 | useEffect(() => { | 74 | useEffect(() => { |
71 | loadData(); | 75 | loadData(); |
76 | + }, [statisticsMethod]); | ||
77 | + | ||
78 | + useEffect(() => { | ||
79 | + loadData(); | ||
72 | }, []); | 80 | }, []); |
73 | 81 | ||
74 | const items: TabsProps['items'] = [ | 82 | const items: TabsProps['items'] = [ |
@@ -121,7 +129,11 @@ const OrderReportPage = () => { | @@ -121,7 +129,11 @@ const OrderReportPage = () => { | ||
121 | > | 129 | > |
122 | <Space direction="vertical" size="middle" className="flex"> | 130 | <Space direction="vertical" size="middle" className="flex"> |
123 | <Spin spinning={loading}> | 131 | <Spin spinning={loading}> |
124 | - <OrderStatisticCard data={statisticData} /> | 132 | + <OrderStatisticCard |
133 | + data={statisticData} | ||
134 | + statisticsMethod={statisticsMethod} | ||
135 | + reFreshData={loadData} | ||
136 | + /> | ||
125 | </Spin> | 137 | </Spin> |
126 | 138 | ||
127 | <ProCard tooltip="这是提示" bordered> | 139 | <ProCard tooltip="这是提示" bordered> |
src/services/definition.ts
@@ -733,22 +733,6 @@ export interface QueryMainOrderDto { | @@ -733,22 +733,6 @@ export interface QueryMainOrderDto { | ||
733 | export interface QueryReportFormsDto { | 733 | export interface QueryReportFormsDto { |
734 | /** | 734 | /** |
735 | * @description | 735 | * @description |
736 | - * 开始时间 | ||
737 | - * @format date-time | ||
738 | - * @example | ||
739 | - * 2023-12-10 12:55:55 | ||
740 | - */ | ||
741 | - beginTime?: string; | ||
742 | - /** | ||
743 | - * @description | ||
744 | - * 结束时间 | ||
745 | - * @format date-time | ||
746 | - * @example | ||
747 | - * 2023-12-10 12:55:55 | ||
748 | - */ | ||
749 | - endTime?: string; | ||
750 | - /** | ||
751 | - * @description | ||
752 | * 所属部门 | 736 | * 所属部门 |
753 | */ | 737 | */ |
754 | productBelongBusiness?: string; | 738 | productBelongBusiness?: string; |
src/services/request.ts
@@ -6589,6 +6589,77 @@ export const postServiceOrderUpdateOrder = /* #__PURE__ */ (() => { | @@ -6589,6 +6589,77 @@ export const postServiceOrderUpdateOrder = /* #__PURE__ */ (() => { | ||
6589 | return request; | 6589 | return request; |
6590 | })(); | 6590 | })(); |
6591 | 6591 | ||
6592 | +/** @description request parameter type for postServiceOrderUpdateReportFormsTarget */ | ||
6593 | +export interface PostServiceOrderUpdateReportFormsTargetOption { | ||
6594 | + /** | ||
6595 | + * @description | ||
6596 | + * dto | ||
6597 | + */ | ||
6598 | + body: { | ||
6599 | + /** | ||
6600 | + @description | ||
6601 | + dto */ | ||
6602 | + dto: Dto; | ||
6603 | + }; | ||
6604 | +} | ||
6605 | + | ||
6606 | +/** @description response type for postServiceOrderUpdateReportFormsTarget */ | ||
6607 | +export interface PostServiceOrderUpdateReportFormsTargetResponse { | ||
6608 | + /** | ||
6609 | + * @description | ||
6610 | + * OK | ||
6611 | + */ | ||
6612 | + 200: ServerResult; | ||
6613 | + /** | ||
6614 | + * @description | ||
6615 | + * Created | ||
6616 | + */ | ||
6617 | + 201: any; | ||
6618 | + /** | ||
6619 | + * @description | ||
6620 | + * Unauthorized | ||
6621 | + */ | ||
6622 | + 401: any; | ||
6623 | + /** | ||
6624 | + * @description | ||
6625 | + * Forbidden | ||
6626 | + */ | ||
6627 | + 403: any; | ||
6628 | + /** | ||
6629 | + * @description | ||
6630 | + * Not Found | ||
6631 | + */ | ||
6632 | + 404: any; | ||
6633 | +} | ||
6634 | + | ||
6635 | +export type PostServiceOrderUpdateReportFormsTargetResponseSuccess = | ||
6636 | + PostServiceOrderUpdateReportFormsTargetResponse[200]; | ||
6637 | +/** | ||
6638 | + * @description | ||
6639 | + * 修改指标 | ||
6640 | + * @tags 内部订单 | ||
6641 | + * @produces * | ||
6642 | + * @consumes application/json | ||
6643 | + */ | ||
6644 | +export const postServiceOrderUpdateReportFormsTarget = /* #__PURE__ */ (() => { | ||
6645 | + const method = 'post'; | ||
6646 | + const url = '/service/order/updateReportFormsTarget'; | ||
6647 | + function request( | ||
6648 | + option: PostServiceOrderUpdateReportFormsTargetOption, | ||
6649 | + ): Promise<PostServiceOrderUpdateReportFormsTargetResponseSuccess> { | ||
6650 | + return requester(request.url, { | ||
6651 | + method: request.method, | ||
6652 | + ...option, | ||
6653 | + }) as unknown as Promise<PostServiceOrderUpdateReportFormsTargetResponseSuccess>; | ||
6654 | + } | ||
6655 | + | ||
6656 | + /** http method */ | ||
6657 | + request.method = method; | ||
6658 | + /** request url */ | ||
6659 | + request.url = url; | ||
6660 | + return request; | ||
6661 | +})(); | ||
6662 | + | ||
6592 | /** @description request parameter type for postServiceOrderViewImages */ | 6663 | /** @description request parameter type for postServiceOrderViewImages */ |
6593 | export interface PostServiceOrderViewImagesOption { | 6664 | export interface PostServiceOrderViewImagesOption { |
6594 | /** | 6665 | /** |