Преглед на файлове

Merge branch 'ZL' into dev

ZL преди 2 месеца
родител
ревизия
2235567aca
променени са 19 файла, в които са добавени 170 реда и са изтрити 120 реда
  1. 13 1
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/AppmanageController.java
  2. 8 8
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java
  3. 5 3
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysRoleController.java
  4. 2 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/AppBaseInfoMapper.java
  5. 1 1
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysPermissionMapper.java
  6. 10 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/AppBaseInfoMapper.xml
  7. 1 3
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysPermissionMapper.xml
  8. 1 0
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/AppmanageService.java
  9. 1 1
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java
  10. 22 3
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AppmanageServiceImpl.java
  11. 6 8
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java
  12. 16 13
      jeecgboot-vue3/src/views/system/menu/components/AppPermissionTree.vue
  13. 14 7
      jeecgboot-vue3/src/views/system/menu/components/PermissionLeftTable.vue
  14. 11 7
      jeecgboot-vue3/src/views/system/menu/menu/menu.api.ts
  15. 1 0
      jeecgboot-vue3/src/views/system/menu/menu/menu.data.ts
  16. 37 28
      jeecgboot-vue3/src/views/system/menu/permission/permission.vue
  17. 1 8
      jeecgboot-vue3/src/views/system/menu/report/report.api.ts
  18. 6 23
      jeecgboot-vue3/src/views/system/menu/report/report.data.ts
  19. 14 6
      jeecgboot-vue3/src/views/system/menu/report/report.vue

+ 13 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/AppmanageController.java

@@ -5,8 +5,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.PermissionData;
 import org.jeecg.modules.system.entity.AppmanageEntity.*;
-import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.service.AppmanageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -168,4 +168,16 @@ public class AppmanageController {
         return Result.ok(appInfoService.isAppAdminOrDevOrOpe(appid));
     }
 
+    // 获取应用列表(权限隔离)
+    @PermissionData
+//    @RequiresPermissions("sys:app:admin")
+    @RequestMapping(value = "/appList", method = RequestMethod.GET)
+    public Result<List<AppBaseInfo>> adminAppList() {
+        List<AppBaseInfo> appBaseInfos = appInfoService.appList();
+        Result<List<AppBaseInfo>> result = new Result<>();
+        result.setResult(appBaseInfos);
+        result.setSuccess(true);
+        return result;
+    }
+
 }

+ 8 - 8
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java

