Parcourir la source

提交报价管理代码

hezhanp il y a 9 mois
Parent
commit
794f222bb9

Fichier diff supprimé car celui-ci est trop grand
+ 491 - 459
src/BIZComponents/inventoryTable.vue


+ 129 - 118
src/BIZComponents/inventoryTableDetails.vue

@@ -67,19 +67,19 @@
           style="margin-bottom: 20px"
           :prop="'datasource.' + scope.$index + '.' + countObj.countKey"
         >
-          {{ scope.row[countObj.countKey] }}{{ scope.row[countObj.unitKey] }}
+          {{ scope.row[countObj.countKey] }}
         </el-form-item>
       </template>
-      <!-- <template v-slot:saleUnit="scope">
+      <template v-slot:saleUnit="scope">
         <el-form-item
           style="margin-bottom: 20px"
           :prop="'datasource.' + scope.$index + '.' + countObj.unitKey"
         >
           {{ scope.row[countObj.unitKey] }}
         </el-form-item>
-      </template> -->
+      </template>
 
-      <!-- 新增字段插槽 -->
+      <!-- 新增字段插槽 - 只在类型为2时显示 -->
       <template v-slot:thickNess="scope">
         <el-form-item
           style="margin-bottom: 20px"
@@ -269,6 +269,11 @@
       isProductionRequirements: {
         type: Boolean,
         default: false
+      },
+      // 报价类型(1:产品销售,2:生产加工)
+      quoteType: {
+        type: Number,
+        default: 1
       }
     },
     data() {
@@ -311,7 +316,9 @@
             align: 'center'
           };
         }
-        return [
+
+        // 基础列(所有类型都显示)
+        const baseColumns = [
           {
             width: 45,
             type: 'index',
@@ -347,54 +354,65 @@
             label: '规格',
             slot: 'specification',
             align: 'center'
-          },
-          // 新增字段:厚度
-          {
-            width: 150,
-            prop: 'thickNess',
-            label: '厚度',
-            slot: 'thickNess',
-            align: 'center'
-          },
-          // 新增字段:平方数
-          {
-            width: 150,
-            prop: 'squareNumber',
-            label: '平方数',
-            slot: 'squareNumber',
-            align: 'center'
-          },
-          // 新增字段:加工费(未税)
-          {
-            width: 150,
-            prop: 'processingFeeBeforeTax',
-            label: '加工费(未税)',
-            slot: 'processingFeeBeforeTax',
-            align: 'center'
-          },
-          // 新增字段:包装费(未税)
-          {
-            width: 150,
-            prop: 'packagingFeeNotTaxed',
-            label: '包装费(未税)',
-            slot: 'packagingFeeNotTaxed',
-            align: 'center'
-          },
-          // 新增字段:运输费(未税)
-          {
-            width: 150,
-            prop: 'transportationFeeWithoutTax',
-            label: '运输费(未税)',
-            slot: 'transportationFeeWithoutTax',
-            align: 'center'
-          },
-          {
-            width: 150,
-            prop: 'quotationSubtotalBeforeTax',
-            label: '报价小计(未税)',
-            slot: 'quotationSubtotalBeforeTax',
-            align: 'center'
-          },
+          }
+        ];
+
+        // 类型为2时显示的列(生产加工)
+        const type2Columns = [];
+        if (this.quoteType === 2) {
+          type2Columns.push(
+            // 新增字段:厚度
+            {
+              width: 150,
+              prop: 'thickNess',
+              label: '厚度',
+              slot: 'thickNess',
+              align: 'center'
+            },
+            // 新增字段:平方数
+            {
+              width: 150,
+              prop: 'squareNumber',
+              label: '平方数',
+              slot: 'squareNumber',
+              align: 'center'
+            },
+            // 新增字段:加工费(未税)
+            {
+              width: 150,
+              prop: 'processingFeeBeforeTax',
+              label: '加工费(未税)',
+              slot: 'processingFeeBeforeTax',
+              align: 'center'
+            },
+            // 新增字段:包装费(未税)
+            {
+              width: 150,
+              prop: 'packagingFeeNotTaxed',
+              label: '包装费(未税)',
+              slot: 'packagingFeeNotTaxed',
+              align: 'center'
+            },
+            // 新增字段:运输费(未税)
+            {
+              width: 150,
+              prop: 'transportationFeeWithoutTax',
+              label: '运输费(未税)',
+              slot: 'transportationFeeWithoutTax',
+              align: 'center'
+            },
+            {
+              width: 150,
+              prop: 'quotationSubtotalBeforeTax',
+              label: '报价小计(未税)',
+              slot: 'quotationSubtotalBeforeTax',
+              align: 'center'
+            }
+          );
+        }
+
+        // 其他公共列
+        const otherColumns = [
           {
             width: 200,
             prop: 'customerMark',
@@ -447,21 +465,21 @@
                 width: 1
               },
           {
-            width: 180,
+            width: 150,
             prop: 'saleCount',
             label: '数量',
             slot: 'saleCount',
             headerSlot: 'headerTotalCount',
             align: 'center'
           },
-          // {
-          //   width: 150,
-          //   prop: 'saleUnit',
-          //   label: '单位',
-          //   slot: 'saleUnit',
-          //   headerSlot: 'headerTotalCount',
-          //   align: 'center'
-          // },
+          {
+            width: 150,
+            prop: 'saleUnit',
+            label: '单位',
+            slot: 'saleUnit',
+            headerSlot: 'headerTotalCount',
+            align: 'center'
+          },
           {
             width: 120,
             prop: 'packingSpecification',
@@ -482,79 +500,59 @@
             },
             align: 'center'
           },
