Browse Source

搜索bug修改 供应商发布类目带出

yangc 7 years ago
parent
commit
8d0da9ba5e

+ 15 - 13
components/main/Search.vue

@@ -1,9 +1,9 @@
 <template>
   <div class="search-box" :class="{'search-box2': !SelectItem}">
     <div class="input-group">
-      <select @change="onSelectTypeChange" class="form-control select-type select-adder" v-if="SelectItem">
-        <option value="">产品</option>
-        <option value="">店铺</option>
+      <select v-model="searchType" class="form-control select-type select-adder" v-if="SelectItem">
+        <option value="product">产品</option>
+        <option value="store">店铺</option>
       </select>
       <input v-model="keyword" type="text" class="search-input form-control input-primary"
              placeholder="型号/类目/品牌"
@@ -127,14 +127,14 @@
       }
     },
     methods: {
-      onSelectTypeChange: function (e) {
-        let type = e.target[e.target.selectedIndex].innerHTML
-        if (type === '产品') {
-          this.searchType = 'product'
-        } else if (type === '店铺') {
-          this.searchType = 'store'
-        }
-      },
+//      onSelectTypeChange: function (e) {
+//        let type = e.target[e.target.selectedIndex].innerHTML
+//        if (type === '产品') {
+//          this.searchType = 'product'
+//        } else if (type === '店铺') {
+//          this.searchType = 'store'
+//        }
+//      },
       onFocus () {
         this.associate.show = true
       },
@@ -172,8 +172,10 @@
         }
       },
       searchKeywords () {
-        this.associate.show = true
-        this.$store.dispatch('searchKeywords', { keyword: this.keyword })
+        if (this.searchType === 'product') {
+          this.associate.show = true
+          this.$store.dispatch('searchKeywords', { keyword: this.keyword })
+        }
       },
       onSearch () {
         document.getElementsByClassName('search-input')[0].blur()

+ 51 - 39
components/mobile/applyPurchase/PublishSupplierSeek.vue

@@ -87,48 +87,60 @@
       setRemindText: function (str) {
         this.$emit('remindAction', str)
       },
+      getMaterialKind: function (code, brand) {
+        return this.$http.get('/productuser/match/getKind', {params: {cmpCode: code, brand: brand}})
+      },
+      startPublish: function (prodTitle) {
+        let inquiry = {}
+        let inquiryItem = {}
+        if (this.user.data.enterprise) {
+          inquiry.enUU = this.user.data.enterprise.uu
+        }
+        let date = new Date()
+        let endDate = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
+        inquiry.recorderUU = this.user.data.userUU
+        inquiry.code = 'MALL' + date.getTime()
+        inquiry.date = date
+        inquiry.recorder = this.user.data.userName
+        inquiry.endDate = endDate
+        inquiry.sourceapp = 'MALL'
+        inquiryItem.userUU = this.user.data.userUU
+        inquiryItem.source = 'MALL'
+        inquiryItem.userName = this.user.data.userName
+        inquiryItem.userTel = this.user.data.userTel
+        inquiryItem.needquantity = this.applyObj.amount
+        inquiryItem.inbrand = this.applyObj.brand
+        inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
+        inquiryItem.prodTitle = prodTitle || this.applyObj.prodTitle || '其他'
+        inquiryItem.date = date
+        inquiryItem.endDate = endDate
+        let inquiryItems = []
+        inquiryItems.push(inquiryItem)
+        inquiry.inquiryItems = inquiryItems
+        this.$http.post('/inquiry/buyer/save', inquiry)
+          .then(response => {
+            //              this.$message.success('发布成功')
+            this.setRemindText('发布成功')
+            //                this.showRemindBox = true
+            this.emptyForm()
+            //                this.validObj.deadline = true
+//              this.$emit('reloadAction')
+            this.cancel()
+          }, error => {
+            console.log(error)
+            //              this.$message.error('发布失败')
+            this.setRemindText('发布失败')
+          })
+      },
       goPublish: function () {
         if (this.checkAll()) {
-          let inquiry = {}
-          let inquiryItem = {}
-          if (this.user.data.enterprise) {
-            inquiry.enUU = this.user.data.enterprise.uu
-          }
-          let date = new Date()
-          let endDate = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
-          inquiry.recorderUU = this.user.data.userUU
-          inquiry.code = 'MALL' + date.getTime()
-          inquiry.date = date
-          inquiry.recorder = this.user.data.userName
-          inquiry.endDate = endDate
-          inquiry.sourceapp = 'MALL'
-          inquiryItem.userUU = this.user.data.userUU
-          inquiryItem.source = 'MALL'
-          inquiryItem.userName = this.user.data.userName
-          inquiryItem.userTel = this.user.data.userTel
-          inquiryItem.needquantity = this.applyObj.amount
-          inquiryItem.inbrand = this.applyObj.brand
-          inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
-          inquiryItem.prodTitle = this.applyObj.prodTitle
-          inquiryItem.date = date
-          inquiryItem.endDate = endDate
-          let inquiryItems = []
-          inquiryItems.push(inquiryItem)
-          inquiry.inquiryItems = inquiryItems
-          this.$http.post('/inquiry/buyer/save', inquiry)
-            .then(response => {
-              //              this.$message.success('发布成功')
-              this.setRemindText('发布成功')
-              //                this.showRemindBox = true
-              this.emptyForm()
-              //                this.validObj.deadline = true
-//              this.$emit('reloadAction')
-              this.cancel()
-            }, error => {
-              console.log(error)
-              //              this.$message.error('发布失败')
-              this.setRemindText('发布失败')
+          if (!this.applyObj.prodTitle || this.applyObj.prodTitle.length === 0) {
+            this.getMaterialKind(this.applyObj.code, this.applyObj.brand).then(response => {
+              this.startPublish(response.data && response.data.length ? response.data : '其他')
             })
+          } else {
+            this.startPublish()
+          }
         } else {
           if (!this.validObj.deadline) {
             this.setRemindText('截止日期不能为空')

+ 3 - 0
components/mobile/applyPurchase/SayPrice.vue

@@ -4,6 +4,9 @@
       <div class="mobile-modal-header">编辑报价<i class="icon-guanbi iconfont" @click="cancel"></i></div>
       <div class="say-price">
         <div class="base-info">
+          <div class="content-line">
+            类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+          </div>
           <div class="content-line">
             型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
           </div>

+ 6 - 0
components/mobile/applyPurchase/SayPriceInfo.vue

@@ -5,6 +5,9 @@
       <div class="say-price-info">
         <div v-if="isBuyer">
           <div class="base-info">
+            <div class="content-line">
+              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+            </div>
             <div class="content-line">
               型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
             </div>
@@ -68,6 +71,9 @@
         </div>
         <div v-if="!isBuyer">
           <div class="base-info">
+            <div class="content-line">
+              类目(产品名称):<span>{{purchaseDetail.prodTitle || '-'}}</span>
+            </div>
             <div class="content-line">
               型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
             </div>

+ 1 - 1
components/mobile/search/MainSearch.vue

@@ -23,7 +23,7 @@
       <div class="search-history" v-if="searchHistory && searchHistory.length > 0">
         <p>历史搜索<i class="iconfont icon-lajitong" @click="deleteHistory"></i></p>
         <ul>
-          <li v-for="item in searchHistory" @click="onSearch(item)">
+          <li v-for="item in searchHistory" @click="onSearch(item)" v-if="item.keyword && item.keyword.trim().length">
             <a>{{item.keyword}}</a>
           </li>
         </ul>

+ 24 - 16
components/searchStore/SearchTitle.vue

@@ -9,16 +9,16 @@
     </span>
     <div class="tab-filter" >
       <div class="fr">
-        <div :class="activeType == 0?'active':''" @click="defaultSearch"><a >综合排序</a></div>
+        <div :class="{'active': activeType == '0'}" @click="defaultSearch"><a >综合排序</a></div>
         <!--<div :class="activeType == 1?'active':''"><a >库存</a></div>-->
         <!--<div :class="activeType == 2?'active':''"><a >销量</a></div>-->
         <!--<div :class="activeType == 3?'active':''"><a >信用</a></div>-->
-        <div :class="activeType == 4?'active':''">
-          <select @change="onSelectTypeChange" class="form-control select-type select-adder">
-            <option value="">店铺类型</option>
-            <option value="">原厂</option>
-            <option value="">代理</option>
-            <option value="">经销</option>
+        <div :class="{'active': activeType > '0'}">
+          <select v-model="activeType" @change="onSelectTypeChange" class="form-control select-type select-adder">
+            <option value="0">店铺类型</option>
+            <option value="1">原厂</option>
+            <option value="2">代理</option>
+            <option value="3">经销</option>
             <!--<option value="">寄售</option>-->
           </select>
         </div>
@@ -39,11 +39,20 @@
     props: ['keyword'],
     data () {
       return {
-        activeType: 0,
+        activeType: '0',
         paramType: 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY-CONSIGNMENT',
         show: true
       }
     },
+    watch: {
+      '$route.query.w': {
+        handler: function (val) {
+          this.activeType = '0'
+          this.paramType = 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY-CONSIGNMENT'
+        },
+        immediate: false
+      }
+    },
     computed: {
       goodsCount () {
         if (this.$store.state.searchStore.searchStoreDetail.detail.data[0].stores) {
@@ -55,7 +64,7 @@
     },
     methods: {
       defaultSearch: function () {
-        this.activeType = 0
+        this.activeType = '0'
         this.paramType = 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY'
         this.$store.dispatch('searchStore/searchStoreDetail',
           {
@@ -65,15 +74,15 @@
             types: this.paramType,
             op: 'pageByType'})
       },
-      onSelectTypeChange: function (e) {
-        let type = e.target[e.target.selectedIndex].innerHTML
-        if (type === '原厂') {
+      onSelectTypeChange: function () {
+        let type = this.activeType
+        if (type === '1') {
           this.paramType = 'ORIGINAL_FACTORY'
-        } else if (type === '代理') {
+        } else if (type === '2') {
           this.paramType = 'AGENCY'
-        } else if (type === '经销') {
+        } else if (type === '3') {
           this.paramType = 'DISTRIBUTION'
-        } else if (type === '店铺类型') {
+        } else if (type === '0') {
           this.paramType = 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY'
         }
         this.$emit('typeAction', this.paramType)
@@ -84,7 +93,6 @@
             keyword: this.$route.query.w,
             types: this.paramType,
             op: 'pageByType'})
-        this.activeType = 4
       },
       showClick: function () {
         this.show = !this.show

+ 4 - 4
nuxt.config.js

@@ -6,10 +6,10 @@ const materialUrl = process.env.MATERIAL_URL || (isProdMode ? 'https://api-produ
 
 module.exports = {
   router: {
-    middleware: 'check-auth'
-    // scrollBehavior: function (to, from, savedPosition) {
-    //   return { x: 0, y: 0 }
-    // }
+    middleware: 'check-auth',
+    scrollBehavior: function (to, from, savedPosition) {
+      return { x: 0, y: 0 }
+    }
   },
   /*
   ** Headers of the page

+ 19 - 0
pages/search/_keyword.vue

@@ -49,7 +49,26 @@
       GoodList,
       DetailBrand
     },
+    watch: {
+      '$route.query.w': {
+        handler: function (val) {
+          this.key = val
+          this.reloadAll()
+        },
+        immediate: false
+      }
+    },
     methods: {
+      reloadAll: function () {
+        this.filter = {}
+        this.sorting = {}
+        this.paramJSON = {}
+        this.reloadList()
+        this.reloadKind()
+        this.reloadBrand()
+        this.reloadStoreType()
+        this.reloadCrname()
+      },
       reloadList: function () {
         if (this.sorting === {}) {
           this.sorting = {}

+ 13 - 0
pages/searchStore/_keyword.vue

@@ -19,12 +19,25 @@
         type: 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY'
       }
     },
+    watch: {
+      '$route.query.w': {
+        handler: function (val) {
+          this.key = val
+          this.reloadAll()
+        },
+        immediate: false
+      }
+    },
     fetch ({store, route}) {
       return Promise.all([
         store.dispatch('searchStore/searchStoreDetail', {page: 1, count: 8, keyword: route.query.w, types: 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY', op: 'pageByType'})
       ])
     },
     methods: {
+      reloadAll: function () {
+        this.types = 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY'
+        this.$store.dispatch('searchStore/searchStoreDetail', {page: 1, count: 8, keyword: this.key, types: 'AGENCY-DISTRIBUTION-ORIGINAL_FACTORY', op: 'pageByType'})
+      },
       showAction: function (show) {
         this.show = show
       },