@@ -82,14 +82,6 @@ public class SysPermissionController {
      * 子菜单
      */
 	private static final String CHILDREN = "children";
-	@RequestMapping(value = "/appList", method = RequestMethod.GET)
-	public Result<List<AppBaseInfo>> appList() {
-		List<AppBaseInfo> appBaseInfos = sysPermissionService.appList();
-		Result<List<AppBaseInfo>> result = new Result<>();
-		result.setResult(appBaseInfos);
-		result.setSuccess(true);
-		return result;
-	}
 
 
 	/**
@@ -136,6 +128,14 @@ public class SysPermissionController {
 													  HttpServletRequest req) {
 		long start = System.currentTimeMillis();
 		Result<List<SysPermissionReportVO>> result = new Result<>();
+		LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		Boolean isAdmin = loginUser.getUsername().equals("admin");
+		if (appId.isEmpty()&&!isAdmin){
+			result.setResult(new ArrayList<>());
+			result.setSuccess(true);
+			return result;
+		}
+
 		SysPermissionReportVO sysPermission = new SysPermissionReportVO();
 		sysPermission.setAppId(appId);
 		sysPermission.setBusiness(business);

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

@@ -129,7 +129,12 @@ public class SysRoleController {
 												@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 												@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 												HttpServletRequest req) {
+
 		Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
+		if (role.getAppId().isEmpty()){
+			result.setSuccess(true);
+			result.setResult(new Page<SysRole>());
+		}
 		QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
 		String s = QueryGenerator.installAuthJdbc(SysRole.class);
 		queryWrapper.orderByDesc("create_time");
@@ -168,9 +173,6 @@ public class SysRoleController {
 		return result;
 	}
 
-	/*
-	* 查询用户所拥有的全部角色
-	* */
 
 	
 	/**

+ 2 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/AppBaseInfoMapper.java

@@ -19,4 +19,6 @@ public interface AppBaseInfoMapper extends BaseMapper<AppBaseInfo> {
     List<AppBaseInfo> queryAppInfoList(@Param("key") String key,
                                           @Param("type") String type,
                                           @Param("status") String status);
+
+    List<AppBaseInfo> appList(@Param("permissionSql") String permissionSql);
 }

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

@@ -29,7 +29,7 @@ public interface SysPermissionMapper extends BaseMapper<SysPermission> {
 	public List<TreeModel> queryListByParentId(@Param("parentId") String parentId);
 	public List<SysPermission> listAndAppName( SysPermission sysPermission) ;
 	public List<SysPermission> listAndAppNameWithPermission( @Param("permission")SysPermission sysPermission,@Param("permissionSql")String permissionSql);
-	public List<AppBaseInfo> appList();
+
 	/**
 	 * 根据用户查询用户权限
      * @param userId 用户ID

+ 10 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/AppBaseInfoMapper.xml

@@ -23,4 +23,14 @@
         </if>
         ORDER BY app.create_time DESC
     </select>
+
+    <select id="appList" parameterType="String" resultType="org.jeecg.modules.system.entity.AppmanageEntity.AppBaseInfo">
+        select *
+        from app_base_info
+
+        where del_flag = 0
+        <if test="permissionSql !=null and permissionSql != ''">
+            ${permissionSql}
+        </if>
+    </select>
 </mapper>

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

@@ -37,9 +37,7 @@
 		<result column="permission" property="permission" jdbcType="INTEGER"/>
 	</resultMap>
 
-	<select id="appList" parameterType="Object" resultMap="AppBaseInfo">
-		select id,name from app_base_info
-	</select>
+
 
 	<!--根据查询权限列表并添加app名称-->
 	<select id="listAndAppName" parameterType="Object" resultMap="SysPermission">

+ 1 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/AppmanageService.java

@@ -59,5 +59,6 @@ public interface AppmanageService {
     // 是否为应用管理员或开发负责人、运维负责人
     boolean isAppAdminOrDevOrOpe(String appid);
 
+     List<AppBaseInfo> appList();
 }
 

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysPermissionService.java

@@ -32,7 +32,7 @@ public interface ISysPermissionService extends IService<SysPermission> {
 //	public List<SysPermission> joinList(MPJLambdaWrapper<SysPermission> querywrapper);
 	public List<SysPermission> listAndAppName( SysPermission sysPermission);
 	public List<SysPermission> listAndAppNameWithPermission( SysPermission sysPermission);
-	public List<AppBaseInfo> appList();
+
 	/**
      * 真实删除
      * @param id 菜单id

+ 22 - 3
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AppmanageServiceImpl.java

@@ -1,16 +1,18 @@
 package org.jeecg.modules.system.service.impl;
 
-import cn.hutool.system.UserInfo;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.modules.base.service.BaseCommonService;
 import org.jeecg.modules.system.controller.SysUserController;
-import org.jeecg.modules.system.entity.*;
 import org.jeecg.modules.system.entity.AppmanageEntity.*;
+import org.jeecg.modules.system.entity.SysPermission;
+import org.jeecg.modules.system.entity.SysRole;
+import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.mapper.*;
 import org.jeecg.modules.system.service.*;
 import org.jeecg.modules.system.vo.SysUserRoleVO;
@@ -647,5 +649,22 @@ public class AppmanageServiceImpl implements AppmanageService {
         return roleNameInfo;
     }
 
-
+    @Override
+    public List<AppBaseInfo> appList() {
+        String sql = QueryGenerator.installAuthJdbc(AppBaseInfo.class);
+        //对sql进行处理避免注入
+        StringBuilder inSql = new StringBuilder("AND id IN (");
+        System.out.println("sql----------------------->"
+                +sql);
+        if (sql.startsWith(" and id in (")&& sql.endsWith(")")){
+            String inClause = sql.substring(" and id in (".length(), sql.length() - 1);
+            List<String> ids = Arrays.asList(inClause.split(","));
+            if (!ids.isEmpty()){
+                ids.forEach(id -> inSql.append(id).append(","));
+                inSql.deleteCharAt(inSql.length() - 1);
+            }else inSql.append(inClause);
+        }
+        inSql .append(") ");
+        return baseInfoMapper.appList(inSql.toString());
+    }
 }

+ 6 - 8
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysPermissionServiceImpl.java

@@ -91,19 +91,17 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
 	}
 	public static String modifySql(String sql) {
 		String regex ="(?i)\\s+AND\\s+";
-		String modiSQL = "";
+		StringBuilder modiSQL = new StringBuilder();
 		for (String s : sql.split(regex)) {
-			if(s.trim().length()>0){
-				modiSQL += " AND p."+s.trim();
+			String trim = s.trim();
+			if(!trim.isEmpty()){
+				modiSQL.append(" AND p.").append(trim);
 			}
 		}
-		return modiSQL;
-	}
-	@Override
-	public List<AppBaseInfo> appList() {
-		return sysPermissionMapper.appList();
+		return modiSQL.toString();
 	}
 
+
 	/**
 	  * 真实删除
 	 */

+ 16 - 13
jeecgboot-vue3/src/views/system/menu/components/AppPermissionTree.vue

@@ -75,10 +75,9 @@ const props = defineProps({
 // 计算当前选中的 appId 对应的 label
 const selectedAppName = ref('');
 function setAppName() {
-  if (!appId || !props.appList || props.appList?.length < 1) return '基础平台';
+  if (!appId || !props.appList || props.appList?.length < 1) return ' ';
   if (props.appList.length > 0) {
-    const selectedApp = props.appList.find((app) => app.value === appId.value);
-    console.log('selectedAppName', selectedApp.label);
+    const selectedApp = props.appList.find((app) => app.value === appId.value)
     return selectedApp ? selectedApp.label : '';
   }
 }
@@ -119,8 +118,11 @@ async function loadData() {
   try {
     loading.value = true;
     treeType.value = 'role';
-    treeData.value = await loadTreeData(appId.value);
-    selectedAppName.value = setAppName();
+    // if(appId.value){
+      treeData.value = await loadTreeData(appId.value);
+      selectedAppName.value = setAppName();
+    // }
+    
 
     await nextTick();
     toggleExpandAll(true);
@@ -191,6 +193,9 @@ function clearTree() {
 
 async function loadTreeData(appId) {
   try {
+    if(!appId){
+      return [];
+    }
     const { treeList } = await queryTreeList({ appId });
     return translateTitle(treeList);
   } catch (error) {
@@ -246,9 +251,7 @@ async function onSubmit() {
  * 选中节点,打开数据权限抽屉
  */
 function onTreeNodeSelect(key,{selectedNodes}) {
-  // if (key && key.length > 0) {
-  //   selectedKeys.value = key;
-  // }
+ 
   if(key[0]&&selectedNodes[0].ruleFlag){
     if (tabType.value === 'role') {
     openDataRuleDrawer(true, { functionId: key[0], selectId: unref(selectId), ruleType: unref(tabType) });
@@ -256,8 +259,8 @@ function onTreeNodeSelect(key,{selectedNodes}) {
     openDataRuleDrawer(true, { functionId: key[0], selectId: unref(selectId), ruleType: unref(tabType) });
   }
   }
-  onExpand(key)
-  // toggleExpandAll(true);
+  // onExpand(key)
+  toggleExpandAll(true);
 }
 
 function getNodeAllKey(node: any, children: any, key: string) {
@@ -303,8 +306,8 @@ function onCheck(o, e) {
 
 // tree展开事件
 function onExpand($expandedKeys) {
-  // expandedKeys.value = $expandedKeys;
-  expandedKeys.value =  [...new Set([...expandedKeys.value, ...$expandedKeys])];
+  expandedKeys.value = $expandedKeys;
+  // expandedKeys.value =  [...new Set([...expandedKeys.value, ...$expandedKeys])];
 }
 
 // tree选中事件
@@ -343,4 +346,4 @@ async function toggleCheckALL(flag) {
 .rule-tree :deep(.scrollbar__bar) {
   pointer-events: none;
 }
-</style>
+</style>

+ 14 - 7
jeecgboot-vue3/src/views/system/menu/components/PermissionLeftTable.vue

@@ -1,6 +1,7 @@
 <template>
-  <div style="margin-left: 2%">
-    <a-select ref="select" v-model:value="props.clickParam.appId" style="width: 40%" :options="props.appList" />
+  <div style="margin-left: 7%">
+    应用:<a-select ref="select" v-model:value="props.clickParam.appId" style="width: 31%" :options="props.appList" placeholder="暂无应用" />
+    <!-- <AppSelect style="width: 31%" :selectedApp="props.clickParam.appId" ></AppSelect> -->
   </div>
 
   <BasicTable @register="registerTable" :rowSelection="rowSelection" />
@@ -15,11 +16,12 @@ import { useListPage } from '/@/hooks/system/useListPage';
 import { list as roleList } from '../../role/role.api';
 import { roleColumns, userColumns, roleSchema, userSchema } from '../permission/permission.data';
 import { list as userList } from '../../user/user.api';
+// import AppSelect from './AppSelect.vue';
 
 const props = defineProps({
   appList: {
     type: Object,
-    default: () => [],
+    default: undefined,
   },
   clickParam: {
     type: Object,
@@ -35,6 +37,7 @@ type Key = string | number;
 const appList = ref<SelectProps['options']>([]);
 const handleClick = () => {
   emit('update:clickParam', { ...props.clickParam, appId: appId.value });
+  setProps({ api: appId.value ? (tabType.value === 'role' ? roleList : userList) : undefined, dataSource: appId.value ? undefined : [] });
   reload();
 };
 
@@ -44,7 +47,9 @@ watch(tabType, () => deleteSelect());
 // 列表页面公共参数、方法
 const { prefixCls, tableContext } = useListPage({
   tableProps: {
-    api: tabType.value === 'role' ? roleList : userList,
+    // api: tabType.value === 'role' ? roleList : userList,
+    api: appId.value ? (tabType.value === 'role' ? roleList : userList) : undefined,
+    dataSource: appId.value ? undefined : [],
     columns: tabType.value === 'role' ? roleColumns : userColumns,
     size: 'small',
     pagination: true,
@@ -56,7 +61,6 @@ const { prefixCls, tableContext } = useListPage({
     showActionColumn: false,
     tableSetting: { fullScreen: true },
     beforeFetch: (params) => {
-      console.log('提交前的app', appId.value);
       params.appId = appId.value;
     },
     formConfig: {
@@ -91,8 +95,11 @@ const { prefixCls, tableContext } = useListPage({
   },
 });
 //注册table
-const [registerTable, { reload, expandAll, collapseAll, getForm, deleteSelectRowByKey, getSelectRowKeys }, { rowSelection, selectedRowKeys }] =
-  tableContext;
+const [
+  registerTable,
+  { reload, setProps, expandAll, collapseAll, getForm, deleteSelectRowByKey, getSelectRowKeys },
+  { rowSelection, selectedRowKeys },
+] = tableContext;
 //取消选中行
 async function deleteSelect() {
   console.log('取消选中行');

+ 11 - 7
jeecgboot-vue3/src/views/system/menu/menu/menu.api.ts

@@ -15,7 +15,7 @@ enum Api {
   checkPermDuplication = '/sys/permission/checkPermDuplication',
   queryUserPermission = '/sys/permission/queryUserPermission',
   saveUserPermission = '/sys/permission/saveUserPermission',
-  appList = '/sys/permission/appList',
+  appList = '/sys/applicationInfo/appList',
   queryByUser = '/sys/permission/queryByUser',
   queryDataRule = '/sys/permission/datarule',
 }
@@ -102,7 +102,7 @@ export const getCheckPermDuplication = (params) => defHttp.get({ url: Api.checkP
  * @param schema
  * @param required
  */
-export const checkPermDuplication=(model, schema, required?)=>{
+export const checkPermDuplication = (model, schema, required?) => {
   return [
     {
       validator: (_, value) => {
@@ -113,14 +113,18 @@ export const checkPermDuplication=(model, schema, required?)=>{
           return Promise.reject(`请输入${schema.label}`);
         }
         return new Promise<void>((resolve, reject) => {
+          let url = model.url.trim();
+          if (!url.startsWith('/')) {
+            url = '/' + url;
+          }
           getCheckPermDuplication({
             id: model.id,
-            url:model.url,
-            alwaysShow:model.alwaysShow
+            url: url,
+            alwaysShow: model.alwaysShow
           }).then((res) => {
-              res.success ? resolve() : reject(res.message || '校验失败');
+            res.success ? resolve() : reject(res.message || '校验失败');
           }).catch((err) => {
-              reject(err.message || '验证失败');
+            reject(err.message || '验证失败');
           });
         });
       },
@@ -153,7 +157,7 @@ export const queryByUser = (params) => defHttp.get({ url: Api.queryByUser, param
 /**
  * 查询数据规则
  */
-export const queryDataRule = (params) =>defHttp.get({ url: `${Api.queryDataRule}/${params.functionId}` , params});
+export const queryDataRule = (params) => defHttp.get({ url: `${Api.queryDataRule}/${params.functionId}`, params });
 
 // /**
 //  * 查询用户数据规则

+ 1 - 0
jeecgboot-vue3/src/views/system/menu/menu/menu.data.ts

@@ -93,6 +93,7 @@ export const formSchema: FormSchema[] = [
     label: '应用',
     field: 'appId',
     component: 'JDictSelectTag',
+    required: true,
     componentProps: {
       dictCode: 'app_base_info,name,id',
       placeholder: '请选择应用',

+ 37 - 28
jeecgboot-vue3/src/views/system/menu/permission/permission.vue

@@ -1,18 +1,27 @@
 <template>
   <div class="p-4">
-    
-      <a-row :class="['p-4', `${prefixCls}--box`]" type="flex" :gutter="10">
+    <a-row :class="['p-4', `${prefixCls}--box`]" type="flex" :gutter="10">
       <a-col :xl="12" :lg="24" :md="24" style="margin-bottom: 10px">
         <div style="height: 100%" :class="[`${prefixCls}`]">
           <a-tabs @change="handleTabChange">
-            <a-tab-pane tab="角色授权" key="role-info"  style="position: relative">
+            <a-tab-pane tab="角色授权" key="role-info" style="position: relative">
               <div style="padding: 20px">
-                <PermissionLeftTable  :clickParam="clickParam" @update:clickParam="selectIdUpdate" :appList="appList" @update:appList="appListUpdated" />
+                <PermissionLeftTable
+                  :clickParam="clickParam"
+                  @update:clickParam="selectIdUpdate"
+                  :appList="appList"
+                  @update:appList="appListUpdated"
+                />
               </div>
             </a-tab-pane>
             <a-tab-pane tab="用户授权" key="user-info">
               <div style="padding: 20px">
-                <PermissionLeftTable :clickParam="clickParam" @update:clickParam="selectIdUpdate" :appList="appList" @update:appList="appListUpdated"/>
+                <PermissionLeftTable
+                  :clickParam="clickParam"
+                  @update:clickParam="selectIdUpdate"
+                  :appList="appList"
+                  @update:appList="appListUpdated"
+                />
               </div>
             </a-tab-pane>
           </a-tabs>
@@ -21,19 +30,16 @@
       <a-col :xl="12" :lg="24" :md="24" style="margin-bottom: 10px">
         <div style="height: 100%" :class="[`${prefixCls}`]">
           <div style="padding: 20px">
-            <AppPermissionTree  :clickParam="clickParam" :appList="appList"/>
+            <AppPermissionTree :clickParam="clickParam" :appList="appList" />
           </div>
-          
         </div>
       </a-col>
     </a-row>
-    
-    
   </div>
 </template>
   
   <script lang="ts" setup name="system-menu-permission">
-import { provide, reactive, ref, watch, nextTick, onMounted,onBeforeMount } from 'vue';
+import { provide, reactive, ref, watch, nextTick, onMounted, onBeforeMount } from 'vue';
 import type { SelectProps } from 'ant-design-vue';
 import { useDesign } from '/@/hooks/web/useDesign';
 import { appList as getAppList } from '../menu/menu.api';
@@ -42,17 +48,16 @@ import PermissionLeftTable from '../components/PermissionLeftTable.vue';
 
 const { prefixCls } = useDesign('menu-manage');
 provide('prefixCls', prefixCls);
-// const appList = ref([]);
 const appList = ref<SelectProps['options']>([]);
 
 //当前选中的条件信息
-const clickParam = reactive({ appId: '0', tabType: 'role', selectId: '' });
+const clickParam = reactive({ appId: '', tabType: 'role', selectId: '' });
 
 const selectIdUpdate = (newClickParam) => {
   clickParam.selectId = newClickParam.selectId;
 };
 const appListUpdated = (newAppList) => {
-  appList.value = newAppList
+  appList.value = newAppList;
 };
 //切换页签清空树选中
 const handleTabChange = (key: string) => {
@@ -61,30 +66,34 @@ const handleTabChange = (key: string) => {
   } else if (key === 'user-info') {
     clickParam.tabType = 'user'; // 用户授权对应的 tabType
   }
-  clickParam.selectId = ''
+  clickParam.selectId = '';
   console.log('切换页签app-----' + clickParam.appId);
 };
 
-// onMounted( async() => {
-//   await nextTick();
-//   console.log('appList-----3', appList.value);
-// });
 onBeforeMount(async () => {
-  console.log('appList-----1', appList.value);
   loadApp();
 });
 async function loadApp() {
-  const apps = await getAppList(); 
-  const appOptions = apps.map(app => {
-    return { 
-        value: app.id, 
-        label: app.name 
+  const apps = await getAppList();
+  if (!apps) {
+    appList.value = undefined;
+    return;
+  }
+  const appOptions = apps.map((app) => {
+    return {
+      value: app.id,
+      label: app.name,
     };
-});
+  });
+  const hasJCPT = appOptions.some((option) => option.value === '0');
+  if (hasJCPT) {
+    clickParam.appId = '0';
+  } else {
+    clickParam.appId = appOptions[0].value;
+  }
 
-appList.value = appOptions;
-console.log('appList-----' ,appList.value);
-await nextTick();
+  appList.value = appOptions;
+  await nextTick();
 }
 </script>
   

+ 1 - 8
jeecgboot-vue3/src/views/system/menu/report/report.api.ts

@@ -10,12 +10,5 @@ enum Api {
 * @param params
 */
 export const report = (params) => {
-    // const formparam = {
-    //     type: params.type,
-    //     sysPermission: params.sysPermission || {},
-    //   };
-    console.log(params);
-    return defHttp.get({
-        url: Api.report, params
-    }, { isTransformResponse: false });
+    return defHttp.get({ url: Api.report, params }, { isTransformResponse: false });
 }

+ 6 - 23
jeecgboot-vue3/src/views/system/menu/report/report.data.ts

@@ -1,14 +1,17 @@
 import { BasicColumn } from '/@/components/Table';
 import { FormSchema } from '/@/components/Table';
+import { appList  } from '../menu/menu.api';
 
 
 export const formSchema: FormSchema[] = [
     {
         label: '应用',
         field: 'appId',
-        component: 'JDictSelectTag',
+        component: 'ApiSelect',
         componentProps: {
-            dictCode: 'app_base_info,name,id',
+            api: appList,
+            labelField: 'name',
+            valueField: 'id',
             placeholder: '请选择应用',
         },
 
@@ -26,27 +29,7 @@ export const formSchema: FormSchema[] = [
         component: 'Input',
 
     },
-    // {
-    //     label: '菜单',
-    //     field: 'menu',
-    //     component: 'Input',
-    //     colProps: { span: 5 },
-    // },
-    // {
-    //     label: '权限类型',
-    //     field: 'menuType',
-    //     component: 'JDictSelectTag',
-    //     componentProps: {
-    //         dictCode: 'menu_type',
-    //         type: 'select'
-    //         // options: [
-    //         //     { label: '一级菜单', value: 0 },
-    //         //     { label: '子菜单', value: 1 },
-    //         //     { label: '按钮/权限', value: 2 },
-    //         //   ],
-    //     },
-    //     colProps: { span: 6 },
-    // },
+    
 
 ]
 

+ 14 - 6
jeecgboot-vue3/src/views/system/menu/report/report.vue

@@ -1,5 +1,4 @@
 <template>
-  
   <a-card style="margin: 10px">
     <BasicForm @register="registerForm" @submit="handleSubmit" />
     <a-tabs @change="handleTabChange" type="card">
@@ -25,6 +24,7 @@ import { useDesign } from '/@/hooks/web/useDesign';
 import { useListPage } from '/@/hooks/system/useListPage';
 import { BasicForm, useForm } from '/@/components/Form/index';
 import { formSchema, roleColumns, userColumns } from './report.data';
+import { appList } from '../menu/menu.api';
 import { report } from './report.api';
 const { prefixCls } = useDesign('menu-report');
 provide('prefixCls', prefixCls);
@@ -33,9 +33,9 @@ const loading = ref<boolean>(false);
 const roleReport = ref([]);
 const userReport = ref([]);
 const tabtype = ref('role');
-
+const apps = ref<any>([]);
 //表单配置
-const [registerForm] = useForm({
+const [registerForm,] = useForm({
   schemas: formSchema,
   autoSubmitOnEnter: true,
   baseColProps: {
@@ -54,19 +54,27 @@ const [registerForm] = useForm({
     xl: 6,
     xxl: 6,
   },
-  
 });
 
 // 初始化报表数据
 onBeforeMount(async () => {
-  await fetchReportData('role', {});
+  const applist = await appList();
+  if (!applist) {
+    return;
+  }
+  apps.value = applist;
+  await fetchReportData('role', { appId: applist[0].id });
 });
 
 // 根据页签变化获取数据
 async function handleTabChange(key: string) {
   try {
     loading.value = true;
-    await fetchReportData(key, {});
+    if(!apps.value){
+      return;
+    }
+    console.log('切换页签app-----' + apps.value);
+    await fetchReportData(key, {appId: apps.value[0].id});
   } finally {
     tabtype.value = key;
     loading.value = false;