Quellcode durchsuchen

fix(inventoryTable): 重构生产加工相关字段命名和计算逻辑,优化表单显示方式

yusheng vor 8 Monaten
Ursprung
Commit
c2ffd7e07c
2 geänderte Dateien mit 113 neuen und 286 gelöschten Zeilen
  1. 61 161
      src/BIZComponents/inventoryTable.vue
  2. 52 125
      src/BIZComponents/inventoryTableDetails.vue

+ 61 - 161
src/BIZComponents/inventoryTable.vue

@@ -626,7 +626,6 @@
             placeholder="请输入"
             type="number"
             :min="0"
-          
             @input="handleCountChange(scope.row, scope.$index)"
           >
             <template slot="append">
@@ -759,9 +758,11 @@
       </template>
 
       <!-- 新增未税小记列模板 -->
-      <template v-slot:untaxedSubtotal="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.untaxedSubtotal'">
-          {{ (Number(row.untaxedSubtotal) || 0).toFixed(2) }}元
+      <template v-slot:quotationSubtotalBeforeTax="{ row, $index }">
+        <el-form-item
+          :prop="'datasource.' + $index + '.quotationSubtotalBeforeTax'"
+        >
+          {{ (Number(row.quotationSubtotalBeforeTax) || 0).toFixed(2) }}元
         </el-form-item>
       </template>
 
@@ -779,15 +780,16 @@
       </template>
 
       <!-- 含税单价改为含税小计 -->
-      <template v-slot:includingTaxPrice="{ row, $index }">
-        <el-form-item :prop="'datasource.' + $index + '.includingTaxPrice'">
-          <el-input
-            v-model="row.includingTaxPrice"
+      <template v-slot:quotationSubtotalTax="{ row, $index }">
+        <el-form-item :prop="'datasource.' + $index + '.quotationSubtotalTax'">
+          {{ (Number(row.quotationSubtotalTax) || 0).toFixed(2) }}元
+          <!-- <el-input
+            v-model="row.quotationSubtotalTax"
             type="number"
             placeholder="请输入"
           >
             <template slot="append">元</template>
-          </el-input>
+          </el-input> -->
         </el-form-item>
       </template>
 
@@ -1032,9 +1034,9 @@
         packagingFeeNotTaxed: '',
         transportationFeeWithoutTax: '',
         extraTax: '',
-        includingTaxPrice: '',
+        quotationSubtotalTax: '',
         // 新增未税小记字段
-        untaxedSubtotal: ''
+        quotationSubtotalBeforeTax: ''
       };
       return {
         levelList,
@@ -1180,7 +1182,7 @@
             },
             {
               width: 150,
-              prop: 'untaxedSubtotal',
+              prop: 'quotationSubtotalBeforeTax',
               label: '未税小计',
               slot: 'additionalTaxRate_untaxed',
               align: 'center'
@@ -1194,9 +1196,9 @@
             },
             {
               width: 150,
-              prop: 'includingTaxPrice',
+              prop: 'quotationSubtotalTax',
               label: '含税小计',
-              slot: 'includingTaxPrice',
+              slot: 'quotationSubtotalTax',
               align: 'center'
             }
           );
@@ -1593,36 +1595,6 @@
           this.isDate = res.value;
         }
       });
