From 578361bf5a3fe6e236c8d459bed53a3bdd795243 Mon Sep 17 00:00:00 2001 From: 15820893422 <1978476055@qq.com> Date: Fri, 17 May 2024 14:07:11 +0800 Subject: [PATCH] edit --- src/utils/util.js | 5 +++++ src/views/product/productExamine/editAttr.vue | 9 +++++---- src/views/product/productExamine/proDetails.vue | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/utils/util.js b/src/utils/util.js index 9a2a16e..bb552b9 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -17,6 +17,11 @@ export const getCookies = key => { return Cookies.get(key); }; +// 保留两位小数; +// num +export function toFixedNoRounding(num) { + return Math.floor(num * 100) / 100; +} /** * 从cookie中移除指定的键值对 * @param {string} key - 要移除的键名 diff --git a/src/views/product/productExamine/editAttr.vue b/src/views/product/productExamine/editAttr.vue index 85d8576..4a4c180 100644 --- a/src/views/product/productExamine/editAttr.vue +++ b/src/views/product/productExamine/editAttr.vue @@ -215,6 +215,7 @@ import { freeTrialApi } from '@/api/product' import { roterPre } from "@/settings"; +import { toFixedNoRounding } from '@/utils/util' const defaultObj = { store_name: '', cate_id: '', @@ -448,13 +449,13 @@ export default { methods: { // 占比值变化处理 proportionChange(val,i,e){ - val.cost = (val.price * e).toFixed(2) + val.cost = toFixedNoRounding(val.price * e) let obj = this.proportionList.find(item=>item.value==e) val.coupon = Math.floor(val.price*obj.coupon) val.growth = Math.floor(val.price*obj.growth) }, BatchProportionChange(){ - this.oneFormBatch[0].cost = (this.oneFormBatch[0].price * this.oneFormBatch[0].proportion).toFixed(2) + this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion) let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion) this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon) this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth) @@ -468,7 +469,7 @@ export default { // this.oneFormBatch[0].proportion = (this.oneFormBatch[0].cost/this.oneFormBatch[0].price).toFixed(2) }else{ this.oneFormBatch[0].price = this.oneFormBatch[0].price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1') - this.oneFormBatch[0].cost = (this.oneFormBatch[0].price * this.oneFormBatch[0].proportion).toFixed(2) + this.oneFormBatch[0].cost = toFixedNoRounding(this.oneFormBatch[0].price * this.oneFormBatch[0].proportion) let obj = this.proportionList.find(item=>item.value==this.oneFormBatch[0].proportion) this.oneFormBatch[0].coupon = Math.floor(this.oneFormBatch[0].price*obj.coupon) this.oneFormBatch[0].growth = Math.floor(this.oneFormBatch[0].price*obj.growth) @@ -502,7 +503,7 @@ export default { case 'price': val.price=val.price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1') let obj = this.proportionList.find(item=>item.value==val.proportion) - val.cost = (val.price * val.proportion).toFixed(2) + val.cost = toFixedNoRounding(val.price * val.proportion) val.coupon = Math.floor(val.price*obj.coupon) val.growth = Math.floor(val.price*obj.growth) break; diff --git a/src/views/product/productExamine/proDetails.vue b/src/views/product/productExamine/proDetails.vue index f3168ba..7655322 100644 --- a/src/views/product/productExamine/proDetails.vue +++ b/src/views/product/productExamine/proDetails.vue @@ -1189,9 +1189,9 @@ const defaultObj = { price: null, svip_price: null, cost: null, - ot_price: null, proportion: 0.6, + coupon:'', stock: 0, growth: 0, bar_code: "", @@ -1222,6 +1222,9 @@ const objTitle = { proportion: { title: "占比", }, + coupon:{ + title:'抵扣卷' + }, stock: { title: "库存", },