Commit 24d321bc1682c54856d909f33d1755ea471f162d

Authored by zhongnanhuang
1 parent ba311679

feat: update

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 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 13 const [edit, setEdit] = useState(false);
8 14  
9 15 const UpBig = () => (
... ... @@ -51,13 +57,20 @@ export default ({ data }) => {
51 57 sameMonthPercentageChange = -1000,
52 58 editable = false,
53 59 }) => {
  60 + const [targetValue, setTargetValue] = useState(0);
  61 + useEffect(() => {
  62 + setTargetValue(content);
  63 + }, [content]);
54 64 let trendIcon;
55 65 let trendPercentage;
56 66 if (sameMonthPercentageChange > 0) {
57 67 trendIcon = <Icon component={UpBig} />;
58 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 74 <Icon component={UpSmall} />
62 75 <span className="text-[#d81e06]">+{sameMonthPercentageChange}%</span>
63 76 </div>
... ... @@ -67,8 +80,11 @@ export default ({ data }) =&gt; {
67 80 if (sameMonthPercentageChange < 0) {
68 81 trendIcon = <Icon component={DownBig} />;
69 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 88 <Icon component={DownSmall} />
73 89 <span className="text-[#1DB302]">{sameMonthPercentageChange}%</span>
74 90 </div>
... ... @@ -85,13 +101,17 @@ export default ({ data }) =&gt; {
85 101 <Flex>
86 102 <Flex align="center">
87 103 <span className="text-base pr-1">{unit}</span>
88   - <div className={editable ? 'w-[120px]' : ''}>
  104 + <div style={{ width: 'max-content', display: 'flex' }}>
89 105 {editable ? (
90 106 edit ? (
91 107 <InputNumber
92 108 placeholder="请输入指标(¥)"
93 109 width={200}
  110 + value={targetValue}
94 111 max={100000000}
  112 + onChange={(value) => {
  113 + setTargetValue(value);
  114 + }}
95 115 />
96 116 ) : (
97 117 <span className="text-2xl">
... ... @@ -114,12 +134,33 @@ export default ({ data }) =&gt; {
114 134  
115 135 {editable ? (
116 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 165 <EditTwoTone
125 166 style={{ fontSize: '20px' }}
... ... @@ -151,7 +192,7 @@ export default ({ data }) =&gt; {
151 192 <CardContent
152 193 unit="¥"
153 194 content={data.totalPayment}
154   - sameMonthPercentageChange={20}
  195 + sameMonthPercentageChange={data.totalPaymentTrend}
155 196 />
156 197 </ProCard>
157 198 <ProCard
... ... @@ -169,7 +210,7 @@ export default ({ data }) =&gt; {
169 210 <CardContent
170 211 unit="单"
171 212 content={data.totalOrderNumber}
172   - sameMonthPercentageChange={-15}
  213 + sameMonthPercentageChange={data.totalOrderNumberTrend}
173 214 />
174 215 </ProCard>
175 216 <ProCard
... ...
src/pages/OrderReport/index.tsx
... ... @@ -38,8 +38,9 @@ const OrderReportPage = () =&gt; {
38 38 }>();
39 39 const [statisticData, setStatisticData] = useState([]);
40 40 const [loading, setLoading] = useState(false);
  41 + const [statisticsMethod, setStatisticsMethod] = useState('MONTH_STATISTICS');
41 42 const onChange = (key: string) => {
42   - console.log(key);
  43 + setStatisticsMethod(key);
43 44 };
44 45  
45 46 /**
... ... @@ -59,16 +60,23 @@ const OrderReportPage = () =&gt; {
59 60 // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]),
60 61 // body.endTime=formatDate(form.getFieldValue("dateRange")[1])
61 62 // }
62   - body.statisticsMethod = 'MONTH_STATISTICS';
  63 + body.statisticsMethod = statisticsMethod;
63 64 const { data } = await postServiceOrderQueryReportFormsInformation({
64 65 data: body,
65 66 });
66   - setStatisticData(data);
  67 + if (data !== undefined) {
  68 + setStatisticData(data);
  69 + }
  70 +
67 71 setLoading(false);
68 72 };
69 73  
70 74 useEffect(() => {
71 75 loadData();
  76 + }, [statisticsMethod]);
  77 +
  78 + useEffect(() => {
  79 + loadData();
72 80 }, []);
73 81  
74 82 const items: TabsProps['items'] = [
... ... @@ -121,7 +129,11 @@ const OrderReportPage = () =&gt; {
121 129 >
122 130 <Space direction="vertical" size="middle" className="flex">
123 131 <Spin spinning={loading}>
124   - <OrderStatisticCard data={statisticData} />
  132 + <OrderStatisticCard
  133 + data={statisticData}
  134 + statisticsMethod={statisticsMethod}
  135 + reFreshData={loadData}
  136 + />
125 137 </Spin>
126 138  
127 139 <ProCard tooltip="这是提示" bordered>
... ...
src/services/definition.ts
... ... @@ -733,22 +733,6 @@ export interface QueryMainOrderDto {
733 733 export interface QueryReportFormsDto {
734 734 /**
735 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 738 productBelongBusiness?: string;
... ...
src/services/request.ts
... ... @@ -6589,6 +6589,77 @@ export const postServiceOrderUpdateOrder = /* #__PURE__ */ (() =&gt; {
6589 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 6663 /** @description request parameter type for postServiceOrderViewImages */
6593 6664 export interface PostServiceOrderViewImagesOption {
6594 6665 /**
... ...