2021-12-21 19:19:35 +08:00
|
|
|
|
import lodash from 'lodash'
|
|
|
|
|
|
export default {
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 解析请求参数,初始化 searchLabel
|
2021-12-22 14:20:13 +08:00
|
|
|
|
initQueryFromPath (searchKeys) {
|
2021-12-21 19:19:35 +08:00
|
|
|
|
const q = this.$route.query
|
|
|
|
|
|
lodash.forIn(searchKeys, (val, key) => {
|
|
|
|
|
|
let qv = lodash.get(q, key)
|
|
|
|
|
|
if (qv && val.type == 'number') {
|
|
|
|
|
|
qv = lodash.toNumber(qv)
|
|
|
|
|
|
}
|
2021-12-22 14:55:22 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.setSearchInput(val, qv)
|
|
|
|
|
|
}, 200)
|
2021-12-21 19:19:35 +08:00
|
|
|
|
qv && this.$set(val.target, val.propertyName, qv)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 更新path,包含请求参数
|
2021-12-22 14:20:13 +08:00
|
|
|
|
updatePath (param, path) {
|
2021-12-22 19:54:51 +08:00
|
|
|
|
console.log(param)
|
2021-12-23 14:54:00 +08:00
|
|
|
|
const params = lodash.cloneDeep(param)
|
|
|
|
|
|
Object.keys(params).forEach(key => {
|
|
|
|
|
|
if (!params[key]) {
|
|
|
|
|
|
delete params[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.$router.replace({ path: path, query: params }).catch(err => {})
|
2021-12-22 14:55:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
setSearchInput (val, qv) {
|
|
|
|
|
|
let dataList = ''
|
|
|
|
|
|
if (this.detailType !== 'view') {
|
|
|
|
|
|
dataList = 'dataList'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
dataList = 'detailList'
|
|
|
|
|
|
}
|
|
|
|
|
|
if (val.isSearchInput) {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
const obj = lodash.cloneDeep(val.defaultJson)
|
|
|
|
|
|
obj[val.jsonKey] = qv
|
2021-12-22 19:54:51 +08:00
|
|
|
|
console.log(obj[val.jsonKey])
|
2021-12-22 14:55:22 +08:00
|
|
|
|
this.$refs[dataList].$refs.searchInput.select_list.push(obj)
|
|
|
|
|
|
this.$refs[dataList].$refs.searchInput.sreach_num++
|
|
|
|
|
|
// this.$refs[dataList].$refs.searchInput.searchLabelList = this.$refs[dataList].$refs.searchInput.searchLabelList.filter(item => item.label !== 'projectIds')
|
2021-12-22 19:54:51 +08:00
|
|
|
|
}, 500)
|
2021-12-22 14:55:22 +08:00
|
|
|
|
}
|
2021-12-21 19:19:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|