Kaynağa Gözat

合同/订单 重构费用算法

Z 2 yıl önce
ebeveyn
işleme
5d45a26d4c

+ 30 - 37
src/views/contractManage/contractBook/components/inventoryTable.vue

@@ -994,7 +994,7 @@ export default {
         this.$set(r, 'discountSinglePrice', r.singlePrice ? Number(r.singlePrice) : '')
         if (r.singlePrice && r.totalCount) {
           r.totalPrice = this.getAllPrice(r);
-          r.discountTotalPrice = this.getAllPrice(r);
+          r.discountTotalPrice = this.getDiscountTotalPrice(r);
           this.$set(this.form.datasource[index], 'totalPrice', Number(r.totalPrice))
           this.$set(this.form.datasource[index], 'discountTotalPrice', Number(r.discountTotalPrice))
           sum += Number(r.totalPrice);
@@ -1003,30 +1003,16 @@ export default {
           this.$set(r, 'discountTotalPrice', '')
         }
       });
-      return sum
-    },
-    getAllPrice(row) {
-      console.log(this.pricingWay, this.pricingWay == 1, this.pricingWay == 2);
-      let num = 0
-      switch (this.pricingWay) {
-        case 1: //按数量计价计算总金额
-          num = Number(row.singlePrice) * Number(row.totalCount)
-          break;
-        case 2 ://按重量计价计算总金额
-          num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
-          break;
-      }
-      return num
+      return isNaN(sum) ? 0 : sum
     },
     //更新优惠总金额
     discountInput(val) {
       this.$store.commit('concact/setDiscountAmount', val);
     },
-
     //设置优惠总金额修改产品单价
     discountInputByOrder(val) {
+      this.form.discountTotalPrice = val
       //获取优惠金额和总计的差价
-      let diffPrice = this.allPrice - val
       this.form.datasource.forEach((item) => {
         if (val === 0) {
           item.discountTotalPrice = 0
@@ -1038,36 +1024,43 @@ export default {
           item.discountSinglePrice = item.singlePrice
           return
         }
-
-
-
-
-
-
-
-
-
-        //获取详情每条的小计
-        let totalPrice = this.getAllPrice(item)
-        // 使用小计除以总价得出该条数据小计占比 在乘以差价或的该条数据应承担的差价 在小计-应承担差价获得折让后的小计
-        item.discountTotalPrice = (totalPrice - totalPrice / this.allPrice * diffPrice).toFixed(2)
-        //使用折让后的小计除以数量得到单价
+        //获取折让单价
         item.discountSinglePrice = this.getDiscountSinglePrice(item)
+        item.discountTotalPrice = this.getDiscountTotalPrice(item)
       })
       this.$refs.table.reload()
       this.$store.commit('concact/setDiscountAmount', val);
     },
+    //获取折让单价
     getDiscountSinglePrice(row) {
+      let num = Number(this.form.discountTotalPrice) / Number(this.allPrice) * Number(row.singlePrice)
+      return isNaN(num) ? '' : num
+    },
+    //获取合计
+    getAllPrice(row) {
       let num = 0
       switch (this.pricingWay) {
-        case 1: //按数量优惠金额和总计
-          num = Number(row.discountTotalPrice) / Number(row.totalCount)
+        case 1: //按数量计价计算总金额
+          num = Number(row.singlePrice) * Number(row.totalCount)
+          break;
+        case 2 ://按重量计价计算总金额
+          num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
+          break;
+      }
+      return isNaN(num) ? '' : num.toFixed(2)
+    },
+    //获取折让合计
+    getDiscountTotalPrice(row) {
+      let num = 0
+      switch (this.pricingWay) {
+        case 1: //按数量计价计算折让合计
+          num = Number(row.discountSinglePrice) * Number(row.totalCount)
+          break;
+        case 2 ://按重量计价计算折让合计
+          num = Number(row.discountSinglePrice) * Number(row.totalCount) * Number(row.singleWeight)
           break;
-        case 2 ://按重量优惠金额和总计
-          num = Number(row.discountTotalPrice) / Number(row.totalCount) / Number(row.singleWeight)
-          break
       }
-      return num
+      return isNaN(num) ? '' : num.toFixed(2)
     },
     //修改回显
     putTableValue(data) {

+ 0 - 2
src/views/contractManage/contractBook/components/product-list.vue

@@ -156,8 +156,6 @@
             showOverflowTooltip: true
           }
         ],
