diff --git a/src/tools/index.js b/src/tools/index.js index 4ae68846..f1b8cd65 100644 --- a/src/tools/index.js +++ b/src/tools/index.js @@ -1,4 +1,15 @@ import { divNum } from "./number"; + +// 判断 +const kgType = (item) => { + let type = sessionStorage.getItem("KeyPcType"); + if (type === "2" || type === "3") { + return divNum(item.all_budget, item.reduce_amount); + } else { + return item.stock; + } +}; + // 立减金对象重构 export const knockGoldFun = (item) => { let table_obj = {}; @@ -11,9 +22,7 @@ export const knockGoldFun = (item) => { table_obj.official_price = item.reduce_amount; // 官方价 table_obj.contract_price = item.price; // 合同价格 table_obj.quantity = item.total_stock; // 库存数量 - table_obj.stock = item.stock - ? item.stock - : divNum(item.all_budget, item.reduce_amount); // 剩余库存数量 + table_obj.stock = kgType(item); // 剩余库存数量 table_obj.channel_activity_id = item.channel_activity_id; // 批次号 table_obj.all_budget = Number(item.all_budget); // 总预算 table_obj.effectDate = `${item.time_limit.effect_time.start_time} 至 ${item.time_limit.effect_time.end_time}`; // 有效时间段