Эх сурвалжийг харах

Merge branch 'dev/v1.0.53_yf' of jianyu/web into feature/v1.0.53

yangfeng 1 жил өмнө
parent
commit
7a9a7b5ad3

+ 13 - 1
apps/bigmember_pc/src/views/search/bidding/components/search-bid-header.vue

@@ -5,6 +5,7 @@ import KeywordTagsPc from '@/views/search/components/keyword-tags.vue'
 import CommonSingleChoice from '@/components/filter-items/CommonSingleChoice.vue'
 import { SearchBidModel } from '../model/index'
 import $bus from '@/utils/bus'
+import { useStore } from '@/store'
 
 const {
   isInApp,
@@ -19,7 +20,9 @@ const {
   onChangeTab,
   searchModelOptions,
   SearchTabsModel,
-  goWorkSpace
+  goWorkSpace,
+  clearHistoryQuery,
+  searchHistoryList
 } = SearchBidModel
 
 const { searchTabs } = SearchTabsModel
@@ -28,6 +31,7 @@ const that = getCurrentInstance().proxy
 
 function doSearch($event) {
   const firstSearch = !$event ? 'firstSearch' : undefined
+
   return doQuery({}, firstSearch)
 }
 // 跳转信息发布
@@ -68,6 +72,12 @@ function onSelectMoreKey () {
 const showNewPublish = computed(() => {
   return !isInBI.value && !isBidField
 })
+
+function onClearSearchHistory () {
+  if(!searchHistoryList.value || searchHistoryList.value.length === 0) return
+  clearHistoryQuery({ type: 1 })
+}
+
 </script>
 
 <template>
@@ -81,7 +91,9 @@ const showNewPublish = computed(() => {
       :show-wx-qr="!cooperateCode && !inBIPropertyIframe && !isBidField"
       :show-workspace-button="isLogin && !isInApp"
       :showTab="!inBIPropertyIframe"
+      :historyEnabled="true"
       @goWorkSpace="goWorkSpace"
+      @clearSearch="onClearSearchHistory"
       :immediateSearch="false"
     >
       <div class="flex flex-(row items-center)">

+ 21 - 2
apps/bigmember_pc/src/views/search/bidding/model/base.js

@@ -1,4 +1,4 @@
-import { computed, reactive, ref, toRefs, onMounted,onBeforeMount, onBeforeUnmount, getCurrentInstance } from 'vue'
+import { computed, reactive, ref, toRefs, onMounted,onBeforeMount, onBeforeUnmount, getCurrentInstance, provide } from 'vue'
 import { without, throttle } from 'lodash'
 import { useStore } from '@/store'
 import { useRoute, useRouter } from 'vue-router/composables'
@@ -38,6 +38,8 @@ import { dataAddActionsModel } from './modules/data-add-actions'
 import { beforeSearchModel } from './modules/before-search'
 // 潜在客户引流--市场分析报告&&超前项目推荐数据请求
 import { recommendCardModel } from './modules/recommend-card'
+// 搜索历史业务模型
+import useSearchHistoryModel from '@jy/data-models/modules/quick-search-history/model'
 
 export default function () {
   const that = getCurrentInstance().proxy
@@ -74,6 +76,18 @@ export default function () {
     return isOld
   })
 
+  // 获取搜索历史业务数据模型
+  const searchHistoryModel = useSearchHistoryModel({ type: 1 })
+  const { getHistoryQuery, clearHistoryQuery, searchHistoryList } = searchHistoryModel
+ 
+  // 标讯搜索历史列表
+  const bidHistoryList = computed(() => {
+    return searchHistoryList.value
+  })
+
+  // 跨组件通信 将历史搜索列表数据注入 在SearchHeader子组件中引用
+  provide('searchHistoryList', bidHistoryList)
+  
 
   // 是否在工作台内
   // 本地调试,可改为工作台内isInApp = ref(true),  isInWeb = ref(false)   提交记得改回!
@@ -681,8 +695,11 @@ export default function () {
       return
     }
     beforeSearchSomthing (pageNum)
+
     // Ajax请求
     return doRunQuery(getParams(params)).then((res) => {
+      // 搜索重新获取搜索历史
+      getHistoryQuery({ type: 1 })
       afterQueryAjax(res, searchType)
     })
   }
@@ -1558,6 +1575,8 @@ export default function () {
     doToggleSearchBlurMode,
     recommendCardCircleModel,
     getWhiteList,
-    storageConfig
+    storageConfig,
+    clearHistoryQuery,
+    searchHistoryList
   }
 }

+ 56 - 1
apps/bigmember_pc/src/views/search/components/SearchHeader.vue

@@ -7,11 +7,32 @@
       <div class="search-header-top">
         <SearchInput
           :placeholder="placeholder"
+          :historyEnabled="historyEnabled && Boolean(searchHistoryList.length || browseHistoryList.length)"
           :value="searchContent"
           @input="onInput"
           @onSearch="onSearch"
+          @focus="onFocus"
           clearable
         >
+          <div slot="preSearchContent"></div>
+          <div slot="history">
+            <!-- 历史搜索(标讯、企业、采购搜索关键词) -->
+            <SearchHistoryList
+              v-if="searchHistoryList.length"
+              :list="searchHistoryList"
+              @tag="onClickHistory"
+              @clear="onClearSearch"
+            >
+            </SearchHistoryList>
+            <!-- 历史浏览(企业、采购画像查看历史) -->
+            <BrowseHistoryList
+              v-if="browseHistoryList.length"
+              :list="browseHistoryList"
+              @select="onSelectBrowser"
+              @clear="onClearBrowse"
+            >
+            </BrowseHistoryList>
+          </div>
         </SearchInput>
         <slot></slot>
         <div
@@ -39,10 +60,23 @@
 <script>
 import SearchInput from '@/components/search-input/SearchInput.vue'
 import { tryCallHooks } from '@jianyu/easy-inject-qiankun'
+import SearchHistoryList from '@/components/history/SearchHistory.vue'
+import BrowseHistoryList from '@/components/history/BrowseHistory.vue'
+
 export default {
   name: 'SearchHeader',
   components: {
-    SearchInput
+    SearchInput,
+    SearchHistoryList,
+    BrowseHistoryList
+  },
+  inject: {
+    searchHistoryList: {
+      default: () => []
+    },
+    browseHistoryList: {
+      default: () => []
+    }
   },
   props: {
     searchContent: {
@@ -67,6 +101,11 @@ export default {
     needReplaceRouter: {
       type: Boolean,
       default: false
+    },
+    // 是否激活搜索历史
+    historyEnabled: {
+      type: Boolean,
+      default: false
     }
   },
   model: {
@@ -127,6 +166,22 @@ export default {
         "transform":"scale(0)",
         "transition":"transform 0.2s"
       })
+    },
+    onFocus(e) {
+      this.$emit('focus', e)
+    },
+    onClickHistory(item) {
+      this.onInput(item)
+      this.onSearch()
+    },
+    onClearSearch() {
+      this.$emit('clearSearch')
+    },
+    onSelectBrowser(data) {
+      this.$emit('select', data)
+    },
+    onClearBrowse() {
+      this.$emit('clearBrowse')
     }
   }
 }

+ 25 - 1
apps/bigmember_pc/src/views/search/components/search-header-card.vue

@@ -34,15 +34,34 @@ const props = defineProps({
   immediateSearch: {
     type: Boolean,
     default: true
+  },
+  // 是否展示搜索历史
+  historyEnabled: {
+    type: Boolean,
+    default: false  
   }
 })
 
-const emit = defineEmits(['goWorkSpace'])
+const emit = defineEmits(['goWorkSpace', 'clearSearch', 'clearBrowse', 'select'])
 
 function goWorkSpaceCustom() {
   emit('goWorkSpace')
 }
 
+function clearSearchHistory() {
+  emit('clearSearch')
+}
+
+function clearBrowseHistory() {
+  // 处理浏览历史
+  emit('clearBrowse')
+}
+
+function selectBrowse(data) {
+  // 点击浏览历史(企业、采购单位)
+  emit('select', data)
+}
+
 </script>
 
 <template>
@@ -68,9 +87,14 @@ function goWorkSpaceCustom() {
       :placeholder="placeholder"
       :searchContent="value"
       :show-wx-qr="showWxQr"
+      :historyEnabled="historyEnabled"
       @input="$emit('input', $event)"
       @search="$emit('search', $event)"
+      @focus="$emit('focus', $event)"
       :immediateSearch="immediateSearch"
+      @clearSearch="clearSearchHistory"
+      @clearBrowse="clearBrowseHistory"
+      @select="selectBrowse"
     >
       <div class="tab-switch" slot="tab-switch">
         <slot name="tab-switch-content"></slot>

+ 24 - 1
apps/bigmember_pc/src/views/search/ent/index.vue

@@ -19,8 +19,27 @@ const {
   searchListProps,
   doChangePageNum,
   doChangePageSize,
-  doChangeFilter
+  doChangeFilter,
+  clearHistoryQuery
 } = SearchEntModel
+
+// 跳转到企业画像详情页
+function onSelectEnt(data) {
+  const { id } = data
+  if (!id) return
+  window.open(`/swordfish/page_big_pc/free/loading/ent/${encodeURIComponent(id)}`)
+}
+
+// 清空企业搜索历史
+function onClearSearchHistory() {
+  clearHistoryQuery({ type: 2 })
+}
+
+// 清空企业画像浏览历史
+function onClearBrowseHistory() {
+  clearHistoryQuery({ type: 3 })
+}
+
 </script>
 <template>
   <div class="search-ent-page">
@@ -30,6 +49,10 @@ const {
         :tabs="searchTabs"
         placeholder="输入企业名称"
         @search="doSearch"
+        :historyEnabled="true"
+        @select="onSelectEnt"
+        @clearSearch="onClearSearchHistory"
+        @clearBrowse="onClearBrowseHistory"
       >
         <div>
           <span>筛选</span>

+ 26 - 3
apps/bigmember_pc/src/views/search/ent/model/base.js

@@ -1,6 +1,8 @@
-import { computed, reactive, ref } from 'vue'
+import { computed, reactive, ref, provide } from 'vue'
 import useQuickSearchModel from '@jy/data-models/modules/quick-search/model'
 import { filterState } from './modules/filter'
+// 搜索历史业务模型
+import useSearchHistoryModel from '@jy/data-models/modules/quick-search-history/model'
 
 export default function () {
   // 解构基础业务
@@ -8,6 +10,23 @@ export default function () {
     type: 'search-ent'
   })
 
+  // 获取搜索历史业务数据模型
+  const searchHistoryModel = useSearchHistoryModel({ type: '2,3'})
+  // 解构数据模型:获取历史方法、清除历史方法、保存画像浏览方法及搜索、浏览列表
+  const { getHistoryQuery, clearHistoryQuery, saveViewHistoryQuery, searchHistoryList, browseHistoryList } = searchHistoryModel
+ 
+  // 企业搜索历史列表
+  const entSearchHistoryList = computed(() => {
+    return searchHistoryList.value
+  })
+  // 企业浏览记录列表
+  const entBrowseHistoryList = computed(() => {
+    return browseHistoryList.value
+  })
+  // 跨组件通信 将历史搜索列表数据注入 在SearchHeader子组件中引用
+  provide('searchHistoryList', entSearchHistoryList)
+  provide('browseHistoryList', entBrowseHistoryList)
+
   const searchTabs = [
     {
       label: '企业搜索',
@@ -35,7 +54,10 @@ export default function () {
    * @param [params] - 可选值,默认会和 getParams(params) 返回值进行合并
    */
   function doQuery(params = {}) {
-    return doRunQuery(getParams(params))
+    return doRunQuery(getParams(params)).then(res => {
+      // 获取企业历史搜索、历史浏览记录
+      getHistoryQuery({ type: '2,3'})
+    })
   }
 
   function doSearch() {
@@ -127,6 +149,7 @@ export default function () {
     inputKeywordsState,
     doSearch,
     doChangePageNum,
-    doChangePageSize
+    doChangePageSize,
+    clearHistoryQuery
   }
 }

+ 23 - 1
apps/bigmember_pc/src/views/search/purchase/index.vue

@@ -19,8 +19,26 @@ const {
   searchListProps,
   doChangePageNum,
   doChangePageSize,
-  doChangeFilter
+  doChangeFilter,
+  clearHistoryQuery
 } = SearchPurchaseModel
+
+// 跳转到采购单位画像详情页
+function onSelectEnt(data) {
+  const { name } = data
+  window.open(`/swordfish/page_big_pc/free/loading/buyer/${encodeURIComponent(name)}`)
+}
+
+// 清空采购单位搜索历史
+function onClearSearchHistory() {
+  clearHistoryQuery({ type: 4 })
+}
+
+// 清空采购单位浏览历史
+function onClearBrowseHistory() {
+  clearHistoryQuery({ type: 5 })
+}
+
 </script>
 
 <template>
@@ -31,6 +49,10 @@ const {
         :tabs="searchTabs"
         placeholder="输入采购单位名称"
         @search="doSearch"
+        :historyEnabled="true"
+        @select="onSelectEnt"
+        @clearSearch="onClearSearchHistory"
+        @clearBrowse="onClearBrowseHistory"
       >
         <div>
           <span>筛选</span>

+ 25 - 3
apps/bigmember_pc/src/views/search/purchase/model/base.js

@@ -1,7 +1,9 @@
-import { computed, reactive, ref } from 'vue'
+import { computed, reactive, ref, provide } from 'vue'
 import useQuickSearchModel from '@jy/data-models/modules/quick-search/model'
 import { filterState } from './modules/filter'
 import { useStore } from '@/store'
+// 搜索历史业务模型
+import useSearchHistoryModel from '@jy/data-models/modules/quick-search-history/model'
 export default function () {
   // 解构基础业务
   const APIModel = useQuickSearchModel({
@@ -35,7 +37,10 @@ export default function () {
    * @param [params] - 可选值,默认会和 getParams(params) 返回值进行合并
    */
   function doQuery(params = {}) {
-    return doRunQuery(getParams(params))
+    return doRunQuery(getParams(params)).then(res => {
+      // 获取采购单位历史搜索、历史浏览记录
+      getHistoryQuery({ type: '4,5'})
+    })
   }
 
   function doSearch() {
@@ -96,6 +101,22 @@ export default function () {
     }
   }
 
+  // 获取搜索历史业务数据模型
+  const searchHistoryModel = useSearchHistoryModel({ type: '4,5'})
+  const { getHistoryQuery, clearHistoryQuery, saveViewHistoryQuery, searchHistoryList, browseHistoryList } = searchHistoryModel
+ 
+  // 采购单位搜索历史列表
+  const buyerSearchHistoryList = computed(() => {
+    return searchHistoryList.value
+  })
+  // 采购单位浏览记录列表
+  const buyerBrowseHistoryList = computed(() => {
+    return browseHistoryList.value
+  })
+  // 跨组件通信 将历史搜索列表数据注入 在SearchHeader子组件中引用
+  provide('searchHistoryList', buyerSearchHistoryList)
+  provide('browseHistoryList', buyerBrowseHistoryList)
+
   return {
     // 列表
     list,
@@ -108,6 +129,7 @@ export default function () {
     inputKeywordsState,
     doSearch,
     doChangePageNum,
-    doChangePageSize
+    doChangePageSize,
+    clearHistoryQuery
   }
 }

+ 16 - 11
data/data-models/modules/quick-search-history/plugins/base.js

@@ -2,7 +2,7 @@ import { ajaxGetSearchHistory, ajaxClearSearchHistory, ajaxSaveViewHistory  } fr
 
 class SearchHistoryBaseApi {
   constructor(config = {}) {
-    // 初始化需要将type值传进来(标讯搜索:1  企业搜索:2,3 采购单位搜索: 4,5)
+    // 初始化需要将type值传进来(标讯搜索:1  企业搜索:2,3 采购单位搜索: 4,5)必传
     this._getParams = config || (() => {})
     // 历史搜索列表
     this.searchHistoryList = []
@@ -15,13 +15,13 @@ class SearchHistoryBaseApi {
   }
 
   /**
-   * 统一查询 API 入口
-   * @param params - 请求参数
+   * 历史搜索、历史浏览查询 API 入口
+   * @param params - 请求参数(可传可不传,不传会从this._getParams中取 传了会合并)
    * @returns {Promise<{success: boolean, search: [], browse: []}>}
    */
 
   async runQuery(params) {
-    const query = Object.assign({}, params)
+    const query = Object.assign({}, params, this._getParams)
     const result = await this.ajaxQuery(query)
     if (result.success) {
       this.searchHistoryList = result.search
@@ -38,7 +38,7 @@ class SearchHistoryBaseApi {
     return ajaxGetSearchHistory(params).then((res) => {
       let success = res?.error_code === 0
       if (res?.data?.browse) {
-        // 格式化浏览历史数据(企业画像浏览记录跳转需要企业id, 存历史记录的时候保存格式为“企业名称_企业id”)
+        // 格式化浏览历史数据(企业画像浏览记录跳转需要企业id, 存历史记录的时候保存格式为“企业名称_企业id”, 取的时候要分割开)
         res.data.browse = res.data.browse.map((item) => {
           if (item.indexOf('_') > -1) {
             const [name, id] = item.split('_')
@@ -61,15 +61,17 @@ class SearchHistoryBaseApi {
     })
   }
 
-  // 清除搜索历史
+  /**
+   * 清除搜索历史
+   * @param params - 请求参数必传
+   */
   async ajaxClearQuery(params) {
     const query = Object.assign({}, params)
     return ajaxClearSearchHistory(query).then((res) => {
       let success = res?.error_code === 0
-
       const { type } = this._getParams
-      if (success && res.data) {
-        // 清除成功再次获取历史列表
+      if (success && res.data && type) {
+        // 清除成功更新取历史列表
         this.getHistoryQuery({ type: type })
       }
       return {
@@ -78,13 +80,16 @@ class SearchHistoryBaseApi {
     })
   }
 
-  // 保存企业浏览记录
+  /**
+   * 保存画像浏览记录
+   * @param params - {type: buyer-采购单位画像  ent-企业画像, name: 采购单位画像时传名称,企业画像传 名称_企业id}
+   */
   async ajaxSaveViewQuery(params) {
     const { type } = this._getParams
     const query = Object.assign({}, params)
     return ajaxSaveViewHistory(query).then((res) => {
       let success = res?.error_code === 0
-      if (success && res.data &&  type) {
+      if (success && res.data && type) {
         // 保存成功更新历史列表
         this.getHistoryQuery({ type: type })
       }