gaoluyang
5 天以前 d8f82e70f0d2e98d45fd9341e35d042d3ee9e1e6
src/views/inventoryManagement/receiptManagement/components/formDiaManual.vue
@@ -31,14 +31,14 @@
            <el-input v-model="scope.row.unit" placeholder="请输入单位" />
          </template>
        </el-table-column>
        <!-- <el-table-column label="供应商" prop="supplierName" width="200">
        <el-table-column label="供应商" prop="supplierName" width="200">
          <template #default="scope">
            <el-input v-model="scope.row.supplierName" placeholder="请输入供应商" />
          </template>
        </el-table-column> -->
        <el-table-column label="物品类型" prop="itemType" width="140">
        </el-table-column>
        <el-table-column label="物品类型" prop="itemType" width="150">
          <template #default="scope">
            <el-select v-model="scope.row.itemType" placeholder="请选择物品类型" style="width: 100%">
            <el-select v-model="scope.row.itemType" filterable allow-create placeholder="请选择物品类型" style="width: 100%">
              <el-option
                v-for="item in itemTypeOptions"
                :key="item.value"
@@ -65,45 +65,22 @@
            />
          </template>
        </el-table-column>
        <el-table-column label="税率(%)" prop="taxRate" width="150">
          <template #default="scope">
            <el-select v-model="scope.row.taxRate" placeholder="请选择税率" style="width: 100%" @change="() => calculateExclusivePrice(scope.row)">
              <el-option
                v-for="item in taxRateOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          label="含税单价(元)"
          prop="taxInclusiveUnitPrice"
          width="180"
        >
          <template #default="scope">
            <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.taxInclusiveUnitPrice" @change="calculateTotalPrice(scope.row)" />
          </template>
        </el-table-column>
        <el-table-column
          label="含税总价(元)"
          prop="taxInclusiveTotalPrice"
          width="180"
        >
          <template #default="scope">
            <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.taxInclusiveTotalPrice" @change="calculateExclusivePrice(scope.row)" />
          </template>
        </el-table-column>
        <el-table-column
          label="不含税总价(元)"
          prop="taxExclusiveTotalPrice"
          width="180"
        >
          <template #default="scope">
            <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.taxExclusiveTotalPrice" />
          </template>
        </el-table-column>
<!--        <el-table-column label="数量" prop="quantityStock" width="150">-->
<!--          <template #default="scope">-->
<!--            <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.quantityStock" @change="() => calculateTotalPrice(scope.row)" />-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="单价(元)" prop="taxInclusiveUnitPrice" width="150">-->
<!--          <template #default="scope">-->
<!--            <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.taxInclusiveUnitPrice" @change="() => calculateTotalPrice(scope.row)" />-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column -->
<!--           label="总价(元)" -->
<!--           prop="taxInclusiveTotalPrice" -->
<!--           width="150" -->
<!--         >-->
<!--        </el-table-column>-->
        <el-table-column label="操作" width="80" v-if="operationType === 'add'">
          <template #default="scope">
            <el-button type="danger" size="small" @click="removeProductRow(scope.$index)">删除</el-button>
@@ -199,9 +176,10 @@
    itemType: '',
    inboundNum: 0,
    inboundDate: '',
    taxRate: null,
    quantityStock: 0,
    taxInclusiveUnitPrice: 0,
    taxInclusiveTotalPrice: 0,
    taxRate: null,
    taxExclusiveTotalPrice: 0,
  });
};
@@ -211,19 +189,20 @@
  productList.value.splice(index, 1);
};
// 计算含税总价(根据单价和数量)
// 计算总价(根据数量、单价和含税单价)
const calculateTotalPrice = (row) => {
  const unitPrice = Number(row.taxInclusiveUnitPrice || 0);
  const quantity = Number(row.inboundNum || 0);
  row.taxInclusiveTotalPrice = unitPrice * quantity;
  // 计算普通总价:quantityStock * taxInclusiveUnitPrice
  const quantity = Number(row.quantityStock || 0);
  const taxInclusiveUnitPrice = Number(row.taxInclusiveUnitPrice || 0);
  row.taxInclusiveTotalPrice = quantity * taxInclusiveUnitPrice;
  calculateExclusivePrice(row);
};
// 计算不含税总价(根据含税总价和税率)
const calculateExclusivePrice = (row) => {
  const totalPrice = Number(row.taxInclusiveTotalPrice || 0);
  const taxInclusiveTotalPrice = Number(row.taxInclusiveTotalPrice || 0);
  const taxRate = Number(row.taxRate || 0);
  row.taxExclusiveTotalPrice = totalPrice / (1 + taxRate / 100);
  row.taxExclusiveTotalPrice = taxInclusiveTotalPrice / (1 + taxRate / 100);
};
const submitForm = async () => {
@@ -267,9 +246,9 @@
      itemType: product.itemType,
      inboundDate: formatDateTime(product.inboundDate, false),
      taxRate: Number(product.taxRate || 0),
      taxInclusiveUnitPrice: Number(product.taxInclusiveUnitPrice || 0),
      taxInclusiveTotalPrice: Number(product.taxInclusiveTotalPrice || 0),
      taxExclusiveTotalPrice: Number(product.taxExclusiveTotalPrice || 0),
         taxInclusiveUnitPrice: Number(product.taxInclusiveUnitPrice || 0),
         taxInclusiveTotalPrice: Number(product.taxInclusiveTotalPrice || 0),
    }));
    loading.value = true
    if (operationType.value === 'edit') {
@@ -335,6 +314,7 @@
      itemType: row?.itemType ?? '',
      inboundNum: Number(row?.inboundNum ?? row?.inboundQuantity ?? 0),
      inboundDate: row?.inboundDate ?? row?.createTime ?? '',
      quantityStock: Number(row?.quantityStock ?? 0),
      taxRate: Number(row?.taxRate ?? 0),
      taxInclusiveUnitPrice: Number(row?.taxInclusiveUnitPrice ?? 0),
      taxInclusiveTotalPrice: Number(row?.taxInclusiveTotalPrice ?? 0),