|
@@ -1,6 +1,7 @@
|
|
|
import { getForecastList, addForecast, updateForecast } from '@/api/forecast'
|
|
|
import { getCustomerList } from '@/api/common'
|
|
|
import { getItemList } from '@/api/common'
|
|
|
+import { getSalesForecastSummaryPage } from '@/api/forecast/forecast-summary'
|
|
|
import {
|
|
|
APPROVAL_STATUS,
|
|
|
APPROVAL_STATUS_CONFIG,
|
|
@@ -541,14 +542,36 @@ export default {
|
|
|
async onLoad(page, params = {}) {
|
|
|
this.loading = true
|
|
|
try {
|
|
|
- const res = await getForecastList(page.currentPage, page.pageSize, {
|
|
|
- ...params,
|
|
|
- ...this.query
|
|
|
- })
|
|
|
- if (res.data && res.data.success) {
|
|
|
- const data = res.data.data
|
|
|
- this.page.total = data.total
|
|
|
- this.data = data.records
|
|
|
+ // 将 year/month 搜索条件转换为 startMonth/endMonth
|
|
|
+ const q = { ...this.query, ...params }
|
|
|
+ const year = q.year
|
|
|
+ const month = q.month
|
|
|
+ const pad = (n) => String(n).padStart(2, '0')
|
|
|
+ /** @type {Record<string, any>} */
|
|
|
+ const filterParams = {}
|
|
|
+ if (year && month) {
|
|
|
+ filterParams.startMonth = `${year}-${pad(month)}`
|
|
|
+ filterParams.endMonth = `${year}-${pad(month)}`
|
|
|
+ } else if (year && !month) {
|
|
|
+ filterParams.startMonth = `${year}-01`
|
|
|
+ filterParams.endMonth = `${year}-12`
|
|
|
+ }
|
|
|
+ if (q.startDate) filterParams.startDate = q.startDate
|
|
|
+ if (q.endDate) filterParams.endDate = q.endDate
|
|
|
+ if (q.brandName) filterParams.brandName = q.brandName
|
|
|
+
|
|
|
+ const res = await getSalesForecastSummaryPage(page.currentPage, page.pageSize, filterParams)
|
|
|
+ if (res.data && (res.data.success || res.data.code === 200)) {
|
|
|
+ const data = res.data.data || {}
|
|
|
+ const records = Array.isArray(data.records) ? data.records : []
|
|
|
+ this.page.total = Number(data.total || 0)
|
|
|
+ // 字段兼容转换:确保页面所需字段存在
|
|
|
+ this.data = records.map(r => ({
|
|
|
+ ...r,
|
|
|
+ // 兼容旧列表字段:部分接口无此字段则回退
|
|
|
+ forecastCode: r.forecastCode || '',
|
|
|
+ currentInventory: r.currentInventory != null ? r.currentInventory : 0
|
|
|
+ }))
|
|
|
} else {
|
|
|
this.$message.error(res.data?.msg || '加载数据失败')
|
|
|
this.data = []
|