|
@@ -1,152 +1,464 @@
|
|
|
import dayjs from 'dayjs'
|
|
|
-
|
|
|
+import { InfoTypeTransform } from './info-type-transform'
|
|
|
+import {
|
|
|
+ biddingSearchScope,
|
|
|
+ biddingSearchConcat,
|
|
|
+ wordsModeList,
|
|
|
+ searchModeList,
|
|
|
+ biddingSearchTime,
|
|
|
+ buyerclassListMapExp,
|
|
|
+ industryListMapExp
|
|
|
+} from '@/assets/js/selector'
|
|
|
+import { dateFormatter } from '@jy/util'
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 整理已存筛选数据,去除空数据
|
|
|
- * 需要和 FilterHistoryAjaxModel2ViewModel.formatAll 配合使用
|
|
|
+ * 接口中的数据转前端标准数据
|
|
|
*/
|
|
|
-export function filterHistoryNotEmptyFormat(formatted) {
|
|
|
- const {
|
|
|
- searchGroup,
|
|
|
- scopeText,
|
|
|
- industryText,
|
|
|
- AreaCityText,
|
|
|
- priceText,
|
|
|
- publishTimeText,
|
|
|
- buyerClassText,
|
|
|
- winnerConcatText,
|
|
|
- buyerConcatText,
|
|
|
- fileExists,
|
|
|
- notKey,
|
|
|
- buyerList,
|
|
|
- winnerList,
|
|
|
- agencyList
|
|
|
- } = formatted
|
|
|
- let { infoTypeText } = formatted
|
|
|
-
|
|
|
- const formattedList = []
|
|
|
- if (Array.isArray(scopeText) && scopeText.length) {
|
|
|
- formattedList.push({
|
|
|
- label: '搜索范围:',
|
|
|
- text: scopeText.join('/')
|
|
|
- })
|
|
|
+export class FilterHistoryAjaxModel2ViewModel {
|
|
|
+ static formatAll(map) {
|
|
|
+ // wordsMode
|
|
|
+ const { wordsMode, wordsModeText } = this.formatWordsMode(map.wordsMode)
|
|
|
+ // 精准匹配/模糊匹配
|
|
|
+ const { searchMode, searchModeText } = this.formatSearchMode(map.searchMode)
|
|
|
+ // 搜索范围整理
|
|
|
+ const { scope, scopeText } = this.formatScope(map.selectType)
|
|
|
+ // 行业整理
|
|
|
+ const { industry, industryText } = this.formatIndustry(map.industry)
|
|
|
+ // 地区整理
|
|
|
+ const regionMap = this.formatRegion(map.regionMap)
|
|
|
+ // 金额筛选整理
|
|
|
+ const price = this.formatPriceText(map.minprice, map.maxprice)
|
|
|
+ // 时间筛选整理
|
|
|
+ const { publishTime, publishTimeText } = this.formatTime(map.publishtime)
|
|
|
+ // 信息类型
|
|
|
+ const { infoType, infoTypeText } = this.formatInfoType(map.subtype)
|
|
|
+ // 采购单位
|
|
|
+ const { buyerClass, buyerClassText } = this.formatBuyerClass(map.buyerclass)
|
|
|
+ // 联系方式
|
|
|
+ const { basicData: buyerTel, basicDataText: buyerTelText } = this.formatContact(map.buyertel)
|
|
|
+ const { basicData: winnerTel, basicDataText: winnerTelText } = this.formatContact(map.winnertel)
|
|
|
+ // 附件
|
|
|
+ const fileExists = this.formatAttach(map.fileExists)
|
|
|
+
|
|
|
+ const formatted = {
|
|
|
+ keywords: map.searchvalue,
|
|
|
+ additionalWords: map.additionalWords,
|
|
|
+ wordsMode,
|
|
|
+ wordsModeText,
|
|
|
+ searchMode,
|
|
|
+ searchModeText,
|
|
|
+ searchGroup: map.searchGroup !== undefined ? String(map.searchGroup) : '0',
|
|
|
+ scope,
|
|
|
+ scopeText,
|
|
|
+ industry,
|
|
|
+ industryText,
|
|
|
+ regionMap,
|
|
|
+ price,
|
|
|
+ dateTime: publishTime, // 标讯搜索恢复数据可能要用到?
|
|
|
+ publishTime,
|
|
|
+ publishTimeText,
|
|
|
+ infoType,
|
|
|
+ infoTypeText,
|
|
|
+ buyerClass,
|
|
|
+ buyerClassText,
|
|
|
+ buyerTel,
|
|
|
+ buyerTelText,
|
|
|
+ winnerTel,
|
|
|
+ winnerTelText,
|
|
|
+ notkey: map.notkey,
|
|
|
+ buyer: map.buyer,
|
|
|
+ winner: map.winner,
|
|
|
+ agency: map.agency,
|
|
|
+ fileExists
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删去undefined/null的项
|
|
|
+ for (const key in formatted) {
|
|
|
+ if (!formatted[key]) {
|
|
|
+ delete formatted[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return formatted
|
|
|
}
|
|
|
- if (Array.isArray(industryText) && industryText.length) {
|
|
|
- formattedList.push({
|
|
|
- label: '行业:',
|
|
|
- text: industryText.join('/')
|
|
|
- })
|
|
|
+
|
|
|
+ static mapToList(map) {
|
|
|
+ let list = []
|
|
|
+ if (!map) return list
|
|
|
+ for (const key in map) {
|
|
|
+ if (Array.isArray(map[key])) {
|
|
|
+ list = list.concat(map[key])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list
|
|
|
}
|
|
|
- if (Array.isArray(AreaCityText) && AreaCityText.length) {
|
|
|
- formattedList.push({
|
|
|
- label: '地区:',
|
|
|
- text: AreaCityText.join('/')
|
|
|
- })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关键词匹配方式wordsModeList整理
|
|
|
+ * (输出包含文字描述和选择器使用的数据结构)
|
|
|
+ * @param String m '0'/'1'
|
|
|
+ * @returns Object
|
|
|
+ */
|
|
|
+ static formatWordsMode(m) {
|
|
|
+ const result = {
|
|
|
+ wordsMode: undefined,
|
|
|
+ wordsModeText: undefined
|
|
|
+ }
|
|
|
+ if (!m) {
|
|
|
+ m = '0'
|
|
|
+ }
|
|
|
+ m = String(m)
|
|
|
+ const target = wordsModeList.find((item) => m === item.key)
|
|
|
+ if (target) {
|
|
|
+ result.wordsMode = [target.key]
|
|
|
+ result.wordsModeText = target.label
|
|
|
+ }
|
|
|
+ return result
|
|
|
}
|
|
|
- if (priceText) {
|
|
|
- formattedList.push({
|
|
|
- label: '金额:',
|
|
|
- text: priceText
|
|
|
- })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索方式整理 精准匹配/模糊匹配
|
|
|
+ * @param String m '0'/'1'
|
|
|
+ * @returns Object
|
|
|
+ */
|
|
|
+ static formatSearchMode(m) {
|
|
|
+ const result = {
|
|
|
+ searchMode: undefined,
|
|
|
+ searchModeText: undefined
|
|
|
+ }
|
|
|
+ // m为空默认为0
|
|
|
+ if (!m) {
|
|
|
+ m = '0'
|
|
|
+ }
|
|
|
+ m = String(m)
|
|
|
+ const target = searchModeList.find((item) => m === item.key)
|
|
|
+ if (target) {
|
|
|
+ result.searchMode = [target.key]
|
|
|
+ result.searchModeText = target.label
|
|
|
+ }
|
|
|
+ return result
|
|
|
}
|
|
|
- if (publishTimeText) {
|
|
|
- formattedList.push({
|
|
|
- label: '时间:',
|
|
|
- text: publishTimeText
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索范围整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:'content,title,ppa'
|
|
|
+ */
|
|
|
+ static formatScope(val) {
|
|
|
+ const result = {
|
|
|
+ scope: undefined,
|
|
|
+ scopeText: undefined
|
|
|
+ }
|
|
|
+ if (!val) return result
|
|
|
+ const map = {}
|
|
|
+ biddingSearchScope.forEach((item) => {
|
|
|
+ map[item.key] = item.label
|
|
|
})
|
|
|
+ // 将字符转换为中文
|
|
|
+ const selectKeyArr = val.split(',')
|
|
|
+ const selectKeyTextArr = selectKeyArr
|
|
|
+ .map((key) => {
|
|
|
+ return map[key]
|
|
|
+ })
|
|
|
+ .filter((key) => !!key)
|
|
|
+
|
|
|
+ result.scope = selectKeyArr
|
|
|
+ result.scopeText = selectKeyTextArr ? selectKeyTextArr.toString().replace(/,/g, ",") : ''
|
|
|
+ return result
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * searchGroup === '1' 表示为非超前项目
|
|
|
- * searchGroup === '2' 表示为超前项目
|
|
|
- * 如果此时信息类型为空。则显示其所有类型的文字,而非"全部"两个字
|
|
|
+ * 行业整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:'机械设备_工程机械,机械设备_车辆,机械设备_其他机械设备,行政办公_通用办公设备,行政办公_办公家具'
|
|
|
*/
|
|
|
- const infoTypeAll =
|
|
|
- !infoTypeText || (Array.isArray(infoTypeText) && infoTypeText.length === 0)
|
|
|
- if (infoTypeAll) {
|
|
|
- if (searchGroup === '1') {
|
|
|
- // 非超前项目
|
|
|
- infoTypeText = infoTypeNotAdvancedList
|
|
|
- .map((i) => i.value)
|
|
|
- .filter((i) => !!i)
|
|
|
- } else if (searchGroup === '2') {
|
|
|
- // 超前项目
|
|
|
- infoTypeText = infoTypeAdvancedList
|
|
|
- .map((i) => {
|
|
|
- if (i && i.value && i.value.includes('拟建')) {
|
|
|
- return i.name
|
|
|
- } else {
|
|
|
- return i.value
|
|
|
- }
|
|
|
- })
|
|
|
- .filter((i) => !!i)
|
|
|
+ static formatIndustry(val) {
|
|
|
+ const result = {
|
|
|
+ industry: undefined,
|
|
|
+ industryText: undefined
|
|
|
}
|
|
|
- }
|
|
|
- if (Array.isArray(infoTypeText) && infoTypeText.length) {
|
|
|
- formattedList.push({
|
|
|
- label: '信息类型:',
|
|
|
- text: infoTypeText.join('/')
|
|
|
+ if (!val || val === '全部') return result
|
|
|
+
|
|
|
+ const industry = {}
|
|
|
+ let industryText = []
|
|
|
+
|
|
|
+ // 整理行业
|
|
|
+ val.split(',').forEach((v) => {
|
|
|
+ const vSplit = v.split('_')
|
|
|
+ const industryChildren = industry[vSplit[0]]
|
|
|
+ if (Array.isArray(industryChildren)) {
|
|
|
+ industryChildren.push(vSplit[1])
|
|
|
+ } else {
|
|
|
+ industry[vSplit[0]] = [vSplit[1]]
|
|
|
+ }
|
|
|
})
|
|
|
- }
|
|
|
- if (fileExists && Array.isArray(fileExists)) {
|
|
|
- // 附件选择全部时候,则不显示
|
|
|
- const fileState = fileExists.join('')
|
|
|
- if (fileState !== '0') {
|
|
|
- const textInfo = biddingSearchFileExists.find((item) => {
|
|
|
- return fileState === item.key
|
|
|
- })
|
|
|
- if (textInfo) {
|
|
|
- formattedList.push({
|
|
|
- label: '附件:',
|
|
|
- text: textInfo.label
|
|
|
- })
|
|
|
+ if (Object.keys(industry).length) {
|
|
|
+ result.industry = industry
|
|
|
+ }
|
|
|
+
|
|
|
+ // 整理行业text
|
|
|
+ // 统计完整行业数量
|
|
|
+ const calcChildrenCount = {}
|
|
|
+ for (const key in industryListMapExp) {
|
|
|
+ calcChildrenCount[key] = industryListMapExp[key].length
|
|
|
+ }
|
|
|
+ // 如果行业数据为全部,则只显示一级行业,否则需要显示二级行业
|
|
|
+ for (const key in industry) {
|
|
|
+ if (industry[key].length === calcChildrenCount[key]) {
|
|
|
+ industryText.push(key)
|
|
|
+ } else {
|
|
|
+ industryText = [...industryText, ...industry[key]]
|
|
|
}
|
|
|
}
|
|
|
+ if (industryText.length) {
|
|
|
+ result.industryText = industryText ? industryText.toString().replace(/,/g, ",") : ''
|
|
|
+ }
|
|
|
+ return result
|
|
|
}
|
|
|
- if (buyerClassText) {
|
|
|
- formattedList.push({
|
|
|
- label: '采购单位类型:',
|
|
|
- text: buyerClassText.join('/')
|
|
|
- })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 三级地区整理
|
|
|
+ * @params Object regionMap
|
|
|
+ * {
|
|
|
+ * 北京: {
|
|
|
+ * 朝阳区: [],
|
|
|
+ * 东城区: []
|
|
|
+ * },
|
|
|
+ * 河南: {
|
|
|
+ * 南阳市: [],
|
|
|
+ * 郑州: ['金水区'],
|
|
|
+ * 洛阳市: ['栾川县']
|
|
|
+ * },
|
|
|
+ * 澳门: {}
|
|
|
+ * }
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ */
|
|
|
+ static formatRegion (region) {
|
|
|
+ if (!region || Object.keys(region).length === 0) return '全国'
|
|
|
+ var arr = []
|
|
|
+ for (var povince in region) {
|
|
|
+ if (Object.keys(region[povince]).length === 0) {
|
|
|
+ arr.push(povince)
|
|
|
+ } else {
|
|
|
+ for (var city in region[povince]) {
|
|
|
+ if (region[povince][city].length === 0) {
|
|
|
+ arr.push(city)
|
|
|
+ } else {
|
|
|
+ arr.push(...region[povince][city])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr.toString().replace(/,/g, ",")
|
|
|
}
|
|
|
- if (winnerConcatText) {
|
|
|
- formattedList.push({
|
|
|
- label: '中标企业联系方式:',
|
|
|
- text: winnerConcatText.join('/')
|
|
|
- })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 价格区间处理
|
|
|
+ * @param start
|
|
|
+ * @param end
|
|
|
+ * @param unit
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
+ static formatPriceText(start, end, unit = '万元') {
|
|
|
+ let priceText = ''
|
|
|
+ if (start && end) {
|
|
|
+ priceText = `${start}-${end}${unit}`
|
|
|
+ } else if (start && !end) {
|
|
|
+ priceText = `${start}${unit}以上`
|
|
|
+ } else if (!start && end) {
|
|
|
+ priceText = `${end}${unit}以下`
|
|
|
+ }
|
|
|
+ return priceText
|
|
|
}
|
|
|
- if (buyerConcatText) {
|
|
|
- formattedList.push({
|
|
|
- label: '采购单位联系方式:',
|
|
|
- text: buyerConcatText.join('/')
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 时间整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:'1653321600_1654012800'
|
|
|
+ * 参数val示例:'fiveyear'
|
|
|
+ */
|
|
|
+ static formatTime(val) {
|
|
|
+ const result = {
|
|
|
+ publishTime: undefined,
|
|
|
+ publishTimeText: undefined
|
|
|
+ }
|
|
|
+ if (!val) return result
|
|
|
+ const map = {}
|
|
|
+ biddingSearchTime.forEach((item) => {
|
|
|
+ map[item.key] = item.label
|
|
|
})
|
|
|
+ const t = {
|
|
|
+ start: 0,
|
|
|
+ end: 0,
|
|
|
+ exact: 'exact'
|
|
|
+ }
|
|
|
+ // 如果是精确时间
|
|
|
+ if (val.includes('_')) {
|
|
|
+ const split = val.split('_')
|
|
|
+ const start = split[0] * 1000
|
|
|
+ const end = split[1] * 1000
|
|
|
+ const textArr = []
|
|
|
+ if (start && !isNaN(start)) {
|
|
|
+ t.start = start
|
|
|
+ textArr[0] = dateFormatter(start, 'yyyy/MM/dd')
|
|
|
+ }
|
|
|
+ if (end && !isNaN(end)) {
|
|
|
+ t.end = end
|
|
|
+ textArr[1] = dateFormatter(end, 'yyyy/MM/dd')
|
|
|
+ }
|
|
|
+
|
|
|
+ let publishTimeText = ''
|
|
|
+ if (textArr[0] && textArr[1]) {
|
|
|
+ publishTimeText = textArr.join('-')
|
|
|
+ } else if (textArr[0] && !textArr[1]) {
|
|
|
+ publishTimeText = `${textArr[0]}以后`
|
|
|
+ } else if (!textArr[0] && textArr[1]) {
|
|
|
+ publishTimeText = `${textArr[1]}以前`
|
|
|
+ }
|
|
|
+ // 计算text
|
|
|
+ result.publishTimeText = publishTimeText
|
|
|
+ } else {
|
|
|
+ t.exact = val
|
|
|
+ result.publishTimeText = map[val] || ''
|
|
|
+ }
|
|
|
+ result.publishTime = t
|
|
|
+ return result
|
|
|
}
|
|
|
- if (notKey) {
|
|
|
- formattedList.push({
|
|
|
- label: '排除词:',
|
|
|
- text: notKey.split(',').join(' ')
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 信息类型整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:'采购意向,中标,成交,废标,流标'
|
|
|
+ */
|
|
|
+ static formatInfoType(val) {
|
|
|
+ const result = {
|
|
|
+ infoType: undefined,
|
|
|
+ infoTypeText: undefined
|
|
|
+ }
|
|
|
+ if (!val || val === '全部') return result
|
|
|
+ const arr = val.split(',').map((v) => {
|
|
|
+ // 把<拟建>替换成<拟建项目>
|
|
|
+ if (v === '拟建') {
|
|
|
+ return '拟建项目'
|
|
|
+ } else {
|
|
|
+ return v
|
|
|
+ }
|
|
|
})
|
|
|
+ const obj = InfoTypeTransform.formatListToMap(arr)
|
|
|
+ result.infoType = InfoTypeTransform.mapToList(obj)
|
|
|
+
|
|
|
+ const map = InfoTypeTransform.listToMap(result.infoType)
|
|
|
+ result.infoTypeText = InfoTypeTransform.formatMapToList(map)
|
|
|
+ return {
|
|
|
+ infoType: result.infoType, // 恢复组件的数组内容
|
|
|
+ infoTypeText: result.infoTypeText ? result.infoTypeText.toString().replace(/,/g, ",") : ''// 文字
|
|
|
+ }
|
|
|
}
|
|
|
- if (buyerList) {
|
|
|
- formattedList.push({
|
|
|
- label: '采购单位:',
|
|
|
- text: buyerList.split(',').join(' ')
|
|
|
- })
|
|
|
+ /**
|
|
|
+ * 采购单位类型整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:'住建,传媒,建筑业,能源化工,批发零售,信息技术,运输物流,制造业,住宿餐饮'
|
|
|
+ */
|
|
|
+ static formatBuyerClass(val) {
|
|
|
+ const result = {
|
|
|
+ buyerClass: undefined,
|
|
|
+ buyerClassText: undefined
|
|
|
+ }
|
|
|
+ if (!val || val === '全部') return result
|
|
|
+ result.buyerClass = val.split(',')
|
|
|
+
|
|
|
+ // 逻辑和行业类似,如果二级全选,则展示一级分类文字,否则展示二级分类文字
|
|
|
+ // 1. 把选中的整理成原始数据结构
|
|
|
+ const keyList = []
|
|
|
+ const keyListMap = {}
|
|
|
+ for (const key in buyerclassListMapExp) {
|
|
|
+ keyList.push(key)
|
|
|
+ if (val.indexOf(key) !== -1) {
|
|
|
+ // 存在
|
|
|
+ if (Array.isArray(keyListMap[key])) {
|
|
|
+ keyListMap[key] = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Array.isArray(buyerclassListMapExp[key])) {
|
|
|
+ // 循环二级子项
|
|
|
+ buyerclassListMapExp[key].forEach((item) => {
|
|
|
+ if (val.indexOf(item) !== -1) {
|
|
|
+ // 存在
|
|
|
+ if (Array.isArray(keyListMap[key])) {
|
|
|
+ keyListMap[key].push(item)
|
|
|
+ } else {
|
|
|
+ keyListMap[key] = [item]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 判断是否某一项全选了
|
|
|
+ let buyerClassText = []
|
|
|
+ for (const key in keyListMap) {
|
|
|
+ if (keyListMap[key].length === buyerclassListMapExp[key].length) {
|
|
|
+ buyerClassText.push(key)
|
|
|
+ } else {
|
|
|
+ buyerClassText = [...buyerClassText, ...keyListMap[key]]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (buyerClassText.length) {
|
|
|
+ result.buyerClassText = buyerClassText ? buyerClassText.toString().replace(/,/g, ",") : ''
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ buyerClass: result.buyerClass,
|
|
|
+ buyerClassText: result.buyerClassText,
|
|
|
+ keyListMap: keyListMap
|
|
|
+ }
|
|
|
}
|
|
|
- if (winnerList) {
|
|
|
- formattedList.push({
|
|
|
- label: '中标企业:',
|
|
|
- text: winnerList.split(',').join(' ')
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理联系方式
|
|
|
+ * @param val
|
|
|
+ * @returns {{basicDataText: undefined, basicData: undefined}}
|
|
|
+ */
|
|
|
+ static formatContact(val = '') {
|
|
|
+ const result = {
|
|
|
+ basicData: undefined,
|
|
|
+ basicDataText: undefined
|
|
|
+ }
|
|
|
+ const map = {}
|
|
|
+ biddingSearchConcat.forEach((item) => {
|
|
|
+ map[item.key] = item.label
|
|
|
})
|
|
|
+
|
|
|
+ if (val) {
|
|
|
+ result.basicData = [val]
|
|
|
+ result.basicDataText = map[val]
|
|
|
+ }
|
|
|
+ return result
|
|
|
}
|
|
|
- if (agencyList) {
|
|
|
- formattedList.push({
|
|
|
- label: '代理机构:',
|
|
|
- text: agencyList.split(',').join(' ')
|
|
|
- })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理-附件
|
|
|
+ * @param val
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
+ static formatAttach (val) {
|
|
|
+ if (val == 1 || val == '1') {
|
|
|
+ return '有附件'
|
|
|
+ } else if (val == -1 || val == '-1') {
|
|
|
+ return '无附件'
|
|
|
+ } else {
|
|
|
+ return '全部'
|
|
|
+ }
|
|
|
}
|
|
|
- return formattedList
|
|
|
}
|
|
|
|
|
|
|
|
@@ -164,13 +476,13 @@ export class FilterHistoryViewModel2AjaxModel {
|
|
|
// 地区整理
|
|
|
// const { area, city } = this.formatAreaCity(map.area)
|
|
|
// 金额筛选整理
|
|
|
- const price = this.formatPrice(map.price)
|
|
|
+ const { minPrice, maxPrice } = this.formatPrice(map.price)
|
|
|
// 时间筛选整理
|
|
|
// const publishTime = this.formatTime(map.publishTime)
|
|
|
// 信息类型
|
|
|
const subtype = this.formatInfoType(map.subtype)
|
|
|
- // 采购单位
|
|
|
- const { buyerClass } = this.formatBuyerClass(map.buyerclass)
|
|
|
+ // 采购单位类型
|
|
|
+ const buyerClass = this.formatBuyerClass(map.buyerclass)
|
|
|
// 包含关系、多个关键词
|
|
|
const { additionalWords, wordsMode } = this.formatSelectMoreKey(map.selectMoreKey, map.additionalWords, map.wordsMode)
|
|
|
|
|
@@ -178,24 +490,24 @@ export class FilterHistoryViewModel2AjaxModel {
|
|
|
searchvalue: map.input,
|
|
|
selectType,
|
|
|
industry,
|
|
|
- minprice: map.minprice,
|
|
|
- maxprice: map.maxprice,
|
|
|
- publishtime: map.publishtime, // 发布时间
|
|
|
+ minprice: minPrice,
|
|
|
+ maxprice: maxPrice,
|
|
|
+ publishtime: map.publishTime, // 发布时间
|
|
|
subtype, // 信息类型
|
|
|
- buyerclass: buyerClass, // 采购单位
|
|
|
+ buyerclass: buyerClass, // 采购单位类型
|
|
|
buyertel: map.buyertel, // 采购单位联系方式
|
|
|
winnertel: map.winnertel, // 中标企业联系方式
|
|
|
notkey: map.notkey ? map.notkey.join(',') : '', // 排除词
|
|
|
buyer: map.buyer ? map.buyer.join(',') : '', // 采购单位
|
|
|
winner: map.winner ? map.winner.join(',') : '', // 中标企业
|
|
|
agency: map.agency ? map.agency.join(',') : '', // 招标代理机构
|
|
|
- fileExists: map.fileExists, // 附件
|
|
|
+ fileExists: map.fileExists.toString(), // 附件
|
|
|
regionMap: map.regionMap, // 地区
|
|
|
searchGroup: map.searchGroup, // 搜索分组:默认0:全部;1:招标采购公告;2:超前项目
|
|
|
searchMode: Number(map.searchMode), // 搜索模式:0:精准搜索;1:模糊搜索
|
|
|
wordsMode: wordsMode, // 搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
additionalWords: additionalWords, //关键词:附加关键词(副:五组,每组最多15个字符)
|
|
|
- dateTime: map.publishtime, // 标讯搜索恢复数据可能要用到?
|
|
|
+ dateTime: map.publishTime, // 标讯搜索恢复数据可能要用到?
|
|
|
}
|
|
|
|
|
|
// 删去undefined/null的项
|
|
@@ -276,12 +588,14 @@ export class FilterHistoryViewModel2AjaxModel {
|
|
|
* 金额整理
|
|
|
* @returns String
|
|
|
*/
|
|
|
- static formatPrice(price = { start: '', end: '' }, split = '-') {
|
|
|
- const { start, end } = price
|
|
|
- if (start || end) {
|
|
|
- return [start || '', end || ''].join(split)
|
|
|
- } else {
|
|
|
- return ''
|
|
|
+ static formatPrice(price, split = '-') {
|
|
|
+ let priceArr = []
|
|
|
+ if(price) {
|
|
|
+ priceArr = price.split(split)
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ minPrice: priceArr[0] || '',
|
|
|
+ maxPrice: priceArr[1] || '',
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -365,7 +679,7 @@ export class FilterHistoryViewModel2AjaxModel {
|
|
|
* 格式化包含关键词模式、包含关键词
|
|
|
*/
|
|
|
static formatSelectMoreKey (selectMoreKey, additionalWords, wordsMode) {
|
|
|
- let aWords = '' // 附加关键词筛选模式
|
|
|
+ let aWords = '' // 附加关键词
|
|
|
let wMode = 0 // 附加关键词筛选模式
|
|
|
if(selectMoreKey) {
|
|
|
aWords = additionalWords ? additionalWords.join(',') : ''
|
|
@@ -377,3 +691,48 @@ export class FilterHistoryViewModel2AjaxModel {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 三级地区对象转换成,单个area、city、district
|
|
|
+ */
|
|
|
+function areaObjToSingle(obj, split = ',') {
|
|
|
+ const map = {
|
|
|
+ area: '',
|
|
|
+ city: '',
|
|
|
+ district: ''
|
|
|
+ }
|
|
|
+ if (!obj) return map
|
|
|
+ const area = []
|
|
|
+ let city = []
|
|
|
+ let district = []
|
|
|
+ for (const key in obj) {
|
|
|
+ if (typeof obj[key] === 'object') {
|
|
|
+ if (Object.keys(obj[key]).length === 0) {
|
|
|
+ area.push(key)
|
|
|
+ } else {
|
|
|
+ // 城市项
|
|
|
+ const cityItem = obj[key]
|
|
|
+ for (const cKey in cityItem) {
|
|
|
+ // 区县项
|
|
|
+ const districtItem = cityItem[cKey]
|
|
|
+ if (Array.isArray(districtItem)) {
|
|
|
+ if (districtItem.length === 0) {
|
|
|
+ city.push(cKey)
|
|
|
+ } else {
|
|
|
+ const resetArr = districtItem.map((temp) => {
|
|
|
+ return cKey + '_' + temp
|
|
|
+ })
|
|
|
+ district = district.concat(resetArr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ area: area.join(split),
|
|
|
+ city: city.join(split),
|
|
|
+ district: district.join(split)
|
|
|
+ }
|
|
|
+}
|