NEZ-1400 feat: 初始版本页面路由使用 url path 传递参数

This commit is contained in:
@changcode
2021-12-22 14:20:13 +08:00
parent 8c21906fa2
commit 74521c5d1f
13 changed files with 275 additions and 26 deletions

View File

@@ -2,19 +2,8 @@ import lodash from 'lodash'
export default {
methods: {
// 解析请求参数,初始化 searchLabel
initQueryFromPath () {
initQueryFromPath (searchKeys) {
const q = this.$route.query
const searchKeys = {
// key: path 键
// value: vue set 参数
pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' },
pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' },
orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' },
id: { target: this.searchLabel, propertyName: 'id', type: 'number' },
severityIds: { target: this.searchLabel, propertyName: 'severityIds', type: 'string' },
type: { target: this.searchLabel, propertyName: 'type', type: 'number' },
name: { target: this.searchLabel, propertyName: 'name', type: 'string' }
}
lodash.forIn(searchKeys, (val, key) => {
let qv = lodash.get(q, key)
if (qv && val.type == 'number') {
@@ -24,8 +13,9 @@ export default {
})
},
// 更新path包含请求参数
updatePath (param) {
this.$router.replace({ path: this.fromRoute.alertRule, query: param }).catch(err => {})
updatePath (param, path) {
console.log(param)
this.$router.replace({ path: path, query: param }).catch(err => {})
}
}
}