fix: 修复搜索组件在页面刷新后搜索条件是布尔类型时页面不显示中文问题

1、优化获取url中搜索条件的算法
This commit is contained in:
“怀磊”
2022-02-14 17:21:08 +08:00
committed by Jiangjie.Bai
parent 542e34208e
commit 375c6bf44b

View File

@@ -151,32 +151,39 @@ export default {
// this.$nextTick(() => this.$emit('tagSearch', this.filterMaps)) // this.$nextTick(() => this.$emit('tagSearch', this.filterMaps))
}, },
methods: { methods: {
// 判断url中的查询条件 // 获取url中的查询条件,判断是不是包含在当前查询条件里
checkInTableColumns() { checkInTableColumns() {
const routeQuery = this.getUrlQuery ? this.$route?.query : {} const routeQuery = this.getUrlQuery ? this.$route?.query : {}
const routeQueryKeys = Object.keys(routeQuery) const routeQueryKeys = Object.keys(routeQuery)
const routeQueryKeysLength = routeQueryKeys.length
const keys = {} const keys = {}
if (routeQueryKeys.length < 1) return keys if (routeQueryKeysLength < 1) return keys
if (routeQueryKeys.length > 0) { if (routeQueryKeysLength > 0) {
for (let i = 0; i < routeQueryKeys.length; i++) { for (let i = 0; i < routeQueryKeysLength; i++) {
const key = routeQueryKeys[i] const key = routeQueryKeys[i]
const valueDecode = decodeURI(routeQuery[key]) let valueDecode = decodeURI(routeQuery[key])
const isSearch = key !== 'search' const isSearch = key !== 'search'
for (let k = 0, len = this.options.length; k < len; k++) { const curOptions = this.options || []
const cur = this.options[k] for (let k = 0, len = curOptions.length; k < len; k++) {
const cur = curOptions[k]
if (cur?.type === 'boolean') {
valueDecode = !!valueDecode
}
if (key === cur.value || !isSearch) { if (key === cur.value || !isSearch) {
const curChildren = cur.children || [] const curChildren = cur.children || []
keys[key] = { keys[key] = {
...cur,
key, key,
label: isSearch ? cur.label : '', label: isSearch ? cur.label : '',
value: valueDecode value: valueDecode
} }
if (isSearch && curChildren.length > 0) { if (isSearch && curChildren.length > 0) {
curChildren.forEach(item => { for (const item of curChildren) {
if (valueDecode === item.value) { if (valueDecode === item.value) {
keys[key].valueLabel = item.label keys[key].valueLabel = item.label
break
} }
}) }
} }
} }
} }