-
-        radio: null
       };
     },
 

+ 30 - 24
src/views/purchasingManage/purchaseOrder/components/inventoryTable.vue

@@ -681,7 +681,8 @@ export default {
       this.form.datasource.forEach((r) => {
         this.$set(r, 'discountSinglePrice', r.singlePrice ? Number(r.singlePrice) : '')
         if (r.singlePrice && r.totalCount) {
-          r.discountTotalPrice = r.totalPrice = this.getAllPrice(r);
+          r.totalPrice = this.getAllPrice(r);
+          r.discountTotalPrice = this.getDiscountTotalPrice(r);
           this.$set(r, 'totalPrice', Number(r.totalPrice))
           this.$set(r, 'discountTotalPrice', Number(r.discountTotalPrice))
           sum += Number(r.totalPrice);
@@ -692,17 +693,6 @@ export default {
       });
       return sum
     },
-    getAllPrice(row) {
-      let num = 0
-      switch (this.pricingWay) {
-        case 1: //按数量计价计算总金额
-          num = Number(row.singlePrice) * Number(row.totalCount)
-          break;
-        case 2 ://按重量计价计算总金额
-          num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
-      }
-      return num
-    },
 
     //计算单重
     singleWeightChange(row, index) {
@@ -716,8 +706,8 @@ export default {
     },
     //设置优惠总金额修改产品单价
     discountInputByOrder(val) {
+      this.form.discountTotalPrice = val
       //获取优惠金额和总计的差价
-      let diffPrice = this.allPrice - val
       this.form.datasource.forEach((item) => {
         if (val === 0) {
           item.discountTotalPrice = 0
@@ -729,28 +719,44 @@ export default {
           item.discountSinglePrice = item.singlePrice
           return
         }
-        //获取详情每条的小计
-        let totalPrice = this.getAllPrice(item)
-        // 使用小计除以总价得出该条数据小计占比 在乘以差价或的该条数据应承担的差价 在小计-应承担差价获得折让后的小计
-        item.discountTotalPrice = (totalPrice - totalPrice / this.allPrice * diffPrice).toFixed(2)
-        //使用折让后的小计除以数量得到单价
+        //获取折让单价
         item.discountSinglePrice = this.getDiscountSinglePrice(item)
+        item.discountTotalPrice = this.getDiscountTotalPrice(item)
       })
       this.$refs.table.reload()
       this.$store.commit('concact/setDiscountAmount', val);
     },
+    //获取折让单价
     getDiscountSinglePrice(row) {
+      let num = Number(this.form.discountTotalPrice) / Number(this.allPrice) * Number(row.singlePrice)
+      return isNaN(num) ? '' : num
+    },
+    //获取合计
+    getAllPrice(row) {
       let num = 0
       switch (this.pricingWay) {
-        case 1: //按数量优惠金额和总计
-          num = (row.discountTotalPrice / row.totalCount).toFixed(2)
+        case 1: //按数量计价计算总金额
+          num = Number(row.singlePrice) * Number(row.totalCount)
+          break;
+        case 2 ://按重量计价计算总金额
+          num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
           break;
-        case 2 ://按重量优惠金额和总计
-          num = (row.discountTotalPrice / row.totalCount / row.singleWeight).toFixed(2)
       }
-      return num
+      return isNaN(num) ? '' : num.toFixed(2)
+    },
+    //获取折让合计
+    getDiscountTotalPrice(row) {
+      let num = 0
+      switch (this.pricingWay) {
+        case 1: //按数量计价计算折让合计
+          num = Number(row.discountSinglePrice) * Number(row.totalCount)
+          break;
+        case 2 ://按重量计价计算折让合计
+          num = Number(row.discountSinglePrice) * Number(row.totalCount) * Number(row.singleWeight)
+          break;
+      }
+      return isNaN(num) ? '' : num.toFixed(2)
     },
-
     //修改回显
     putTableValue(data, contractStartDate) {
       if (contractStartDate) {

+ 43 - 69
src/views/saleManage/saleOrder/components/product-list.vue

@@ -52,8 +52,7 @@ export default {
           action: 'action',
           slot: 'action',
           align: 'center',
-          label: '选择',
-          width: 50,
+          label: '选择'
         },
         {
           columnKey: 'index',
@@ -64,103 +63,78 @@ export default {
           label: '序号'
         },
         {
-          width: 200,
-          prop: 'productName',
-          label: '名称',
-          slot: 'productName',
-          align: "center"
-        },
-        {
-          width: 200,
-          prop: 'productCode',
+          prop: 'code',
           label: '编码',
-          slot: 'productCode',
-          align: "center"
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 110
         },
         {
-          width: 200,
-          prop: 'productCategoryName',
-          label: '类型',
-          slot: 'productCategoryName',
-          align: "center"
+          prop: 'name',
+          label: '名称',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 110
         },
+
         {
-          width: 150,
-          prop: 'productBrand',
+          prop: 'brandNum',
+          align: 'center',
           label: '牌号',
-          slot: 'productBrand',
-          align: "center"
+          showOverflowTooltip: true
         },
         {
-          minWidth: 120,
           prop: 'modelType',
           label: '型号',
-          slot: 'modelType',
-          align: "center"
+          align: 'center',
+          showOverflowTooltip: true
         },
         {
-          minWidth: 120,
           prop: 'specification',
           label: '规格',
-          slot: 'specification',
-          align: "center"
-        },
-        {
-          width: 80,
-          prop: 'totalCount',
-          label: '数量',
-          slot: 'totalCount',
-          align: "center"
+          align: 'center',
+          showOverflowTooltip: true
         },
         {
-          minWidth: 100,
           prop: 'measuringUnit',
           label: '计量单位',
-          slot: 'measuringUnit',
-          align: "center"
-        },
-        {
-          width: 120,
-          prop: 'singleWeight',
-          label: '单重',
-          slot: 'singleWeight',
-          align: "center"
+          showOverflowTooltip: true,
+          minWidth: 90
         },
+
         {
-          width: 100,
           prop: 'weightUnit',
           label: '重量单位',
-          slot: 'weightUnit',
-          align: "center"
+          showOverflowTooltip: true,
+          minWidth: 90
         },
+
         {
-          width: 80,
-          prop: 'singlePrice',
-          label: '单价',
-          slot: 'singlePrice',
-          align: "center"
+          prop: 'roughWeight',
+          label: '毛重',
+          showOverflowTooltip: true,
+          minWidth: 90
         },
+
         {
-          width: 100,
-          prop: 'discountSinglePrice',
-          label: '折让单价',
-          slot: 'discountSinglePrice',
-          align: "center"
+          prop: 'netWeight',
+          label: '净重',
+          showOverflowTooltip: true,
+          minWidth: 90
         },
+
         {
-          width: 80,
-          prop: 'totalPrice',
-          label: '合计',
-          slot: 'totalPrice',
-          align: "center"
+          prop: 'packingUnit',
+          align: 'center',
+          label: '包装单位',
+          showOverflowTooltip: true
         },
         {
-          width: 100,
-          prop: 'discountTotalPrice',
-          label: '折让合计',
-          slot: 'discountTotalPrice',
-          align: "center"
-        },
+          prop: 'categoryLevelPath',
+          label: '分类',
+          align: 'center',
+          showOverflowTooltip: true
+        }
       ],
 
       radio: null,