diff --git a/data/magic-api/api/系统管理/组件/保存tree.ms b/data/magic-api/api/系统管理/组件/保存tree.ms index a884bd8..fb4526c 100644 --- a/data/magic-api/api/系统管理/组件/保存tree.ms +++ b/data/magic-api/api/系统管理/组件/保存tree.ms @@ -5,7 +5,7 @@ "groupId" : "6f106ebdee21489db34b956f7770ff03", "name" : "保存tree", "createTime" : null, - "updateTime" : 1710083166610, + "updateTime" : 1712742368621, "lock" : null, "createBy" : null, "updateBy" : null, @@ -37,13 +37,32 @@ let data if(id){ data = {id, name} - if(db.selectInt("select count(1) from sys_dynamic_component where is_del = 0 and name = #{name} and id != #{id}") > 0){ - exit 0, '名称不能重复' + if(type == '1'){ + if(db.selectInt("select count(1) from sys_dynamic_component where is_del = 0 and type = 1 and name = #{name} and id != #{id}") > 0){ + exit 0, '组件名称不能重复' + } + }else{ + if( + db.selectInt(""" + select count(1) from sys_dynamic_component where is_del = 0 and type = 0 + and pid = (select pid from sys_dynamic_component where is_del = 0 and id = #{id}) and name = #{name} and id != #{id} + """) > 0 + ){ + exit 0, '当前分组下已存在相同分组名称' + } } }else{ data = {pid, name} - if(db.selectInt("select count(1) from sys_dynamic_component where is_del = 0 and name = #{name}") > 0){ - exit 0, '名称不能重复' + if(type == '1'){ + if(db.selectInt("select count(1) from sys_dynamic_component where is_del = 0 and type = 1 and name = #{name}") > 0){ + exit 0, '组件名称不能重复' + } + }else{ + if(db.selectInt("select count(1) from sys_dynamic_component where is_del = 0 and type = 0 and pid = #{pid} and name = #{name}") > 0){ + exit 0, '当前分组下已存在相同分组名称' + } } } +data.type = type +data.remark = remark return db.table("sys_dynamic_component").primary("id").saveOrUpdate(data) \ No newline at end of file diff --git a/data/magic-api/api/系统管理/组件/获取组件tree.ms b/data/magic-api/api/系统管理/组件/获取组件tree.ms index 7ff4fca..b093166 100644 --- a/data/magic-api/api/系统管理/组件/获取组件tree.ms +++ b/data/magic-api/api/系统管理/组件/获取组件tree.ms @@ -5,7 +5,7 @@ "groupId" : "6f106ebdee21489db34b956f7770ff03", "name" : "获取组件tree", "createTime" : null, - "updateTime" : 1710083862734, + "updateTime" : 1712742831654, "lock" : null, "createBy" : null, "updateBy" : null, @@ -35,7 +35,16 @@ } ================================ var toTree = (list,pid) => select t.*,toTree(list,t.id) children from list t where t.pid = pid -var list = toTree(db.select('select id,name,pid from sys_dynamic_component where is_del = 0 order by name'),'0') +var list = toTree(db.select(""" + select + dc.id, + (case when dc.remark is not null and dc.remark != '' then concat(dc.name,'(',dc.remark, ')') else dc.name end) name, + dc.pid, + (case when dc.type = 0 then 1 else 0 end) is_group + from sys_dynamic_component dc + where dc.is_del = 0 + order by dc.name +"""),'0') return { list: list,