|
@@ -1,4 +1,4 @@
|
|
|
-import { computed, reactive, ref, toRefs, onMounted, getCurrentInstance } from 'vue'
|
|
|
+import { computed, reactive, ref, toRefs, onMounted, onBeforeUnmount, getCurrentInstance } from 'vue'
|
|
|
import { without, throttle } from 'lodash'
|
|
|
import { useStore } from '@/store'
|
|
|
import { useRoute, useRouter } from 'vue-router/composables'
|
|
@@ -29,6 +29,8 @@ import { joinBidActionsModel } from './modules/join-bid-actions'
|
|
|
import { dataEmployActionsModel } from './modules/data-employ-actions'
|
|
|
// 添加业务
|
|
|
import { dataAddActionsModel } from './modules/data-add-actions'
|
|
|
+// 进行搜索前业务判断
|
|
|
+import { beforeSearchModel } from './modules/before-search'
|
|
|
|
|
|
|
|
|
export default function () {
|
|
@@ -71,8 +73,6 @@ export default function () {
|
|
|
// 本地调试,可改为工作台内isInApp = ref(true), isInWeb = ref(false) 提交记得改回!
|
|
|
const isInApp = ref(InContainer.inApp)
|
|
|
const isInWeb = ref(InContainer.inWeb)
|
|
|
- console.log(8888888)
|
|
|
- console.log(isInWeb)
|
|
|
|
|
|
// 是否是渠道商
|
|
|
const cooperateCode = ref(false)
|
|
@@ -128,13 +128,19 @@ export default function () {
|
|
|
const {
|
|
|
inputKeywordsState,
|
|
|
searchModelOptions,
|
|
|
- getFormatAPIParams: getFormatOfInputKeywords
|
|
|
+ getFormatAPIParams: getFormatOfInputKeywords,
|
|
|
+ updateInputKeywordsState,
|
|
|
} = useSearchInputKeywordsModel()
|
|
|
const {
|
|
|
filterState,
|
|
|
getFormatAPIParams: getFormatOfFilter,
|
|
|
updateFilterBase
|
|
|
} = useSearchFilterModel({ inBIPropertyIframe })
|
|
|
+
|
|
|
+ const {
|
|
|
+ onTheWhiteList,
|
|
|
+ checkAndClearTextIncludesCommonWords
|
|
|
+ } = beforeSearchModel({ inputKeywordsState })
|
|
|
const {
|
|
|
limitActions,
|
|
|
headerActions,
|
|
@@ -144,8 +150,11 @@ export default function () {
|
|
|
disabledHeaderActions
|
|
|
} = useSearchListHeaderActionsModel()
|
|
|
|
|
|
- // 页面tab切换Model
|
|
|
+ $bus.$on('bidding:updateInputKeywords', function (obj) {
|
|
|
+ updateInputKeywordsState(obj)
|
|
|
+ })
|
|
|
|
|
|
+ // 页面tab切换Model
|
|
|
const SearchTabsModel = useSearchTabsModel({ showTabs2: !isInApp.value })
|
|
|
const { activeTab, doChangeTab } = SearchTabsModel
|
|
|
// tab切换处理
|
|
@@ -155,7 +164,7 @@ export default function () {
|
|
|
})
|
|
|
doChangeTab(item)
|
|
|
if(isInApp.value) {
|
|
|
- doQuery()
|
|
|
+ doQuery({}, 'tab')
|
|
|
} else {
|
|
|
if(item.link) {
|
|
|
location.replace(item.link)
|
|
@@ -493,12 +502,50 @@ export default function () {
|
|
|
)
|
|
|
return result
|
|
|
}
|
|
|
+
|
|
|
+ function beforeSearch () {
|
|
|
+ console.log('beforesearch----------')
|
|
|
+ // 如果在反爬白名单,则空搜索刷新搜索结果(即允许空搜索)
|
|
|
+ // 不在,则不允许空搜索(此处空搜索指的是主搜索框是否为空)
|
|
|
+ if (!onTheWhiteList.value) {
|
|
|
+ const searchKeywords = inputKeywordsState.value.input
|
|
|
+ const hasOneKey = (filterState.value.buyer?.length || filterState.value.winner?.length || filterState.value.agency?.length) > 0
|
|
|
+ // 切换三种筛选类型时候判断(切换tab时不弹窗)
|
|
|
+ // if (!searchKeywords && !hasOneKey) {
|
|
|
+ // if (from.indexOf('tab-') !== -1) {
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // 关键词去两边空格后为空
|
|
|
+ if (!searchKeywords && inputKeywordsState.value.additionalWords.length === 0) {
|
|
|
+ if (!hasOneKey) {
|
|
|
+ that.$toast('请先输入关键词')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 判断关键词中是否有通用词,并清空对应通用词的项
|
|
|
+ const hasCommonWords = checkAndClearTextIncludesCommonWords(searchKeywords)
|
|
|
+ if (hasCommonWords) {
|
|
|
+ that.$toast('请输入项目名称等关键词')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
/**
|
|
|
* 统一查询入口
|
|
|
* - 拦截 doQuery 进行一些返回值处理
|
|
|
* @param [params] - 可选值,默认会和 getParams(params) 返回值进行合并
|
|
|
*/
|
|
|
- function doQuery(params = {}) {
|
|
|
+ function doQuery(params = {}, searchType) {
|
|
|
+
|
|
|
+ if(!searchType) {
|
|
|
+ const bSearch = beforeSearch()
|
|
|
+ if(!bSearch) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
return doRunQuery(getParams(params)).then((res) => {
|
|
|
|
|
|
let matchKeys = []
|
|
@@ -559,7 +606,7 @@ export default function () {
|
|
|
showFilter.value = !showFilter.value
|
|
|
}
|
|
|
|
|
|
- // 组合好的筛选条件
|
|
|
+ // 组合好的组件格式的筛选条件
|
|
|
function packageFilter () {
|
|
|
const originParams = Object.assign(
|
|
|
{
|
|
@@ -620,7 +667,7 @@ export default function () {
|
|
|
sessionStorage.setItem('search:bidding:filter', JSON.stringify(originParams))
|
|
|
// window.location.replace('/page_workDesktop/work-bench/swordfish/page_big_pc/search/bidding?goback=true')
|
|
|
|
|
|
- window.location.replace(`/page_workDesktop/work-bench/page?link=${encodeURIComponent(goHref_ + 'goback=true')}`)
|
|
|
+ window.location.replace(`/page_workDesktop/work-bench/page?link=${encodeURIComponent(goHref_ + '?goback=true')}`)
|
|
|
}
|
|
|
// 监听路由事件
|
|
|
onMounted(() => {
|