mirror of https://github.com/veops/cmdb.git
fix:ci relation add type filter (#208)
This commit is contained in:
parent
2a5091c51a
commit
e0e2ca6294
|
@ -549,11 +549,11 @@ export default {
|
||||||
q = q.slice(1)
|
q = q.slice(1)
|
||||||
}
|
}
|
||||||
if (this.treeKeys.length === 0) {
|
if (this.treeKeys.length === 0) {
|
||||||
|
await this.judgeCITypes(q)
|
||||||
if (!refreshType) {
|
if (!refreshType) {
|
||||||
this.loadRoot()
|
this.loadRoot()
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.judgeCITypes(q)
|
|
||||||
const fuzzySearch = (this.$refs['search'] || {}).fuzzySearch || ''
|
const fuzzySearch = (this.$refs['search'] || {}).fuzzySearch || ''
|
||||||
if (fuzzySearch) {
|
if (fuzzySearch) {
|
||||||
q = `q=_type:${this.currentTypeId[0]},*${fuzzySearch}*,` + q
|
q = `q=_type:${this.currentTypeId[0]},*${fuzzySearch}*,` + q
|
||||||
|
@ -635,6 +635,7 @@ export default {
|
||||||
statisticsCIRelation({
|
statisticsCIRelation({
|
||||||
root_ids: key.split('%')[0],
|
root_ids: key.split('%')[0],
|
||||||
level: this.treeKeys.length - index,
|
level: this.treeKeys.length - index,
|
||||||
|
type_ids: this.showTypes.map((type) => type.id).join(','),
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
let result
|
let result
|
||||||
const getTreeItem = (data, id) => {
|
const getTreeItem = (data, id) => {
|
||||||
|
@ -689,6 +690,7 @@ export default {
|
||||||
}
|
}
|
||||||
const promises = _showTypeIds.map((typeId) => {
|
const promises = _showTypeIds.map((typeId) => {
|
||||||
const _q = (`q=_type:${typeId},` + q).replace(/count=\d*/, 'count=1')
|
const _q = (`q=_type:${typeId},` + q).replace(/count=\d*/, 'count=1')
|
||||||
|
console.log(_q)
|
||||||
if (this.treeKeys.length === 0) {
|
if (this.treeKeys.length === 0) {
|
||||||
return searchCI2(_q).then((res) => {
|
return searchCI2(_q).then((res) => {
|
||||||
if (res.numfound !== 0) {
|
if (res.numfound !== 0) {
|
||||||
|
@ -739,7 +741,11 @@ export default {
|
||||||
level = idx + 1
|
level = idx + 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return statisticsCIRelation({ root_ids: ciIds.join(','), level: level }).then((num) => {
|
return statisticsCIRelation({
|
||||||
|
root_ids: ciIds.join(','),
|
||||||
|
level: level,
|
||||||
|
type_ids: this.showTypes.map((type) => type.id).join(','),
|
||||||
|
}).then((num) => {
|
||||||
facet.forEach((item, idx) => {
|
facet.forEach((item, idx) => {
|
||||||
item[1] += num[ciIds[idx] + '']
|
item[1] += num[ciIds[idx] + '']
|
||||||
})
|
})
|
||||||
|
@ -752,25 +758,35 @@ export default {
|
||||||
|
|
||||||
async loadNoRoot(rootIdAndTypeId, level) {
|
async loadNoRoot(rootIdAndTypeId, level) {
|
||||||
const rootId = rootIdAndTypeId.split('%')[0]
|
const rootId = rootIdAndTypeId.split('%')[0]
|
||||||
searchCIRelation(`root_id=${rootId}&level=1&count=10000`).then(async (res) => {
|
const typeId = Number(rootIdAndTypeId.split('%')[1])
|
||||||
const facet = []
|
const topo_flatten = this.relationViews?.views[this.$route.meta.name]?.topo_flatten ?? []
|
||||||
const ciIds = []
|
const index = topo_flatten.findIndex((id) => id === typeId)
|
||||||
res.result.forEach((item) => {
|
const _type = topo_flatten[index + 1]
|
||||||
facet.push([item[item.unique], 0, item._id, item._type, item.unique])
|
if (_type) {
|
||||||
ciIds.push(item._id)
|
searchCIRelation(`q=_type:${_type}&root_id=${rootId}&level=1&count=10000`).then(async (res) => {
|
||||||
})
|
const facet = []
|
||||||
const promises = level.map((_level) => {
|
const ciIds = []
|
||||||
if (_level > 1) {
|
res.result.forEach((item) => {
|
||||||
return statisticsCIRelation({ root_ids: ciIds.join(','), level: _level - 1 }).then((num) => {
|
facet.push([item[item.unique], 0, item._id, item._type, item.unique])
|
||||||
facet.forEach((item, idx) => {
|
ciIds.push(item._id)
|
||||||
item[1] += num[ciIds[idx] + '']
|
})
|
||||||
|
const promises = level.map((_level) => {
|
||||||
|
if (_level > 1) {
|
||||||
|
return statisticsCIRelation({
|
||||||
|
root_ids: ciIds.join(','),
|
||||||
|
level: _level - 1,
|
||||||
|
type_ids: this.showTypes.map((type) => type.id).join(','),
|
||||||
|
}).then((num) => {
|
||||||
|
facet.forEach((item, idx) => {
|
||||||
|
item[1] += num[ciIds[idx] + '']
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
|
await Promise.all(promises)
|
||||||
|
this.wrapTreeData(facet, 'loadNoRoot')
|
||||||
})
|
})
|
||||||
await Promise.all(promises)
|
}
|
||||||
this.wrapTreeData(facet, 'loadNoRoot')
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onNodeClick(keys) {
|
onNodeClick(keys) {
|
||||||
|
|
Loading…
Reference in New Issue