3 Commits

Author SHA1 Message Date
D哥
d402420a5e Pre Merge pull request !401 from D哥/N/A 2025-05-07 05:27:20 +00:00
RuoYi
b80932ceb4 菜单搜索支持键盘选择&悬浮主题背景 2025-05-07 13:27:13 +08:00
D哥
6fb42d117e 解决数据权限过滤处理逻辑中,莫名其妙添加AND (d.dept_id = 0)的问题
解决数据权限过滤处理逻辑中,莫名其妙添加AND (d.dept_id = 0)的问题。
修改前生成sql语句:
SELECT d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.tenant_id FROM sys_dept d WHERE d.del_flag = '0' AND (d.dept_id = 0) ORDER BY d.parent_id, d.order_num

修改后生成sql语句:
SELECT d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.tenant_id FROM sys_dept d WHERE d.del_flag = '0' ORDER BY d.parent_id, d.order_num

Signed-off-by: D哥 <12271764+darrenteng@user.noreply.gitee.com>
2025-03-21 07:27:12 +00:00
3 changed files with 50 additions and 16 deletions

View File

@@ -113,9 +113,10 @@ public class DataScopeAspect
}
if (DATA_SCOPE_ALL.equals(dataScope))
{
// 全部数据权限,不添加额外条件
sqlString = new StringBuilder();
conditions.add(dataScope);
break;
conditions.clear();
return;
}
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
{
@@ -143,28 +144,28 @@ public class DataScopeAspect
{
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
}
else
{
// 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
// 当没有 userAlias 时,不添加任何条件
}
conditions.add(dataScope);
}
// 角色都不包含传递过来的权限字符,这个时候sqlString也会为空所以要限制一下,不查询任何数据
// 角色都不包含传递过来的权限字符,这个时候不添加任何条件
if (StringUtils.isEmpty(conditions))
{
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
sqlString = new StringBuilder();
}
if (StringUtils.isNotBlank(sqlString.toString()))
String sql = sqlString.toString().trim();
if (sql.startsWith("OR ")) {
sql = sql.substring(3);
}
if (StringUtils.isNotBlank(sql))
{
Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
if (params instanceof BaseEntity)
{
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sql + ")");
}
}
}
@@ -181,4 +182,4 @@ public class DataScopeAspect
baseEntity.getParams().put(DATA_SCOPE, "");
}
}
}
}

View File

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1746590936918" class="icon" viewBox="0 0 1194 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5378" xmlns:xlink="http://www.w3.org/1999/xlink" width="233.203125" height="200"><path d="M1151.9144 325.11999969V89.12a57.04000031 57.04000031 0 0 0-28.8-49.44 58.15999969 58.15999969 0 0 0-57.76000031 0 57.04000031 57.04000031 0 0 0-28.8 49.44v235.99999969c0.24 84.31999969-33.6 152.56000031-94.08 212.00000062-60.07999969 59.83999969-141.84 80.64-227.04 80.4H225.91440031L388.07439969 457.11999969a56.80000031 56.80000031 0 0 0 12.40000031-62.16 57.76000031 57.76000031 0 0 0-94.00000031-18.63999938L48.8744 631.20000031a56.88 56.88 0 0 0 0 80.79999938l264.96 262.56a58.08 58.08 0 0 0 96.55999969-25.59999938 56.80000031 56.80000031 0 0 0-14.95999969-55.2L232.07439969 731.67999969h483.44000062c116.56000031 0 226.15999969-32.08000031 308.64-113.76 82.15999969-80.80000031 128.23999969-178.15999969 127.83999938-292.87999969" p-id="5379"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -16,11 +16,14 @@
prefix-icon="el-icon-search"
placeholder="菜单搜索支持标题、URL模糊查询"
clearable
@keyup.enter.native="selectActiveResult"
@keydown.up.native="navigateResult('up')"
@keydown.down.native="navigateResult('down')"
>
</el-input>
<el-scrollbar wrap-class="right-scrollbar-wrapper">
<div class="result-wrap">
<div class="search-item" v-for="item in options" :key="item.path">
<div class="search-item" v-for="(item, index) in options" :key="item.path" :style="activeStyle(index)" @mouseenter="activeIndex = index" @mouseleave="activeIndex = -1">
<div class="left">
<svg-icon class="menu-icon" :icon-class="item.icon" />
</div>
@@ -32,6 +35,7 @@
{{ item.path }}
</div>
</div>
<svg-icon icon-class="enter" v-show="index === activeIndex"/>
</div>
</div>
</el-scrollbar>
@@ -51,11 +55,15 @@ export default {
search: '',
options: [],
searchPool: [],
activeIndex: -1,
show: false,
fuse: undefined
}
},
computed: {
theme() {
return this.$store.state.settings.theme
},
routes() {
return this.$store.getters.defaultRoutes
}
@@ -84,6 +92,7 @@ export default {
this.search = ''
this.options = []
this.show = false
this.activeIndex = -1
},
change(val) {
const path = val.path
@@ -162,11 +171,31 @@ export default {
return res
},
querySearch(query) {
this.activeIndex = -1
if (query !== '') {
this.options = this.fuse.search(query).map((item) => item.item) ?? this.searchPool
} else {
this.options = this.searchPool
}
},
activeStyle(index) {
if (index !== this.activeIndex) return {}
return {
"background-color": this.theme,
"color": "#fff"
}
},
navigateResult(direction) {
if (direction === "up") {
this.activeIndex = this.activeIndex <= 0 ? this.options.length - 1 : this.activeIndex - 1
} else if (direction === "down") {
this.activeIndex = this.activeIndex >= this.options.length - 1 ? 0 : this.activeIndex + 1
}
},
selectActiveResult() {
if (this.options.length > 0 && this.activeIndex >= 0) {
this.change(this.options[this.activeIndex])
}
}
}
}
@@ -189,11 +218,13 @@ export default {
.result-wrap {
height: 280px;
margin: 12px 0;
margin: 6px 0;
.search-item {
display: flex;
height: 48px;
align-items: center;
padding-right: 10px;
.left {
width: 60px;
@@ -202,16 +233,17 @@ export default {
.menu-icon {
width: 18px;
height: 18px;
margin-top: 5px;
}
}
.search-info {
padding-left: 5px;
margin-top: 10px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
flex: 1;
.menu-title,
.menu-path {