Ver código fonte

feat:增加处理二级分类其他分类的函数

yangfeng 1 ano atrás
pai
commit
07788cbbe9

+ 20 - 8
apps/bigmember_pc/src/utils/format/search-bid-filter.js

@@ -562,12 +562,9 @@ export class FilterHistoryViewModel2AjaxModel {
    * {
    * {
    *    机械设备: ['工程机械', '车辆', '其他机械设备', '办公家具']
    *    机械设备: ['工程机械', '车辆', '其他机械设备', '办公家具']
    * }
    * }
-   * isApi:因该格式化函数在已存筛选地方有调用,因此为了区分调用需要加上isApi参数 意为仅在 提交查询的时候需要该参数
-   * 需求及后端接口订制:传参的时候需要把二级分类中的其他再生成一个“其它”当作参数传递到后端
-   * 数据归类有其他和其它,但在前端要求只展示其他
    * 
    * 
    */
    */
-  static formatIndustry(val = {}, split = ',', isApi = false) {
+  static formatIndustry(val = {}, split = ',') {
     let industry = ''
     let industry = ''
     if (!val || Object.keys(val).length === 0) return industry
     if (!val || Object.keys(val).length === 0) return industry
 
 
@@ -575,10 +572,6 @@ export class FilterHistoryViewModel2AjaxModel {
 
 
     for (const key in val) {
     for (const key in val) {
       if (Array.isArray(val[key])) {
       if (Array.isArray(val[key])) {
-        // 行业分类 其他还是展示其他筛选项。传参的时候需要把其他和其它都当作参数传递到后端
-        if (isApi && val[key].includes('其他')) {
-          val[key].push('其它')
-        }
         val[key].forEach((item) => {
         val[key].forEach((item) => {
           industryArr.push(`${key}_${item}`)
           industryArr.push(`${key}_${item}`)
         })
         })
@@ -1064,3 +1057,22 @@ export function infoTypeMapFormat (infoType = {}) {
   const resultType = InfoTypeTransform.formatMoreMapToList(infoType)
   const resultType = InfoTypeTransform.formatMoreMapToList(infoType)
   return resultType ? resultType.join(',') : ''
   return resultType ? resultType.join(',') : ''
 }
 }
+
+/**
+ * 处理筛选条件二级类(行业)其他, 查询参数有其他时,提交时需要再增加一个‘其它’
+ * '建筑工程,水利水电_其他,信息技术_其他,机械设备_其他设备'
+ */
+export const formatFilterApiOther = function(str) {
+  if (!str) return
+  const arr = str.split(',')
+  const newArr = arr.map(item => {
+    if(item.indexOf('_其他') > -1) {
+      const value = item.split('_')[1]
+      if (value ==='其他') {
+        item = `${item},${item.replace('其他', '其它')}`
+      }
+    }
+    return item
+  })
+  return newArr.toString()
+}