Browse Source

'添加产品页面产品类型和品牌接口调试'

zhangyu 4 years ago
parent
commit
a7c2c8aea2
2 changed files with 48 additions and 94 deletions
  1. 6 1
      src/api/brand/index.js
  2. 42 93
      src/components/supplement/sagaSupplement.vue

+ 6 - 1
src/api/brand/index.js

@@ -2,7 +2,7 @@
  * @Author: zhangyu
  * @Date: 2020-05-13 11:18:18
  * @Info:
- * @LastEditTime: 2020-05-18 11:27:42
+ * @LastEditTime: 2020-05-21 15:15:54
  */
 import {baseUrl} from '@/api/scan/config'
 import http from '@/api/scan/httpUtil'
@@ -68,3 +68,8 @@ export function brandQueryByClass(param, success) {
   http.postJson(url, param, success)
 }
 
+//查询最新创建过产品型号的5个品牌
+export function brandRecordQuery(param, success) {
+  let url = `${baseUrl}/prod/brand/recordQuery`
+  http.postJson(url, param, success)
+}

+ 42 - 93
src/components/supplement/sagaSupplement.vue

@@ -8,16 +8,16 @@
         <section class="d_jump">
           <p class="title"><i class="iconfont iconjuxing" style="color:#3A8DDE;"></i>基本信息</p>
           <el-form-item label="产品类型" prop="product">
-            <el-select v-model="ruleForm.product" placeholder="请选择">
-              <el-option-group v-for="group in productList" :key="group.label" :label="group.label">
-                <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value"></el-option>
+            <el-select v-model="ruleForm.product" filterable placeholder="请选择" @change="handleChangeProduct">
+              <el-option-group v-for="group in productList" :key="group.label" :label="group.text">
+                <el-option v-for="item in group.options" :key="item.Code" :label="item.AliasName" :value="item.Code"></el-option>
               </el-option-group>
             </el-select>
           </el-form-item>
           <el-form-item label="品牌" prop="brand">
-            <el-select v-model="ruleForm.brand" multiple :multiple-limit="1" filterable @focus="focus" remote
+            <el-select v-model="ruleForm.brand" filterable remote @change="handleChangeBrand"
               placeholder="请选择" :remote-method="remoteMethods" :loading="loading">
-              <el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value" />
+              <el-option v-for="item in brandList" :key="item.BrandID" :label="`${item.BrandCname}${item.BrandName?`(${item.BrandCname})`:''}`" :value="item.BrandID" />
             </el-select>
           </el-form-item>
           <el-form-item label="型号" prop="type">
@@ -74,13 +74,15 @@
 
 <script>
   import uploadFiles from "@/components/public/uploadFiles"
-  import {prodRecordQuery} from "@/api/product"
-  import {mapGetters} from "vuex"
+  import { prodRecordQuery } from "@/api/product"
+  import { brandRecordQuery, brandQueryByKeyword } from "@/api/brand"
+  import { mapGetters } from "vuex"
 
   export default {
     components: {uploadFiles},
     created() {
       this.getProdType()
+      this.getBrandNum5()
     },
     mounted() {
       console.log(this.$route.query)
@@ -105,80 +107,9 @@
       list: [],
       keysArr: [],
       loading: false,
-      states: ["Alabama", "Alaska", "Arizona",
-        "Arkansas", "California", "Colorado",
-        "Connecticut", "Delaware", "Florida",
-        "Georgia", "Hawaii", "Idaho", "Illinois",
-        "Indiana", "Iowa", "Kansas", "Kentucky",
-        "Louisiana", "Maine", "Maryland",
-        "Massachusetts", "Michigan", "Minnesota",
-        "Mississippi", "Missouri", "Montana",
-        "Nebraska", "Nevada", "New Hampshire",
-        "New Jersey", "New Mexico", "New York",
-        "North Carolina", "North Dakota", "Ohio",
-        "Oklahoma", "Oregon", "Pennsylvania",
-        "Rhode Island", "South Carolina",
-        "South Dakota", "Tennessee", "Texas",
-        "Utah", "Vermont", "Virginia",
-        "Washington", "West Virginia", "Wisconsin",
-        "Wyoming"],
-      bbs: [{
-        value: '选项1',
-        label: '黄金糕'
-      }, {
-        value: '选项2',
-        label: '双皮奶'
-      }, {
-        value: '选项3',
-        label: '蚵仔煎'
-      }, {
-        value: '选项4',
-        label: '龙须面'
-      }, {
-        value: '选项5',
-        label: '北京烤鸭'
-      }],
-      brandList: [{
-        value: '选项1',
-        label: '黄金糕'
-      }, {
-        value: '选项2',
-        label: '双皮奶'
-      }, {
-        value: '选项3',
-        label: '蚵仔煎'
-      }, {
-        value: '选项4',
-        label: '龙须面'
-      }, {
-        value: '选项5',
-        label: '北京烤鸭'
-      }],
-      productList: [{
-        label: '热门城市',
-        options: [{
-          value: 'Shanghai',
-          label: '上海'
-        }, {
-          value: 'Beijing',
-          label: '北京'
-        }]
-      }, {
-        label: '城市名',
-        options: [{
-          value: 'Chengdu',
-          label: '成都'
-        }, {
-          value: 'Shenzhen',
-          label: '深圳'
-        }, {
-          value: 'Guangzhou',
-          label: '广州'
-        }, {
-          value: 'Dalian',
-          label: '大连'
-        }]
-      }],
+      bbs: [],
+      brandList: [],
+      productList: [],
       labelKey: [
         {
           name: '基本信息',
@@ -213,16 +144,40 @@
     ...mapGetters('layout', ['dictionary']),
   },
   methods: {
-    getProdType() {
+    getProdType() {// 获取产品类型
       let params = {
         Type: this.dictionary.dictionaryType,
         GroupId: this.dictionary.groupId,
         ProjectId: this.dictionary.projectId,
       }
       prodRecordQuery(params, res => {
-        debugger
+        res.Content.map(item => {
+          if (item.label == 'record') {
+            item.text = `最近使用`
+          } else if (item.label == 'all') {
+            item.text = ''
+          }
+        })
+        this.productList = res.Content
+      })
+    },
+    getBrandNum5() {// 获取最新创建过产品型号的5个品牌
+      let params = {
+        Type: this.dictionary.dictionaryType,
+        GroupId: this.dictionary.groupId,
+        ProjectId: this.dictionary.projectId,
+      }
+      brandRecordQuery(params, res => {
+        this.bbs = res.Content
+        this.brandList = res.Content
       })
     },
+    handleChangeProduct(item) {// 切换产品类型
+      debugger
+    },
+    handleChangeBrand(item) {// 切换品牌
+      debugger
+    },
     jump(tab, event) {
       this.stepActive = tab.index
       let jump = document.querySelectorAll('.d_jump'),
@@ -270,22 +225,16 @@
       }
     },
     remoteMethods(query) {
-      console.log(query, 'query')
       if (query !== '') {
         this.loading = true
-        setTimeout(() => {
+        brandQueryByKeyword({keyword: query, PageSize: 50,}, res => {
           this.loading = false
-          this.brandList = this.list.filter(item => {
-            return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1
-          })
-        }, 200)
+          this.brandList = res.Content
+        })
       } else {
-        this.brandList = []
+        this.brandList = this.bbs
       }
     },
-    focus() {
-      this.brandList = this.bbs
-    },
     submitForm() {
       this.$refs.ruleForm.validate((valid) => {
         if (valid) {