支持添加分组

This commit is contained in:
zegezy
2024-04-10 20:35:24 +08:00
parent f01a1ad6be
commit ddd423616c
2 changed files with 35 additions and 7 deletions
@@ -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)