-          // {
-          //   width: 120,
-          //   prop: 'measuringUnit',
-          //   label: '计量单位',
-          //   slot: 'measuringUnit',
-          //   align: 'center'
-          // },
+          {
+            width: 120,
+            prop: 'measuringUnit',
+            label: '计量单位',
+            slot: 'measuringUnit',
+            align: 'center'
+          },
           wmsColumn,
           this.pageName == 'send'
             ? {
-                minWidth: 140,
+                minWidth: 110,
                 prop: 'sendTotalCount',
                 label: '已发货数量',
                 slot: 'sendTotalCount',
-                align: 'center',
-                formatter: (row, column) => {
-                  if (row.sendTotalCount) {
-                    return row.sendTotalCount + ' ' + row.measuringUnit;
-                  }
-                }
+                align: 'center'
               }
             : {
                 width: 1
               },
           this.pageName == 'send'
             ? {
-                minWidth: 140,
+                minWidth: 110,
                 prop: 'notSendTotalCount',
                 label: '未发货数量',
                 slot: 'notSendTotalCount',
-                align: 'center',
-                formatter: (row, column) => {
-                  if (row.notSendTotalCount) {
-                    return row.notSendTotalCount + ' ' + row.measuringUnit;
-                  }
-                }
+                align: 'center'
               }
             : {
                 width: 1
               },
 
           {
-            width: 140,
+            width: 120,
             prop: 'singleWeight',
             label: '单重',
             slot: 'singleWeight',
             headerSlot: 'headerSingleWeight',
-            formatter: (row, column) => {
-              if (row.singleWeight) {
-                return row.singleWeight + ' ' + row.weightUnit;
-              }
-            },
             align: 'center'
           },
           {
-            width: 140,
+            width: 120,
             prop: 'totalWeight',
             label: '总重',
             slot: 'totalWeight',
-            formatter: (row, column) => {
-              if (row.totalWeight) {
-                return row.totalWeight + ' ' + row.weightUnit;
-              }
-            },
             align: 'center'
           },
-          // {
-          //   width: 120,
-          //   prop: 'weightUnit',
-          //   label: '重量单位',
-          //   slot: 'weightUnit',
-          //   align: 'center'
-          // },
+          {
+            width: 120,
+            prop: 'weightUnit',
+            label: '重量单位',
+            slot: 'weightUnit',
+            align: 'center'
+          },
 
           {
             width: 160,
@@ -660,22 +658,32 @@
             slot: 'modelType',
             align: 'center'
           },
