Jelajahi Sumber

报价管理-自动计算小计

yuanchengman 1 tahun lalu
induk
melakukan
38d49f6982
1 mengubah file dengan 22 tambahan dan 14 penghapusan
  1. 22 14
      src/views/modules/cus/quoted-price.vue

+ 22 - 14
src/views/modules/cus/quoted-price.vue

@@ -15,6 +15,7 @@
               v-model="dataForm.coId"
               placeholder="请选择"
               style="width: 100%"
+              disabled
             >
               <el-option
                 v-for="item in coOption"
@@ -31,6 +32,7 @@
             <el-input
               v-model="dataForm.projectName"
               placeholder="项目名称"
+              disabled
             ></el-input>
           </el-form-item>
         </el-col>
@@ -40,6 +42,7 @@
               v-model="dataForm.type"
               placeholder="请选择"
               style="width: 100%"
+              disabled
             >
               <el-option
                 v-for="item in productTypeOption"
@@ -76,6 +79,7 @@
               @change="productIdChangeHandle"
               placeholder="请选择"
               style="width: 100%"
+              disabled
             >
               <el-option
                 v-for="item in productIdOption"
@@ -91,7 +95,7 @@
       <div>
         <div class="title">BOM物料明细报价</div>
         <el-row>
-          <el-table :data="productList" border style="width: 100%">
+          <el-table :data="dataForm.quotedPriceProductList" border style="width: 100%">
             <el-table-column
               label="序号"
               type="index"
@@ -390,6 +394,7 @@
             type="primary"
             icon="el-icon-plus"
             @click="inBound"
+            disabled
           ></el-button>
         </el-row>
       </div>
@@ -438,7 +443,7 @@ export default {
       productSearchLoading: false,
       dataForm: {
         materialCost: 0,
-        quotedPriceProductParamsList: [], // 报价物料清单
+        quotedPriceProductList: [], // 报价物料清单
         workInfoList: []
       },
       dataRule: {
@@ -493,9 +498,10 @@ export default {
       getDetail(priceId).then(({ data }) => {
         if (data && data.code === '200') {
           this.dataForm = data.data
-
-          if (this.dataForm.productId) {
-            this.productIdChangeHandle(this.dataForm.productId)
+          if (!this.dataForm.quotedPriceProductList) {
+            if (this.dataForm.productId) {
+              this.productIdChangeHandle(this.dataForm.productId)
+            }
           }
         }
       })
@@ -534,12 +540,13 @@ export default {
       if (val) {
         getProductAllDetail(val).then(({ data }) => {
           if (data && data.code === '200') {
-            this.dataForm.quotedPriceProductParamsList = []
+            this.dataForm.quotedPriceProductList = []
             this.productList = data.data
             this.productList.forEach((item) => {
-              this.dataForm.quotedPriceProductParamsList.push({
+              this.dataForm.quotedPriceProductList.push({
                 productId: item.productId
               })
+              item.id = this.dataForm.quotedPriceProductList.find(t => t.productId === item.productId).id
             })
           }
         })
@@ -581,14 +588,14 @@ export default {
     },
     inputNumChangeHandle (currentValue, oldValue) {
       // 计算报价小计
-      let temp = this.dataForm.materialCost + currentValue
-      if (oldValue) {
-        temp = temp - oldValue
-      }
-      this.dataForm.materialCost = temp
+      let tempMaterialCost = 0
+      this.dataForm.quotedPriceProductList.forEach(item => {
+        tempMaterialCost += item.handlePrice + item.materialPrice + item.processPrice
+      })
+      this.dataForm.materialCost = tempMaterialCost
 
-      console.log(currentValue)
-      console.log(oldValue)
+      // 计算总价
+      this.dataForm.totalPrice = 0
     },
     dataFormSubmit () {
       if (this.type === 'first') {
@@ -609,6 +616,7 @@ export default {
             totalPrice: this.dataForm.totalPrice,
             quotedPriceProductFirstParamsList: this.productList.map(item => {
               let temp = {
+                id: item.id,
                 priceId: this.id,
                 productId: item.productId,
                 materialPrice: item.materialPrice,