|
@@ -1,224 +1,9 @@
|
|
|
-import { computed, reactive } from 'vue'
|
|
|
-import { without } from 'lodash'
|
|
|
-// API 业务模型
|
|
|
-import useQuickSearchModel from '@jy/data-models/modules/quick-search/model'
|
|
|
-// 扩展业务模型
|
|
|
-import { useSearchFilterModel } from './modules/filter'
|
|
|
-import { useSearchInputKeywordsModel } from './modules/filter-keywords'
|
|
|
-import { useSearchListHeaderActionsModel } from './modules/list-header-actions'
|
|
|
-import { useSearchTabsModel } from './modules/tabs'
|
|
|
-import { useStore } from '@/store'
|
|
|
+import useModel from './base'
|
|
|
|
|
|
-// 解构基础业务
|
|
|
-const APIModel = useQuickSearchModel({
|
|
|
- type: 'search-bid'
|
|
|
-})
|
|
|
-
|
|
|
-const {
|
|
|
- list,
|
|
|
- total,
|
|
|
- loading,
|
|
|
- finished,
|
|
|
- selectIds,
|
|
|
- listIds,
|
|
|
- searchResultCount,
|
|
|
- isSelectSomeCheckbox,
|
|
|
- selectCheckboxCount,
|
|
|
- isSelectListAllCheckbox,
|
|
|
- doToggleItemSelection,
|
|
|
- doToggleListSelection,
|
|
|
- doClearAllSelection,
|
|
|
- doQuery: doRunQuery
|
|
|
-} = APIModel
|
|
|
-
|
|
|
-const {
|
|
|
- inputKeywordsState,
|
|
|
- searchModelOptions,
|
|
|
- getFormatAPIParams: getFormatOfInputKeywords
|
|
|
-} = useSearchInputKeywordsModel()
|
|
|
-const { filterState, getFormatAPIParams: getFormatOfFilter } =
|
|
|
- useSearchFilterModel()
|
|
|
-const {
|
|
|
- headerActions,
|
|
|
- listItemStyleType,
|
|
|
- activeItemStyleType,
|
|
|
- activeHeaderActions
|
|
|
-} = useSearchListHeaderActionsModel()
|
|
|
-const SearchTabsModel = useSearchTabsModel()
|
|
|
-
|
|
|
-// 列表状态
|
|
|
-const listState = reactive({
|
|
|
- finished,
|
|
|
- loading,
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 5,
|
|
|
- total
|
|
|
-})
|
|
|
-
|
|
|
-// 当前展示的列表
|
|
|
-const activeList = computed(() => {
|
|
|
- return list.value.map((v) => {
|
|
|
- v.id = v._id
|
|
|
- v.checked = selectIds.value.includes(v.id)
|
|
|
- return v
|
|
|
- })
|
|
|
-})
|
|
|
-
|
|
|
-// search-list 组件所需参数
|
|
|
-const searchListProps = computed(() => {
|
|
|
- return {
|
|
|
- isSelectAllCheckbox: isSelectListAllCheckbox.value,
|
|
|
- isSelectSomeCheckbox: isSelectSomeCheckbox.value,
|
|
|
- selectCheckboxCount: selectCheckboxCount.value,
|
|
|
- searchResultCount: searchResultCount.value,
|
|
|
- headerActions: headerActions.value,
|
|
|
- list: activeList.value,
|
|
|
- listState: listState
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
-/**
|
|
|
- * 切换列表展示风格
|
|
|
- * @param type - 可选风格 ['refined-list', 'detailed-list', 'table']
|
|
|
- */
|
|
|
-function doChangeItemStyleType(type) {
|
|
|
- const styleTypes = ['refined-list', 'detailed-list', 'table']
|
|
|
- if (!styleTypes.includes(type)) {
|
|
|
- return console.warn('Not find style type!')
|
|
|
- }
|
|
|
- listItemStyleType.value = type
|
|
|
- activeHeaderActions.value = without(activeHeaderActions.value, ...styleTypes)
|
|
|
- activeHeaderActions.value.push(type)
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 列表顶部按钮操作事件统一入口
|
|
|
- * @param item - 按钮原型
|
|
|
- * @param item.key - 按钮标识
|
|
|
- */
|
|
|
-function doListHeaderAction(item) {
|
|
|
- const { key } = item
|
|
|
- switch (key) {
|
|
|
- case 'refined-list': {
|
|
|
- doChangeItemStyleType(key)
|
|
|
- break
|
|
|
- }
|
|
|
- case 'detailed-list': {
|
|
|
- doChangeItemStyleType(key)
|
|
|
- break
|
|
|
- }
|
|
|
- case 'table': {
|
|
|
- doChangeItemStyleType(key)
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 全选复选框事件
|
|
|
-function doChangeAllSelect(type) {
|
|
|
- doToggleListSelection(type)
|
|
|
-}
|
|
|
-
|
|
|
-// 单个复选框事件
|
|
|
-function doChangeSelect(item) {
|
|
|
- doToggleItemSelection(item.id)
|
|
|
+let SearchBidModel = {}
|
|
|
+function useSearchBidModel() {
|
|
|
+ SearchBidModel = useModel()
|
|
|
+ return SearchBidModel
|
|
|
}
|
|
|
|
|
|
-// 分页事件
|
|
|
-function doChangePageNum(page) {
|
|
|
- listState.pageNum = page
|
|
|
- doQuery()
|
|
|
-}
|
|
|
-
|
|
|
-// 分页大小事件
|
|
|
-function doChangePageSize(size) {
|
|
|
- listState.pageSize = size
|
|
|
- listState.pageNum = 1
|
|
|
- doQuery()
|
|
|
-}
|
|
|
-
|
|
|
-// 获取 store getters
|
|
|
-const userType = computed(() => {
|
|
|
- return useStore().getters['user/userType']
|
|
|
-})
|
|
|
-
|
|
|
-/**
|
|
|
- * 格式化请求参数
|
|
|
- * @param [params] - 可选值,部分情况会提供,默认会和该函数返回值进行合并
|
|
|
- */
|
|
|
-
|
|
|
-function getParams(params = {}) {
|
|
|
- // 完整参数参考
|
|
|
- const fullParams = {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 50,
|
|
|
- reqType: '',
|
|
|
- keyWords: '',
|
|
|
- province: '',
|
|
|
- city: '',
|
|
|
- district: '',
|
|
|
- subtype: '',
|
|
|
- publishTime: '1682319144-1713941544',
|
|
|
- searchGroup: 0,
|
|
|
- searchMode: 0,
|
|
|
- wordsMode: 0,
|
|
|
- selectType: 'title,content',
|
|
|
- price: '',
|
|
|
- industry: '',
|
|
|
- buyerClass: '',
|
|
|
- winnerTel: '',
|
|
|
- buyerTel: '',
|
|
|
- exclusionWords: '',
|
|
|
- buyer: '',
|
|
|
- winner: '',
|
|
|
- agency: '',
|
|
|
- fileExists: '0',
|
|
|
- splitKeywords: ''
|
|
|
- }
|
|
|
- // 合并所有模型的搜索筛选项
|
|
|
- const result = Object.assign(
|
|
|
- {
|
|
|
- reqType: 'lastNews',
|
|
|
- pageNum: listState.pageNum,
|
|
|
- pageSize: listState.pageSize,
|
|
|
- // 该接口与用户身份有关
|
|
|
- _expand: {
|
|
|
- type: userType.value
|
|
|
- }
|
|
|
- },
|
|
|
- getFormatOfInputKeywords(),
|
|
|
- getFormatOfFilter(),
|
|
|
- params
|
|
|
- )
|
|
|
- return result
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 统一查询入口
|
|
|
- * - 拦截 doQuery 进行一些返回值处理
|
|
|
- * @param [params] - 可选值,默认会和 getParams(params) 返回值进行合并
|
|
|
- */
|
|
|
-function doQuery(params = {}) {
|
|
|
- return doRunQuery(getParams(params)).then((res) => {
|
|
|
- // 用于搜索关键词高亮
|
|
|
- inputKeywordsState.value.matchKeys = res.origin?.heightWords?.split(
|
|
|
- ' '
|
|
|
- ) || [inputKeywordsState.value.input]
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-export default {
|
|
|
- searchModelOptions,
|
|
|
- searchListProps,
|
|
|
- SearchTabsModel,
|
|
|
- inputKeywordsState,
|
|
|
- filterState,
|
|
|
- listState,
|
|
|
- activeItemStyleType,
|
|
|
- doQuery,
|
|
|
- doListHeaderAction,
|
|
|
- doChangeAllSelect,
|
|
|
- doChangeSelect,
|
|
|
- doChangePageNum,
|
|
|
- doChangePageSize
|
|
|
-}
|
|
|
+export { useSearchBidModel, SearchBidModel }
|