|
@@ -7,30 +7,47 @@
|
|
|
@click="goPage"
|
|
|
></association-list>
|
|
|
<history-list
|
|
|
- v-show="type === 'history' && isLogin"
|
|
|
+ class="content-module"
|
|
|
+ v-if="showHistoryList"
|
|
|
:list="companySearchHistory"
|
|
|
- @click="goPage"
|
|
|
- @delete="deleteList"
|
|
|
+ @click="goSearch"
|
|
|
+ @delete="deleteList('2')"
|
|
|
></history-list>
|
|
|
+ <div class="divide-line" v-show="showBrowseList && showHistoryList"></div>
|
|
|
+ <history-browse-list
|
|
|
+ v-show="showBrowseList"
|
|
|
+ :list="companyBrowseHistory"
|
|
|
+ :keys="getKeys"
|
|
|
+ searchType="company"
|
|
|
+ @click="goBrowseClick"
|
|
|
+ @delete="deleteList('3')"
|
|
|
+ ></history-browse-list>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { ajaxGetCompanyAssociation } from '@/api/modules'
|
|
|
import AssociationList from '@/components/search/AssociationList'
|
|
|
+import HistoryBrowseList from '@/components/search/HistoryBrowseList'
|
|
|
import { HistoryList } from '@/ui'
|
|
|
import { debounce } from 'lodash'
|
|
|
import { mapActions, mapGetters } from 'vuex'
|
|
|
import { openAppOrWxPage } from '@/utils'
|
|
|
import { LINKS } from '@/data'
|
|
|
import { mixinPoints } from '@/utils/mixins/modules/points'
|
|
|
+// 搜索历史业务模型
|
|
|
+import useSearchHistoryModel from '@jy/data-models/modules/quick-search-history/model'
|
|
|
+// 解构搜索历史业务数据模型
|
|
|
+const searchHistoryModel = useSearchHistoryModel()
|
|
|
+const { getHistoryQuery, clearHistoryQuery, saveViewHistoryQuery } = searchHistoryModel
|
|
|
|
|
|
export default {
|
|
|
name: 'SearchMiddleCompany',
|
|
|
mixins: [mixinPoints],
|
|
|
components: {
|
|
|
[AssociationList.name]: AssociationList,
|
|
|
- [HistoryList.name]: HistoryList
|
|
|
+ [HistoryList.name]: HistoryList,
|
|
|
+ [HistoryBrowseList.name]: HistoryBrowseList
|
|
|
},
|
|
|
inject: {
|
|
|
topSearch: {
|
|
@@ -41,15 +58,23 @@ export default {
|
|
|
return {
|
|
|
cacheSearch: '',
|
|
|
type: 'history',
|
|
|
- list: []
|
|
|
+ list: [],
|
|
|
+ companySearchHistory: [],
|
|
|
+ companyBrowseHistory: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapGetters('user', ['isNewBusiness', 'isBusiness', 'isLogin']),
|
|
|
- ...mapGetters('search', ['companySearchHistory']),
|
|
|
+ // ...mapGetters('search', ['companySearchHistory']),
|
|
|
getKeys() {
|
|
|
return this.topSearch.input.split(' ').filter((v) => v.trim())
|
|
|
- }
|
|
|
+ },
|
|
|
+ showHistoryList() {
|
|
|
+ return this.type === 'history' && this.companySearchHistory.length && this.isLogin
|
|
|
+ },
|
|
|
+ showBrowseList() {
|
|
|
+ return this.type === 'history' && this.companyBrowseHistory.length && this.isLogin
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
this.input()
|
|
@@ -57,8 +82,20 @@ export default {
|
|
|
activated() {
|
|
|
this.input()
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getHistoryInfo()
|
|
|
+ },
|
|
|
methods: {
|
|
|
...mapActions('search', ['removeHistory', 'setHistory']),
|
|
|
+ // 历史搜索、历史浏览
|
|
|
+ getHistoryInfo() {
|
|
|
+ getHistoryQuery({ type: '2,3' }).then((res) => {
|
|
|
+ if (res.success === true) {
|
|
|
+ this.companySearchHistory = res?.search || []
|
|
|
+ this.companyBrowseHistory = res?.browse || []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
clear() {
|
|
|
this.type = 'history'
|
|
|
this.cacheSearch = ''
|
|
@@ -75,10 +112,25 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- deleteList() {
|
|
|
- this.removeHistory({
|
|
|
- type: 'company'
|
|
|
- })
|
|
|
+ deleteList(data) {
|
|
|
+ const historyTypeMap = {
|
|
|
+ 2: 'companySearchHistory',
|
|
|
+ 3: 'companyBrowseHistory'
|
|
|
+ };
|
|
|
+ clearHistoryQuery({ type: data })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ const historyProperty = historyTypeMap[data]
|
|
|
+ if (historyProperty) {
|
|
|
+ this[historyProperty] = [];
|
|
|
+ } else {
|
|
|
+ console.warn(`未知的数据类型: ${data}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error(`清除历史记录失败: ${error}`);
|
|
|
+ })
|
|
|
},
|
|
|
submit() {
|
|
|
// if (!this.isLogin) {
|
|
@@ -98,11 +150,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
goPage(data) {
|
|
|
- // 历史记录新增
|
|
|
- this.setHistory({
|
|
|
- type: 'company',
|
|
|
- item: data
|
|
|
- })
|
|
|
// 缓存定位值用于产品落地页
|
|
|
sessionStorage.setItem(
|
|
|
'landinfo',
|
|
@@ -111,15 +158,12 @@ export default {
|
|
|
landname: data.label
|
|
|
})
|
|
|
)
|
|
|
- // 未登录跳至登录页将目标地址作为参数传给登录页
|
|
|
- // if (!this.isLogin) {
|
|
|
- // const url = `/jyapp/big/page/ent_portrait?eId=${data?.entId || data?.id}`
|
|
|
- // return openLinkOfOther(LINKS.APP登录页.app, {
|
|
|
- // query: {
|
|
|
- // url: url
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
+ saveViewHistoryQuery({
|
|
|
+ type: 'ent',
|
|
|
+ name: data?.name + '_' + data?.entId || data?.id,
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(res, 'res')
|
|
|
+ })
|
|
|
openAppOrWxPage(LINKS.企业画像页面, {
|
|
|
query: {
|
|
|
eId: data?.entId || data?.id,
|
|
@@ -127,6 +171,26 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ goBrowseClick(data) {
|
|
|
+ if (data) {
|
|
|
+ openAppOrWxPage(LINKS.企业画像页面, {
|
|
|
+ query: {
|
|
|
+ eId: data.eId,
|
|
|
+ ...this.fromPointTask
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goSearch(data) {
|
|
|
+ const keyword = data.label || ''
|
|
|
+ this.syncInput(keyword)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.submit()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ syncInput(text = '') {
|
|
|
+ this.topSearch.input = text
|
|
|
+ },
|
|
|
loadList: debounce(function () {
|
|
|
this.clear()
|
|
|
this.cacheSearch = '' + this.topSearch.input
|
|
@@ -158,5 +222,10 @@ export default {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.page-search-company {
|
|
|
+ .divide-line{
|
|
|
+ width: 100%;
|
|
|
+ height: 12px;
|
|
|
+ background: #F7F9FA;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|