Browse Source

fix(forecast-summary): 处理yearMonth字段拆分并更新查询参数

yz 2 weeks ago
parent
commit
7716269cc1
1 changed files with 22 additions and 2 deletions
  1. 22 2
      src/views/forecast-summary/summaryIndex.js

+ 22 - 2
src/views/forecast-summary/summaryIndex.js

@@ -308,11 +308,31 @@ export default {
      * @param {Function} done - 完成回调
      */
     searchChange(params, done) {
+      // 处理年月字段拆分
+      const processedParams = { ...params }
+      
+      // 如果有yearMonth字段,拆分为year和month
+      if (processedParams.yearMonth) {
+        const yearMonthValue = processedParams.yearMonth
+        if (yearMonthValue) {
+          // 解析年月格式 (yyyy-MM)
+          const [year, month] = yearMonthValue.split('-')
+          if (year) {
+            processedParams.year = parseInt(year, 10)
+          }
+          if (month) {
+            processedParams.month = parseInt(month, 10)
+          }
+        }
+        // 删除原始的yearMonth字段,避免传递到后端
+        delete processedParams.yearMonth
+      }
+      
       this.query = {
         ...this.query,
-        ...params
+        ...processedParams
       }
-      this.onLoad(this.page, params)
+      this.onLoad(this.page, processedParams)
       done()
     },