Bladeren bron

Fix: 产品编辑问题

liqianyi 2 jaren geleden
bovenliggende
commit
e8563fd132
2 gewijzigde bestanden met toevoegingen van 47 en 29 verwijderingen
  1. 41 29
      src/views/modules/tech/product-add-or-update.vue
  2. 6 0
      src/views/modules/tech/product-detail.vue

+ 41 - 29
src/views/modules/tech/product-add-or-update.vue

@@ -85,8 +85,7 @@
           <el-row class="my-row">
             <el-form-item label="是否组合产品" prop="displayProductList">
               <el-switch
-                v-model="dataForm.displayProductList"
-                :disabled="display"
+                v-model="displayProductList"
                 active-color="#13ce66"
                 inactive-color="#ff4949"
                 active-text="是"
@@ -94,7 +93,7 @@
               </el-switch>
             </el-form-item>
           </el-row>
-          <el-row v-if="dataForm.displayProductList">
+          <el-row v-if="displayProductList">
             <div class="title"><span style="color: red">*</span> 组合小产品</div>
             <el-table
               :data="productDetails"
@@ -112,6 +111,12 @@
                 align="center"
                 label="产品名称">
               </el-table-column>
+              <el-table-column
+                prop="materialName"
+                header-align="center"
+                align="center"
+                label="物品名称">
+              </el-table-column>
               <el-table-column
                 prop="productSpec"
                 header-align="center"
@@ -220,11 +225,11 @@ export default {
         get () { return this.$store.state.user.orgId }
       }
     },
-    watch: {
-      'dataForm.isCompose' (value) {
-        this.dataForm.displayProductList = value === '1'
-      }
-    },
+    // watch: {
+    //   'dataForm.isCompose' (value) {
+    //     this.dataForm.displayProductList = value === '1'
+    //   }
+    // },
     data () {
       return {
         productListVisible: false,
@@ -239,9 +244,8 @@ export default {
         id: 0,
         productDetails: [],
         materialList: [],
-        dataForm: {
-          displayProductList: false
-        },
+        displayProductList: false,
+        dataForm: {},
         dataRule: {
           productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
           productSpec: [{ required: true, message: '产品规格不能为空', trigger: 'blur' }],
@@ -306,6 +310,7 @@ export default {
                   id: item.url
                 })
               })
+              console.log(this.fileList.length)
             }
             // 产品配料清单附件
             if (data.data.listingList) {
@@ -323,13 +328,19 @@ export default {
               dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
             }
             // 组合小产品
-            data.data.composeProductMaterialList.forEach((item) => {
-              this.productDetails.push(item)
-            })
-            // 产品配料清单
-            data.data.productMaterialList.forEach((item) => {
-              this.materialList.push(item)
-            })
+            if (data.data.composeProductMaterialList) {
+              data.data.composeProductMaterialList.forEach((item) => {
+                this.productDetails.push({
+                  ...item,
+                  productSpec: item.specifications
+                })
+              })
+              this.displayProductList = true
+            }
+            // // 产品配料清单
+            // data.data.productMaterialList.forEach((item) => {
+            //   this.materialList.push(item)
+            // })
             // 产品来源
             if (data.data.source) {
               this.optionsSource = [{
@@ -422,7 +433,7 @@ export default {
           if (valid) {
             // 组合小产品
             this.dataForm.composeProductMaterialList = []
-            const b1 = this.dataForm.displayProductList
+            const b1 = this.displayProductList
             this.dataForm.isCompose = b1 === true ? '1' : '0'
             if (this.dataForm.isCompose === '1' && this.productDetails.length > 0) {
               this.productDetails.forEach((item) => {
@@ -431,15 +442,15 @@ export default {
                 })
               })
             }
-            // 产品配料清单
-            this.dataForm.productMaterialList = []
-            if (this.materialList.length > 0) {
-              this.materialList.forEach((item) => {
-                this.dataForm.productMaterialList.push({
-                  ...item
-                })
-              })
-            }
+            // // 产品配料清单
+            // this.dataForm.productMaterialList = []
+            // if (this.materialList.length > 0) {
+            //   this.materialList.forEach((item) => {
+            //     this.dataForm.productMaterialList.push({
+            //       ...item
+            //     })
+            //   })
+            // }
             // 产品技术文件
             let fList = this.fileList
             if (fList.length > 0) {
@@ -469,7 +480,8 @@ export default {
               return
             }
             this.$http({
-              url: this.$http.adornUrl(`/biz-service/product/save`),
+              url: !this.id ? this.$http.adornUrl(`/biz-service/product/save`) : this.$http.adornUrl(`/biz-service/product/update`),
+              // url: this.$http.adornUrl(`/biz-service/product/save`),
               method: 'post',
               data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
             }).then(({data}) => {

+ 6 - 0
src/views/modules/tech/product-detail.vue

@@ -90,6 +90,12 @@
             align="center"
             label="产品名称">
           </el-table-column>
+          <el-table-column
+            prop="materialName"
+            header-align="center"
+            align="center"
+            label="物品名称">
+          </el-table-column>
           <el-table-column
             prop="specifications"
             header-align="center"