Przeglądaj źródła

feat(第三方应用管理):修改角色管理的菜单权限功能逻辑,修改角色管理,权限管理,视图管理页面数据显示逻辑

xu 1 rok temu
rodzic
commit
5148e8ae0a

+ 7 - 3
admin.ui.plus-master/src/api/admin/data-contracts.ts

@@ -4414,8 +4414,10 @@ export interface oauthPermissionDto {
   sort?: string|null
   /** 应用id */
   appID?: number
-  /** 视图 */
-  viewId?: string|null
+  /** 视图id */
+  viewId?: number|null
+   /** 视图地址 */
+  viewPath?: string|null
   /** 说明 */
   // description?: string | null
 }
@@ -4453,8 +4455,10 @@ export interface OauthPermission {
   sort?: string|null
   /** 应用id */
   appID?: number
-  /** 视图 */
+  /** 视图id */
   viewId?: string|null
+  /** 视图地址 */
+  viewPath?: string|null
   /** 展开 */
   opened?: boolean
   /** 说明 */

+ 0 - 141
admin.ui.plus-master/src/router/route.ts

@@ -1197,99 +1197,6 @@ export const dynamicRoutes: Array<RouteRecordRaw> = [
                   icon: 'iconfont icon-neiqianshujuchucun',
                 },
               },
-              {
-                path: '/example/application',
-                name: 'example/application',
-                component: () => import('/@/layout/routerView/parent.vue'),
-                redirect: '/application/applicationManage',
-                meta: {
-                  title: 'message.application.applicationManage',
-                  isLink: '',
-                  isHide: false,
-                  isKeepAlive: true,
-                  isAffix: false,
-                  isIframe: false,
-                  roles: ['admin', 'common'],
-                  icon: 'iconfont icon-crew_feature',
-                },
-                children: [
-                  {
-                    path: '/example/application/roleManage',
-                    name: 'example/roleManage',
-                    component: () => import('/@/views/example/application/roleManage/index.vue'),
-                    meta: {
-                      title: 'message.application.roleManage',
-                      isLink: '',
-                      isHide: false,
-                      isKeepAlive: true,
-                      isAffix: false,
-                      isIframe: false,
-                      roles: ['admin', 'common'],
-                      icon: 'ele-ColdDrink',
-                    },
-                  },
-                  {
-                    path: '/example/application/permissionManage',
-                    name: 'example/permissionManage',
-                    component: () => import('/@/views/example/application/permissionManage/index.vue'),
-                    meta: {
-                      title: 'message.application.permissionManage',
-                      isLink: '',
-                      isHide: false,
-                      isKeepAlive: true,
-                      isAffix: false,
-                      isIframe: false,
-                      roles: ['admin'],
-                      icon: 'iconfont icon-quanxian',
-                    },
-                  },
-                  {
-                    path: '/example/application/applicationManage',
-                    name: 'example/applicationManage',
-                    component: () => import('/@/views/example/application/applicationManage/index.vue'),
-                    meta: {
-                      title: 'message.application.applicationManage',
-                      isLink: '',
-                      isHide: false,
-                      isKeepAlive: true,
-                      isAffix: false,
-                      isIframe: false,
-                      roles: ['admin'],
-                      icon: 'iconfont icon-crew_feature',
-                    },
-                  },
-                  {
-                    path: '/example/application/viewManage',
-                    name: 'example/viewManage',
-                    component: () => import('/@/views/example/application/viewManage/index.vue'),
-                    meta: {
-                      title: 'message.application.viewManage',
-                      isLink: '',
-                      isHide: false,
-                      isKeepAlive: true,
-                      isAffix: false,
-                      isIframe: false,
-                      roles: ['admin'],
-                      icon: 'iconfont icon-biaodan',
-                    },
-                  },
-                  {
-                    path: '/example/application/operationLog',
-                    name: 'example/operationLog',
-                    component: () => import('/@/views/example/application/operationLog/index.vue'),
-                    meta: {
-                      title: 'message.application.operationLog',
-                      isLink: '',
-                      isHide: false,
-                      isKeepAlive: true,
-                      isAffix: false,
-                      isIframe: false,
-                      roles: ['admin'],
-                      icon: 'ele-Document',
-                    },
-                  },
-                ],
-              },
               {
                 path: '/example/codeGeneration',
                 name: '代码生成',
@@ -1323,54 +1230,6 @@ export const dynamicRoutes: Array<RouteRecordRaw> = [
               icon: 'iconfont icon-crew_feature',
             },
           },