-
-      // 监听数据变化以重新计算含税单价
-      let calculating = false;
-      this.$watch(
-        'form.datasource',
-        (newVal) => {
-          newVal.forEach((row, index) => {
-            // 为每个行项目添加监听器,但使用标志位避免循环
-            this.$watch(
-              () => [
-                row.processingFeeBeforeTax,
-                row.packagingFeeNotTaxed,
-                row.transportationFeeWithoutTax,
-                row.extraTax,
-                row[this.countObj.countKey]
-              ],
-              () => {
-                if (!calculating) {
-                  calculating = true;
-                  this.calculateIncludingTaxPrice(row, index);
-                  this.changeAll();
-                  calculating = false;
-                }
-              },
-              { deep: true }
-            );
-          });
-        },
-        { immediate: true, deep: true }
-      );
     },
     methods: {
       handleCountChange(row, index) {
@@ -1778,15 +1750,10 @@
       changeCount(row, index) {
         if (!row) {
           this.form.datasource = this.form.datasource.map((item, i) => {
-            return changeCount(item, this.countObj, false, this.quoteType);
+            return changeCount(item, this.countObj, false);
           });
         } else {
-          const updatedRow = changeCount(
-            row,
-            this.countObj,
-            false,
-            this.quoteType
-          );
+          const updatedRow = changeCount(row, this.countObj, false);
           this.$set(this.form.datasource, index, updatedRow);
         }
 
@@ -1802,54 +1769,47 @@
             }
           } else {
             this.getNotaxSinglePrice();
+            this.changeAll();
           }
-          this.changeAll();
         });
       },
 
       // 计算含税小计(原含税单价逻辑)
       calculateIncludingTaxPrice(row, index) {
+        console.log('row', row);
         if (!row) return;
 
         // 计算未税小记
-        const untaxedSubtotal =
+        const quotationSubtotalBeforeTax =
           (Number(row.processingFeeBeforeTax) || 0) +
           (Number(row.packagingFeeNotTaxed) || 0) +
           (Number(row.transportationFeeWithoutTax) || 0);
 
         // 使用 $nextTick 确保响应式更新完成
         this.$nextTick(() => {
-          this.$set(row, 'untaxedSubtotal', untaxedSubtotal.toFixed(2));
+          this.$set(
+            row,
+            'quotationSubtotalBeforeTax',
+            quotationSubtotalBeforeTax.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();
-            });
-          }
+          const quotationSubtotalTax =
+            quotationSubtotalBeforeTax * (1 + taxRate);
+          this.$set(
+            row,
+            'quotationSubtotalTax',
+            quotationSubtotalTax.toFixed(2)
+          );
+          const quantity = Number(row[this.countObj.countKey]) || 1;
+          const totalPrice = quotationSubtotalTax * quantity;
+          this.$set(row, 'totalPrice', totalPrice.toFixed(2));
+          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;
@@ -1944,10 +1904,6 @@
             if (item.colorKey) {
               item.colorKey = item.colorKey.split(',');
             }
-            item.pricingWay =
-              item.pricingWay ||
-              data.pricingWay ||
-              data?.contractVO?.pricingWay;
 
             item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode
               ? item.guaranteePeriodUnitCode + ''
@@ -1973,38 +1929,6 @@
             // }
             item['customerMark'] = item.customerMark || this.customerMark;
             item['arrivalWay'] = item.arrivalWay || 1;
-
-            // 当quoteType为2时,数量默认设置为1
-            if (
-              this.quoteType === 2 &&
-              item[this.countObj.countKey] === undefined
-            ) {
-              item[this.countObj.countKey] = 1;
-            }
-
-            // 初始化生产加工特有字段及未税小记
-            if (this.quoteType === 2) {
-              item.thickNess = item.thickNess || '';
-              item.squareNumber = item.squareNumber || '';
-              item.processingFeeBeforeTax = item.processingFeeBeforeTax || '';
-              item.packagingFeeNotTaxed = item.packagingFeeNotTaxed || '';
-              item.transportationFeeWithoutTax =
-                item.transportationFeeWithoutTax || '';
-              item.extraTax = item.extraTax || '13'; // 设置默认税率
-              // 强制计算一次
-              const untaxedSubtotal =
-                (Number(item.processingFeeBeforeTax) || 0) +
-                (Number(item.packagingFeeNotTaxed) || 0) +
-                (Number(item.transportationFeeWithoutTax) || 0);
-              item.untaxedSubtotal = untaxedSubtotal.toFixed(2);
-
-              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;
 
@@ -2038,11 +1962,6 @@
               data.payAmount || data?.contractVO?.discountTotalPrice;
           }
           this.$refs.table.reload();
-
-          // 额外确保计算一次
-          this.$nextTick(() => {
-            this.changeAll();
-          });
         }
       },
 
@@ -2099,8 +2018,12 @@
           this.$set(parasm, 'pricingWay', 1);
           this.$set(parasm, 'goodsLevel', item.goodsLevel);
           this.$set(parasm, 'guaranteePeriod', item.warrantyPeriod);
-          this.$set(parasm, 'customerExpectDeliveryDeadline', dayjs(new Date()).format('YYYY-MM-DD'))
-          
+          this.$set(
+            parasm,
+            'customerExpectDeliveryDeadline',
+            dayjs(new Date()).format('YYYY-MM-DD')
+          );
+
           if (item.modelKey) {
             this.$set(parasm, 'modelKey', item.modelKey.split(','));
           }
