refactor: 标签列表选择调整

This commit is contained in:
meilin.huang
2022-10-31 23:03:26 +08:00
parent 87ae2f81fa
commit 936ca61f94
4 changed files with 28 additions and 12 deletions

View File

@@ -208,7 +208,7 @@ const state = reactive({
list: [],
total: 0,
currentId: null,
currentData: null,
currentData: null as any,
query: {
pageNum: 1,
pageSize: 10,
@@ -277,9 +277,8 @@ const choose = (item: any) => {
state.currentData = item;
};
const showDatabases = async (id: number, row: any) => {
console.log(row)
state.query.tagPath = row.tagPath
const showDatabases = async (id: number) => {
// state.query.tagPath = row.tagPath
state.dbOps.dbId = id
state.databaseDialog.data = (await mongoApi.databases.request({ id })).Databases;
@@ -412,10 +411,11 @@ const openDataOps = (row: any) => {
debugger
let data = {
tagPath: state.query.tagPath,
tagPath: state.currentData.tagPath,
dbId: state.dbOps.dbId,
db: state.dbOps.db,
}
state.databaseDialog.visible = false;
// 判断db是否发生改变
let oldDb = store.state.mongoDbOptInfo.dbOptInfo.db;
if (oldDb !== row.Name) {

View File

@@ -14,7 +14,15 @@ type TagTree struct {
}
func (p *TagTree) GetAccountTags(rc *ctx.ReqCtx) {
rc.ResData = p.TagTreeApp.ListTagByAccountId(rc.LoginAccount.Id)
tagPaths := p.TagTreeApp.ListTagByAccountId(rc.LoginAccount.Id)
allTagPath := make([]string, 0)
if len(tagPaths) > 0 {
tags := p.TagTreeApp.ListTagByPath(tagPaths...)
for _, v := range tags {
allTagPath = append(allTagPath, v.CodePath)
}
}
rc.ResData = allTagPath
}
func (p *TagTree) GetTagTree(rc *ctx.ReqCtx) {

View File

@@ -31,6 +31,9 @@ type TagTree interface {
// 获取以指定tagPath数组开头的所有标签id
ListTagIdByPath(tagPath ...string) []uint64
// 根据tagPath获取自身及其所有子标签信息
ListTagByPath(tagPath ...string) []entity.TagTree
// 根据账号id获取其可访问标签信息
ListTagByAccountId(accountId uint64) []string
@@ -109,14 +112,19 @@ func (p *tagTreeAppImpl) ListTagIdByAccountId(accountId uint64) []uint64 {
return p.ListTagIdByPath(p.ListTagByAccountId(accountId)...)
}
func (p *tagTreeAppImpl) ListTagByPath(tagPaths ...string) []entity.TagTree {
var tags []entity.TagTree
p.tagTreeRepo.SelectByCondition(&entity.TagTreeQuery{CodePathLikes: tagPaths}, &tags)
return tags
}
func (p *tagTreeAppImpl) ListTagIdByPath(tagPaths ...string) []uint64 {
tagIds := make([]uint64, 0)
if len(tagPaths) == 0 {
return tagIds
}
var tags []entity.TagTree
p.tagTreeRepo.SelectByCondition(&entity.TagTreeQuery{CodePathLikes: tagPaths}, &tags)
tags := p.ListTagByPath(tagPaths...)
for _, v := range tags {
tagIds = append(tagIds, v.Id)
}

View File

@@ -15,7 +15,7 @@ func newTagTreeRepo() repository.TagTree {
}
func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEntity interface{}, orderBy ...string) {
sql := "SELECT p.* FROM t_tag_tree p WHERE 1 = 1 "
sql := "SELECT DISTINCT(p.id), p.pid, p.code, p.code_path, p.name, p.remark, p.create_time, p.creator, p.update_time, p.modifier FROM t_tag_tree p WHERE 1 = 1 "
if condition.Name != "" {
sql = sql + " AND p.name LIKE '%" + condition.Name + "%'"
}
@@ -39,7 +39,7 @@ func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEn
}
sql = sql + ")"
}
sql = sql + " ORDER BY p.pid DESC"
sql = sql + " ORDER BY p.code_path"
model.GetListBySql2Model(sql, toEntity)
}
@@ -56,11 +56,11 @@ func (a *tagTreeRepoImpl) GetBy(condition *entity.TagTree, cols ...string) error
}
func (p *tagTreeRepoImpl) Insert(project *entity.TagTree) {
biz.ErrIsNil(model.Insert(project), "新增项目失败")
biz.ErrIsNil(model.Insert(project), "新增标签失败")
}
func (p *tagTreeRepoImpl) UpdateById(project *entity.TagTree) {
biz.ErrIsNil(model.UpdateById(project), "更新项目失败")
biz.ErrIsNil(model.UpdateById(project), "更新标签失败")
}
func (p *tagTreeRepoImpl) Delete(id uint64) {