Forráskód Böngészése

权限管理数据隔离相关修改

ZL 2 hónapja
szülő
commit
7587b90dbb

+ 5 - 0
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");

+ 10 - 5
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) {

+ 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('取消选中行');

+ 1 - 1
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',
 }

+ 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;