4 Commits

Author SHA1 Message Date
D哥
22c7768c61 Pre Merge pull request !401 from D哥/N/A 2025-04-21 07:31:37 +00:00
RuoYi
d4af286f41 显隐列组件支持全选/全不选 2025-04-21 15:30:32 +08:00
RuoYi
60e2d55a23 优化菜单搜索查询页 2025-04-21 13:28:32 +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 136 additions and 75 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

@@ -1,25 +1,44 @@
<template>
<div :class="{'show':show}" class="header-search">
<div class="header-search">
<svg-icon class-name="search-icon" icon-class="search" @click.stop="click" />
<el-select
ref="headerSearchSelect"
v-model="search"
:remote-method="querySearch"
filterable
default-first-option
remote
placeholder="Search"
class="header-search-select"
@change="change"
<el-dialog
:visible.sync="show"
width="600px"
@close="close"
:show-close="false"
append-to-body
>
<el-option v-for="option in options" :key="option.item.path" :value="option.item" :label="option.item.title.join(' > ')" />
</el-select>
<el-input
v-model="search"
ref="headerSearchSelectRef"
size="large"
@input="querySearch"
prefix-icon="Search"
placeholder="菜单搜索支持标题、URL模糊查询"
>
</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="left">
<svg-icon class="menu-icon" :icon-class="item.icon" />
</div>
<div class="search-info" @click="change(item)">
<div class="menu-title">
{{ item.title.join(" / ") }}
</div>
<div class="menu-path">
{{ item.path }}
</div>
</div>
</div>
</div>
</el-scrollbar>
</el-dialog>
</div>
</template>
<script>
// fuse is a lightweight fuzzy-search module
// make search results more in line with expectations
import Fuse from 'fuse.js/dist/fuse.min.js'
import path from 'path'
import { isHttp } from '@/utils/validate'
@@ -46,13 +65,6 @@ export default {
},
searchPool(list) {
this.initFuse(list)
},
show(value) {
if (value) {
document.body.addEventListener('click', this.close)
} else {
document.body.removeEventListener('click', this.close)
}
}
},
mounted() {
@@ -63,23 +75,25 @@ export default {
this.show = !this.show
if (this.show) {
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus()
this.options = this.searchPool
}
},
close() {
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur()
this.search = ''
this.options = []
this.show = false
},
change(val) {
const path = val.path;
const query = val.query;
const path = val.path
const query = val.query
if(isHttp(val.path)) {
// http(s):// 路径新窗口打开
const pindex = path.indexOf("http");
window.open(path.substr(pindex, path.length), "_blank");
window.open(path.substr(pindex, path.length), "_blank")
} else {
if (query) {
this.$router.push({ path: path, query: JSON.parse(query) });
this.$router.push({ path: path, query: JSON.parse(query) })
} else {
this.$router.push(path)
}
@@ -117,11 +131,13 @@ export default {
const data = {
path: !isHttp(router.path) ? path.resolve(basePath, router.path) : router.path,
title: [...prefixTitle]
title: [...prefixTitle],
icon: ''
}
if (router.meta && router.meta.title) {
data.title = [...data.title, router.meta.title]
data.icon = router.meta.icon
if (router.redirect !== 'noRedirect') {
// only push the routes with title
@@ -146,51 +162,70 @@ export default {
},
querySearch(query) {
if (query !== '') {
this.options = this.fuse.search(query)
this.options = this.fuse.search(query).map((item) => item.item) ?? this.searchPool
} else {
this.options = []
this.options = this.searchPool
}
}
}
}
</script>
<style lang="scss" scoped>
.header-search {
font-size: 0 !important;
<style lang='scss' scoped>
::v-deep {
.el-dialog__header {
padding: 0 !important;
}
}
.header-search {
.search-icon {
cursor: pointer;
font-size: 18px;
vertical-align: middle;
}
}
.header-search-select {
font-size: 18px;
transition: width 0.2s;
width: 0;
overflow: hidden;
background: transparent;
border-radius: 0;
display: inline-block;
vertical-align: middle;
.result-wrap {
height: 280px;
margin: 12px 0;
::v-deep .el-input__inner {
border-radius: 0;
border: 0;
padding-left: 0;
padding-right: 0;
box-shadow: none !important;
border-bottom: 1px solid #d9d9d9;
vertical-align: middle;
.search-item {
display: flex;
height: 48px;
.left {
width: 60px;
text-align: center;
.menu-icon {
width: 18px;
height: 18px;
margin-top: 5px;
}
}
.search-info {
padding-left: 5px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
.menu-title,
.menu-path {
height: 20px;
}
.menu-path {
color: #ccc;
font-size: 10px;
}
}
}
&.show {
.header-search-select {
width: 210px;
margin-left: 10px;
}
.search-item:hover {
cursor: pointer;
}
}
</style>

View File

@@ -12,9 +12,14 @@
<el-dropdown trigger="click" :hide-on-click="false" style="padding-left: 12px" v-if="showColumnsType == 'checkbox'">
<el-button size="mini" circle icon="el-icon-menu" />
<el-dropdown-menu slot="dropdown">
<!-- 全选/反选 按钮 -->
<el-dropdown-item>
<el-checkbox :indeterminate="isIndeterminate" v-model="isChecked" @change="toggleCheckAll"> 列展示 </el-checkbox>
</el-dropdown-item>
<div class="check-line"></div>
<template v-for="item in columns">
<el-dropdown-item :key="item.key">
<el-checkbox :checked="item.visible" @change="checkboxChange($event, item.label)" :label="item.label" />
<el-checkbox v-model="item.visible" @change="checkboxChange($event, item.label)" :label="item.label" />
</el-dropdown-item>
</template>
</el-dropdown-menu>
@@ -41,33 +46,33 @@ export default {
// 弹出层标题
title: "显示/隐藏",
// 是否显示弹出层
open: false,
open: false
};
},
props: {
/* 是否显示检索条件 */
showSearch: {
type: Boolean,
default: true,
default: true
},
/* 显隐列信息 */
columns: {
type: Array,
type: Array
},
/* 是否显示检索图标 */
search: {
type: Boolean,
default: true,
default: true
},
/* 显隐列类型transfer穿梭框、checkbox复选框 */
showColumnsType: {
type: String,
default: "checkbox",
default: "checkbox"
},
/* 右外边距 */
gutter: {
type: Number,
default: 10,
default: 10
},
},
computed: {
@@ -77,6 +82,15 @@ export default {
ret.marginRight = `${this.gutter / 2}px`;
}
return ret;
},
isChecked: {
get() {
return this.columns.every((col) => col.visible);
},
set() {}
},
isIndeterminate() {
return this.columns.some((col) => col.visible) && !this.isChecked;
}
},
created() {
@@ -109,9 +123,14 @@ export default {
showColumn() {
this.open = true;
},
// 勾选
// 勾选
checkboxChange(event, label) {
this.columns.filter(item => item.label == label)[0].visible = event;
},
// 切换全选/反选
toggleCheckAll() {
const newValue = !this.isChecked;
this.columns.forEach((col) => (col.visible = newValue))
}
},
};
@@ -126,4 +145,10 @@ export default {
::v-deep .el-transfer__button:first-child {
margin-bottom: 10px;
}
.check-line {
width: 90%;
height: 1px;
background-color: #ccc;
margin: 3px auto;
}
</style>