yuan
9 天以前 bdfab89d8afbc60faeb89715a461f77e877d7f5d
src/views/salesManagement/salesQuotation/index.vue
@@ -65,7 +65,7 @@
        </el-table-column>
        <el-table-column prop="totalAmount" label="报价金额" width="120">
          <template #default="scope">
            ¥{{ scope.row.totalAmount.toFixed(2) }}
            ¥{{ formatDecimal(scope.row.totalAmount) }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right" align="center">
@@ -185,7 +185,7 @@
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="ProductModel" label="规格型号" width="200">
            <el-table-column prop="specification" label="规格型号" width="200">
              <template #default="scope">
                <el-form-item :prop="`products.${scope.$index}.productModelId`" class="product-table-form-item">
                  <el-select
@@ -215,7 +215,7 @@
            <el-table-column prop="unitPrice" label="单价">
              <template #default="scope">
                <el-form-item :prop="`products.${scope.$index}.unitPrice`" class="product-table-form-item">
                  <el-input-number v-model="scope.row.unitPrice" :min="0" :precision="2" style="width: 100%" />
                  <el-input-number v-model="scope.row.unitPrice" :min="0" :precision="6" :step="0.000001" style="width: 100%" />
                </el-form-item>
              </template>
            </el-table-column>
@@ -267,7 +267,7 @@
<!--          <el-tag :type="getStatusType(currentQuotation.status)">{{ currentQuotation.status }}</el-tag>-->
<!--        </el-descriptions-item>-->
        <el-descriptions-item label="报价总额" :span="2">
          <span style="font-size: 18px; color: #e6a23c; font-weight: bold;">¥{{ currentQuotation.totalAmount?.toFixed(2) }}</span>
          <span style="font-size: 18px; color: #e6a23c; font-weight: bold;">¥{{ formatDecimal(currentQuotation.totalAmount) }}</span>
        </el-descriptions-item>
      </el-descriptions>
@@ -275,11 +275,11 @@
        <h4>产品明细</h4>
        <el-table :data="currentQuotation.products" border style="width: 100%">
          <el-table-column prop="product" label="产品名称" />
          <el-table-column prop="ProductModel" label="规格型号" />
          <el-table-column prop="specification" label="规格型号" />
          <el-table-column prop="unit" label="单位" />
          <el-table-column prop="unitPrice" label="单价">
            <template #default="scope">
              ¥{{ scope.row.unitPrice.toFixed(2) }}
              ¥{{ formatDecimal(scope.row.unitPrice) }}
            </template>
          </el-table-column>
        </el-table>
@@ -303,6 +303,7 @@
import {modelList, productTreeList} from "@/api/basicData/product.js";
import {listCustomer} from "@/api/basicData/customer.js";
import { userListNoPage } from "@/api/system/user.js";
import { formatDecimal, roundAmount } from '@/utils/numberFormat';
// 响应式数据
const loading = ref(false)
@@ -346,6 +347,7 @@
const baseRules = {
  customer: [{ required: true, message: '请选择客户', trigger: 'change' }],
  customerId: [{ required: true, message: '请选择客户', trigger: 'change' }],
  salesperson: [{ required: true, message: '请选择业务员', trigger: 'change' }],
  quotationDate: [{ required: true, message: '请选择报价日期', trigger: 'change' }],
  validDate: [{ required: true, message: '请选择有效期', trigger: 'change' }],
@@ -458,7 +460,7 @@
      row.product = '';
      row.modelOptions = [];
      row.productModelId = '';
      row.ProductModel = '';
      row.specification = '';
      row.unit = '';
      return;
   }
@@ -479,7 +481,7 @@
   // 如果清空选择,则清空相关字段
   if (!value) {
      row.productModelId = '';
      row.ProductModel = '';
      row.specification = '';
      row.unit = '';
      return;
   }
@@ -488,10 +490,10 @@
   const modelOptions = row.modelOptions || [];
   const index = modelOptions.findIndex((item) => item.id === value);
   if (index !== -1) {
      row.ProductModel = modelOptions[index].model;
      row.specification = modelOptions[index].model;
      row.unit = modelOptions[index].unit;
   } else {
      row.ProductModel = '';
      row.specification = '';
      row.unit = '';
   }
};
@@ -524,7 +526,7 @@
      productId: product.productId || '',
      product: product.product || product.productName || '',
      productModelId: product.productModelId || '',
      ProductModel: product.ProductModel || '',
      specification: product.specification || '',
      quantity: product.quantity || 0,
      unit: product.unit || '',
      unitPrice: product.unitPrice || 0,
@@ -570,9 +572,9 @@
        const res = await modelList({ id: resolvedProductId });
        modelOptions = res || [];
        // 如果返回的数据没有 productModelId,但有 ProductModel 名称,根据名称查找 ID
        if (!resolvedProductModelId && product.ProductModel) {
          const foundModel = modelOptions.find(item => item.model === product.ProductModel);
        // 如果返回的数据没有 productModelId,但有 specification 名称,根据名称查找 ID
        if (!resolvedProductModelId && product.specification) {
          const foundModel = modelOptions.find(item => item.model === product.specification);
          if (foundModel) {
            resolvedProductModelId = foundModel.id;
          }
@@ -586,7 +588,7 @@
      productId: resolvedProductId,
      product: productName,
      productModelId: resolvedProductModelId,
      ProductModel: product.ProductModel || '',
      specification: product.specification || '',
      quantity: product.quantity || 0,
      unit: product.unit || '',
      unitPrice: product.unitPrice || 0,
@@ -686,11 +688,11 @@
        return
      }
      // 计算所有产品的单价总和
      form.totalAmount = form.products.reduce((sum, product) => {
      // 计算所有产品的单价总和,保留六位小数
      form.totalAmount = roundAmount(form.products.reduce((sum, product) => {
        const price = Number(product.unitPrice) || 0
        return sum + price
      }, 0)
      }, 0))
      form.customer = customerOption.value.find(item => item.id === form.customerId)?.customerName || ''
      if (isEdit.value) {
@@ -755,7 +757,7 @@
          productId: product.productId || '',
          product: product.product || product.productName || '',
          productModelId: product.productModelId || '',
          ProductModel: product.ProductModel || '',
          specification: product.specification || '',
          quantity: product.quantity || 0,
          unit: product.unit || '',
          unitPrice: product.unitPrice || 0,