@@ -2126,7 +2049,7 @@
               )
             );
           }
-          
+
           this.$set(
             parasm,
             'packageDispositionList',
@@ -2166,9 +2089,10 @@
             this.$set(parasm, 'singlePrice', parasm.singlePrice || 0);
           }
 
+          // 初始化生产加工特有字段及未税小记
           // 当quoteType为2时,数量默认设置为1
           if (this.quoteType === 2) {
-            this.$set(parasm, this.countObj.countKey, 1);
+            this.processSetValue(parasm);
           }
 
           if (this.isSupplier) {
@@ -2195,18 +2119,6 @@
           }
           this.$set(parasm, 'provenance', item.purchaseOrigins || []);
 
-          // 初始化生产加工特有字段及未税小记
-          if (this.quoteType === 2) {
-            parasm.thickNess = '';
-            parasm.squareNumber = '';
-            parasm.processingFeeBeforeTax = '';
-            parasm.packagingFeeNotTaxed = '';
-            parasm.transportationFeeWithoutTax = '';
-            parasm.extraTax = 13;
-            parasm.untaxedSubtotal = '0.00';
-            parasm.includingTaxPrice = '';
-          }
-
           if (idx == -1) {
             this.form.datasource.push(row);
           }
@@ -2307,23 +2219,11 @@
           }
           this.$set(parasm, 'provenance', item.purchaseOrigins || []);
 
-          // 当quoteType为2时,数量默认设置为1
-          if (this.quoteType === 2) {
-            this.$set(parasm, this.countObj.countKey, 1);
-          }
-
           // 初始化生产加工特有字段及未税小记
+          // 当quoteType为2时,数量默认设置为1
           if (this.quoteType === 2) {
-            parasm.thickNess = '';
-            parasm.squareNumber = '';
-            parasm.processingFeeBeforeTax = '';
-            parasm.packagingFeeNotTaxed = '';
-            parasm.transportationFeeWithoutTax = '';
-            parasm.extraTax = '';
-            parasm.untaxedSubtotal = '0.00';
-            parasm.includingTaxPrice = '';
+            this.processSetValue(parasm);
           }
-
           if (idx == -1) {
             this.form.datasource.push(row);
           }
@@ -2347,25 +2247,25 @@
         item.key = this.form.datasource.length + 1;
         item.customerMark = this.customerMark;
 
-        // 当quoteType为2时,数量默认设置为1
-        if (this.quoteType === 2) {
-          item[this.countObj.countKey] = 1;
-        }
-
         // 初始化生产加工特有字段及未税小记
+        // 当quoteType为2时,数量默认设置为1
         if (this.quoteType === 2) {
-          item.thickNess = '';
-          item.squareNumber = '';
-          item.processingFeeBeforeTax = '';
-          item.packagingFeeNotTaxed = '';
-          item.transportationFeeWithoutTax = '';
-          item.extraTax = '';
-          item.untaxedSubtotal = '0.00';
-          item.includingTaxPrice = '';
+          this.processSetValue(item);
         }
 
         this.form.datasource.push(item);
       },
