ソースを参照

Merge branch 'ZL' into dev

ZL 3 日 前
コミット
ef7d0405c2

+ 5 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleController.java

@@ -478,6 +478,11 @@ public class SysRoleController {
 		// Step.1 组装查询条件
 //		QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
 		String ids = request.getParameter("ids");
+		if (ids.length() > 2) {
+			ids = ids.substring(1, ids.length() - 1);
+		} else {
+			ids = null;
+		}
 		//Step.2 AutoPoi 导出Excel
 		ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
 		List<SysRole> pageList = sysRoleService.listExport(sysRole,ids);

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml

@@ -58,7 +58,7 @@
         app_base_info sa ON r.app_id = sa.id
         WHERE 1=1
           <if test="ids!=null">
-            AND r.id in (#{ids})
+            AND r.id in (${ids})
         </if>
         <if test="role.appId!=null">
             AND r.app_id = #{role.appId}

+ 20 - 6
jeecgboot-vue3/src/views/system/menu/components/AppPermissionTree.vue

@@ -263,6 +263,21 @@ function onTreeNodeSelect(key,{selectedNodes}) {
   toggleExpandAll(true);
 }
 
+function findAncestors(tree, targetId, path = []) {
+    for (let node of tree) {
+        if (node.key === targetId) {
+            return path;  
+        }
+        if (node.children) {
+            const result = findAncestors(node.children, targetId, [...path, node]);
+            if (result) {
+                return result;
+            }
+        }
+    }
+    return null;
+}
+
 function getNodeAllKey(node: any, children: any, key: string) {
   const result: any = [];
   result.push(node[key]);
@@ -289,15 +304,14 @@ function removeMatchingItems(arr1, arr2) {
 
 // tree勾选复选框事件
 function onCheck(o, e) {
-  // if (!Array.isArray(event)) {
-  //   checkedKeys.value = event.checked;
-  // } else {
-  //   checkedKeys.value = event;
-  // }
+  //勾选子节点时自动选择父节点与祖宗节点
+  const ancestors = findAncestors(treeData.value, e.node.key);
+  const ancestorsKeys = ancestors.map(item => item.key);
+  // console.log('ancestors', ancestors);
   const keys = getNodeAllKey(e.node, 'children', 'key');
   if (e.checked) {
     // 反复操作下可能会有重复的keys,得用new Set去重下
-    checkedKeys.value = [...new Set([...checkedKeys.value, ...keys])];
+    checkedKeys.value = [...new Set([...checkedKeys.value, ...keys,...ancestorsKeys])];
   } else {
     const result = removeMatchingItems(checkedKeys.value, keys);
     checkedKeys.value = result;

+ 1 - 1
jeecgboot-vue3/src/views/system/role/index.vue

@@ -114,7 +114,7 @@ const { prefixCls, tableContext, onImportXls, onExportXls } = useListPage({
   exportConfig: {
     name: '角色列表',
     url: ()=>{
-      const ids = encodeURIComponent(JSON.stringify(selectedRowKeys))
+      const ids = encodeURIComponent(JSON.stringify(selectedRowKeys.value))
       return `${getExportUrl}?ids=${ids}`;
     },
   },