Переглянути джерело

新增本部门数据权限

RuoYi 5 роки тому
батько
коміт
9be8716776

+ 14 - 0
ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css

@@ -685,6 +685,20 @@ label {
 	float: none;
 }
 
+.select-list .select-selectpicker li {
+	float: none;
+}
+
+.select-list .dropdown-menu>li>a {
+    line-height: inherit;
+}
+
+.select-list .dropdown-menu li>a:hover,.dropdown-menu li>a:focus,.dropdown-submenu:hover>a {
+	color: #fff;
+	text-decoration: none;
+	background-color: #12889a
+}
+
 .select-list .select-time input {
 	width: 93px;
 }

+ 2 - 1
ruoyi-admin/src/main/resources/templates/system/role/dataScope.html

@@ -26,11 +26,12 @@
 					<select id="dataScope" name="dataScope" class="form-control m-b">
 						<option value="1" th:field="*{dataScope}">全部数据权限</option>
 						<option value="2" th:field="*{dataScope}">自定数据权限</option>
+						<option value="3" th:field="*{dataScope}">本部门数据权限</option>
 					</select>
 					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 特殊情况下,设置为“自定数据权限”</span>
 				</div>
 			</div>
-			<div class="form-group" id="authDataScope" th:style="'display:' + @{(*{dataScope=='1'} ? 'none' : 'block')} + ''">
+			<div class="form-group" id="authDataScope" th:style="'display:' + @{(*{dataScope=='2'} ? 'block' : 'none')} + ''">
 				<label class="col-sm-3 control-label">数据权限</label>
 				<div class="col-sm-8">
 					<div id="deptTrees" class="ztree"></div>

+ 10 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java

@@ -34,6 +34,11 @@ public class DataScopeAspect
      */
     public static final String DATA_SCOPE_CUSTOM = "2";
 
+    /**
+     * 部门数据权限
+     */
+    public static final String DATA_SCOPE_DEPT = "3";
+
     /**
      * 数据权限过滤关键字
      */
@@ -73,6 +78,7 @@ public class DataScopeAspect
 
     /**
      * 数据范围过滤
+     * 
      * @param joinPoint 切点
      * @param user 用户
      * @param alias 别名
@@ -95,6 +101,10 @@ public class DataScopeAspect
                         " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", alias,
                         role.getRoleId()));
             }
+            else if (DATA_SCOPE_DEPT.equals(dataScope))
+            {
+                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", alias, user.getDeptId()));
+            }
         }
 
         if (StringUtils.isNotBlank(sqlString.toString()))

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml

@@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="businessType != null">
 				AND business_type = #{businessType}
 			</if>
-			<if test="businessTypes != null and businessTypes != ''">
+			<if test="businessTypes != null and businessTypes.length > 0">
 			    AND business_type in
 			    <foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
 		 			#{businessType}