Browse Source

fix(forecast-form): 修复大数字类型转换问题并优化库存数据处理

yz 2 weeks ago
parent
commit
bd686ba8d3

+ 5 - 4
src/components/forecast-form/forecast-form-mixin.js

@@ -78,6 +78,7 @@ import { getCustomerList, getItemList, getCustomerInfo } from '@/api/common'
 
 // 表单配置导入
 import { getFormOption } from './form-option'
+import { safeBigInt } from '@/util/util'
 
 /**
  * 销售预测表单事件常量
@@ -380,18 +381,18 @@ export default {
             try {
               this.stockTableData = newData.pcBladeSalesForecastSummaryList.map(item => ({
                 // 尽量保持与 PjpfStockDesc 结构一致,便于表格渲染
-                id: item.id != null ? item.id : undefined,
-                goodsId: item.itemId != null ? item.itemId : undefined,
+                id: item.id ? safeBigInt(item.id) : undefined,
+                goodsId: item.itemId ? safeBigInt(item.itemId) : undefined,
                 code: item.itemCode || '',
                 cname: item.itemName || '',
-                brandId: item.brandId != null ? item.brandId : undefined,
+                brandId: item.brandId ? safeBigInt(item.brandId) : undefined,
                 brandCode: item.brandCode || '',
                 brandName: item.brandName || '',
                 typeNo: item.specs || '',
                 productDescription: item.pattern || '',
                 brandItem: item.pattern || '',
                 // 回显数据可能无库存,先不默认写入 '0',留给后续合并方法填充
-                storeInventory: (item.storeInventory !== undefined && item.storeInventory !== null && item.storeInventory !== '') ? String(item.storeInventory) : undefined,
+                storeInventory: undefined,
                 // 预测数量用于编辑
                 forecastQuantity: Number(item.forecastQuantity || 0)
               }))

+ 1 - 1
src/components/forecast-form/types.d.ts

@@ -158,7 +158,7 @@ export interface ForecastFormMixinData {
   /** 品牌选项列表 */
   brandOptions: Array<SelectOption<number>>;
   /** 物料表格数据(来自用户关联商品 pjpfStockDescList),带预测数量字段 */
-  stockTableData: Array<import('@/api/types/order').PjpfStockDesc & { forecastQuantity: number }>;
+  stockTableData: Array<Partial<import('@/api/types/order').PjpfStockDesc> & { forecastQuantity: number }>;
   /** 表格加载状态 */
   tableLoading: boolean;
   /** 品牌描述列表(用于品牌信息匹配) */

+ 1 - 1
src/util/util.js

@@ -383,7 +383,7 @@ export const formatFileSize = (bytes) => {
 /**
  * BigInt 安全转换(兼容 stringify)
  * @param {string|number|bigint|null|undefined} v
- * @returns {string|null}
+ * @returns {string}
  */
 export const safeBigInt = (v) => {
   try {