+      processSetValue(parasm) {
+        this.$set(parasm, this.countObj.countKey, 1);
+        this.$set(parasm, 'thickNess', '');
+        this.$set(parasm, 'squareNumber', '');
+        this.$set(parasm, 'processingFeeBeforeTax', '');
+        this.$set(parasm, 'packagingFeeNotTaxed', '');
+        this.$set(parasm, 'transportationFeeWithoutTax', '');
+        this.$set(parasm, 'extraTax', 13);
+        this.$set(parasm, 'quotationSubtotalBeforeTax', '0.00');
+        this.$set(parasm, 'quotationSubtotalTax', '');
+      },
 
       validateForm(callback) {
         this.$refs.form.validate((valid, obj) => {

+ 52 - 125
src/BIZComponents/inventoryTableDetails.vue

@@ -76,97 +76,6 @@
         </el-form-item>
       </template>
 
-      <!-- 新增字段插槽 -->
-      <template v-slot:thickNess="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.thickNess'"
-        >
-          {{ scope.row.thickNess }} mm
-        </el-form-item>
-      </template>
-
-      <template v-slot:squareNumber="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.squareNumber'"
-        >
-          {{ scope.row.squareNumber }} cm²
-        </el-form-item>
-      </template>
-
-      <template v-slot:processingFeeBeforeTax="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.processingFeeBeforeTax'"
-        >
-          {{ scope.row.processingFeeBeforeTax || 0 }} 元
-        </el-form-item>
-      </template>
-
-      <template v-slot:packagingFeeNotTaxed="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.packagingFeeNotTaxed'"
-        >
-          {{ scope.row.packagingFeeNotTaxed || 0 }} 元
-        </el-form-item>
-      </template>
-
-      <template v-slot:transportationFeeWithoutTax="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.transportationFeeWithoutTax'"
-        >
-          {{ scope.row.transportationFeeWithoutTax || 0 }} 元
-        </el-form-item>
-      </template>
-
-      <!-- 新增的未税小计插槽 -->
-      <template v-slot:additionalTaxRate_untaxed="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.untaxedSubtotal'"
-        >
-          {{
-            (
-              Number(scope.row.processingFeeBeforeTax || 0) +
-              Number(scope.row.packagingFeeNotTaxed || 0) +
-              Number(scope.row.transportationFeeWithoutTax || 0)
-            ).toFixed(2)
-          }}
-          元
-        </el-form-item>
-      </template>
-
-      <!-- 新增的税率插槽 -->
-      <template v-slot:additionalTaxRate="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.additionalTaxRate'"
-        >
-          {{ scope.row.additionalTaxRate || 0 }}%
-        </el-form-item>
-      </template>
-
-      <!-- 新增的含税小计插槽 -->
-      <template v-slot:includingTaxPrice="scope">
-        <el-form-item
-          style="margin-bottom: 20px"
-          :prop="'datasource.' + scope.$index + '.includingTaxPrice'"
-        >
-          {{
-            (
-              (Number(scope.row.processingFeeBeforeTax || 0) +
-                Number(scope.row.packagingFeeNotTaxed || 0) +
-                Number(scope.row.transportationFeeWithoutTax || 0)) *
-              (1 + Number(scope.row.additionalTaxRate || 0) / 100)
-            ).toFixed(2)
-          }}
-          元
-        </el-form-item>
-      </template>
-
       <template v-slot:modelKey="scope">
         <el-form-item
           style="margin-bottom: 20px"
@@ -330,7 +239,7 @@
     computed: {
       columns() {
         let columnsVersion = this.columnsVersion;
-        console.log(this.quoteType,'this.quoteType')
+        console.log(this.quoteType, 'this.quoteType');
 
         // 基础列(新增字段之前的列)
         const baseColumns = [
@@ -347,7 +256,7 @@
             align: 'center',
             selectable: (row, index) => {
               return row.sendTotalCount && row.sendTotalCount > 0;
-          },
+            }
           },
           {
             minWidth: 200,
@@ -398,6 +307,11 @@
                   prop: 'thickNess',
                   label: '厚度',
                   slot: 'thickNess',
+                  formatter: (row, column) => {
+                    if (row.thickNess) {
+                      return row.thickNess + ' mm';
+                    }
+                  },
                   align: 'center'
                 },
                 // 新增字段:平方数
@@ -405,7 +319,11 @@
                   width: 150,
                   prop: 'squareNumber',
                   label: '平方数',
-                  slot: 'squareNumber',
+                  formatter: (row, column) => {
+                    if (row.squareNumber) {
+                      return row.squareNumber + ' cm²';
+                    }
+                  },
                   align: 'center'
                 },
                 // 新增字段:加工费(未税)
@@ -413,7 +331,11 @@
                   width: 150,
                   prop: 'processingFeeBeforeTax',
                   label: '加工费(未税)',
-                  slot: 'processingFeeBeforeTax',
+                  formatter: (row, column) => {
+                    if (row.processingFeeBeforeTax) {
+                      return row.processingFeeBeforeTax + ' 元';
+                    }
+                  },
                   align: 'center'
                 },
                 // 新增字段:包装费(未税)
@@ -421,7 +343,11 @@
                   width: 150,
                   prop: 'packagingFeeNotTaxed',
                   label: '包装费(未税)',
-                  slot: 'packagingFeeNotTaxed',
+                  formatter: (row, column) => {
+                    if (row.packagingFeeNotTaxed) {
+                      return row.packagingFeeNotTaxed + ' 元';
+                    }
+                  },
                   align: 'center'
                 },
                 // 新增字段:运输费(未税)
@@ -429,32 +355,46 @@
                   width: 150,
                   prop: 'transportationFeeWithoutTax',
                   label: '运输费(未税)',
-                  slot: 'transportationFeeWithoutTax',
+                  formatter: (row, column) => {
+                    if (row.transportationFeeWithoutTax) {
+                      return row.transportationFeeWithoutTax + ' 元';
+                    }
+                  },
                   align: 'center'
                 },
                 // 新增字段:未税小计
                 {
                   width: 150,
-                  prop: 'untaxedSubtotal',
+                  prop: 'quotationSubtotalBeforeTax',
                   label: '未税小计',
-                  slot: 'additionalTaxRate_untaxed',
-                  align: 'center'
+                  align: 'center',
+                  formatter: (row, column) => {
+                    if (row.quotationSubtotalBeforeTax) {
+                      return row.quotationSubtotalBeforeTax + ' 元';
+                    }
+                  }
                 },
                 // 新增字段:税率(%)
                 {
                   width: 150,
-                  prop: 'additionalTaxRate',
+                  prop: 'extraTax',
                   label: '税率(%)',
-                  slot: 'additionalTaxRate',
-                  align: 'center'
+                  align: 'center',
+                  formatter: (row, column) => {
+                    return row.extraTax;
+                  }
                 },
                 // 新增字段:含税小计
                 {
                   width: 150,
-                  prop: 'includingTaxPrice',
+                  prop: 'quotationSubtotalTax',
                   label: '含税小计',
-                  slot: 'includingTaxPrice',
-                  align: 'center'
+                  align: 'center',
+                  formatter: (row, column) => {
+                    if (row.quotationSubtotalTax) {
+                      return row.quotationSubtotalTax + ' 元';
+                    }
+                  }
                 }
               ]
             : [];
