浏览代码

fix: 商品盲豆数量计算

Sun 3 年之前
父节点
当前提交
fc3d5c2f03

+ 3 - 3
src/views/business/goods/add.vue

@@ -162,7 +162,7 @@ export default {
         const { goodsId, title, picUrl, exchangeShow, multiSku, value, exchangePrice, cost, quantity, description, skuList } = res.data
         this.addData = {
           value: accDiv(value, 100),
-          cost: accDiv(cost, 100),
+          cost: cost == '' || cost == null ? '' : accDiv(cost, 100),
           goodsId, title, picUrl, exchangeShow, multiSku, exchangePrice, quantity, description, skuList
         }
         if (multiSku && skuList instanceof Array && skuList.length > 0) {
@@ -188,8 +188,8 @@ export default {
           const { value, cost, description, ...rest } = this.addData
           addGoods({...rest, ...{
             value: accMul(value, 100),
-            cost: accMul(cost, 100),
-            exchangePrice: accMul(value, 1000),
+            cost: cost == '' || cost == null ? '' : accMul(cost, 100),
+            exchangePrice: accMul(value, 10),
             description: encodeURI(description)
           }}).then(res => {
             if (res.code === 0) {

+ 3 - 4
src/views/business/goods/components/spec.vue

@@ -140,7 +140,6 @@ export default {
             specObj[key] = []
             console.log(specObj[key])
           }
-          
           specObj[key].push(p.split(':')[1])
         })
       })
@@ -155,7 +154,7 @@ export default {
       this.specListTmp = JSON.parse(JSON.stringify(this.specList))
       this.skuList = sku.map(item => {
         this.$set(item, 'valueY', accDiv(item.value, 100))
-        this.$set(item, 'costY', accDiv(item.cost, 100))
+        this.$set(item, 'costY', item.cost == '' ? '' : accMul(costY, 100) )
         this.$set(item, 'picUrlArr', item.picUrl.split(',').map(item => { return { fileName: item }}))
         this.$set(item, 'status', !!item.quantity)
         return item
@@ -287,8 +286,8 @@ export default {
           this.skuList.forEach(item => {
             const { valueY, costY } = item
             item.value = accMul(valueY, 100)
-            item.exchangePrice = item.value * 10
-            item.cost = accMul(costY, 100)
+            item.exchangePrice = accDiv(item.value, 10)
+            item.cost = costY == '' ? '' : accMul(costY, 100)
             item.picUrl = item.picUrlArr.map(item => { return item.fileName }).toString()
           })
           this.$emit('valid', this.skuList)

+ 1 - 5
src/views/business/goods/index.vue

@@ -76,11 +76,7 @@
           ¥{{$numberFormat(row.cost)}}
         </template>
       </el-table-column>
-      <el-table-column label="兑换盲豆数量" prop="exchangePrice">
-        <template slot-scope="{row}">
-          {{$numberFormat(row.exchangePrice)}}
-        </template>
-      </el-table-column>
+      <el-table-column label="兑换盲豆数量" prop="exchangePrice" />
       <el-table-column label="销量" prop="exchangedQty" />
       <el-table-column label="库存" prop="quantity" />
       <el-table-column label="状态" prop="status">