-          {
-            path: '/example/application/roleManage/:id',
-            name: '/example/application/roleManage/:id',
-            component: () => import('/@/views/example/application/roleManage/index.vue'),
-            //redirect: '/application/applicationManage',
-            meta: {
-              title: '角色管理',
-              isLink: '',
-              isHide: true,
-              isKeepAlive: true,
-              isAffix: false,
-              isIframe: false,
-              roles: ['admin', 'common'],
-              icon: 'iconfont icon-crew_feature',
-            },
-          },
-          {
-            path: '/example/application/permissionManage/:id',
-            name: '/example/application/permissionManage/:id',
-            component: () => import('/@/views/example/application/permissionManage/index.vue'),
-            //redirect: '/application/applicationManage',
-            meta: {
-              title: '权限管理',
-              isLink: '',
-              isHide: true,
-              isKeepAlive: true,
-              isAffix: false,
-              isIframe: false,
-              roles: ['admin', 'common'],
-              icon: 'iconfont icon-crew_feature',
-            },
-          },
-          {
-            path: '/example/application/viewManage/:id',
-            name: '/example/application/viewManage/:id',
-            component: () => import('/@/views/example/application/viewManage/index.vue'),
-            //redirect: '/application/applicationManage',
-            meta: {
-              title: '视图管理',
-              isLink: '',
-              isHide: true,
-              isKeepAlive: true,
-              isAffix: false,
-              isIframe: false,
-              roles: ['admin', 'common'],
-              icon: 'iconfont icon-crew_feature',
-            },
-          },
         ],
   },
 ]

+ 1 - 1
admin.ui.plus-master/src/stores/globalCacheStore.ts

