Commit 3aac27a2060f4681a3bbe48aeb346b4242a3a74a

Authored by boyang
1 parent cfc5c16b

fix: 报表

src/pages/OrderReport/components/OrderDualAxes.tsx
@@ -42,11 +42,7 @@ const OrderDualAxes = ({ data, statisticMethod, onXValueClick }) => { @@ -42,11 +42,7 @@ const OrderDualAxes = ({ data, statisticMethod, onXValueClick }) => {
42 const handleClick = (event) => { 42 const handleClick = (event) => {
43 // 获取当前点击点的数据 43 // 获取当前点击点的数据
44 const pointData = event?.data?.data; 44 const pointData = event?.data?.data;
45 - if (  
46 - pointData &&  
47 - (data?.targetAndTotalPaymentDtoList !== undefined ||  
48 - data?.orderNumberDtoList !== undefined)  
49 - ) { 45 + if (pointData) {
50 // 解析年份和月份 46 // 解析年份和月份
51 if (yFiledString === 'curMonth') { 47 if (yFiledString === 'curMonth') {
52 const xValue = pointData['curMonth']; // 格式类似 "2025-01" 48 const xValue = pointData['curMonth']; // 格式类似 "2025-01"
@@ -57,29 +53,29 @@ const OrderDualAxes = ({ data, statisticMethod, onXValueClick }) => { @@ -57,29 +53,29 @@ const OrderDualAxes = ({ data, statisticMethod, onXValueClick }) => {
57 return; 53 return;
58 } 54 }
59 55
60 - // 减 1 获得目标年份  
61 - const targetYear = String(Number(yearFromXValue) - 1); // "2024" 56 + // // 减 1 获得目标年份
  57 + // const targetYear = String(Number(yearFromXValue) - 1); // "2024"
62 58
63 - // 检查 pointData.type 是否包含目标年份  
64 - if (  
65 - pointData?.type?.includes(targetYear) ||  
66 - pointData?.name?.includes(targetYear)  
67 - ) {  
68 - // 调用父组件传递的回调  
69 - onXValueClick?.(xValue); 59 + // // 检查 pointData.type 是否包含目标年份
  60 + // if (
  61 + // pointData?.type?.includes(targetYear) ||
  62 + // pointData?.name?.includes(targetYear)
  63 + // ) {
  64 + // 调用父组件传递的回调
  65 + onXValueClick?.(xValue, pointData?.name);
70 66
71 - // // 合并两个数据源  
72 - // const allData = [...targetData, ...orderData]; 67 + // // 合并两个数据源
  68 + // const allData = [...targetData, ...orderData];
73 69
74 - // // 筛选出当前列的所有数据  
75 - // const columnData = allData.filter(  
76 - // (item) => item[yFiledString] === xValue,  
77 - // ); 70 + // // 筛选出当前列的所有数据
  71 + // const columnData = allData.filter(
  72 + // (item) => item[yFiledString] === xValue,
  73 + // );
78 74
79 - // 可选择将筛选出的数据展示到页面或以其他方式处理  
80 - // alert(`当前列数据: ${JSON.stringify(columnData, null, 2)}`);  
81 - } else {  
82 - } 75 + // 可选择将筛选出的数据展示到页面或以其他方式处理
  76 + // alert(`当前列数据: ${JSON.stringify(columnData, null, 2)}`);
  77 + // } else {
  78 + // }
83 } 79 }
84 } else { 80 } else {
85 console.warn('点击事件未携带有效数据'); 81 console.warn('点击事件未携带有效数据');
src/pages/OrderReport/index.tsx
@@ -147,31 +147,25 @@ const OrderReportPage = () => { @@ -147,31 +147,25 @@ const OrderReportPage = () => {
147 147
148 setLoading(false); 148 setLoading(false);
149 }; 149 };
150 - const handleXValueClick = async (xValue) => { 150 + const handleXValueClick = async (xValue, type) => {
151 try { 151 try {
152 const [yearValue, monthValue] = xValue.split('-'); 152 const [yearValue, monthValue] = xValue.split('-');
153 - const adjustedYearValue = (parseInt(yearValue, 10) - 1).toString();  
154 - const adjustedMonthValue = monthValue.startsWith('0')  
155 - ? monthValue.slice(1)  
156 - : monthValue;  
157 - // 更新年份和月份选项的选中值  
158 - setSelectedYear(adjustedYearValue);  
159 - setSelectedMonth(adjustedMonthValue);  
160 -  
161 - // const yearSelect = document.querySelector('select[name="year"]'); // 根据 ProFormSelect 的 `name` 属性找到对应 DOM  
162 - // if (yearSelect) {  
163 - // const event = new Event('change', { bubbles: true });  
164 - // yearSelect.value = adjustedYearValue;  
165 - // yearSelect.dispatchEvent(event);  
166 - // }  
167 -  
168 - // // 触发月份选择器的 onChange  
169 - // const monthSelect = document.querySelector('select[name="month"]'); // 根据 ProFormSelect 的 `name` 属性找到对应 DOM  
170 - // if (monthSelect) {  
171 - // const event = new Event('change', { bubbles: true });  
172 - // monthSelect.value = adjustedMonthValue;  
173 - // monthSelect.dispatchEvent(event);  
174 - // } 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 + }
175 } catch (error) { 169 } catch (error) {
176 console.error('Failed to fetch updated data:', error); 170 console.error('Failed to fetch updated data:', error);
177 } 171 }
@@ -287,8 +281,8 @@ const OrderReportPage = () => { @@ -287,8 +281,8 @@ const OrderReportPage = () => {
287 <div> 281 <div>
288 <ProForm.Group> 282 <ProForm.Group>
289 <ProFormSelect 283 <ProFormSelect
290 - name="salesCode"  
291 - key="salesCode" 284 + name="selectedMonth"
  285 + key="selectedMonth"
292 width="100px" 286 width="100px"
293 // actionRef={mainTableRef} 287 // actionRef={mainTableRef}
294 // formRef={mainTableFormRef} 288 // formRef={mainTableFormRef}
@@ -302,8 +296,8 @@ const OrderReportPage = () =&gt; { @@ -302,8 +296,8 @@ const OrderReportPage = () =&gt; {
302 }} 296 }}
303 /> 297 />
304 <ProFormSelect 298 <ProFormSelect
305 - name="salesCode"  
306 - key="salesCode" 299 + name="selectedYear"
  300 + key="selectedYear"
307 width="100px" 301 width="100px"
308 // actionRef={mainTableRef} 302 // actionRef={mainTableRef}
309 // formRef={mainTableFormRef} 303 // formRef={mainTableFormRef}
@@ -312,7 +306,8 @@ const OrderReportPage = () =&gt; { @@ -312,7 +306,8 @@ const OrderReportPage = () =&gt; {
312 placeholder="2025" 306 placeholder="2025"
313 options={yearOptions} 307 options={yearOptions}
314 onChange={(value) => { 308 onChange={(value) => {
315 - setSelectedYear(value); // 更新选中值 309 + const newValue = value === undefined ? '2025' : value;
  310 + setSelectedYear(newValue); // 更新选中值
316 }} 311 }}
317 /> 312 />
318 </ProForm.Group> 313 </ProForm.Group>