Skip to content

Commit

Permalink
feat:制品搜索页面搜索 generic 类型制品条件调整 #1370 (#1388)
Browse files Browse the repository at this point in the history
* feat:制品搜索页面搜索 generic 类型制品条件调整 #1370

* feat:制品搜索页面搜索 generic 类型制品条件调整 #1370

* feat:制品搜索页面搜索 generic 类型制品条件调整 #1370
  • Loading branch information
lannoy0523 authored Nov 20, 2023
1 parent 82bd134 commit e9af7d1
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
)
},
// 跨仓库搜索
searchPackageList (_, { projectId, repoType, repoName, packageName, property = 'name', direction = 'ASC', current = 1, limit = 20, extRules = [] }) {
searchPackageList (_, { projectId, repoType, repoName, repoNames = [], packageName, property = 'name', direction = 'ASC', current = 1, limit = 20, extRules = [] }) {
const isGeneric = repoType === 'generic'
return Vue.prototype.$ajax.post(
`${prefix}/${isGeneric ? 'node/queryWithoutCount' : 'package/search'}`,
Expand All @@ -119,7 +119,7 @@ export default {
operation: 'EQ'
}]
: []),
...(repoType
...((MODE_CONFIG === 'ci' ? !isGeneric : true) && repoType
? [{
field: 'repoType',
value: repoType.toUpperCase(),
Expand All @@ -136,8 +136,8 @@ export default {
...(MODE_CONFIG === 'ci' && isGeneric
? [{
field: 'repoName',
value: ['report', 'log'],
operation: 'NIN'
value: repoNames,
operation: 'IN'
}]
: [])
]),
Expand Down
89 changes: 55 additions & 34 deletions src/frontend/devops-repository/src/views/repoGeneric/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@
created () {
this.getRepoListAll({ projectId: this.projectId })
this.initTree()
this.debounceClickTreeNode = debounce(this.clickTreeNodeHandler, 100)
this.pathChange()
window.repositoryVue.$on('upload-refresh', debounce((path) => {
if (path.replace(/\/[^/]+$/, '').includes(this.selectedTreeNode.fullPath)) {
this.itemClickHandler(this.selectedTreeNode)
}
}))
this.debounceClickTreeNode = debounce(this.clickTreeNodeHandler, 100)
if (!this.community || SHOW_ANALYST_MENU) {
this.refreshSupportFileNameExtList()
}
Expand Down Expand Up @@ -421,17 +421,36 @@
pathChange () {
const paths = (this.$route.query.path || '').split('/').filter(Boolean)
paths.pop() // 定位到文件/文件夹的上级目录
paths.reduce(async (chain, path) => {
const node = await chain
if (!node) return
await this.updateGenericTreeNode(node)
const child = node.children.find(child => child.name === path)
if (!child) return
this.sideTreeOpenList.push(child.roadMap)
return child
}, Promise.resolve(this.genericTree[0])).then(node => {
this.itemClickHandler(node || this.genericTree[0])
})
const tempPaths = paths
const num = paths.length
let tempTree = this.genericTree[0]
if (tempTree.children.length === 0 && num > 0) {
paths.reduce(async (chain, path) => {
const node = await chain
if (!node) return
await this.updateGenericTreeNode(node)
const child = node.children.find(child => child.name === path)
if (!child) return
this.sideTreeOpenList.push(child.roadMap)
return child
}, Promise.resolve(this.genericTree[0])).then(node => {
this.itemClickHandler(node || this.genericTree[0])
})
} else {
let destNode
while (tempPaths.length !== 0) {
tempTree = tempTree.children.find(node => node.name === tempPaths[0])
if (tempPaths.length === 1) {
destNode = tempTree
}
tempPaths.shift()
}
if (num !== 0) {
this.itemClickHandler(destNode)
} else {
this.itemClickHandler(this.genericTree[0])
}
}
},
// 获取中间列表数据
async getArtifactories () {
Expand Down Expand Up @@ -560,29 +579,31 @@
this.debounceClickTreeNode(node)
},
clickTreeNodeHandler (node) {
this.selectedTreeNode = node
this.handlerPaginationChange()
// 更新已展开文件夹数据
const reg = new RegExp(`^${node.roadMap}`)
const openList = this.sideTreeOpenList
openList.splice(0, openList.length, ...openList.filter(v => !reg.test(v)))
// 打开选中节点的左侧树的所有祖先节点
node.roadMap.split(',').forEach((v, i, arr) => {
const roadMap = arr.slice(0, i + 1).join(',')
!openList.includes(roadMap) && openList.push(roadMap)
})
// 更新子文件夹
if (node.loading) return
this.updateGenericTreeNode(node)
if (node.fullPath + '/default' === this.$route.query.path) {
this.selectedTreeNode = node
// 更新url参数
this.$router.replace({
query: {
...this.$route.query,
path: `${node.fullPath}/default`
}
})
this.handlerPaginationChange()
// 更新已展开文件夹数据
const reg = new RegExp(`^${node.roadMap}`)
const openList = this.sideTreeOpenList
openList.splice(0, openList.length, ...openList.filter(v => !reg.test(v)))
// 打开选中节点的左侧树的所有祖先节点
node.roadMap.split(',').forEach((v, i, arr) => {
const roadMap = arr.slice(0, i + 1).join(',')
!openList.includes(roadMap) && openList.push(roadMap)
})
// 更新子文件夹
if (node.loading) return
this.updateGenericTreeNode(node)
} else {
// 更新url参数
this.$router.replace({
query: {
...this.$route.query,
path: `${node.fullPath}/default`
}
})
}
},
iconClickHandler (node) {
// 更新已展开文件夹数据
Expand Down
29 changes: 26 additions & 3 deletions src/frontend/devops-repository/src/views/repoSearch/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@
},
resultList: [],
hasNext: true,
focusContent: this.$t('toggle')
focusContent: this.$t('toggle'),
repoNames: [],
init: false
}
},
computed: {
Expand Down Expand Up @@ -180,6 +182,7 @@
projectId: this.projectId,
repoType: this.repoType,
repoName: this.repoName,
repoNames: this.repoNames,
packageName: this.packageName,
property: this.property,
direction: this.direction,
Expand All @@ -198,8 +201,7 @@
handlerPaginationChange ({ current = 1, limit = this.pagination.limit } = {}, scrollLoad = false) {
this.pagination.current = current
this.pagination.limit = limit
this.searckPackageHandler(scrollLoad)
!scrollLoad && this.$refs.infiniteScroll && this.$refs.infiniteScroll.scrollToTop()
this.changeQuery(scrollLoad)
},
changeSortType () {
this.refreshRoute()
Expand Down Expand Up @@ -290,6 +292,27 @@
permits: '',
time: 7
})
},
// ci模式下generic的查询repoName的NIN条件会和repoType的In组装条件会异常(更改为传递查询repoName,去掉repoType传递)
changeQuery (scrollLoad) {
if (this.repoType === 'generic' && MODE_CONFIG === 'ci' && !this.init) {
this.searchRepoList({
projectId: this.projectId,
repoType: this.repoType,
packageName: this.packageName || ''
}).then(([item]) => {
item.repos.forEach(item => {
this.repoNames.push(item.repoName)
})
this.init = true
this.searckPackageHandler(scrollLoad)
!scrollLoad && this.$refs.infiniteScroll && this.$refs.infiniteScroll.scrollToTop()
})
} else {
this.init = true
this.searckPackageHandler(scrollLoad)
!scrollLoad && this.$refs.infiniteScroll && this.$refs.infiniteScroll.scrollToTop()
}
}
}
}
Expand Down

0 comments on commit e9af7d1

Please sign in to comment.