Procházet zdrojové kódy

新增供应商下拉列表及其相应功能

张启 před 4 roky
rodič
revize
50fe0cb58e

+ 4 - 4
src/views/pms/product/components/ProductDetail.vue

@@ -1,4 +1,4 @@
-<template> 
+<template>
   <el-card class="form-container" shadow="never">
     <el-steps :active="active" finish-status="success" align-center>
       <el-step title="填写商品信息"></el-step>
@@ -44,8 +44,9 @@
 
   const defaultProductParam = {
     albumPics: '',
-    brandId: null,    
+    brandId: null,
     brandName: '',
+    compId: null,
     placeOfProductionId: null,
     placeOfProduction:'',
     deleteStatus: 0,
@@ -128,8 +129,7 @@
     created(){
       if(this.isEdit){
         getProduct(this.$route.query.id).then(response=>{
-          this.productParam=response.data;
-          console.log('productParam',JSON.parse(JSON.stringify(this.productParam)))
+          this.productParam = Object.assign({}, response.data);
         });
       }
     },

+ 12 - 8
src/views/pms/product/components/ProductInfoDetail.vue

@@ -103,7 +103,7 @@
 <script>
   import {fetchListWithChildren} from '@/api/productCate'
   import {fetchList as fetchBrandList,fetchOriginList} from '@/api/brand'
-  import {getProduct} from '@/api/product';
+  import {getProduct, selectCompList} from '@/api/product';
 
   export default {
     name: "ProductInfoDetail",
@@ -122,6 +122,7 @@
         productCateOptions: [],
         brandOptions: [],
         originOptions:[],
+        supplierOptList: [],
         cascaderPlaceholder:'',
         rules: {
           name: [
@@ -131,6 +132,7 @@
           subTitle: [{required: true, message: '请输入商品副标题', trigger: 'blur'}],
           productCategoryId: [{required: true, message: '请选择商品分类', trigger: 'blur'}],
           brandId: [{required: true, message: '请选择商品品牌', trigger: 'blur'}],
+          compId: [{required: true, message: '请选择供应商', trigger: 'blur'}],
           placeOfProductionId: [{required: true, message: '请选择生产地', trigger: 'blur'}],
           description: [{required: true, message: '请输入商品介绍', trigger: 'blur'}],
           requiredProp: [{required: true, message: '该项为必填项', trigger: 'blur'}],
@@ -144,8 +146,7 @@
     created() {
       this.getProductCateList();
       this.getBrandList();
-      this.getOriginList();
-      console.log('selectProductCateValue',this.selectProductCateValue);
+      this.getSupplierOptList();
     },
     computed:{
       //商品的编号
@@ -177,8 +178,9 @@
           this.value.productBigCategoryId = null;
           this.value.productBigCategoryName = null;
         }
-
-
+      },
+      'value.compId'(newValue) {
+        this.getOriginList(newValue);
       }
     },
     methods: {
@@ -222,9 +224,9 @@
           this.supplierOptList = response.data;
         });
       },
-      getOriginList() {
-        fetchOriginList({pageNum: 1, pageSize: 100}).then(response => {
-          // console.log('getOriginList',response);
+      getOriginList(compId) {
+        if(!compId) { return; }
+        fetchOriginList(compId).then(response => {
           this.originOptions = [];
           let originList = response.data;
           for (let i = 0; i < originList.length; i++) {
@@ -280,6 +282,8 @@
         this.value.brandName = brandName;
       },
       handleSupplierChange(val) {
+        this.value.placeOfProductionId = '';
+        this.getOriginList(val);
         let supplierInfoObj = {};
         supplierInfoObj = this.supplierOptList.find(item => {
           return item.value === val;