@@ -32,7 +32,7 @@ export const useGlobalCacheStore = defineStore('globalCacheStore', {
       Object.keys(data as object).forEach(key => {
         const newMap = data?.[key]?.reduce((map, obj) => {
           // @ts-ignore
-          obj.color = obj.code.split("_")[1] ?? ''
+          obj.color = obj.code?.split("_")[1] ?? ''
           map.set(obj.value,{...obj})
           return map
         },new Map)

+ 6 - 6
admin.ui.plus-master/src/views/example/application/applicationManage/index.vue

@@ -105,13 +105,13 @@ const onDelete = (row: OauthApply) => {
     .catch(() => {})
 }
 const toRolePage = (row) => {
-  router.push({path:`/example/application/roleManage/${row.name}`})
+  router.push({path:`/platform/application/roleManage/${row.name}`})
 }
 const toViewPage = (row) => {
-  router.push({path:`/example/application/viewManage/${row.name}`})
+  router.push({path:`/platform/application/viewManage/${row.name}`})
 }
 const toPermissPage = (row) => {
-  router.push({path:`/example/application/permissionManage/${row.name}`})
+  router.push({path:`/platform/application/permissionManage/${row.name}`})
 }
 </script>
 
@@ -131,14 +131,14 @@ const toPermissPage = (row) => {
 }
 .appDdd{
   border: #7728F5 dashed 1px;
-  cursor: default; 
+  cursor: default;
 }
 .delete{
   width: 25px;
   height: 25px;
   border: #BBBBBB solid 2px;
   color: #BBBBBB;
-  font-size: 25px;      
-  cursor: default;     
+  font-size: 25px;
+  cursor: default;
 }
 </style>

+ 18 - 16
admin.ui.plus-master/src/views/example/application/permissionManage/components/permission-menu-form.vue

@@ -31,7 +31,7 @@
               />
             </el-form-item>
           </el-col>
-          <!-- <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
             <el-form-item label="视图">
               <el-tree-select
                 v-model="form.viewId"
@@ -57,7 +57,7 @@
                 </template>
               </el-tree-select>
             </el-form-item>
-          </el-col> -->
+          </el-col>
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
             <el-form-item label="名称" prop="label" :rules="[{ required: true, message: '请输入名称', trigger: ['blur', 'change'] }]">
               <el-input v-model="form.label" clearable />
@@ -137,7 +137,7 @@
 
 <script lang="ts" setup name="admin/permission/permission-menu-form">
 import { reactive, toRefs, getCurrentInstance, ref, PropType, defineAsyncComponent } from 'vue'
-import { PermissionListOutput, PermissionUpdateMenuInput, ViewListOutput,OauthPermission,oauthPermissionDto } from '/@/api/admin/data-contracts'
+import { OauthView,OauthPermission,oauthPermissionDto } from '/@/api/admin/data-contracts'
 import { PermissionApi } from '/@/api/admin/Permission'
 import { ViewApi } from '/@/api/admin/View'
 import { listToTree } from '/@/utils/tree'
@@ -164,13 +164,14 @@ const state = reactive({
   showDialog: false,
   sureLoading: false,
   form: {} as oauthPermissionDto,
-  viewTreeData: [] as OauthPermission[],
+  viewTreeData: [] as OauthView[],
   app:''
 })
 const { form } = toRefs(state)
 
-const getViews = async () => {
-  const res = await new PermissionApi().getPermissionInfo({appid:0})
+const getViews = async (app) => {
+  const appDate=await new PermissionApi().getApplyInfo({Name:app})
+  const res = await new PermissionApi().getViewInfo({appid:appDate.data[0].id})
   res.data=res.data.map((item)=>{
     if(item.parentId===''||item.parentId===null){
       item.parentId=Number('0')
@@ -180,7 +181,7 @@ const getViews = async () => {
     return item
   })
   if (res?.success && res.data && res.data.length > 0) {
-    state.viewTreeData = listToTree(res.data) as OauthPermission[]
+    state.viewTreeData = listToTree(res.data) as OauthView[]
   } else {
     state.viewTreeData = []
   }
@@ -191,7 +192,7 @@ const open = async (app:any,row: any = {}) => {
   state.app=app
   proxy.$modal.loading()
 
-  await getViews()
+  await getViews(app)
 
   // if (row.id > 0) {
   //   const res = await new PermissionApi().getPermissionInfo({appid:0,id: row.id}).catch(() => {
@@ -211,19 +212,19 @@ const open = async (app:any,row: any = {}) => {
   state.showDialog = true
 }
 
-// const onViewFilterNode = (value: string, data: OauthPermission) => {
-//   if (!value) return true
-//   return data.label?.indexOf(value) !== -1 || data.path?.indexOf(value) !== -1
-// }
+const onViewFilterNode = (value: string, data: OauthView) => {
+  if (!value) return true
+  return data.label?.indexOf(value) !== -1 || data.path?.indexOf(value) !== -1
+}
 
-const onViewCurrentChange = (data: OauthPermission) => {
+const onViewCurrentChange = (data: OauthView) => {
   if (data) {
     if (!state.form.label) {
       state.form.label = data.label
     }
-    // if (!state.form.path) {
-    //   state.form.path = '/' + data.path
-    // }
+    if (!state.form.viewPath) {
+      state.form.viewPath = '/' + data.path
+    }
   }
 }
 
@@ -243,6 +244,7 @@ const onSure = () => {
     state.form.type=2
     const appData=await new PermissionApi().getApplyInfo({name:state.app})
     state.form.appID=appData.data[0].id
+    console.log(state.form)
     if (state.form.id != undefined && state.form.id > 0) {
       res = await new PermissionApi().addAppPermission(state.form, { showSuccessMessage: true }).catch(() => {
         state.sureLoading = false

+ 8 - 13
admin.ui.plus-master/src/views/example/application/permissionManage/index.vue

@@ -3,9 +3,7 @@
     <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
       <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
         <el-form-item label="应用">
-          <el-select v-model="state.filter.app"  placeholder="请选择应用" style="width: 200px;">
-            <el-option v-for="(value, key) in state.app" :key="key" :label="value.name"  :value="value.name" />
-          </el-select>
+          <el-input v-model="state.filter.app" disabled placeholder="请选择应用" @keyup.enter="onQuery" />
         </el-form-item>
         <el-form-item label="权限名称">
           <el-input v-model="state.filter.name" placeholder="权限名称" @keyup.enter="onQuery" />
@@ -56,7 +54,6 @@
             <div v-if="row.type === 1 || row.type === 2">
               {{ row.viewPath ? '视图地址:' + row.viewPath : '' }}
             </div>
-            <div v-if="row.type === 3">接口地址:{{ row.viewPath }}</div>
           </template>
         </el-table-column>
         <el-table-column prop="sort" label="排序" width="80" align="center" show-overflow-tooltip />
@@ -114,6 +111,7 @@ import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyn
 import { OauthPermission,OauthApply } from '/@/api/admin/data-contracts'
 import { PermissionApi } from '/@/api/admin/Permission'
 import { listToTree, treeToList, filterTree } from '/@/utils/tree'
+import router from "/@/router";
 import { cloneDeep } from 'lodash-es'
 import eventBus from '/@/utils/mitt'
 import { auth } from '/@/utils/authFunction'
@@ -134,18 +132,16 @@ const state = reactive({
   permissionFormTitle: '',
   filter: {
     name: '',
-    app:'1'
+    app:''
   },
   permissionTreeData: [] as Array<OauthPermission>,
   formPermissionGroupTreeData: [] as Array<OauthPermission>,
   formPermissionMenuTreeData: [] as Array<OauthPermission>,
-  expandRowKeys: [] as string[],
-  app:[] as Array<OauthApply>,
+  expandRowKeys: [] as string[]
 })
 
 onMounted(async () => {
   await onQuery()
-  //state.filter.app=state.app[0].name
   state.expandRowKeys = treeToList(cloneDeep(state.permissionTreeData))
     .filter((a: OauthPermission) => a.opened === true)
     .map((a: OauthPermission) => a.id + '') as string[]
@@ -161,11 +157,10 @@ onBeforeMount(() => {
 
 const onQuery = async () => {
   state.loading = true
-  const appForm=await new PermissionApi().getApplyInfo({name:state.filter.app})
-  const appID=appForm.data[0].id
-  const appData=await new PermissionApi().getApplyInfo({id:0})
-  state.app=appData.data
-  const res = await new PermissionApi().getPermissionInfo({appid:appID,label:state.filter.name}).catch(() => {
+  const name = router.currentRoute.value.params.id
+  const appData=await new PermissionApi().getApplyInfo({Name:name})
+  state.filter.app=appData.data[0].name
+  const res = await new PermissionApi().getPermissionInfo({appid:appData.data[0].id,label:state.filter.name}).catch(() => {
     state.loading = false
   })
   res.data=res.data.map((item)=>{

+ 18 - 4
admin.ui.plus-master/src/views/example/application/roleManage/index.vue

@@ -4,6 +4,9 @@
       <div class="my-flex-column w100 h100">
         <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
           <el-form :inline="true" @submit.stop.prevent>
+            <el-form-item label="应用">
+              <el-input v-model="state.filter.app" disabled placeholder="请选择应用" @keyup.enter="onQuery" />
+            </el-form-item>
             <el-form-item label="角色名称">
               <el-input v-model="state.filter.roleName" placeholder="角色名称" @keyup.enter="onQuery" />
             </el-form-item>
@@ -113,11 +116,13 @@
       @sure="onSureUser"
     ></user-select>
     <set-app-menu ref="setAppMenuRef"></set-app-menu>
+    <set-role-menu ref="setRoleMenuRef"></set-role-menu>
     <set-role-data-scope ref="setRoleDataScopeRef"></set-role-data-scope>
   </my-layout>
 </template>
 
 <script lang="ts" setup name="admin/role">
+import router from "/@/router";
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, nextTick, defineAsyncComponent } from 'vue'
 import { OauthRole,RoleGetListOutput, RoleType,UserDto } from '/@/api/admin/data-contracts'
 import { RoleApi } from '/@/api/admin/Role'
@@ -135,7 +140,7 @@ const SetAppMenu = defineAsyncComponent(() => import('./components/set-app-menu.
 const UserSelect = defineAsyncComponent(() => import('./components/user-select.vue'))
 const MyDropdownMore = defineAsyncComponent(() => import('/@/components/my-dropdown-more/index.vue'))
 const MyLayout = defineAsyncComponent(() => import('/@/components/my-layout/index.vue'))
-
+const SetRoleMenu = defineAsyncComponent(() => import('./components/set-role-menu.vue'))
 const { proxy } = getCurrentInstance() as any
 
 const roleTableRef = ref()
@@ -143,6 +148,7 @@ const roleFormRef = ref()
 const userTableRef = ref<InstanceType<typeof ElTable>>()
 const userSelectRef = ref()
 const setAppMenuRef = ref()
+const setRoleMenuRef = ref()
 const setRoleDataScopeRef = ref()
 
 const state = reactive({
@@ -153,6 +159,7 @@ const state = reactive({
   filter: {
     name: '',
     roleName: '',
+    app:''
   },
   roleTreeData: [] as any,
   roleFormTreeData: [] as any,
@@ -175,6 +182,9 @@ onBeforeMount(() => {
 
 const onQuery = async () => {
   state.loading = true
+  const name = router.currentRoute.value.params.id
+  const appData=await new PermissionApi().getApplyInfo({Name:name})
+  state.filter.app=appData.data[0].name
   const res = await new PermissionApi().getRoleInfo({name:state.filter.roleName}).catch(() => {
     state.loading = false
   })
@@ -199,7 +209,7 @@ const onQuery = async () => {
     state.roleFormTreeData = listToTree(cloneDeep(res.data).filter((a) => a.parentId === 0))
     if (state.roleTreeData.length > 0 && state.roleTreeData[0].children?.length > 0) {
       nextTick(() => {
-        roleTableRef.value!.setCurrentRow(state.roleTreeData[0].children[0])
+        roleTableRef.value!?.setCurrentRow(state.roleTreeData[0].children[0])
       })
     }
   } else {
@@ -336,12 +346,16 @@ const onSureUser = async (users: UserDto[]) => {
   onGetRoleUserList()
 }
 
-const onSetAppMenu = (role: RoleGetListOutput) => {
+const onSetAppMenu = async (role: RoleGetListOutput) => {
   if (!((role?.id as number) > 0)) {
     proxy.$modal.msgWarning('请选择角色')
     return
   }
-  setAppMenuRef.value.open(role)
+  const input = { id: role.id, name:role.name }
+  const name = router.currentRoute.value.params.id
+  const appData=await new PermissionApi().getApplyInfo({Name:name})
+  console.log(appData.data)
+  setRoleMenuRef.value.open(input,appData.data[0].id)
 }
 
 const onSetRoleDataScope = (role: RoleGetListOutput) => {

+ 12 - 11
admin.ui.plus-master/src/views/example/application/viewManage/index.vue

@@ -3,9 +3,7 @@
     <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
       <el-form :model="state.filter" :inline="true" @submit.stop.prevent>
         <el-form-item label="应用">
-          <el-select v-model="state.filter.app" placeholder="请选择应用" style="width: 200px;">
-            <el-option v-for="(value, key) in state.app" :key="key" :label="value.name"  :value="value.name" />
-          </el-select>
+          <el-input v-model="state.filter.app" disabled placeholder="请选择应用" @keyup.enter="onQuery" />
         </el-form-item>
         <el-form-item label="视图名称">
           <el-input v-model="state.filter.name" placeholder="视图名称" @keyup.enter="onQuery" />
@@ -51,6 +49,7 @@
 </template>
 
 <script lang="ts" setup name="admin/view">
+import router from "/@/router";
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
 import { OauthView,OauthApply } from '/@/api/admin/data-contracts'
 import { ViewApi } from '/@/api/admin/View'
@@ -70,11 +69,10 @@ const state = reactive({
   viewFormTitle: '',
   filter: {
     name: '',
-    app:'1'
+    app:''
   },
   viewTreeData: [] as Array<OauthView>,
-  formViewTreeData: [] as Array<OauthView>,
-  app:[] as Array<OauthApply>
+  formViewTreeData: [] as Array<OauthView>
 })
 
 onMounted(() => {
@@ -91,14 +89,17 @@ onBeforeMount(() => {
 
 const onQuery = async () => {
   state.loading = true
-  const appForm=await new PermissionApi().getApplyInfo({name:state.filter.app})
-  const appID=appForm.data[0].id
-  const appData=await new PermissionApi().getApplyInfo({id:0})
-  state.app=appData.data
-  const res = await new PermissionApi().getViewInfo({appID:appID,label:state.filter.name}).catch(() => {
+  const name = router.currentRoute.value.params.id
+  const appData=await new PermissionApi().getApplyInfo({Name:name})
+  state.filter.app=appData.data[0].name
+  const res = await new PermissionApi().getViewInfo({appid:appData.data[0].id,label:state.filter.name}).catch(() => {
     state.loading = false
   })
   res.data=res.data.map((item)=>{
+    if(item.parentId===''||item.parentId===null){
+      item.parentId=Number('0')
+      item.type=1
+    }
     item.parentId=Number(item.parentId)
     return item
   })