-          {
-            minWidth: 120,
-            prop: 'modelKey',
-            label: '机型',
-            slot: 'modelKey',
-            showOverflowTooltip: true,
-            align: 'center'
-          },
-          {
-            minWidth: 120,
-            prop: 'colorKey',
-            slot: 'colorKey',
-            showOverflowTooltip: true,
-            label: '颜色',
-            align: 'center'
-          },
+          // 机型列 - 只在类型为2时显示
+          this.quoteType === 2
+            ? {
+                minWidth: 120,
+                prop: 'modelKey',
+                label: '机型',
+                slot: 'modelKey',
+                showOverflowTooltip: true,
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
+          // 颜色列 - 只在类型为2时显示
+          this.quoteType === 2
+            ? {
+                minWidth: 120,
+                prop: 'colorKey',
+                slot: 'colorKey',
+                showOverflowTooltip: true,
+                label: '颜色',
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
           {
             width: 120,
             prop: 'imgCode',
@@ -853,6 +861,9 @@
             align: 'center'
           }
         ];
+
+        // 合并所有列
+        return [...baseColumns, ...type2Columns, ...otherColumns];
       }
     },
 

+ 35 - 14
src/BIZComponents/setProduct.js

@@ -1,9 +1,11 @@
 import Vue from 'vue';
 
 //改变数量
