fix: 修复实体列表切换页码导致参数q为空的问题
This commit is contained in:
@@ -471,7 +471,9 @@ export default {
|
|||||||
const errorList = parser.validateMeta(this.metaList)
|
const errorList = parser.validateMeta(this.metaList)
|
||||||
if (_.isEmpty(errorList)) {
|
if (_.isEmpty(errorList)) {
|
||||||
this.reloadUrl({ mode: 'text' })
|
this.reloadUrl({ mode: 'text' })
|
||||||
this.$emit('changeMode', 'text', handleMetaListToStr(this.metaList).str2)
|
const strObj = handleMetaListToStr(this.metaList)
|
||||||
|
const str2 = strObj.str2 ? strObj.str2 : strObj
|
||||||
|
this.$emit('changeMode', 'text', str2)
|
||||||
} else {
|
} else {
|
||||||
this.reloadUrl({ mode: 'text' })
|
this.reloadUrl({ mode: 'text' })
|
||||||
this.$emit('changeMode', 'text', { metaList: [], str: '' })
|
this.$emit('changeMode', 'text', { metaList: [], str: '' })
|
||||||
|
|||||||
@@ -364,6 +364,14 @@ export default {
|
|||||||
this.metaList = []
|
this.metaList = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 参数q,避免切换页码时,地址栏参数q为空
|
||||||
|
let urlQ = ''
|
||||||
|
if (param.str) {
|
||||||
|
urlQ = encodeURI(param.str)
|
||||||
|
} else if (this.q) {
|
||||||
|
urlQ = encodeURI(this.q)
|
||||||
|
}
|
||||||
|
|
||||||
// 在非列表模式下选择tag模式,在地址栏输入内容时将mode添加到地址栏
|
// 在非列表模式下选择tag模式,在地址栏输入内容时将mode添加到地址栏
|
||||||
const mode = this.$route.query.mode || 'text'
|
const mode = this.$route.query.mode || 'text'
|
||||||
if (this.pageObj.resetPageNo && !this.initFlag) {
|
if (this.pageObj.resetPageNo && !this.initFlag) {
|
||||||
@@ -374,7 +382,7 @@ export default {
|
|||||||
|
|
||||||
this.reloadUrl({
|
this.reloadUrl({
|
||||||
listMode: this.listMode,
|
listMode: this.listMode,
|
||||||
q: param.str ? encodeURI(param.str) : '',
|
q: urlQ,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
pageNo: this.pageObj.pageNo,
|
pageNo: this.pageObj.pageNo,
|
||||||
pageSize: this.pageObj.pageSize
|
pageSize: this.pageObj.pageSize
|
||||||
@@ -386,7 +394,7 @@ export default {
|
|||||||
path: '/entityExplorer',
|
path: '/entityExplorer',
|
||||||
query: {
|
query: {
|
||||||
listMode: this.listMode,
|
listMode: this.listMode,
|
||||||
q: param.str ? encodeURI(param.str) : '',
|
q: urlQ,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
range: this.timeFilter.dateRangeValue,
|
range: this.timeFilter.dateRangeValue,
|
||||||
pageNo: this.pageObj.pageNo,
|
pageNo: this.pageObj.pageNo,
|
||||||
@@ -397,22 +405,16 @@ export default {
|
|||||||
// 跳转页面,则不执行搜索功能
|
// 跳转页面,则不执行搜索功能
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// 带参数时,只查询对应类型的entity;不带参数时,3种entity都查
|
|
||||||
if (q) {
|
|
||||||
this.queryFilterNew({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
|
||||||
this.queryList({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
|
||||||
this.queryCount({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
|
||||||
} else {
|
|
||||||
this.queryFilterNew({ ...this.pageObj, ...this.timeFilter })
|
|
||||||
this.queryList({ ...this.pageObj, ...this.timeFilter })
|
|
||||||
this.queryCount({ ...this.pageObj, ...this.timeFilter })
|
|
||||||
|
|
||||||
// 延时一秒,避免初始化时pageSize为20,pageNo为1也会调用“搜索”的情况
|
this.queryFilterNew({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
||||||
if (this.initFlag) {
|
this.queryList({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
||||||
this.timer = setTimeout(() => {
|
this.queryCount({ q: this.q, ...this.pageObj, ...this.timeFilter })
|
||||||
this.initFlag = false
|
|
||||||
}, 1000)
|
// 延时一秒,避免初始化时pageSize为20,pageNo为1也会调用“搜索”的情况
|
||||||
}
|
if (this.initFlag) {
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
this.initFlag = false
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pageSize (val) {
|
pageSize (val) {
|
||||||
@@ -565,7 +567,7 @@ export default {
|
|||||||
const queryParams = {
|
const queryParams = {
|
||||||
// startTime: getSecond(params.startTime),
|
// startTime: getSecond(params.startTime),
|
||||||
// endTime: getSecond(params.endTime),
|
// endTime: getSecond(params.endTime),
|
||||||
resource: params.q || '' // 目前版本搜索不支持实体名称搜索,下版本改进
|
resource: params.q || ''
|
||||||
}
|
}
|
||||||
axios.get(api.entity.entityList.summaryCount, { params: queryParams }).then(response => {
|
axios.get(api.entity.entityList.summaryCount, { params: queryParams }).then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
@@ -686,11 +688,14 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.getEntityIndexData()
|
this.getEntityIndexData()
|
||||||
const { q, listMode } = this.$route.query
|
let { q, listMode } = this.$route.query
|
||||||
|
|
||||||
// 如果地址栏有listMode,即列表页,并非首页,则开始搜索
|
// 如果地址栏有listMode,即列表页,并非首页,则开始搜索
|
||||||
if (listMode) {
|
if (listMode) {
|
||||||
this.showList = true
|
this.showList = true
|
||||||
|
if (q.indexOf('%20') > -1) {
|
||||||
|
q = decodeURI(q)
|
||||||
|
}
|
||||||
this.initSearch(q)
|
this.initSearch(q)
|
||||||
this.listMode = listMode
|
this.listMode = listMode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user