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-23 19:53:17 +08:00
|
|
|
|
if (qv && val.type == 'array') {
|
|
|
|
|
|
qv = qv.split(',')
|
|
|
|
|
|
}
|
2021-12-23 20:22:40 +08:00
|
|
|
|
if (qv && val.type == 'jsonParse') {
|
|
|
|
|
|
qv = JSON.parse(qv)
|
|
|
|
|
|
}
|
2021-12-22 14:55:22 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.setSearchInput(val, qv)
|
2021-12-23 19:53:17 +08:00
|
|
|
|
if (qv && val.type2 == 'array') {
|
|
|
|
|
|
const arr = qv.split(',').map(item => Number(item))
|
|
|
|
|
|
qv && this.$set(val.target2, val.propertyName, arr)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (qv && val.type2 == 'json') {
|
|
|
|
|
|
qv && this.$set(val.target2, val.propertyName, qv)
|
|
|
|
|
|
}
|
2021-12-22 14:55:22 +08:00
|
|
|
|
}, 200)
|
2021-12-21 19:19:35 +08:00
|
|
|
|
qv && this.$set(val.target, val.propertyName, qv)
|
|
|
|
|
|
})
|
2022-09-05 15:35:32 +08:00
|
|
|
|
if (q.bottomBox && JSON.parse(q.bottomBox)) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.detailType = q.detailType
|
|
|
|
|
|
const detailType = this.detailType === 'list' ? 'dataList' : 'detailList'
|
|
|
|
|
|
this.$refs[detailType].bottomBox.showSubList = JSON.parse(q.bottomBox)
|
|
|
|
|
|
this.$refs[detailType].bottomBox.targetTab = q.targetTab
|
|
|
|
|
|
this.$refs[detailType].bottomBox.object = JSON.parse(q.selectObj)
|
|
|
|
|
|
})
|
2022-09-19 15:39:59 +08:00
|
|
|
|
} else if (this.detailType === 'view' && q.detailType && q.selectObj) {
|
2022-09-05 15:35:32 +08:00
|
|
|
|
this.detailType = q.detailType
|
|
|
|
|
|
this.detailViewRightObj = JSON.parse(q.selectObj)
|
|
|
|
|
|
this.$store.commit('setGlobalSearchId', this.detailViewRightObj.id)
|
|
|
|
|
|
}
|
2021-12-21 19:19:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 更新path,包含请求参数
|
2022-09-05 15:35:32 +08:00
|
|
|
|
updatePath (param, path, from) {
|
2022-09-06 16:15:51 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
const params = lodash.cloneDeep(param)
|
|
|
|
|
|
Object.keys(params).forEach(key => {
|
|
|
|
|
|
if (!params[key]) {
|
|
|
|
|
|
delete params[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (!from) {
|
|
|
|
|
|
const detailType = this.detailType === 'list' ? 'dataList' : 'detailList'
|
|
|
|
|
|
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
|
|
|
|
|
|
params.detailType = this.detailType
|
|
|
|
|
|
if (this.detailType === 'list' && this.$refs[detailType]) {
|
|
|
|
|
|
params.bottomBox = this.$refs[detailType].bottomBox.showSubList
|
|
|
|
|
|
params.targetTab = this.$refs[detailType].bottomBox.targetTab
|
|
|
|
|
|
} else {
|
|
|
|
|
|
params.bottomBox = false
|
|
|
|
|
|
params.targetTab = this.$route.query.targetTab
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.detailType === 'list' && this.$refs[detailType]) {
|
2022-09-05 15:35:32 +08:00
|
|
|
|
params.selectObj = JSON.stringify({
|
2022-09-06 16:15:51 +08:00
|
|
|
|
id: this.$refs[detailType].bottomBox.object.id,
|
|
|
|
|
|
name: this.$refs[detailType].bottomBox.object.name,
|
|
|
|
|
|
configs: this.$refs[detailType].bottomBox.object.configs ? this.$refs[detailType].bottomBox.object.configs.map(item => { return { type: item.type, enable: item.enable } }) : '',
|
|
|
|
|
|
childrenNum: this.$refs[detailType].bottomBox.object.childrenNum || ''
|
2022-09-05 15:35:32 +08:00
|
|
|
|
})
|
2022-09-06 16:15:51 +08:00
|
|
|
|
} else if (this.$refs[detailType] && this.$refs[detailType].detailViewRightObj) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
params.selectObj = JSON.stringify({
|
|
|
|
|
|
id: this.$refs[detailType].detailViewRightObj.id,
|
|
|
|
|
|
name: this.$refs[detailType].detailViewRightObj.name,
|
|
|
|
|
|
configs: this.$refs[detailType].detailViewRightObj.configs ? this.$refs[detailType].detailViewRightObj.configs.map(item => { return { type: item.type, enable: item.enable } }) : '',
|
|
|
|
|
|
childrenNum: this.$refs[detailType].detailViewRightObj.childrenNum || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$router.replace({ path: path, query: params }).catch(err => {})
|
|
|
|
|
|
} else if (from === 'nzDatalist' && this.bottomBox) {
|
|
|
|
|
|
params.bottomBox = this.bottomBox.showSubList
|
|
|
|
|
|
params.targetTab = this.bottomBox.targetTab
|
|
|
|
|
|
params.selectObj = JSON.stringify({
|
|
|
|
|
|
id: this.bottomBox.object.id,
|
|
|
|
|
|
name: this.bottomBox.object.name,
|
|
|
|
|
|
configs: this.bottomBox.object.configs ? this.bottomBox.object.configs.map(item => { return { type: item.type, enable: item.enable } }) : '',
|
2022-09-08 15:10:10 +08:00
|
|
|
|
childrenNum: this.bottomBox.object.childrenNum || '',
|
|
|
|
|
|
clientState: this.bottomBox.object.clientState || ''
|
2022-09-06 16:15:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.$router.replace({ path: path, query: params }).catch(err => {})
|
|
|
|
|
|
} else if (from === 'nzDetailList' && this.detailViewRightObj) {
|
|
|
|
|
|
params.targetTab = this.$route.query.targetTab
|
|
|
|
|
|
params.selectObj = JSON.stringify({
|
|
|
|
|
|
id: this.detailViewRightObj.id,
|
|
|
|
|
|
name: this.detailViewRightObj.name,
|
|
|
|
|
|
configs: this.detailViewRightObj.configs ? this.detailViewRightObj.configs.map(item => { return { type: item.type, enable: item.enable } }) : '',
|
2022-09-08 15:10:10 +08:00
|
|
|
|
childrenNum: this.detailViewRightObj.childrenNum || '',
|
2022-09-09 09:30:10 +08:00
|
|
|
|
clientState: this.detailViewRightObj.clientState || ''
|
2022-09-05 15:35:32 +08:00
|
|
|
|
})
|
2022-09-06 16:15:51 +08:00
|
|
|
|
this.$router.replace({ path: path, query: params }).catch(err => {})
|
|
|
|
|
|
} else if (from === 'bottomBox' && this.targetTab) {
|
|
|
|
|
|
params.targetTab = this.targetTab
|
|
|
|
|
|
this.$router.replace({ path: path, query: params }).catch(err => {})
|
2022-09-05 15:35:32 +08:00
|
|
|
|
}
|
2022-09-06 16:15:51 +08:00
|
|
|
|
})
|
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-23 19:31:00 +08:00
|
|
|
|
if (obj[val.jsonKey]) {
|
|
|
|
|
|
this.$refs[dataList].$refs.searchInput.select_list.push(obj)
|
|
|
|
|
|
this.$refs[dataList].$refs.searchInput.sreach_num++
|
|
|
|
|
|
}
|
2021-12-22 14:55:22 +08:00
|
|
|
|
// 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
|
|
|
|
}
|
2022-02-14 14:39:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
switchChange (formName) {
|
|
|
|
|
|
const $temp = this
|
|
|
|
|
|
$temp.$refs[formName].clearValidate()
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
$temp.$refs[formName].validate()
|
|
|
|
|
|
}, 100)
|
2021-12-21 19:19:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|