mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-10 09:50:25 +08:00
refactor: 标签列表选择调整
This commit is contained in:
@@ -208,7 +208,7 @@ const state = reactive({
|
|||||||
list: [],
|
list: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
currentId: null,
|
currentId: null,
|
||||||
currentData: null,
|
currentData: null as any,
|
||||||
query: {
|
query: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -277,9 +277,8 @@ const choose = (item: any) => {
|
|||||||
state.currentData = item;
|
state.currentData = item;
|
||||||
};
|
};
|
||||||
|
|
||||||
const showDatabases = async (id: number, row: any) => {
|
const showDatabases = async (id: number) => {
|
||||||
console.log(row)
|
// state.query.tagPath = row.tagPath
|
||||||
state.query.tagPath = row.tagPath
|
|
||||||
state.dbOps.dbId = id
|
state.dbOps.dbId = id
|
||||||
|
|
||||||
state.databaseDialog.data = (await mongoApi.databases.request({ id })).Databases;
|
state.databaseDialog.data = (await mongoApi.databases.request({ id })).Databases;
|
||||||
@@ -412,10 +411,11 @@ const openDataOps = (row: any) => {
|
|||||||
|
|
||||||
debugger
|
debugger
|
||||||
let data = {
|
let data = {
|
||||||
tagPath: state.query.tagPath,
|
tagPath: state.currentData.tagPath,
|
||||||
dbId: state.dbOps.dbId,
|
dbId: state.dbOps.dbId,
|
||||||
db: state.dbOps.db,
|
db: state.dbOps.db,
|
||||||
}
|
}
|
||||||
|
state.databaseDialog.visible = false;
|
||||||
// 判断db是否发生改变
|
// 判断db是否发生改变
|
||||||
let oldDb = store.state.mongoDbOptInfo.dbOptInfo.db;
|
let oldDb = store.state.mongoDbOptInfo.dbOptInfo.db;
|
||||||
if (oldDb !== row.Name) {
|
if (oldDb !== row.Name) {
|
||||||
|
|||||||
@@ -14,7 +14,15 @@ type TagTree struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *TagTree) GetAccountTags(rc *ctx.ReqCtx) {
|
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) {
|
func (p *TagTree) GetTagTree(rc *ctx.ReqCtx) {
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ type TagTree interface {
|
|||||||
// 获取以指定tagPath数组开头的所有标签id
|
// 获取以指定tagPath数组开头的所有标签id
|
||||||
ListTagIdByPath(tagPath ...string) []uint64
|
ListTagIdByPath(tagPath ...string) []uint64
|
||||||
|
|
||||||
|
// 根据tagPath获取自身及其所有子标签信息
|
||||||
|
ListTagByPath(tagPath ...string) []entity.TagTree
|
||||||
|
|
||||||
// 根据账号id获取其可访问标签信息
|
// 根据账号id获取其可访问标签信息
|
||||||
ListTagByAccountId(accountId uint64) []string
|
ListTagByAccountId(accountId uint64) []string
|
||||||
|
|
||||||
@@ -109,14 +112,19 @@ func (p *tagTreeAppImpl) ListTagIdByAccountId(accountId uint64) []uint64 {
|
|||||||
return p.ListTagIdByPath(p.ListTagByAccountId(accountId)...)
|
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 {
|
func (p *tagTreeAppImpl) ListTagIdByPath(tagPaths ...string) []uint64 {
|
||||||
tagIds := make([]uint64, 0)
|
tagIds := make([]uint64, 0)
|
||||||
if len(tagPaths) == 0 {
|
if len(tagPaths) == 0 {
|
||||||
return tagIds
|
return tagIds
|
||||||
}
|
}
|
||||||
|
|
||||||
var tags []entity.TagTree
|
tags := p.ListTagByPath(tagPaths...)
|
||||||
p.tagTreeRepo.SelectByCondition(&entity.TagTreeQuery{CodePathLikes: tagPaths}, &tags)
|
|
||||||
for _, v := range tags {
|
for _, v := range tags {
|
||||||
tagIds = append(tagIds, v.Id)
|
tagIds = append(tagIds, v.Id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func newTagTreeRepo() repository.TagTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *tagTreeRepoImpl) SelectByCondition(condition *entity.TagTreeQuery, toEntity interface{}, orderBy ...string) {
|
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 != "" {
|
if condition.Name != "" {
|
||||||
sql = sql + " AND p.name LIKE '%" + 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 + ")"
|
||||||
}
|
}
|
||||||
sql = sql + " ORDER BY p.pid DESC"
|
sql = sql + " ORDER BY p.code_path"
|
||||||
model.GetListBySql2Model(sql, toEntity)
|
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) {
|
func (p *tagTreeRepoImpl) Insert(project *entity.TagTree) {
|
||||||
biz.ErrIsNil(model.Insert(project), "新增项目失败")
|
biz.ErrIsNil(model.Insert(project), "新增标签失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *tagTreeRepoImpl) UpdateById(project *entity.TagTree) {
|
func (p *tagTreeRepoImpl) UpdateById(project *entity.TagTree) {
|
||||||
biz.ErrIsNil(model.UpdateById(project), "更新项目失败")
|
biz.ErrIsNil(model.UpdateById(project), "更新标签失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *tagTreeRepoImpl) Delete(id uint64) {
|
func (p *tagTreeRepoImpl) Delete(id uint64) {
|
||||||
|
|||||||
Reference in New Issue
Block a user