Ver Fonte

合同/订单 重构费用算法

Z há 2 anos atrás
pai
commit
cfa7b9ac38

+ 35 - 29
src/views/bpm/handleTask/components/contractBook/inventoryTable.vue

@@ -995,6 +995,11 @@ export default {
     getPrice() {
       return [this.allPrice, this.form.discountTotalPrice];
     },
+    //改变数量
+    changeCount(row, index) {
+      this.singleWeightChange(row, index);
+      this.getTotalPrice()
+    },
     //计算总金额
     getTotalPrice(row) {
       if (this.form.datasource.length) {
@@ -1021,7 +1026,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);
@@ -1030,20 +1035,7 @@ 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) {
@@ -1051,8 +1043,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
@@ -1064,27 +1056,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)).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 = (Number(row.discountTotalPrice) / Number(row.totalCount) / Number(row.singleWeight)).toFixed(2)
-          break
       }
-      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) {
@@ -1183,8 +1191,6 @@ export default {
     },
     //选择产品回调
     changeParent(obj, idx) {
-      console.log(obj, '33333');
-
       this.$set(this.form.datasource[idx], 'categoryName', obj.name);
       this.$set(
         this.form.datasource[idx],

+ 31 - 25
src/views/bpm/handleTask/components/purchaseOrder/inventoryTable.vue

@@ -85,7 +85,7 @@
               :disabled="isContractId"
               v-model="scope.row.totalCount"
               placeholder="请输入"
-              @input="getTotalPrice"
+              @input="changeCount(scope.row,scope.$index)"
             ></el-input>
           </el-form-item>
         </template>
@@ -641,7 +641,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);
@@ -652,17 +653,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) {
@@ -676,8 +666,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
@@ -689,28 +679,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) {

+ 7 - 0
src/views/bpm/handleTask/components/saleOrder/detailDialog.vue

@@ -101,6 +101,13 @@
             >
               {{ form.salesDeptName }}
             </el-form-item>
+            <el-form-item
+              label="销售类型:"
+              prop="saleTypeName"
+              style="margin-bottom: 16px"
+            >
+              {{ form.saleTypeName }}
+            </el-form-item>
             <el-form-item
               label="应付金额:"
               prop="payAmount"

+ 49 - 11
src/views/bpm/handleTask/components/saleOrder/entrustedReceive/product-list.vue

@@ -109,7 +109,41 @@ export default {
           slot: 'specification',
           align: "center"
         },
-
+        {
+          width: 80,
+          prop: 'totalCount',
+          label: '数量',
+          slot: 'totalCount',
+          align: "center"
+        },
+        {
+          minWidth: 100,
+          prop: 'measuringUnit',
+          label: '计量单位',
+          slot: 'measuringUnit',
+          align: "center"
+        },
+        {
+          width: 120,
+          prop: 'singleWeight',
+          label: '单重',
+          slot: 'singleWeight',
+          align: "center"
+        },
+        {
+          width: 100,
+          prop: 'receiveTotalWeight',
+          label: '收货总重',
+          slot: 'receiveTotalWeight',
+          align: "center"
+        },
+        {
+          width: 100,
+          prop: 'weightUnit',
+          label: '重量单位',
+          slot: 'weightUnit',
+          align: "center"
+        },
         {
           width: 80,
           prop: 'singlePrice',
@@ -118,22 +152,26 @@ export default {
           align: "center"
         },
         {
-          width: 80,
-          prop: 'totalCount',
-          label: '数量',
-          slot: 'totalCount',
+          width: 100,
+          prop: 'discountSinglePrice',
+          label: '折让单价',
+          slot: 'discountSinglePrice',
           align: "center"
         },
         {
-          width: 120,
+          width: 80,
           prop: 'totalPrice',
-          label: '采购总金额',
+          label: '合计',
           slot: 'totalPrice',
-          formatter: (_row, _column, cellValue) => {
-            return _row.totalPrice + '元';
-          },
           align: "center"
-        }
+        },
+        {
+          width: 100,
+          prop: 'discountTotalPrice',
+          label: '折让合计',
+          slot: 'discountTotalPrice',
+          align: "center"
+        },
       ],
 
       radio: null