Parcourir la source

提交报价总计修改回显问题

hezhanp il y a 7 mois
Parent
commit
a63f439795
1 fichiers modifiés avec 162 ajouts et 63 suppressions
  1. 162 63
      src/BIZComponents/inventoryTable.vue

+ 162 - 63
src/BIZComponents/inventoryTable.vue

@@ -746,10 +746,10 @@
         </el-form-item>
       </template>
 
-      <template v-slot:additionalTaxRate="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.additionalTaxRate'">
+      <template v-slot:extraTax="{ row, $index }">
+        <el-form-item :prop="'datasource.' + $index + '.extraTax'">
           <el-input
-            v-model="row.additionalTaxRate"
+            v-model="row.extraTax"
             type="number"
             placeholder="请输入"
             @input="calculateIncludingTaxPrice(row, $index)"
@@ -1012,7 +1012,7 @@ export default {
       processingFeeBeforeTax: '',
       packagingFeeNotTaxed: '',
       transportationFeeWithoutTax: '',
-      additionalTaxRate: '',
+      extraTax: '',
       includingTaxPrice: '',
       // 新增未税小记字段
       untaxedSubtotal: ''
@@ -1185,9 +1185,9 @@ export default {
           },
           {
             width: 150,
-            prop: 'additionalTaxRate',
+            prop: 'extraTax',
             label: '税率(%)',
-            slot: 'additionalTaxRate',
+            slot: 'extraTax',
             align: 'center'
           },
           {
@@ -1218,28 +1218,36 @@ export default {
           label: '单重',
           slot: 'singleWeight',
           headerSlot: 'headerSingleWeight',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
           prop: 'weightUnit',
           label: '重量单位',
           slot: 'weightUnit',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           minWidth: 120,
           prop: 'goodsLevel',
           label: '物品级别',
           slot: 'goodsLevel',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 150,
           prop: 'totalCount',
           label: '计量数量',
           headerSlot: 'headerTotalCount',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 200,
@@ -1247,34 +1255,44 @@ export default {
           label: this.contractBookType == 1 ? '客户代号' : '供应商代号',
           slot: 'customerMark',
           headerSlot: this.isCustomerMark ? 'headerCustomerMark' : '',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           minWidth: 160,
           prop: 'productionCodes',
           label: '生产编号',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2 // 仅当quoteType不是2时显示
         },
         {
           width: 200,
           prop: 'productCategoryName',
           label: '类型',
           slot: 'productCategoryName',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
           prop: 'packingSpecification',
           align: 'center',
           label: '包装规格',
-          showOverflowTooltip: true
+          showOverflowTooltip: true,
+
+          show: this.quoteType !== 2
         },
         {
           width: 160,
           prop: 'goodsPriceType',
           label: '价格类型',
           slot: 'goodsPriceType',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 200,
@@ -1282,7 +1300,9 @@ export default {
           label: '单价',
           slot: 'singlePrice',
           headerSlot: this.isSinglePrice ? 'headerSinglePrice' : '',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 160,
@@ -1290,14 +1310,18 @@ export default {
           label: '税率',
           slot: 'taxRate',
           align: 'center',
-          headerSlot: this.isTaxRate == 1 ? 'headerTaxRate' : ''
+          headerSlot: this.isTaxRate == 1 ? 'headerTaxRate' : '',
+
+          show: this.quoteType !== 2
         },
         {
           width: 180,
           prop: 'notaxSinglePrice',
           label: '不含税单价',
           slot: 'notaxSinglePrice',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         this.isDiscount
           ? {
@@ -1348,14 +1372,18 @@ export default {
           label: '批次号',
           slot: 'batchNo',
           headerSlot: this.isBatchNo ? 'headerBatchNo' : '',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
           prop: 'availableCountBase',
           label: '库存数量',
           slot: 'availableCountBase',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
@@ -1370,7 +1398,9 @@ export default {
           slot: 'provenance',
           align: 'center',
           showOverflowTooltip: true,
-          minWidth: 200
+          minWidth: 200,
+
+          show: this.quoteType !== 2
         },
 
         {
@@ -1385,34 +1415,44 @@ export default {
           prop: 'productBrand',
           label: '牌号',
           slot: 'productBrand',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
           prop: 'modelType',
           label: '型号',
           slot: 'modelType',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 160,
           prop: 'modelKey',
           label: '机型',
           slot: 'modelKey',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 160,
           prop: 'colorKey',
           label: '颜色',
           slot: 'colorKey',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 120,
           prop: 'produceType',
           align: 'center',
           label: '属性类型',
+
+          show: this.quoteType !== 2,
           showOverflowTooltip: true,
           formatter: (row, column) => {
             if (row.produceType) {
@@ -1431,7 +1471,9 @@ export default {
               label: '到货方式',
               slot: 'arrivalWay',
               align: 'center',
-              show: this.isArrivalWay
+              show: this.isArrivalWay,
+
+              show: this.quoteType !== 2
             }
           : {
               width: 1
@@ -1457,7 +1499,9 @@ export default {
           prop: 'guaranteePeriod',
           label: '有效期',
           slot: 'guaranteePeriod',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         this.isGuaranteePeriod
           ? {
@@ -1476,28 +1520,36 @@ export default {
           prop: 'imgCode',
           align: 'center',
           label: '图号/件号',
-          showOverflowTooltip: true
+          showOverflowTooltip: true,
+
+          show: this.quoteType !== 2
         },
         {
           width: 220,
           prop: 'customerReqFiles',
           label: '客户需求',
           slot: 'customerReqFiles',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 130,
           prop: 'technicalAnswerName',
           label: '技术答疑人',
           slot: 'technicalAnswerName',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 220,
           prop: 'technicalParams',
           label: '技术参数',
           slot: 'technicalParams',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 240,
@@ -1510,28 +1562,36 @@ export default {
           width: 120,
           prop: 'drawingVersion',
           label: '图纸版本',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 240,
           prop: 'technologyRouteName',
           label: '工艺路线',
           slot: 'technologyRouteName',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 240,
           prop: 'industryArtFiles',
           label: '工艺附件',
           slot: 'industryArtFiles',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 240,
           prop: 'otherFiles',
           label: '其他附件',
           slot: 'otherFiles',
-          align: 'center'
+          align: 'center',
+
+          show: this.quoteType !== 2
         },
         {
           width: 220,
@@ -1566,22 +1626,27 @@ export default {
     });
 
     // 监听数据变化以重新计算含税单价
+    let calculating = false;
     this.$watch(
       'form.datasource',
       (newVal) => {
         newVal.forEach((row, index) => {
-          // 为每个行项目添加监听器
+          // 为每个行项目添加监听器,但使用标志位避免循环
           this.$watch(
             () => [
               row.processingFeeBeforeTax,
               row.packagingFeeNotTaxed,
               row.transportationFeeWithoutTax,
-              row.additionalTaxRate,
+              row.extraTax,
               row[this.countObj.countKey]
             ],
             () => {
-              this.calculateIncludingTaxPrice(row, index);
-              this.changeAll(); // 更新总价
+              if (!calculating) {
+                calculating = true;
+                this.calculateIncludingTaxPrice(row, index);
+                this.changeAll();
+                calculating = false;
+              }
             },
             { deep: true }
           );
@@ -1736,7 +1801,6 @@ export default {
     changeCount(row, index) {
       if (!row) {
         this.form.datasource = this.form.datasource.map((item, i) => {
-          // 传入quoteType参数
           return changeCount(item, this.countObj, false, this.quoteType);
         });
       } else {
@@ -1746,17 +1810,23 @@ export default {
           false,
           this.quoteType
         );
-        // 关键:用this.$set更新,确保响应式
         this.$set(this.form.datasource, index, updatedRow);
       }
 
       this.$nextTick(() => {
-        // 生产加工类型不需要计算不含税单价,跳过
-        if (this.quoteType !== 2) {
+        // 生产加工类型不需要计算不含税单价,但需要计算含税小计
+        if (this.quoteType === 2) {
+          if (row) {
+            this.calculateIncludingTaxPrice(row, index);
+          } else {
+            this.form.datasource.forEach((item, i) => {
+              this.calculateIncludingTaxPrice(item, i);
+            });
+          }
+        } else {
           this.getNotaxSinglePrice();
         }
         this.changeAll();
-        this.$forceUpdate();
       });
     },
 
@@ -1769,22 +1839,40 @@ export default {
         (Number(row.processingFeeBeforeTax) || 0) +
         (Number(row.packagingFeeNotTaxed) || 0) +
         (Number(row.transportationFeeWithoutTax) || 0);
-      this.$set(row, 'untaxedSubtotal', untaxedSubtotal.toFixed(2));
-
-      // 计算含税小计
-      const taxRate = (Number(row.additionalTaxRate) || 0) / 100;
-      const includingTaxPrice = untaxedSubtotal * (1 + taxRate);
-      this.$set(row, 'includingTaxPrice', includingTaxPrice.toFixed(2));
-
-      // 生产加工类型:使用转换后的总数量(totalCount)计算总价
-      if (this.quoteType === 2 && row.totalCount) {
-        // 关键修改:用totalCount替代this.countObj.countKey
-        const totalPrice = includingTaxPrice * Number(row.totalCount);
-        this.$set(row, 'totalPrice', totalPrice.toFixed(2));
-      }
+
+      // 使用 $nextTick 确保响应式更新完成
+      this.$nextTick(() => {
+        this.$set(row, 'untaxedSubtotal', untaxedSubtotal.toFixed(2));
+
+        // 计算含税小计
+        const taxRate = (Number(row.extraTax) || 0) / 100;
+        const includingTaxPrice = untaxedSubtotal * (1 + taxRate);
+        this.$set(row, 'includingTaxPrice', includingTaxPrice.toFixed(2));
+
+        // 为生产加工类型计算totalPrice
+        if (this.quoteType === 2) {
+          const quantity = Number(row[this.countObj.countKey]) || 1;
+          const totalPrice = includingTaxPrice * quantity;
+          this.$set(row, 'totalPrice', totalPrice.toFixed(2));
+
+          // 强制更新总计
+          this.$nextTick(() => {
+            this.changeAll();
+          });
+        }
+      });
     },
 
     changeAll() {
+      // 确保生产加工类型的行都有正确的totalPrice
+      if (this.quoteType === 2) {
+        this.form.datasource.forEach((row, index) => {
+          if (!row.totalPrice || row.totalPrice === '0.00') {
+            this.calculateIncludingTaxPrice(row, index);
+          }
+        });
+      }
+
       this.allPrice = getAllPrice(this.form.datasource) || 0;
       if (this.isDiscountTotalPrice) {
         this.form.discountTotalPrice = this.allPrice;
@@ -1920,14 +2008,20 @@ export default {
             item.packagingFeeNotTaxed = item.packagingFeeNotTaxed || '';
             item.transportationFeeWithoutTax =
               item.transportationFeeWithoutTax || '';
-            item.additionalTaxRate = item.additionalTaxRate || '';
-            // 计算未税小记
+            item.extraTax = item.extraTax || '13'; // 设置默认税率
+            // 强制计算一次
             const untaxedSubtotal =
               (Number(item.processingFeeBeforeTax) || 0) +
               (Number(item.packagingFeeNotTaxed) || 0) +
               (Number(item.transportationFeeWithoutTax) || 0);
             item.untaxedSubtotal = untaxedSubtotal.toFixed(2);
-            item.includingTaxPrice = item.includingTaxPrice || '';
+
+            const taxRate = (Number(item.extraTax) || 0) / 100;
+            const includingTaxPrice = untaxedSubtotal * (1 + taxRate);
+            item.includingTaxPrice = includingTaxPrice.toFixed(2);
+
+            const quantity = Number(item[this.countObj.countKey]) || 1;
+            item.totalPrice = (includingTaxPrice * quantity).toFixed(2);
           }
         });
         this.form.datasource = productList;
@@ -1961,6 +2055,11 @@ export default {
             data.payAmount || data?.contractVO?.discountTotalPrice;
         }
         this.$refs.table.reload();
+
+        // 额外确保计算一次
+        this.$nextTick(() => {
+          this.changeAll();
+        });
       }
     },
 
@@ -2117,7 +2216,7 @@ export default {
           parasm.processingFeeBeforeTax = '';
           parasm.packagingFeeNotTaxed = '';
           parasm.transportationFeeWithoutTax = '';
-          parasm.additionalTaxRate = 13;
+          parasm.extraTax = 13;
           parasm.untaxedSubtotal = '0.00';
           parasm.includingTaxPrice = '';
         }
@@ -2230,7 +2329,7 @@ export default {
           parasm.processingFeeBeforeTax = '';
           parasm.packagingFeeNotTaxed = '';
           parasm.transportationFeeWithoutTax = '';
-          parasm.additionalTaxRate = '';
+          parasm.extraTax = '';
           parasm.untaxedSubtotal = '0.00';
           parasm.includingTaxPrice = '';
         }
@@ -2270,7 +2369,7 @@ export default {
         item.processingFeeBeforeTax = '';
         item.packagingFeeNotTaxed = '';
         item.transportationFeeWithoutTax = '';
-        item.additionalTaxRate = '';
+        item.extraTax = '';
         item.untaxedSubtotal = '0.00';
         item.includingTaxPrice = '';
       }