update: 添加Search特殊处理like的值

This commit is contained in:
xieyonghong 2023-01-17 14:46:38 +08:00
parent 69142425df
commit d1b28b2333
3 changed files with 25 additions and 1 deletions

View File

@ -222,6 +222,7 @@ const handleItemOptions = (option?: any[] | Function) => {
const columnChange = (value: string, isChange: boolean) => {
const item = columnOptionMap.get(value)
optionLoading.value = false
// valueundefined
termsModel.column = value
termsModel.termType = item.defaultTermType || getTermType(item.type)

View File

@ -172,6 +172,23 @@ const addUrlParams = () => {
urlParams.target = props.target
}
/**
* 处理termType为likenlike的值
* @param v
*/
const handleLikeValue = (v: string) => {
let _v = v
return _v.split('').reduce((pre: string, next: string) => {
let _next = next
if (next === '\\') {
_next = '\\\\'
} else if (next === '%') {
_next = '\\%'
}
return pre + _next
}, '')
}
/**
* 处理为外部使用
*/
@ -181,7 +198,8 @@ const handleParamsFormat = () => {
return {
terms: cloneParams.terms.map(item => {
if (item.terms) {
item.terms = item.terms.filter(iItem => iItem && iItem.value).map(iItem => {
item.terms = item.terms.filter(iItem => iItem && iItem.value)
.map(iItem => {
// handleValuerename
const _item = columnOptionMap.get(iItem.column)
if (_item.rename) {
@ -191,6 +209,10 @@ const handleParamsFormat = () => {
if (_item.handleValue && isFunction(_item.handleValue)) {
iItem.value = _item.handleValue(iItem.value, iItem)
}
if (['like','nlike'].includes(iItem.termType) && !!iItem.value) {
iItem.value = `%${handleLikeValue(iItem.value)}%`
}
return iItem
})
}

View File

@ -1,4 +1,5 @@
import { TOKEN_KEY } from '@/utils/variable'
import { Terms } from 'components/Search/types'
/**
*