|
@@ -0,0 +1,379 @@
|
|
|
+import dayjs from 'dayjs'
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 整理已存筛选数据,去除空数据
|
|
|
+ * 需要和 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('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (Array.isArray(industryText) && industryText.length) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '行业:',
|
|
|
+ text: industryText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (Array.isArray(AreaCityText) && AreaCityText.length) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '地区:',
|
|
|
+ text: AreaCityText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (priceText) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '金额:',
|
|
|
+ text: priceText
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (publishTimeText) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '时间:',
|
|
|
+ text: publishTimeText
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * searchGroup === '1' 表示为非超前项目
|
|
|
+ * searchGroup === '2' 表示为超前项目
|
|
|
+ * 如果此时信息类型为空。则显示其所有类型的文字,而非"全部"两个字
|
|
|
+ */
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Array.isArray(infoTypeText) && infoTypeText.length) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '信息类型:',
|
|
|
+ text: infoTypeText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ 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 (buyerClassText) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '采购单位类型:',
|
|
|
+ text: buyerClassText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (winnerConcatText) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '中标企业联系方式:',
|
|
|
+ text: winnerConcatText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (buyerConcatText) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '采购单位联系方式:',
|
|
|
+ text: buyerConcatText.join('/')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (notKey) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '排除词:',
|
|
|
+ text: notKey.split(',').join(' ')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (buyerList) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '采购单位:',
|
|
|
+ text: buyerList.split(',').join(' ')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (winnerList) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '中标企业:',
|
|
|
+ text: winnerList.split(',').join(' ')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (agencyList) {
|
|
|
+ formattedList.push({
|
|
|
+ label: '代理机构:',
|
|
|
+ text: agencyList.split(',').join(' ')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return formattedList
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 保存筛选条件
|
|
|
+ * 将组件初始化filter,格式成保存筛选条件接口需要数据格式
|
|
|
+ * 前端标准数据转接口中的数据
|
|
|
+ */
|
|
|
+export class FilterHistoryViewModel2AjaxModel {
|
|
|
+ static formatAll(map) {
|
|
|
+ // 搜索范围整理
|
|
|
+ const selectType = this.formatScope(map.selectType)
|
|
|
+ // 行业整理
|
|
|
+ const industry = this.formatIndustry(map.industry)
|
|
|
+ // 地区整理
|
|
|
+ // const { area, city } = this.formatAreaCity(map.area)
|
|
|
+ // 金额筛选整理
|
|
|
+ const price = this.formatPrice(map.price)
|
|
|
+ // 时间筛选整理
|
|
|
+ // const publishTime = this.formatTime(map.publishTime)
|
|
|
+ // 信息类型
|
|
|
+ const subtype = this.formatInfoType(map.subtype)
|
|
|
+ // 采购单位
|
|
|
+ const { buyerClass } = this.formatBuyerClass(map.buyerclass)
|
|
|
+ // 包含关系、多个关键词
|
|
|
+ const { additionalWords, wordsMode } = this.formatSelectMoreKey(map.selectMoreKey, map.additionalWords, map.wordsMode)
|
|
|
+
|
|
|
+ const formatted = {
|
|
|
+ searchvalue: map.input,
|
|
|
+ selectType,
|
|
|
+ industry,
|
|
|
+ minprice: map.minprice,
|
|
|
+ maxprice: map.maxprice,
|
|
|
+ publishtime: map.publishtime, // 发布时间
|
|
|
+ subtype, // 信息类型
|
|
|
+ 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, // 附件
|
|
|
+ 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, // 标讯搜索恢复数据可能要用到?
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删去undefined/null的项
|
|
|
+ for (const key in formatted) {
|
|
|
+ if (formatted[key] === '' || formatted[key] === undefined || formatted[key] === null) {
|
|
|
+ delete formatted[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return formatted
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索范围整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:[content, title ,ppa]
|
|
|
+ */
|
|
|
+ static formatScope(val = [], split = ',') {
|
|
|
+ if (!Array.isArray(val)) return ''
|
|
|
+ return val.join(split)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 行业整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:
|
|
|
+ * {
|
|
|
+ * 机械设备: ['工程机械', '车辆', '其他机械设备', '办公家具']
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ static formatIndustry(val = {}, split = ',') {
|
|
|
+ let industry = ''
|
|
|
+ if (!val || Object.keys(val).length === 0) return industry
|
|
|
+
|
|
|
+ const industryArr = []
|
|
|
+
|
|
|
+ for (const key in val) {
|
|
|
+ if (Array.isArray(val[key])) {
|
|
|
+ val[key].forEach((item) => {
|
|
|
+ industryArr.push(`${key}_${item}`)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ industry = industryArr.join(split)
|
|
|
+
|
|
|
+ return industry
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 三级地级市地区整理
|
|
|
+ * @param String area
|
|
|
+ * @param String city
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数area示例
|
|
|
+ * {
|
|
|
+ * 北京: {
|
|
|
+ * 朝阳区: [],
|
|
|
+ * 东城区: []
|
|
|
+ * },
|
|
|
+ * 河南: {
|
|
|
+ * 南阳市: [],
|
|
|
+ * 郑州: ['金水区'],
|
|
|
+ * 洛阳市: ['栾川县']
|
|
|
+ * },
|
|
|
+ * 澳门: {}
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ static formatAreaCity(p = {}, split = ',') {
|
|
|
+ return areaObjToSingle(p, split)
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 金额整理
|
|
|
+ * @returns String
|
|
|
+ */
|
|
|
+ static formatPrice(price = { start: '', end: '' }, split = '-') {
|
|
|
+ const { start, end } = price
|
|
|
+ if (start || end) {
|
|
|
+ return [start || '', end || ''].join(split)
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 时间整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数time: 时间选择器选择结果
|
|
|
+ * {
|
|
|
+ * start: '',
|
|
|
+ * end: '',
|
|
|
+ * exact: 'exact'
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * exact: 是否只输出精确结果
|
|
|
+ * split: 精确结果的分隔符
|
|
|
+ */
|
|
|
+ static formatTime(time, exact = false, split = '_') {
|
|
|
+ let sortedTime = ''
|
|
|
+ if (!time) return sortedTime
|
|
|
+ const { start, end } = time
|
|
|
+ if (exact || time.exact === 'exact') {
|
|
|
+ const startVal = start ? dayjs(start).unix() : ''
|
|
|
+ const endVal = end ? dayjs(end).unix() : ''
|
|
|
+ sortedTime = [startVal, endVal].join(split)
|
|
|
+ if (startVal || endVal) {
|
|
|
+ return [startVal, endVal].join(split)
|
|
|
+ } else {
|
|
|
+ return [].join(split)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sortedTime = time.exact || ''
|
|
|
+ }
|
|
|
+ return sortedTime
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 信息类型整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:{}
|
|
|
+ */
|
|
|
+ static formatInfoType(infoType, split = ',') {
|
|
|
+ let arr = []
|
|
|
+ if (!infoType) return arr.join(split)
|
|
|
+ for (const key in infoType) {
|
|
|
+ arr = arr.concat(infoType[key])
|
|
|
+ }
|
|
|
+ return arr.join(split)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采购单位类型整理
|
|
|
+ * @param String val
|
|
|
+ * @returns Object
|
|
|
+ *
|
|
|
+ * 参数val示例:{}
|
|
|
+ */
|
|
|
+ static formatBuyerClass(val, split = ',') {
|
|
|
+ let buyerClass = ''
|
|
|
+ if (!val || Object.keys(val).length === 0) return buyerClass
|
|
|
+
|
|
|
+ buyerClass = []
|
|
|
+
|
|
|
+ for (const key in val) {
|
|
|
+ if (Array.isArray(val[key])) {
|
|
|
+ val[key].forEach((item) => {
|
|
|
+ buyerClass.push(item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ buyerClass = buyerClass.join(split)
|
|
|
+
|
|
|
+ return buyerClass
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化包含关键词模式、包含关键词
|
|
|
+ */
|
|
|
+ static formatSelectMoreKey (selectMoreKey, additionalWords, wordsMode) {
|
|
|
+ let aWords = '' // 附加关键词筛选模式
|
|
|
+ let wMode = 0 // 附加关键词筛选模式
|
|
|
+ if(selectMoreKey) {
|
|
|
+ aWords = additionalWords ? additionalWords.join(',') : ''
|
|
|
+ wMode = Number(wordsMode)
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ additionalWords: aWords,
|
|
|
+ wordsMode: wMode
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|