Преглед изворни кода

fix(销售订单): 修复折扣价格计算和显示问题

liujt пре 4 месеци
родитељ
комит
46d8e618fc

+ 9 - 0
src/views/saleManage/saleOrder/accountstatement/components/addAccountDialog.vue

@@ -51,6 +51,7 @@
         :dataForm="dataForm"
         :datasource.sync="datasource"
         :dialogType="dialogType"
+        @changeDiscountPrice="changeDiscountPrice"
       ></inventoryTable>
     </div>
     <div slot="footer" class="footer">
@@ -158,6 +159,14 @@
     },
     computed: {},
     methods: {
+      changeDiscountPrice(price, tableIndex) {
+        console.log('price~~~', price, tableIndex)
+        this.datasource[tableIndex].amountTotalPrice = price;
+        this.datasource[tableIndex].unStatementAmount = price;
+        console.log('this.datasource', this.datasource)
+        this.dataForm.amountTotalPrice = this.datasource.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100;
+        this.dataForm.amountUnCompletePrice = this.datasource.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
+      },
       open(dialogType, row, type = '') {
         this.dialogType = dialogType;
         this.title =

+ 1 - 1
src/views/saleManage/saleOrder/accountstatement/components/detailDialog.vue

@@ -28,7 +28,7 @@
         </div>
       </div>
     </el-card>
-    <div v-if="activeComp==='main'">
+    <div v-show="activeComp==='main'">
       <!--销售表单表单-->
       <sale-form :dataForm.sync="dataForm" :datasource.sync="datasource"
                  dialogType="view"></sale-form>

+ 15 - 7
src/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue

@@ -116,8 +116,8 @@
                       <el-input
                         v-model="scope.row.singlePrice"
                         placeholder="请输入"
-                        @input="changeCount(scope.row, scope.$index)"
-                        :disabled="item.orderCategory != 4"
+                        @input="changeCount(scope.row, scope.$index, item, index)"
+                        :disabled="item.orderCategory != 4 || dialogType === 'view'"
                         type="number"
                       >
                         <template slot="append">元</template>
@@ -139,7 +139,7 @@
                         placeholder="请输入"
                         type="number"
                         @input="getNotaxSinglePrice(scope.row, scope.$index)"
-                        :disabled="item.orderCategory != 4"
+                        :disabled="item.orderCategory != 4 || dialogType === 'view'"
                       >
                         <template slot="append">%</template>
                       </el-input>
@@ -161,7 +161,7 @@
                         type="number"
                         :min="0"
                         :max="100"
-                        :disabled="item.orderCategory != 4"
+                        :disabled="item.orderCategory != 4 || dialogType === 'view'"
                         @input="getDiscountRatioPrice(scope.row, scope.$index)"
                       >
                         <template slot="append">%</template>
@@ -629,7 +629,7 @@ export default {
   },
   methods: {
     //改变数量
-      changeCount(item, index) {
+      changeCount(item, index, row, tableIndex) {
         console.log('changeCount~~~', item)
         console.log('this.datasource[index]~~~', this.datasource[index])
         // row.totalPrice = parseFloat((item.totalCount * item.singlePrice).toFixed(2))
@@ -645,7 +645,7 @@ export default {
           item.totalPrice = ''
         }
         this.getNotaxSinglePrice(item, index);
-        this.getDiscountRatioPrice(item, index);
+        this.getDiscountRatioPrice(item, index, row, tableIndex);
         this.$forceUpdate();
         // if (this.clientEnvironmentId == 4 && !isBlockCount) {
         //   this.tableHandleKeyUp(row, index, 'sum');
@@ -675,7 +675,7 @@ export default {
       },
 
       // 计算折让单价,折让总价
-      getDiscountRatioPrice(item, index) {
+      getDiscountRatioPrice(item, index, row, tableIndex) {
 
           if (item.singlePrice && item.discountRatio) {
             // this.$set(
@@ -706,6 +706,14 @@ export default {
             item.discountSinglePrice = ''
             item.discountTotalPrice = ''
           }
+          console.log('row~~~', row, tableIndex)
+          row.unStatementAmount = this.datasource[tableIndex].deliveryProducts.reduce((prev, curr) => {
+            return prev + Number(curr.discountTotalPrice || 0)
+          }, 0)
+          row.amountTotalPrice = this.datasource[tableIndex].deliveryProducts.reduce((prev, curr) => {
+            return prev + Number(curr.discountTotalPrice || 0)
+          }, 0)
+          this.$emit('changeDiscountPrice', row.amountTotalPrice, tableIndex)
       },
     remove(tableIndex, lineIndex, delType) {
       let params = {