From bbc1aeee7310c441a5d34dad64c173219c346eaa Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 27 Jun 2023 18:21:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=8A=20fix:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseExchangeAddEdit/index.jsx | 7 + .../exchangecode/exchangecodeAdd/utils.js | 319 +++++++++--------- src/tools/index.js | 2 +- 3 files changed, 168 insertions(+), 160 deletions(-) diff --git a/src/components/UseExchangeAddEdit/index.jsx b/src/components/UseExchangeAddEdit/index.jsx index dbc80801..f0a484e3 100644 --- a/src/components/UseExchangeAddEdit/index.jsx +++ b/src/components/UseExchangeAddEdit/index.jsx @@ -59,6 +59,13 @@ const tableColumn = [ name: "effectDate", type: "normal" }, + { + title: "总预算", + prop: "all_budget", + name: "all_budget", + width: "auto", + type: "normal" + }, { title: "当前成本价格", prop: "cost_price", diff --git a/src/pages/exchangecode/exchangecodeAdd/utils.js b/src/pages/exchangecode/exchangecodeAdd/utils.js index 9e96a8ba..cce84964 100644 --- a/src/pages/exchangecode/exchangecodeAdd/utils.js +++ b/src/pages/exchangecode/exchangecodeAdd/utils.js @@ -1,129 +1,135 @@ -import { divNum } from '@/tools/number'; +import { divNum } from "@/tools/number" //基本信息 export const codeInfo = { - code_name: [{ type: 'required', message: '请输入兑换码名称' }], - planSelect: [{ type: 'required', message: '请选择归属计划' }], - keyBatchSelect: [{ type: 'required', message: '请选择归属Key' }], - issued: [{ type: 'required', message: '请输入发放总量' }], + code_name: [{ type: "required", message: "请输入兑换码名称" }], + planSelect: [{ type: "required", message: "请选择归属计划" }], + keyBatchSelect: [{ type: "required", message: "请选择归属Key" }], + issued: [{ type: "required", message: "请输入发放总量" }], restrict: [ - { type: 'required', message: '请输入绑定数量' }, + { type: "required", message: "请输入绑定数量" }, { - type: 'regExp', - message: '请输入大于0的正整数', - reg: '^[0-9]*[1-9][0-9]*$' + type: "regExp", + message: "请输入大于0的正整数", + reg: "^[0-9]*[1-9][0-9]*$" } ] -}; +} //基本规则 export const rulesInfo = { - date_time: [{ type: 'required', message: '请选择生效时间段' }] -}; + date_time: [{ type: "required", message: "请选择生效时间段" }] +} /* 商品范围列表 */ export const Column2 = [ { - title: '商品ID', - name: 'product_id', - prop: 'product_id', - width: 'auto', - type: 'normal' + title: "商品ID", + name: "product_id", + prop: "product_id", + width: "auto", + type: "normal" }, { - title: '商品名称', - width: 'auto', - prop: 'product_name', - name: 'product_name', - type: 'normal' + title: "商品名称", + width: "auto", + prop: "product_name", + name: "product_name", + type: "normal" }, { - title: '总预算', - name: 'all_budget', - prop: 'all_budget', - type: 'normal', - width: 'auto' + title: "总预算", + name: "all_budget", + prop: "all_budget", + type: "normal", + width: "auto" }, { - title: '合同单价', - name: 'contract_price', - prop: 'contract_price', - type: 'normal', - width: 'auto' + title: "合同单价", + name: "contract_price", + prop: "contract_price", + type: "normal", + width: "auto" }, { - title: '商品官方价', - type: 'normal', - prop: 'official_price', - width: 'auto' + title: "商品官方价", + type: "normal", + prop: "official_price", + width: "auto" }, { - title: '类型', - width: 'auto', - prop: 'type', - name: 'type', - type: 'slot' + title: "类型", + width: "auto", + prop: "type", + name: "type", + type: "slot" }, { - title: '上游平台', - width: 'auto', - prop: 'upstream', - name: 'upstream', - type: 'normal' + title: "上游平台", + width: "auto", + prop: "upstream", + name: "upstream", + type: "normal" }, { - title: '批次号', - width: 'auto', - prop: 'channel_activity_id', - name: 'channel_activity_id', - type: 'normal' + title: "批次号", + width: "auto", + prop: "channel_activity_id", + name: "channel_activity_id", + type: "normal" }, { - title: '有效时间段', - width: 'auto', - prop: 'effectDate', - name: 'effectDate', - type: 'normal' + title: "有效时间段", + width: "auto", + prop: "effectDate", + name: "effectDate", + type: "normal" + }, + { + title: "总预算", + prop: "all_budget", + name: "all_budget", + width: "auto", + type: "normal" + }, + { + title: "当前成本价格", + prop: "cost_price", + name: "cost_price", + width: "auto", + type: "slot" }, { - title: '当前成本价格', - prop: 'cost_price', - name: 'cost_price', - width: 'auto', - type: 'slot' - }, - - { - title: '库存总数量', - prop: 'quantity', - name: 'quantity', - type: 'normal', - width: 'auto' + title: "库存总数量", + prop: "quantity", + name: "quantity", + type: "normal", + width: "auto" }, { - title: '剩余数量', - prop: 'stock', - name: 'stock', - type: 'normal', - width: 'auto' + title: "剩余数量", + prop: "stock", + name: "stock", + type: "normal", + width: "auto" }, { - title: '已使用数量', - prop: 'usage', - name: 'usage', - type: 'normal', - width: 'auto' + title: "已使用数量", + prop: "usage", + name: "usage", + type: "normal", + width: "auto" }, { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' + title: "操作", + prop: "edit", + name: "edit", + type: "slot", + width: "auto" } -]; +] /* 初始化数据 */ export const init = () => { @@ -131,29 +137,29 @@ export const init = () => { uploading: false, //上传中 model: { //数据模型不可少 - product_id: '', - product_type: '1', - contract_price: '', - official_price: '', - cost_price: '', - quantity: '', - product_name: '', - show_url: '', - describe_url: '', - detail_url: '', - weight: '0' + product_id: "", + product_type: "1", + contract_price: "", + official_price: "", + cost_price: "", + quantity: "", + product_name: "", + show_url: "", + describe_url: "", + detail_url: "", + weight: "0" }, codeInfo: { //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: '', - range: '', - stock: '', - planSelect: '' /* 归属计划 */, - keyBatchSelect: '' /* 归属key */, - restrict: '' /* 绑定数 */ + code_name: "", + issued: "", //发放总量 + describe: "", + date_time: "", + range: "", + stock: "", + planSelect: "" /* 归属计划 */, + keyBatchSelect: "" /* 归属key */, + restrict: "" /* 绑定数 */ }, isload: false, tempdata: [], @@ -169,78 +175,73 @@ export const init = () => { timer: 3, payType: 3, reseller: null, - payment_direction: ['对私账户', '对公账户', '预付款扣除'], + payment_direction: ["对私账户", "对公账户", "预付款扣除"], isAudit: false, approvalsStatus: false, oldTable: [], - product_title: '新建商品', - plan_time: '', + product_title: "新建商品", + plan_time: "", direct_reseller_id: 0, newGoodsBtnLoading: false, tableLoading: false, - addIsType: '', + addIsType: "", isState: 0 /* 0:新增 1:复制 2:编辑 */, planSelectData: [] /* 归属计划数据 */, keyBatchSelectData: [] /* 归属key数据 */, - codeStatus: '' /* 兑换码状态 */ - }; -}; + codeStatus: "" /* 兑换码状态 */ + } +} /* 转换红包数据 */ export function redPacketsDataFn(params) { - const newObj = {}; + const newObj = {} const price = - params.cash_amount_type === '1' + params.cash_amount_type === "1" ? params.denomination - : params.total_contract_price / params.num; - newObj.product_name = params.batch_goods_name; //名字 - newObj.channel_activity_id = params.cash_activity_id; //批次号 - newObj.cash_activity_id = params.cash_activity_id; //批次号 - newObj.only = params.cash_activity_id; //批次号 - newObj.type = 3; //类型 - newObj.checked = params?.checked; - newObj.upstream = params.channel === 1 ? '支付宝' : '微信'; //上游 - newObj.edit = 'edit'; - newObj.all_budget = params.all_budget; - newObj.effectDate = params.begin_time + ' 至 ' + params.end_time; //有效时间 - newObj.contract_price = price; //单价 - newObj.cost_price = '-'; //单价 - newObj.official_price = price; //官方价 - newObj.quantity = params.total_stock || params.num; //总库 - newObj.stock = params.stock || params.num; //剩余 - newObj.usage = params.usage || 0; //已使用 - newObj.id = params.goods_id || params.id; - newObj.product_id = params.goods_id || '-'; - newObj.origin = params; - return newObj; + : `${params.min_denomination}~${params.max_denomination}` + newObj.product_name = params.batch_goods_name //名字 + newObj.channel_activity_id = params.cash_activity_id //批次号 + newObj.cash_activity_id = params.cash_activity_id //批次号 + newObj.only = params.cash_activity_id //批次号 + newObj.type = 3 //类型 + newObj.checked = params?.checked + newObj.upstream = params.channel === 1 ? "支付宝" : "微信" //上游 + newObj.edit = "edit" + newObj.all_budget = params.all_budget + newObj.effectDate = params.begin_time + " 至 " + params.end_time //有效时间 + newObj.contract_price = params.total_contract_price / params.num //合同单价 + newObj.cost_price = "-" //单价 + newObj.official_price = price //官方价 + newObj.quantity = params.total_stock || params.num //总库 + newObj.stock = params.stock || params.num //剩余 + newObj.usage = params.usage || 0 //已使用 + newObj.id = params.goods_id || params.id + newObj.product_id = params.goods_id || "-" + newObj.origin = params + return newObj } /* 转换立减金数据 */ export function reductionFn(params) { - const newObj = {}; - newObj.product_name = params.batch_goods_name || params.product_name; //名字 - newObj.channel_activity_id = params.channel_activity_id; //批次号 - newObj.only = params.channel_activity_id; //批次号 - newObj.type = 2; //类型 - newObj.checked = params?.checked; - newObj.upstream = String(params.channel) === '1' ? '支付宝' : '微信'; //上游 - newObj.edit = 'edit'; - newObj.all_budget = params.all_budget; + const newObj = {} + newObj.product_name = params.batch_goods_name || params.product_name //名字 + newObj.channel_activity_id = params.channel_activity_id //批次号 + newObj.only = params.channel_activity_id //批次号 + newObj.type = 2 //类型 + newObj.checked = params?.checked + newObj.upstream = String(params.channel) === "1" ? "支付宝" : "微信" //上游 + newObj.edit = "edit" + newObj.all_budget = params.all_budget newObj.effectDate = params.effectDate || - params.time_limit?.effect_time.start_time + - ' 至 ' + - params.time_limit?.effect_time.end_time; //有效时间 - newObj.contract_price = params.contract_price || params.price; //单价 - newObj.official_price = params.official_price || params.reduce_amount; //官方价 - newObj.quantity = - params.quantity || - parseInt(divNum(params.all_budget, params.reduce_amount)); //总库 - newObj.stock = - params.stock || parseInt(divNum(params.all_budget, params.reduce_amount)); //剩余 - newObj.usage = params.usage || 0; //已使用 - newObj.origin = params; - newObj.id = params.goods_id || params.id; - newObj.product_id = params.goods_id || '-'; - return newObj; + params.time_limit?.effect_time.start_time + " 至 " + params.time_limit?.effect_time.end_time //有效时间 + newObj.contract_price = params.contract_price || params.price //单价 + newObj.official_price = params.official_price || params.reduce_amount //官方价 + newObj.quantity = params.quantity || parseInt(divNum(params.all_budget, params.reduce_amount)) //总库 + newObj.stock = params.stock || parseInt(divNum(params.all_budget, params.reduce_amount)) //剩余 + newObj.usage = params.usage || 0 //已使用 + newObj.origin = params + newObj.id = params.goods_id || params.id + newObj.product_id = params.goods_id || "-" + return newObj } diff --git a/src/tools/index.js b/src/tools/index.js index e1047012..f506f988 100644 --- a/src/tools/index.js +++ b/src/tools/index.js @@ -46,7 +46,7 @@ export const redPacketsFun = (item) => { table_obj.only = item // 存储就数据 编辑好用 table_obj.product_id = item.goods_id || item.id || item.cash_activity_id // 商品编号 table_obj.product_name = item.batch_goods_name // 商品名 - table_obj.official_price = price // 官方价 + table_obj.official_price = item.total_contract_price / item.num // 官方价 table_obj.contract_price = price // 合同价格 table_obj.cost_price = "-" //单价 table_obj.quantity = item.num // 库存数量