2026-05-30 1edfaf64891742fdcc72470fab78edd9a584e35e
src/views/salesManagement/salesQuotation/index.vue
@@ -70,7 +70,7 @@
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right" align="center">
          <template #default="scope">
            <el-button link type="primary" @click="handleEdit(scope.row)" :disabled="!['待审批','拒绝'].includes(scope.row.status)">编辑</el-button>
            <el-button link type="primary" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button link type="primary" @click="handleView(scope.row)" style="color: #67C23A">查看</el-button>
            <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
          </template>
@@ -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
@@ -275,7 +275,7 @@
        <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">
@@ -338,9 +338,6 @@
  products: [],
  subtotal: 0,
  freight: 0,
  otherFee: 0,
  discountRate: 0,
  discountAmount: 0,
  totalAmount: 0
})
@@ -458,7 +455,7 @@
      row.product = '';
      row.modelOptions = [];
      row.productModelId = '';
      row.ProductModel = '';
      row.specification = '';
      row.unit = '';
      return;
   }
@@ -479,7 +476,7 @@
   // 如果清空选择,则清空相关字段
   if (!value) {
      row.productModelId = '';
      row.ProductModel = '';
      row.specification = '';
      row.unit = '';
      return;
   }
@@ -488,10 +485,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 +521,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 +567,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 +583,7 @@
      productId: resolvedProductId,
      product: productName,
      productModelId: resolvedProductModelId,
      ProductModel: product.ProductModel || '',
      specification: product.specification || '',
      quantity: product.quantity || 0,
      unit: product.unit || '',
      unitPrice: product.unitPrice || 0,
@@ -595,10 +592,6 @@
    }
  })) : []
  form.subtotal = row.subtotal || 0
  form.freight = row.freight || 0
  form.otherFee = row.otherFee || 0
  form.discountRate = row.discountRate || 0
  form.discountAmount = row.discountAmount || 0
  form.totalAmount = row.totalAmount || 0
  dialogVisible.value = true
@@ -639,8 +632,6 @@
  form.subtotal = 0
  form.freight = 0
  form.otherFee = 0
  form.discountRate = 0
  form.discountAmount = 0
  form.totalAmount = 0
}
@@ -693,11 +684,19 @@
      }, 0)
      form.customer = customerOption.value.find(item => item.id === form.customerId)?.customerName || ''
      // 剔除 products 中的 modelOptions 字段,以及 form 中的 subtotal、freight 字段
      const { subtotal, freight, ...formWithoutSubtotal } = form
      const submitData = {
        ...formWithoutSubtotal,
        products: form.products.map(({ modelOptions, ...rest }) => rest)
      }
      if (isEdit.value) {
        // 编辑
        const index = quotationList.value.findIndex(item => item.id === editId.value)
        if (index > -1) {
          updateQuotation(form).then(res=>{
          updateQuotation(submitData).then(res=>{
            // console.log(res)
            if(res.code===200){
              ElMessage.success('编辑成功')
@@ -708,7 +707,7 @@
        }
      } else {
        // 新增
        addQuotation(form).then(res=>{
        addQuotation(submitData).then(res=>{
          if(res.code===200){
            ElMessage.success('新增成功')
            dialogVisible.value = false
@@ -755,7 +754,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,
@@ -763,9 +762,6 @@
        })) : [],
        subtotal: item.subtotal || 0,
        freight: item.freight || 0,
        otherFee: item.otherFee || 0,
        discountRate: item.discountRate || 0,
        discountAmount: item.discountAmount || 0,
        totalAmount: item.totalAmount || 0
      }))
      pagination.total = res.data.total