@@ -616,6 +556,7 @@
             slot: 'singlePrice',
             isNone: this.quoteType === 2,
             headerSlot: 'headerSinglePrice',
+
             align: 'center'
           },
 
@@ -654,6 +595,11 @@
             prop: 'totalPrice',
             label: '合计',
             slot: 'totalPrice',
+            formatter: (row, column) => {
+              if (row.totalPrice) {
+                return row.totalPrice + ' 元';
+              }
+            },
             align: 'center'
           },
           {
@@ -959,15 +905,6 @@
           v.customerReqFiles = v.customerReqFiles || [];
           v.industryArtFiles = v.industryArtFiles || [];
           v.otherFiles = v.otherFiles || [];
-          // 处理新增字段
-          v.thickNess = v.thickNess || '';
-          v.squareNumber = v.squareNumber || '';
-          v.processingFeeBeforeTax = v.processingFeeBeforeTax || '';
-          v.packagingFeeNotTaxed = v.packagingFeeNotTaxed || '';
-          v.transportationFeeWithoutTax = v.transportationFeeWithoutTax || '';
-          v.untaxedSubtotal = v.untaxedSubtotal || '';
-          v.additionalTaxRate = v.additionalTaxRate || '';
-          v.includingTaxPrice = v.includingTaxPrice || '';
         });
         return comitDatasource;
       },
@@ -1021,16 +958,6 @@
         console.log(productList, 'productList~~~~~~');
         if (productList) {
           productList.forEach((item) => {
-            item.thickNess = item.thickNess || '';
-            item.squareNumber = item.squareNumber || '';
-            item.processingFeeBeforeTax = item.processingFeeBeforeTax || '';
-            item.packagingFeeNotTaxed = item.packagingFeeNotTaxed || '';
-            item.transportationFeeWithoutTax =
-              item.transportationFeeWithoutTax || '';
-            item.untaxedSubtotal = item.untaxedSubtotal || '';
-            item.additionalTaxRate = item.additionalTaxRate || '';
-            item.includingTaxPrice = item.includingTaxPrice || '';
-
             // 处理机型/颜色
             if (item.modelKey && typeof item.modelKey === 'string') {
               item.modelKey = item.modelKey.split(',');