Commit 9eb4ffda945bab98fbfbff24a887e9406234dd74

Authored by 曾国涛
2 parents 5afa2257 30901683

Merge remote-tracking branch 'origin/baobiao'

# Conflicts:
#	src/pages/Order/OrderList/OrderDrawer.tsx
src/pages/Order/OrderList/OrderDrawer.tsx
... ... @@ -908,7 +908,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
908 908 values.productBelongBusinessUpdateTime = formattedDate;
909 909 } else {
910 910 values.productBelongBusinessUpdateTime =
911   - copyData.productBelongBusinessUpdateTime;
  911 + data.productBelongBusinessUpdateTime;
912 912 }
913 913 return item;
914 914 });
... ...
src/pages/OrderReport/components/OrderDualAxes.tsx
1   -// import { DualAxes } from '@ant-design/charts';
2   -
3   -// const OrderDualAxes = ({ data, statisticMethod }) => {
4   -// console.log(data);
5   -// let yFiledString = 'curTime';
6   -// if (
7   -// statisticMethod === 'MONTH_STATISTICS' ||
8   -// statisticMethod === 'LAST_MONTH_STATISTICS'
9   -// ) {
10   -// yFiledString = 'curTime';
11   -// } else {
12   -// yFiledString = 'curMonth';
13   -// }
14   -// const config = {
15   -// data: [
16   -// data.targetAndTotalPaymentDtoList === undefined ||
17   -// data.targetAndTotalPaymentDtoList === null
18   -// ? []
19   -// : data.targetAndTotalPaymentDtoList,
20   -// data.orderNumberDtoList === undefined || data.orderNumberDtoList === null
21   -// ? []
22   -// : data.orderNumberDtoList,
23   -// ],
24   -// xField: yFiledString,
25   -// yField: ['curDayTotalPayment', 'curDayTotalOrderNumber', 'lastTime'],
26   -// geometryOptions: [
27   -// {
28   -// geometry: 'line',
29   -// seriesField: 'type',
30   -// lineStyle: {
31   -// lineWidth: 3,
32   -// lineDash: [5, 5],
33   -// },
34   -// smooth: true,
35   -// },
36   -// {
37   -// geometry: 'line',
38   -// seriesField: 'name',
39   -// point: {},
40   -// },
41   -// ],
42   -// };
43   -// const handleClick = (event) => {
44   -// console.log('点击事件event:', event);
45   -// console.log('点击事件:', event?.data);
46   -// alert(`你点击了数据: ${JSON.stringify(event?.data)}`);
47   -// console.log('点击事件:', JSON.stringify(event?.data));
48   -
49   -// };
50   -
51   -// const handleReady = (plot) => {
52   -// // 绑定多个事件以确保响应
53   -// plot.on('plot:click', handleClick);
54   -// plot.on('element:click', handleClick);
55   -// };
56   -// return <DualAxes {...config} onReady={handleReady} />;
57   -// };
58   -
59   -// export default OrderDualAxes;
60   -
61 1 import { DualAxes } from '@ant-design/charts';
62 2  
63   -const OrderDualAxes = ({ data, statisticMethod }) => {
64   - console.log('传入的数据:', data);
65   -
  3 +const OrderDualAxes = ({ data, statisticMethod, onXValueClick }) => {
66 4 let yFiledString = 'curTime';
67 5  
68   - if (
69   - statisticMethod === 'MONTH_STATISTICS' ||
70   - statisticMethod === 'LAST_MONTH_STATISTICS'
71   - ) {
72   - yFiledString = 'curTime';
73   - } else {
  6 + if (statisticMethod === '0') {
74 7 yFiledString = 'curMonth';
  8 + } else {
  9 + yFiledString = 'curTime';
75 10 }
76 11  
77   - const targetData = data.targetAndTotalPaymentDtoList || [];
78   - const orderData = data.orderNumberDtoList || [];
79   - console.log(orderData, '传入的数据:', targetData);
  12 + const targetData = data?.targetAndTotalPaymentDtoList || [];
  13 + const orderData = data?.orderNumberDtoList || [];
80 14  
81 15 const config = {
82 16 data: [targetData, orderData],
83 17 xField: yFiledString,
84   - yField: ['curDayTotalPayment', 'curDayTotalOrderNumber', 'lastTime'],
  18 + yField: ['curDayTotalPayment', 'curDayTotalOrderNumber'],
85 19 geometryOptions: [
86 20 {
87 21 geometry: 'line',
... ... @@ -106,29 +40,50 @@ const OrderDualAxes = ({ data, statisticMethod }) =&gt; {
106 40 };
107 41  
108 42 const handleClick = (event) => {
109   - // console.log(targetData, '5656')
110 43 // 获取当前点击点的数据
111 44 const pointData = event?.data?.data;
112   -
113 45 if (pointData) {
114   - if (pointData.type === '上年营业额' || pointData.type === '订单量') {
115   - const xValue = pointData[yFiledString]; // 获取当前列的 xField 值
116   -
117   - // 合并两个数据源
118   - const allData = [...targetData, ...orderData];
119   - console.log(orderData, '5656传入的数据:', targetData);
120   - // 筛选出当前列的所有数据
121   - const columnData = allData.filter(
122   - (item) => item[yFiledString] === xValue,
123   - );
124   -
125   - console.log(`当前列中 ${yFiledString} = ${xValue} 的数据:`, columnData);
126   -
127   - // 可选择将筛选出的数据展示到页面或以其他方式处理
128   - alert(`当前列数据: ${JSON.stringify(columnData, null, 2)}`);
  46 + // 解析年份和月份
  47 + if (yFiledString === 'curMonth') {
  48 + const xValue = pointData['curMonth']; // 格式类似 "2025-01"
  49 + if (typeof xValue === 'string' && xValue.includes('-')) {
  50 + const [yearFromXValue] = xValue?.split('-'); // 提取年份部分 "2025"
  51 +
  52 + if (!yearFromXValue) {
  53 + return;
  54 + }
  55 + console.log(pointData, '5656pointData');
  56 + // // 减 1 获得目标年份
  57 + // const targetYear = String(Number(yearFromXValue) - 1); // "2024"
  58 +
  59 + // // 检查 pointData.type 是否包含目标年份
  60 + // if (
  61 + // pointData?.type?.includes(targetYear) ||
  62 + // pointData?.name?.includes(targetYear)
  63 + // ) {
  64 + // 调用父组件传递的回调
  65 + if (pointData?.name) {
  66 + onXValueClick?.(xValue, pointData?.name);
  67 + } else if (pointData?.type) {
  68 + onXValueClick?.(xValue, pointData?.type);
  69 + }
  70 +
  71 + // // 合并两个数据源
  72 + // const allData = [...targetData, ...orderData];
  73 +
  74 + // // 筛选出当前列的所有数据
  75 + // const columnData = allData.filter(
  76 + // (item) => item[yFiledString] === xValue,
  77 + // );
  78 +
  79 + // 可选择将筛选出的数据展示到页面或以其他方式处理
  80 + // alert(`当前列数据: ${JSON.stringify(columnData, null, 2)}`);
  81 + // } else {
  82 + // }
  83 + }
  84 + } else {
  85 + console.warn('点击事件未携带有效数据');
129 86 }
130   - } else {
131   - console.warn('点击事件未携带有效数据');
132 87 }
133 88 };
134 89  
... ...
src/pages/OrderReport/index.tsx
1 1 import {
2 2 getOrderErpOrderZoNingSelectAll,
3 3 postOrderErpOrderZoNingSelectSaleUserByProvince,
4   - // postServiceOrderQueryReportFormsInformation,
  4 + postServiceOrderQueryReportFormsInformation,
5 5 postServiceOrderQuerySalesCode,
6 6 } from '@/services';
7 7 import { enumToSelect } from '@/utils';
... ... @@ -13,7 +13,7 @@ import {
13 13 ProFormSelect,
14 14 QueryFilter,
15 15 } from '@ant-design/pro-components';
16   -import { Form, Segmented, Space, Spin } from 'antd';
  16 +import { Form, Space, Spin } from 'antd';
17 17 import { useEffect, useState } from 'react';
18 18 import { PRODUCT_BELONG_DEPARTMENT_OPTIONS } from '../Order/constant';
19 19 import OrderDualAxes from './components/OrderDualAxes';
... ... @@ -21,7 +21,8 @@ import OrderStatisticCard from &#39;./components/OrderStatisticCard&#39;;
21 21 import './index.less';
22 22 const OrderReportPage = () => {
23 23 const [salesCodeOptions, setSalesCodeOptions] = useState([]);
24   -
  24 + const [selectedYear, setSelectedYear] = useState('2025');
  25 + const [selectedMonth, setSelectedMonth] = useState('0');
25 26 /**
26 27 * 获取销售代码枚举,在复制和编辑的时候判断是否为旧的代码
27 28 */
... ... @@ -44,25 +45,50 @@ const OrderReportPage = () =&gt; {
44 45 }>();
45 46 const [statisticData, setStatisticData] = useState([]);
46 47 const [loading, setLoading] = useState(false);
47   - const [statisticsMethod, setStatisticsMethod] = useState('MONTH_STATISTICS');
48   - const onChange = (key: string) => {
49   - if (key === '本月') {
50   - setStatisticsMethod('MONTH_STATISTICS');
51   - }
  48 + const [statisticsMethod, setStatisticsMethod] = useState('YEAR_STATISTICS');
  49 + // const onChange = (key: string) => {
  50 + // if (key === '本月') {
  51 + // setStatisticsMethod('MONTH_STATISTICS');
  52 + // }
52 53  
53   - if (key === '上月') {
54   - setStatisticsMethod('LAST_MONTH_STATISTICS');
55   - }
  54 + // if (key === '上月') {
  55 + // setStatisticsMethod('LAST_MONTH_STATISTICS');
  56 + // }
56 57  
57   - if (key === '本年') {
58   - setStatisticsMethod('YEAR_STATISTICS');
59   - }
60   - };
  58 + // if (key === '本年') {
  59 + // setStatisticsMethod('YEAR_STATISTICS');
  60 + // }
  61 + // };
  62 + const [yearOptions] = useState([
  63 + { value: '2025', label: '2025' },
  64 + { value: '2024', label: '2024' },
  65 + { value: '2023', label: '2023' },
  66 + ]);
61 67  
  68 + const [monthOptions] = useState([
  69 + { value: '0', label: '全部' },
  70 + { value: '1', label: '1' },
  71 + { value: '2', label: '2' },
  72 + { value: '3', label: '3' },
  73 + { value: '4', label: '4' },
  74 + { value: '5', label: '5' },
  75 + { value: '6', label: '6' },
  76 + { value: '7', label: '7' },
  77 + { value: '8', label: '8' },
  78 + { value: '9', label: '9' },
  79 + { value: '10', label: '10' },
  80 + { value: '11', label: '11' },
  81 + { value: '12', label: '12' },
  82 + ]);
62 83 /**
63 84 * 加载页面数据
64 85 */
65 86 const loadData = async () => {
  87 + if (selectedMonth === '0') {
  88 + setStatisticsMethod('YEAR_STATISTICS');
  89 + } else {
  90 + setStatisticsMethod('MONTH_STATISTICS');
  91 + }
66 92 setLoading(true);
67 93 let body = {
68 94 statisticsMethod: '',
... ... @@ -110,218 +136,50 @@ const OrderReportPage = () =&gt; {
110 136 // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]),
111 137 // body.endTime=formatDate(form.getFieldValue("dateRange")[1])
112 138 // }
113   - body.statisticsMethod = statisticsMethod;
114   - // const { data } = await postServiceOrderQueryReportFormsInformation({
115   - // data: body,
116   - // });
117   - const { data } = {
118   - data: {
119   - invoicedAndReiceptedCount: 1593,
120   - invoicedAndReiceptedPriceSum: 3303364.71,
121   - invoicedNotReiceptCount: 31798,
122   - invoicedNotReiceptPriceSum: 3.276437229e7,
123   - orderNumberDtoList: [
124   - {
125   - curDayTotalOrderNumber: 2,
126   - curMonth: null,
127   - curTime: '2025-01-01',
128   - name: '订单量',
129   - },
130   - {
131   - curDayTotalOrderNumber: 204,
132   - curMonth: null,
133   - curTime: '2025-01-02',
134   - name: '订单量',
135   - },
136   - {
137   - curDayTotalOrderNumber: 0,
138   - curMonth: null,
139   - curTime: '2025-01-03',
140   - name: '订单量',
141   - },
142   - ],
143   - subTotalOrderNumber: 308,
144   - target: 3500000,
145   - targetAndTotalPaymentDtoList: [
146   - {
147   - curDayTotalPayment: 222000,
148   - curMonth: null,
149   - lastTime: '2024-01-01',
150   - curTime: '2025-01-01',
151   - type: '上年营业额',
152   - },
153   - {
154   - curDayTotalPayment: 24820,
155   - curMonth: null,
156   - lastTime: '2024-01-01',
157   - curTime: '2025-01-01',
158   - type: '上年指标',
159   - },
160   - {
161   - curDayTotalPayment: 248200,
162   - curMonth: null,
163   - lastTime: '2024-01-02',
164   - curTime: '2025-01-02',
165   - type: '上年指标',
166   - },
167   - {
168   - curDayTotalPayment: 1906180.59,
169   - curMonth: null,
170   - lastTime: '2024-01-02',
171   - curTime: '2025-01-02',
172   - type: '上年营业额',
173   - },
174   - {
175   - curDayTotalPayment: 248200,
176   - curMonth: null,
177   - lastTime: '2024-01-03',
178   - curTime: '2025-01-03',
179   - type: '上年指标',
180   - },
181   - {
182   - curDayTotalPayment: 768000,
183   - curMonth: null,
184   - curTime: '2025-01-03',
185   - lastTime: '2024-01-03',
186   - type: '上年营业额',
187   - },
188   - {
189   - curDayTotalPayment: 2482,
190   - curMonth: null,
191   - lastTime: '2024-01-01',
192   - curTime: '2025-01-01',
193   - type: '指标',
194   - },
195   - {
196   - curDayTotalPayment: 650,
197   - curMonth: null,
198   - lastTime: '2024-01-01',
199   - curTime: '2025-01-01',
200   - type: '营业额',
201   - },
202   - {
203   - curDayTotalPayment: 2482,
204   - curMonth: null,
205   - curTime: '2025-01-02',
206   - type: '指标',
207   - },
208   - {
209   - curDayTotalPayment: 190618.59,
210   - curMonth: null,
211   - curTime: '2025-01-02',
212   - type: '营业额',
213   - },
214   - {
215   - curDayTotalPayment: 2482,
216   - curMonth: null,
217   - curTime: '2025-01-03',
218   - type: '指标',
219   - },
220   - {
221   - curDayTotalPayment: 0,
222   - curMonth: null,
223   - curTime: '2025-01-03',
224   - type: '营业额',
225   - },
226   - ],
227   - totalOrderNumber: 206,
228   - totalOrderNumberTrend: null,
229   - totalPayment: 191268.59,
230   - totalPaymentTrend: null,
231   - unCheckOrderNumber: 80,
232   - unSendOrderNumber: 37,
233   - waitInvoicingCount: 386,
234   - waitInvoicingPriceSum: 211136.11,
235   - },
236   - message: '成功',
237   - result: 0,
238   - };
  139 + body.month = selectedMonth;
  140 + body.year = selectedYear;
  141 + const { data } = await postServiceOrderQueryReportFormsInformation({
  142 + data: body,
  143 + });
239 144 if (data !== undefined) {
240 145 setStatisticData(data);
241 146 }
242 147  
243 148 setLoading(false);
244 149 };
  150 + const handleXValueClick = async (xValue, type) => {
  151 + try {
  152 + const [yearValue, monthValue] = xValue.split('-');
  153 + if (type?.includes('年')) {
  154 + const adjustedYearValue = (parseInt(yearValue, 10) - 1).toString();
  155 + const adjustedMonthValue = monthValue.startsWith('0')
  156 + ? monthValue.slice(1)
  157 + : monthValue;
  158 + // 更新年份和月份选项的选中值
  159 + setSelectedYear(adjustedYearValue);
  160 + setSelectedMonth(adjustedMonthValue);
  161 + } else {
  162 + // 更新年份和月份选项的选中值
  163 + const adjustedMonthValue = monthValue.startsWith('0')
  164 + ? monthValue.slice(1)
  165 + : monthValue;
  166 + setSelectedYear(yearValue);
  167 + setSelectedMonth(adjustedMonthValue);
  168 + }
  169 + } catch (error) {
  170 + console.error('Failed to fetch updated data:', error);
  171 + }
  172 + };
245 173  
246 174 useEffect(() => {
247 175 loadData();
248   - }, [statisticsMethod]);
  176 + }, [selectedMonth, selectedYear]);
249 177  
250 178 useEffect(() => {
251 179 loadData();
252 180 getSalesCodeOptions();
253 181 }, []);
254 182  
255   - const yearOptions = [
256   - {
257   - value: 'all',
258   - label: '全部',
259   - },
260   - {
261   - value: '2024',
262   - label: '2024',
263   - },
264   - {
265   - value: '2025',
266   - label: '2025',
267   - },
268   - ];
269   -
270   - const monthOptions = [
271   - {
272   - value: 'all',
273   - label: '全部',
274   - },
275   - {
276   - value: '1',
277   - label: '1',
278   - },
279   - {
280   - value: '2',
281   - label: '2',
282   - },
283   - {
284   - value: '3',
285   - label: '3',
286   - },
287   - {
288   - value: '4',
289   - label: '4',
290   - },
291   - {
292   - value: '5',
293   - label: '5',
294   - },
295   - {
296   - value: '6',
297   - label: '6',
298   - },
299   - {
300   - value: '7',
301   - label: '7',
302   - },
303   - {
304   - value: '8',
305   - label: '8',
306   - },
307   - {
308   - value: '9',
309   - label: '9',
310   - },
311   - {
312   - value: '10',
313   - label: '10',
314   - },
315   - {
316   - value: '11',
317   - label: '11',
318   - },
319   - {
320   - value: '12',
321   - label: '12',
322   - },
323   - ];
324   -
325 183 // const items: TabsProps['items'] = [
326 184 // {
327 185 // key: 'MONTH_STATISTICS',
... ... @@ -420,67 +278,37 @@ const OrderReportPage = () =&gt; {
420 278 tooltip="下方汇总统计未统计实验设备事业部数据,如需要请勾选包含实验设备事业部汇总统计"
421 279 extra={
422 280 <div>
423   - <Segmented
424   - options={['本月', '上月', '本年']}
425   - onChange={(val: any) => {
426   - onChange(val);
427   - }}
428   - />
429 281 <div>
430 282 <ProForm.Group>
431 283 <ProFormSelect
432   - name="salesCode"
433   - key="salesCode"
  284 + name="selectedMonth"
  285 + key="selectedMonth"
434 286 width="100px"
435 287 // actionRef={mainTableRef}
436 288 // formRef={mainTableFormRef}
437   - initialValue={'1'}
  289 + value={selectedMonth}
438 290 showSearch
439   - placeholder="月份"
  291 + placeholder="全部"
440 292 options={monthOptions}
441   - // onChange={(_, option) => {
442   - // // if (option === undefined) {
443   - // // selectSalesCode(userInfo.username);
444   - // // }
445   - // // // if (option.value !== undefined) {
446   - // // // selectSalesCode(option.value);
447   - // // // }
448   - // // if (option && option.value !== undefined) {
449   - // // selectSalesCode(option.value);
450   - // // }
451   - // }}
452   - // request={async () => {
453   - // let options = await getSalesCodeOptions();
454   - // setSalesCodeOptions(options);
455   - // return options;
456   - // }}
  293 + onChange={(value) => {
  294 + const newValue = value === undefined ? '0' : value;
  295 + setSelectedMonth(newValue);
  296 + }}
457 297 />
458 298 <ProFormSelect
459   - name="salesCode"
460   - key="salesCode"
  299 + name="selectedYear"
  300 + key="selectedYear"
461 301 width="100px"
462 302 // actionRef={mainTableRef}
463 303 // formRef={mainTableFormRef}
464   - initialValue={'2025'}
  304 + value={selectedYear}
465 305 showSearch
466   - placeholder="年份"
  306 + placeholder="2025"
467 307 options={yearOptions}
468   - // onChange={(_, option) => {
469   - // // if (option === undefined) {
470   - // // selectSalesCode(userInfo.username);
471   - // // }
472   - // // // if (option.value !== undefined) {
473   - // // // selectSalesCode(option.value);
474   - // // // }
475   - // // if (option && option.value !== undefined) {
476   - // // selectSalesCode(option.value);
477   - // // }
478   - // }}
479   - // request={async () => {
480   - // let options = await getSalesCodeOptions();
481   - // setSalesCodeOptions(options);
482   - // return options;
483   - // }}
  308 + onChange={(value) => {
  309 + const newValue = value === undefined ? '2025' : value;
  310 + setSelectedYear(newValue); // 更新选中值
  311 + }}
484 312 />
485 313 </ProForm.Group>
486 314 </div>
... ... @@ -491,7 +319,8 @@ const OrderReportPage = () =&gt; {
491 319 <Spin spinning={loading}>
492 320 <OrderDualAxes
493 321 data={statisticData}
494   - statisticMethod={statisticsMethod}
  322 + statisticMethod={selectedMonth}
  323 + onXValueClick={handleXValueClick}
495 324 />
496 325 </Spin>
497 326 </ProCard>
... ...