|
|
@@ -1,4 +1,4 @@
|
|
|
-import { approveSalesForecastSummary, getSalesForecastForecastList, approveSalesForecastSummaryParticulars } from '@/api/forecast/forecast-summary'
|
|
|
+import { approveSalesForecastSummary, getSalesForecastMainPage, approveSalesForecastSummaryParticulars } from '@/api/forecast/forecast-summary'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
APPROVAL_STATUS,
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
formatNumber,
|
|
|
formatDateTime as formatDateTimeUtil
|
|
|
} from '@/constants/forecast'
|
|
|
+import { safeBigInt } from '@/util/util'
|
|
|
|
|
|
/**
|
|
|
* @typedef {import('./types').ForecastRecord} ForecastRecord
|
|
|
@@ -288,6 +289,10 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 新增:格式化日期时间显示,供子表“审批时间”列使用
|
|
|
+ /**
|
|
|
+ * @param {string|null|undefined} dateTime - 日期时间值
|
|
|
+ * @returns {string} 格式化后的日期时间字符串
|
|
|
+ */
|
|
|
formatDateTime(dateTime) {
|
|
|
return formatDateTimeUtil(dateTime)
|
|
|
},
|
|
|
@@ -579,25 +584,11 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 安全转换为 BigInt(若失败返回 null)
|
|
|
- * @param {string|number|bigint|null|undefined} v
|
|
|
- * @returns {bigint|null}
|
|
|
- */
|
|
|
- toBigIntSafe(v) {
|
|
|
- try {
|
|
|
- if (v === null || v === undefined || v === '') return null
|
|
|
- return BigInt(String(v))
|
|
|
- } catch (e) {
|
|
|
- return null
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 加载数据(使用销售预测主表分页 forecast/list)
|
|
|
- * @this {Vue & ForecastAuditComponent}
|
|
|
- * @param {import('./types').PageConfig} page - 分页配置
|
|
|
- * @param {Partial<{year: number, month: number, customerName: string}>} [params={}] - 查询参数
|
|
|
- */
|
|
|
+ * 加载数据(使用销售预测主表分页)
|
|
|
+ * @this {Vue & ForecastAuditComponent}
|
|
|
+ * @param {import('./types').PageConfig} page - 分页配置
|
|
|
+ * @param {Partial<{year: number, month: number, customerName: string}>} [params={}] - 查询参数
|
|
|
+ */
|
|
|
async onLoad(page, params = {}) {
|
|
|
try {
|
|
|
this.loading = true
|
|
|
@@ -608,48 +599,49 @@ export default {
|
|
|
customerName: params.customerName ?? this.query.customerName
|
|
|
}
|
|
|
|
|
|
- // 调用新的分页接口(含明细)
|
|
|
- const res = await getSalesForecastForecastList(
|
|
|
+ // 使用新分页接口(主表分页)
|
|
|
+ const res = await getSalesForecastMainPage(
|
|
|
page.currentPage,
|
|
|
page.pageSize,
|
|
|
queryParams
|
|
|
)
|
|
|
const { records = [], total = 0, current = 1, size = 10 } = (res.data && res.data.data) || {}
|
|
|
|
|
|
- // 处理ID为 BigInt,同时保留字符串ID以便传输
|
|
|
+ // 处理ID为 BigInt 字符串,同时保留字符串ID以便传输
|
|
|
const mapped = (records || []).map(rec => {
|
|
|
const idStr = rec && rec.id != null ? String(rec.id) : ''
|
|
|
- const idBigint = this.toBigIntSafe(idStr)
|
|
|
+ const idBigint = safeBigInt(idStr)
|
|
|
const subList = Array.isArray(rec.pcBladeSalesForecastSummaryList)
|
|
|
? rec.pcBladeSalesForecastSummaryList.map(sub => {
|
|
|
const subIdStr = sub && sub.id != null ? String(sub.id) : ''
|
|
|
- const subIdBigint = this.toBigIntSafe(subIdStr)
|
|
|
+ const subIdBigint = safeBigInt(subIdStr)
|
|
|
const fmIdStr = sub && sub.forecastMainId != null ? String(sub.forecastMainId) : idStr
|
|
|
- const fmIdBigint = this.toBigIntSafe(fmIdStr)
|
|
|
+ const fmIdBigint = safeBigInt(fmIdStr)
|
|
|
return {
|
|
|
...sub,
|
|
|
id: subIdStr,
|
|
|
forecastMainId: fmIdStr,
|
|
|
+ year: Number(sub.year),
|
|
|
+ month: Number(sub.month),
|
|
|
+ forecastQuantity: typeof sub.forecastQuantity === 'string' ? Number(sub.forecastQuantity) : Number(sub.forecastQuantity),
|
|
|
idBigint: subIdBigint,
|
|
|
forecastMainIdBigint: fmIdBigint,
|
|
|
// 继承父级字段,保证子表新增列有值可展示
|
|
|
approvalStatus: sub && sub.approvalStatus != null ? sub.approvalStatus : (rec && rec.approvalStatus != null ? rec.approvalStatus : APPROVAL_STATUS.PENDING),
|
|
|
customerName: sub && sub.customerName != null ? sub.customerName : rec && rec.customerName,
|
|
|
- year: sub && sub.year != null ? sub.year : rec && rec.year,
|
|
|
- month: sub && sub.month != null ? sub.month : rec && rec.month,
|
|
|
approvedName: sub && sub.approvedName != null ? sub.approvedName : rec && rec.approvedName,
|
|
|
approvedTime: sub && sub.approvedTime != null ? sub.approvedTime : rec && rec.approvedTime
|
|
|
}
|
|
|
})
|
|
|
: []
|
|
|
const approvalStatus = /** @type {import('@/constants/forecast').ApprovalStatus} */ (rec.approvalStatus ?? APPROVAL_STATUS.PENDING)
|
|
|
- return { ...rec, id: idStr, idBigint, approvalStatus, pcBladeSalesForecastSummaryList: subList }
|
|
|
+ return { ...rec, id: idStr, idBigint, year: Number(rec.year), month: Number(rec.month), approvalStatus, pcBladeSalesForecastSummaryList: subList }
|
|
|
})
|
|
|
|
|
|
this.data = /** @type {import('./types').ForecastRecord[]} */ (mapped)
|
|
|
- this.page.total = total
|
|
|
- this.page.currentPage = current
|
|
|
- this.page.pageSize = size
|
|
|
+ this.page.total = Number(total)
|
|
|
+ this.page.currentPage = Number(current)
|
|
|
+ this.page.pageSize = Number(size)
|
|
|
} catch (error) {
|
|
|
// eslint-disable-next-line no-console
|
|
|
console.error('加载列表失败', error)
|