buhuazhen
4 天以前 3b62191f20a09535fece6141495e9e27db5edc91
feat: 更新销售报价和销售账本中的产品型号字段
已修改2个文件
55 ■■■■ 文件已修改
src/views/salesManagement/salesLedger/index.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/salesQuotation/index.vue 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/salesLedger/index.vue
@@ -1705,6 +1705,8 @@
        taxExclusiveTotalPrice: taxExclusiveTotalPrice,
        invoiceType: "增普票",
        isProduction: true,
        productId: p.productId,
        productModelId: p.productModelId
      };
    });
src/views/salesManagement/salesQuotation/index.vue
@@ -185,11 +185,11 @@
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="specification" label="规格型号" width="200">
            <el-table-column prop="ProductModel" label="规格型号" width="200">
              <template #default="scope">
                <el-form-item :prop="`products.${scope.$index}.specificationId`" class="product-table-form-item">
                <el-form-item :prop="`products.${scope.$index}.productModelId`" class="product-table-form-item">
                  <el-select
                    v-model="scope.row.specificationId"
                    v-model="scope.row.productModelId"
                    placeholder="请选择"
                    clearable
                    @change="getProductModel($event, scope.row)"
@@ -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="specification" label="规格型号" />
          <el-table-column prop="ProductModel" label="规格型号" />
          <el-table-column prop="unit" label="单位" />
          <el-table-column prop="unitPrice" label="单价">
            <template #default="scope">
@@ -354,7 +354,7 @@
const productRowRules = {
  productId: [{ required: true, message: '请选择产品名称', trigger: 'change' }],
  specificationId: [{ required: true, message: '请选择规格型号', trigger: 'change' }],
  productModelId: [{ required: true, message: '请选择规格型号', trigger: 'change' }],
  unit: [{ required: true, message: '请填写单位', trigger: 'blur' }],
  unitPrice: [{ required: true, message: '请填写单价', trigger: 'change' }]
}
@@ -362,7 +362,7 @@
  const r = { ...baseRules }
  ;(form.products || []).forEach((_, i) => {
    r[`products.${i}.productId`] = productRowRules.productId
    r[`products.${i}.specificationId`] = productRowRules.specificationId
    r[`products.${i}.productModelId`] = productRowRules.productModelId
    r[`products.${i}.unit`] = productRowRules.unit
    r[`products.${i}.unitPrice`] = productRowRules.unitPrice
  })
@@ -457,8 +457,8 @@
        row.productId = '';
        row.product = '';
        row.modelOptions = [];
        row.specificationId = '';
        row.specification = '';
        row.productModelId = '';
        row.ProductModel = '';
        row.unit = '';
        return;
    }
@@ -478,20 +478,20 @@
    if (!row) return;
    // 如果清空选择,则清空相关字段
    if (!value) {
        row.specificationId = '';
        row.specification = '';
        row.productModelId = '';
        row.ProductModel = '';
        row.unit = '';
        return;
    }
    // 更新 specificationId(v-model 已经自动更新,这里确保一致性)
    row.specificationId = value;
    // 更新 productModelId(v-model 已经自动更新,这里确保一致性)
    row.productModelId = value;
    const modelOptions = row.modelOptions || [];
    const index = modelOptions.findIndex((item) => item.id === value);
    if (index !== -1) {
        row.specification = modelOptions[index].model;
        row.ProductModel = modelOptions[index].model;
        row.unit = modelOptions[index].unit;
    } else {
        row.specification = '';
        row.ProductModel = '';
        row.unit = '';
    }
};
@@ -523,8 +523,8 @@
    products: row.products ? row.products.map(product => ({
      productId: product.productId || '',
      product: product.product || product.productName || '',
      specificationId: product.specificationId || '',
      specification: product.specification || '',
      productModelId: product.productModelId || '',
      ProductModel: product.ProductModel || '',
      quantity: product.quantity || 0,
      unit: product.unit || '',
      unitPrice: product.unitPrice || 0,
@@ -563,18 +563,18 @@
    
    // 如果有产品ID,加载对应的规格型号列表
    let modelOptions = [];
    let resolvedSpecificationId = product.specificationId || '';
    let resolvedProductModelId = product.productModelId || '';
    
    if (resolvedProductId) {
      try {
        const res = await modelList({ id: resolvedProductId });
        modelOptions = res || [];
        
        // 如果返回的数据没有 specificationId,但有 specification 名称,根据名称查找 ID
        if (!resolvedSpecificationId && product.specification) {
          const foundModel = modelOptions.find(item => item.model === product.specification);
        // 如果返回的数据没有 productModelId,但有 ProductModel 名称,根据名称查找 ID
        if (!resolvedProductModelId && product.ProductModel) {
          const foundModel = modelOptions.find(item => item.model === product.ProductModel);
          if (foundModel) {
            resolvedSpecificationId = foundModel.id;
            resolvedProductModelId = foundModel.id;
          }
        }
      } catch (error) {
@@ -585,8 +585,8 @@
    return {
      productId: resolvedProductId,
      product: productName,
      specificationId: resolvedSpecificationId,
      specification: product.specification || '',
      productModelId: resolvedProductModelId,
      ProductModel: product.ProductModel || '',
      quantity: product.quantity || 0,
      unit: product.unit || '',
      unitPrice: product.unitPrice || 0,
@@ -649,8 +649,7 @@
    productId: '',
    product: '',
    productName: '',
    specificationId: '',
    specification: '',
    productModelId: '',
    quantity: 1,
    unit: '',
    unitPrice: 0,
@@ -755,8 +754,8 @@
        products: item.products ? item.products.map(product => ({
          productId: product.productId || '',
          product: product.product || product.productName || '',
          specificationId: product.specificationId || '',
          specification: product.specification || '',
          productModelId: product.productModelId || '',
          ProductModel: product.ProductModel || '',
          quantity: product.quantity || 0,
          unit: product.unit || '',
          unitPrice: product.unitPrice || 0,