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
|
|
|
|
|
|
}
|
2022-11-29 10:26:46 +08:00
|
|
|
|
if (!params.targetTab) delete params.targetTab
|
2022-09-06 16:15:51 +08:00
|
|
|
|
if (this.detailType === 'list' && this.$refs[detailType]) {
|
2022-11-29 10:26:46 +08:00
|
|
|
|
const obj = {
|
2022-09-06 16:15:51 +08:00
|
|
|
|
id: this.$refs[detailType].bottomBox.object.id,
|
|
|
|
|
|
name: this.$refs[detailType].bottomBox.object.name,
|
2022-10-11 17:25:16 +08:00
|
|
|
|
childrenNum: this.$refs[detailType].bottomBox.object.childrenNum || '',
|
|
|
|
|
|
clientState: this.$refs[detailType].bottomBox.object.clientState || '',
|
2022-11-07 09:31:36 +08:00
|
|
|
|
protocol: this.$refs[detailType].bottomBox.object.protocol || '',
|
2022-11-07 14:14:34 +08:00
|
|
|
|
uuid: this.$refs[detailType].bottomBox.object.uuid || '',
|
2022-11-02 13:46:49 +08:00
|
|
|
|
startTime: this.$refs[detailType].bottomBox.object.startTime || '',
|
2022-10-11 17:25:16 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
tsgAppliance: this.$refs[detailType].bottomBox.object.model ? this.$refs[detailType].bottomBox.object.model.tsgAppliance : ''
|
|
|
|
|
|
}
|
2022-11-29 10:26:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (this.$refs[detailType].bottomBox.object.configs) {
|
|
|
|
|
|
// 判断是JSON字符串还是对象
|
|
|
|
|
|
if (typeof (this.$refs[detailType].bottomBox.object.configs) == 'string') {
|
|
|
|
|
|
obj.configs = JSON.parse(this.$refs[detailType].bottomBox.object.configs).map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
obj.configs = this.$refs[detailType].bottomBox.object.configs.map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.removeEmpty(obj)
|
|
|
|
|
|
if (JSON.stringify(obj) != '{}') {
|
|
|
|
|
|
params.selectObj = JSON.stringify(obj)
|
|
|
|
|
|
}
|
2022-09-06 16:15:51 +08:00
|
|
|
|
} else if (this.$refs[detailType] && this.$refs[detailType].detailViewRightObj) {
|
|
|
|
|
|
this.$nextTick(() => {
|
2022-11-29 10:26:46 +08:00
|
|
|
|
const obj = {
|
2022-09-06 16:15:51 +08:00
|
|
|
|
id: this.$refs[detailType].detailViewRightObj.id,
|
|
|
|
|
|
name: this.$refs[detailType].detailViewRightObj.name,
|
2022-10-11 17:25:16 +08:00
|
|
|
|
childrenNum: this.$refs[detailType].detailViewRightObj.childrenNum || '',
|
|
|
|
|
|
clientState: this.$refs[detailType].detailViewRightObj.clientState || '',
|
2022-11-07 09:31:36 +08:00
|
|
|
|
protocol: this.$refs[detailType].detailViewRightObj.protocol || '',
|
2022-11-07 14:14:34 +08:00
|
|
|
|
uuid: this.$refs[detailType].detailViewRightObj.uuid || '',
|
2022-11-02 13:46:49 +08:00
|
|
|
|
startTime: this.$refs[detailType].detailViewRightObj.startTime || '',
|
2022-10-11 17:25:16 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
tsgAppliance: this.$refs[detailType].detailViewRightObj.model ? this.$refs[detailType].detailViewRightObj.model.tsgAppliance : ''
|
|
|
|
|
|
}
|
2022-11-29 10:26:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (this.$refs[detailType].detailViewRightObj.configs) {
|
|
|
|
|
|
// 判断是JSON字符串还是对象
|
|
|
|
|
|
if (typeof (this.$refs[detailType].detailViewRightObj.configs) == 'string') {
|
|
|
|
|
|
obj.configs = JSON.parse(this.$refs[detailType].detailViewRightObj.configs).map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
obj.configs = this.$refs[detailType].detailViewRightObj.configs.map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.removeEmpty(obj)
|
|
|
|
|
|
if (JSON.stringify(obj) != '{}') {
|
|
|
|
|
|
params.selectObj = JSON.stringify(obj)
|
|
|
|
|
|
}
|
2022-09-06 16:15:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2022-11-29 10:26:46 +08:00
|
|
|
|
const obj = {
|
2022-09-06 16:15:51 +08:00
|
|
|
|
id: this.bottomBox.object.id,
|
|
|
|
|
|
name: this.bottomBox.object.name,
|
2022-09-08 15:10:10 +08:00
|
|
|
|
childrenNum: this.bottomBox.object.childrenNum || '',
|
2022-10-08 10:16:09 +08:00
|
|
|
|
clientState: this.bottomBox.object.clientState || '',
|
2022-11-07 09:31:36 +08:00
|
|
|
|
protocol: this.bottomBox.object.protocol || '',
|
2022-11-07 14:14:34 +08:00
|
|
|
|
uuid: this.bottomBox.object.uuid || '',
|
2022-11-02 13:46:49 +08:00
|
|
|
|
startTime: this.bottomBox.object.startTime || '',
|
2022-10-11 17:25:16 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
tsgAppliance: this.bottomBox.object.model ? this.bottomBox.object.model.tsgAppliance : ''
|
|
|
|
|
|
}
|
2022-11-29 10:26:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (this.bottomBox.object.configs) {
|
|
|
|
|
|
// 判断是JSON字符串还是对象
|
|
|
|
|
|
if (typeof (this.bottomBox.object.configs) == 'string') {
|
|
|
|
|
|
obj.configs = JSON.parse(this.bottomBox.object.configs).map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
obj.configs = this.bottomBox.object.configs.map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.removeEmpty(obj)
|
|
|
|
|
|
if (JSON.stringify(obj) != '{}') {
|
|
|
|
|
|
params.selectObj = JSON.stringify(obj)
|
|
|
|
|
|
}
|
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
|
2022-11-29 10:26:46 +08:00
|
|
|
|
const obj = {
|
2022-09-06 16:15:51 +08:00
|
|
|
|
id: this.detailViewRightObj.id,
|
|
|
|
|
|
name: this.detailViewRightObj.name,
|
2022-09-08 15:10:10 +08:00
|
|
|
|
childrenNum: this.detailViewRightObj.childrenNum || '',
|
2022-10-08 10:16:09 +08:00
|
|
|
|
clientState: this.detailViewRightObj.clientState || '',
|
2022-11-07 09:31:36 +08:00
|
|
|
|
protocol: this.detailViewRightObj.protocol || '',
|
2022-11-07 14:14:34 +08:00
|
|
|
|
uuid: this.detailViewRightObj.uuid || '',
|
2022-11-02 13:46:49 +08:00
|
|
|
|
startTime: this.detailViewRightObj.startTime || '',
|
2022-10-11 17:25:16 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
tsgAppliance: this.detailViewRightObj.model ? this.detailViewRightObj.model.tsgAppliance : ''
|
|
|
|
|
|
}
|
2022-11-29 10:26:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (this.detailViewRightObj.configs) {
|
|
|
|
|
|
// 判断是JSON字符串还是对象
|
|
|
|
|
|
if (typeof (this.detailViewRightObj.configs) == 'string') {
|
|
|
|
|
|
obj.configs = JSON.parse(this.detailViewRightObj.configs).map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
obj.configs = this.detailViewRightObj.configs.map(item => { return { type: item.type, enable: item.enable } })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.removeEmpty(obj)
|
|
|
|
|
|
if (JSON.stringify(obj) != '{}') {
|
|
|
|
|
|
params.selectObj = JSON.stringify(obj)
|
|
|
|
|
|
}
|
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)
|
2022-11-29 10:26:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 清除空数据
|
|
|
|
|
|
removeEmpty (obj) {
|
|
|
|
|
|
if (!obj) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
Object.keys(obj).forEach(key => {
|
|
|
|
|
|
// 属性为对象
|
|
|
|
|
|
if (Object.prototype.toString.call(obj[key]) === '[object Object]' && (JSON.stringify(obj[key]) != '{}')) {
|
|
|
|
|
|
this.removeEmpty(obj[key])
|
|
|
|
|
|
}
|
|
|
|
|
|
// 属性值为空
|
|
|
|
|
|
if (!obj[key]) {
|
|
|
|
|
|
delete obj[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
// 属性为空对象
|
|
|
|
|
|
if ((Array.isArray(obj[key]) && !obj[key].length) || (JSON.stringify(obj[key]) == '{}')) {
|
|
|
|
|
|
delete obj[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-12-21 19:19:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|