Sfoglia il codice sorgente

feat(预测汇总): 新增审核相关字段并优化数据处理逻辑

yz 6 giorni fa
parent
commit
78dd968bc8
1 ha cambiato i file con 35 aggiunte e 30 eliminazioni
  1. 35 30
      src/views/forecast-summary/summaryIndex.js

+ 35 - 30
src/views/forecast-summary/summaryIndex.js

@@ -192,12 +192,19 @@ import { mapGetters } from 'vuex'
          menu: false,
          expand: false,
          column: [
-           { label: '商品编码', prop: 'itemCode', minWidth: 120 },
-           { label: '商品名称', prop: 'itemName', minWidth: 180, overHidden: true },
+           { label: '物料编码', prop: 'itemCode', minWidth: 120 },
+           { label: '物料名称', prop: 'itemName', minWidth: 180, overHidden: true },
            { label: '规格型号', prop: 'specs', minWidth: 140, overHidden: true },
            { label: '花型/图案', prop: 'pattern', minWidth: 120, overHidden: true },
            { label: '品牌名称', prop: 'brandName', minWidth: 120, overHidden: true },
-           { label: '预测数量', prop: 'forecastQuantity', minWidth: 120, align: 'right', slot: true }
+           { label: '预测数量', prop: 'forecastQuantity', minWidth: 120, align: 'right', slot: true },
+           // 新增列:审核状态、客户名称、年份、月份、审批人、审批时间
+           { label: '审核状态', prop: 'approvalStatus', minWidth: 100, type: 'select', dicData: APPROVAL_STATUS_OPTIONS, slot: true },
+           { label: '客户名称', prop: 'customerName', minWidth: 160, overHidden: true },
+           { label: '年份', prop: 'year', minWidth: 80 },
+           { label: '月份', prop: 'month', minWidth: 80 },
+           { label: '审批人', prop: 'approvedName', minWidth: 100, overHidden: true },
+           { label: '审批时间', prop: 'approvedTime', minWidth: 160, slot: true }
          ]
        },
 
@@ -504,7 +511,12 @@ import { mapGetters } from 'vuex'
                    forecastMainIdBigint: it.forecastMainId != null ? this.safeBigInt(it.forecastMainId) : null,
                    year: Number(it.year),
                    month: Number(it.month),
-                   forecastQuantity: typeof it.forecastQuantity === 'string' ? Number(it.forecastQuantity) : Number(it.forecastQuantity)
+                   forecastQuantity: typeof it.forecastQuantity === 'string' ? Number(it.forecastQuantity) : Number(it.forecastQuantity),
+                   // 继承主表字段,确保子表数据完整性
+                   customerName: it.customerName != null ? it.customerName : r.customerName,
+                   approvalStatus: it.approvalStatus != null ? it.approvalStatus : r.approvalStatus,
+                   approvedName: it.approvedName != null ? it.approvedName : r.approvedName,
+                   approvedTime: it.approvedTime != null ? it.approvedTime : r.approvedTime
                  }))
                : []
              return {
@@ -519,53 +531,46 @@ import { mapGetters } from 'vuex'
            this.page.currentPage = Number(pageData.current) || 1
            this.page.pageSize = Number(pageData.size) || 10
          } else {
-           this.$message.error(response?.data?.message || '获取数据失败')
            this.data = []
            this.page.total = 0
          }
-       } catch (error) {
-         console.error('获取预测主表分页列表失败:', error)
-         this.$message.error('获取数据失败,请稍后重试')
-         this.data = []
-         this.page.total = 0
+       } catch (e) {
+         console.error('加载销售预测汇总数据失败:', e)
+         this.$message.error('加载失败,请稍后重试')
        } finally {
          this.loading = false
        }
      },
 
      /**
-      * 安全将值转换为BigInt
-      * @param {string|number|null|undefined} v
-      * @returns {bigint|null}
+      * BigInt 安全转换(兼容 stringify)
+      * @param {string|number|bigint|null|undefined} v
+      * @returns {string|null}
       */
      safeBigInt(v) {
        try {
-         if (v === null || v === undefined || v === '') return null
-         return BigInt(v)
+         if (v === null || v === undefined) return null
+         const n = BigInt(v)
+         return n.toString()
        } catch (e) {
-         return null
+         return v != null ? String(v) : null
        }
      },
 
      /**
-      * 获取预测汇总详情
-      * @this {ForecastSummaryComponent & Vue}
-      * @param {string|number} id - 预测汇总ID
-      * @returns {Promise<import('@/api/forecast/types').ForecastSummaryRecord|null>} 详情数据
+      * 查询主表对应的子表明细
+      * @param {string|number} id - 主表ID
       */
      async getForecastSummaryDetail(id) {
        try {
-         const response = await getForecastSummaryDetail(id)
-         if (response && response.data && response.data.code === 200) {
-           return response.data.data
-         } else {
-           this.$message.error(response.data.message || '获取详情失败')
-           return null
+         const res = await getForecastSummaryDetail(id)
+         if (res && res.data && res.data.code === 200) {
+           return res.data.data || []
          }
-       } catch (error) {
-         console.error('获取预测汇总详情失败:', error)
-         this.$message.error('获取详情失败,请稍后重试')
-         return null
+         return []
+       } catch (e) {
+         console.error('获取明细失败:', e)
+         return []
        }
      }
    }