-export function changeCount(row, countObj, noDiscountSingle) {
-  let total = row[countObj.countKey] || 0;
+export function changeCount(row, countObj, noDiscountSingle, quoteType = 1) {
+  let total = row[countObj.countKey] || 0; // 基础数量
   let data = row;
+
+  // 处理包装规格转换(保持原有逻辑)
   if (row.packageDispositionList) {
     let endIndex = row.packageDispositionList.findIndex(
       (ite) => row[countObj.unitIdKey] == ite.id
@@ -15,15 +17,38 @@ export function changeCount(row, countObj, noDiscountSingle) {
       );
     }
   }
+  data['totalCount'] = total; // 转换后的总数量
 
-  data['totalCount'] = total;
+  // 折让单价逻辑(保持原有)
   data['discountSinglePrice'] = !noDiscountSingle
     ? data.singlePrice
     : data.discountSinglePrice;
 
+  // 计算总重量(保持原有)
   setWeight(data);
-  if (row[countObj.countKey] && row.singlePrice) {
-    data['totalPrice'] = row[countObj.countKey] * row.singlePrice;
+
+  // 核心:计算合计(totalPrice)
+  // 1. 确定使用的单价:生产加工类型用含税单价,其他用singlePrice
+  const basePrice =
+    quoteType === 2
+      ? Number(row.includingTaxPrice) || 0 // 生产加工:用含税单价
+      : Number(row.singlePrice) || 0; // 其他类型:用原单价
+
+  // 2. 根据计价方式计算合计
+  if (row[countObj.countKey] && basePrice) {
+    if (row.pricingWay === 1) {
+      // 按数量计价:数量 * 单价
+      data['totalPrice'] = Number(row[countObj.countKey]) * basePrice;
+    } else if (row.pricingWay === 2) {
+      // 按重量计价:数量 * 单重 * 单价
+      data['totalPrice'] =
+        Number(row[countObj.countKey]) *
+        (Number(row.singleWeight) || 0) *
+        basePrice;
+    } else {
+      data['totalPrice'] = 0;
+    }
+    // 折让合计逻辑(保持原有)
     data['discountTotalPrice'] = !noDiscountSingle
       ? data.totalPrice
       : data.discountTotalPrice;
@@ -31,12 +56,8 @@ export function changeCount(row, countObj, noDiscountSingle) {
     data['totalPrice'] = 0;
     data['discountTotalPrice'] = 0;
   }
-  // getNotaxSinglePrice(data);
+
   return data;
-  // if (row) {
-  //   singleWeightChange(row, index);
-  // }
-  // return getNumTotalPrice(arr, noDiscountSingle);
 }
 function setWeight(row) {
   if (row.weightUnit == row.measuringUnit) {
@@ -50,11 +71,11 @@ function setWeight(row) {
 export function getAllPrice(arr) {
   let sum = 0;
   arr.forEach((item) => {
-    if (item.totalPrice) {
-      sum += Number(item.totalPrice);
-    }
+    // 累加所有行的合计(totalPrice),兼容可能的非数字情况
+    sum += Number(item.totalPrice) || 0;
   });
-  return isNaN(sum) ? 0 : sum.toFixed(2);
+  // 保留两位小数,避免NaN
+  return isNaN(sum) ? '0.00' : sum.toFixed(2);
 }
 // //计算不含税单价
 // function getNotaxSinglePrice(row) {

+ 49 - 26
src/views/saleManage/quotation/components/addDialog.vue

@@ -22,6 +22,20 @@
       <headerTitle title="基本信息"></headerTitle>
       <el-row gutter="12">
         <el-col :span="12">
+          <el-form-item label="类型" prop="type">
+            <el-select
+              v-model="form.type"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in typeOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              ></el-option>
+            </el-select>
+          </el-form-item>
           <el-form-item label="询价方名称" prop="contactName">
             <el-input
               clearable
@@ -117,6 +131,7 @@
               placeholder="请输入"
             />
           </el-form-item>
+          
           <el-form-item label="结算方式" prop="settlementMode">
             <DictSelection
               dictName="结算方式"
@@ -211,6 +226,7 @@
         :isTemporary="true"
         :isDiscount="false"
         :cacheKeyUrl="cacheKeyUrl"
+        :quoteType="form.type"
       ></inventoryTable>
 
       <!-- <el-row style="margin-top: 20px">
@@ -346,7 +362,9 @@ export default {
       quoteTel: '',
       taxRate: null,
       totalPrice: null,
-      opportunityType: null
+      opportunityType: null,
+
+      type: 1
     };
 
     return {
@@ -356,6 +374,10 @@ export default {
         { label: '有', value: 1 },
         { label: '无', value: 0 }
       ],
+      typeOptions: [
+        { label: '产品销售', value: 1 },
+        { label: '生产加工', value: 2 }
+      ],
       payWayOptions: [],
       delDetailIds: [],
       linkNameOptions: [],
@@ -386,6 +408,7 @@ export default {
         acceptUnpack: [
           { required: true, message: '请选择是否接受', trigger: 'change' }
         ],
+        type: [{ required: true, message: '请选择类型', trigger: 'change' }],
         contactTel: [
           // {
           //   required: true,
@@ -394,10 +417,9 @@ export default {
           //   trigger: 'blur'
           // },
           {
-            required: true,
-            pattern: telReg,
-            message: '请输入联系电话',
-            trigger: 'blur'
+            required: true, // 只保留必填校验
+            message: '请输入联系电话', // 提示文字不变(仅提示必填)
+            trigger: 'blur' // 触发时机(失去焦点时校验)
           }
         ],
         deliveryDate: [
@@ -525,29 +547,30 @@ export default {
       });
       this.businessList = data.list;
     },
-   queryContactLink(queryString, callback) {
-    const filtered = queryString
-      ? this.linkNameOptions.filter(item => 
-          item.linkName.toLowerCase().includes(queryString.toLowerCase())
-        )
-      : this.linkNameOptions;
-    callback(filtered.map(item => ({ ...item, value: item.linkName })));
-  },
+    queryContactLink(queryString, callback) {
+      const filtered = queryString
+        ? this.linkNameOptions.filter((item) =>
+            item.linkName.toLowerCase().includes(queryString.toLowerCase())
+          )
+        : this.linkNameOptions;
+      callback(filtered.map((item) => ({ ...item, value: item.linkName })));
+    },
 
-  handleContactSelect(selectedItem) {
-    this.form.contactLinkId = selectedItem.id;
-    this.form.contactTel = selectedItem.mobilePhone || selectedItem.phone || '';
-    this.form.contactEmail = selectedItem.email || '';
-  },
+    handleContactSelect(selectedItem) {
+      this.form.contactLinkId = selectedItem.id;
+      this.form.contactTel =
+        selectedItem.mobilePhone || selectedItem.phone || '';
+      this.form.contactEmail = selectedItem.email || '';
+    },
 
-  handleContactInput() {
-    const isExist = this.linkNameOptions.some(
-      item => item.linkName === this.form.contactLinkName
-    );
-    if (!isExist) {
-      this.form.contactLinkId = ''; // 手动输入时无对应ID
-    }
-  },
+    handleContactInput() {
+      const isExist = this.linkNameOptions.some(
+        (item) => item.linkName === this.form.contactLinkName
+      );
+      if (!isExist) {
+        this.form.contactLinkId = ''; // 手动输入时无对应ID
+      }
+    },
     handHead() {
       let item = {
         id: this.form.quoteLinkId

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff