import type { Recordable } from '@/types/global'

/**
 * 处理查询参数模糊查询
 * @param params
 * @param field
 */
export function queryParamsFilter(params: Recordable, field?: string[]) {
  const exclude = ['currentPage', 'pageSize', 'total', 'column', 'order', 'createTime'].concat(field || [])
  const p = Object.assign({}, params)

  if(p.createTime!=null&&p.createTime!="") {
    p.createTime_begin = p.createTime[0]
    p.createTime_end = p.createTime[1]
    p.createTime = null
  } else {
    p.createTime = null
  }
  // alert(JSON.stringify(p))

 

  // for (const key in params) {
  //   if (key === 'createTime' && p[key]?.length) {
  //     p['createTime_begin'] = p[key][0]
  //     p['createTime_end'] = p[key][1]
  //     delete p[key]
  //   } else if (!exclude.includes(key)) {
  //     p[key] = `*${p[key]}*`
  //   }
  // }

  return p
}
