Browse Source

流程权限功能开发

songxy 11 tháng trước cách đây
mục cha
commit
b8c574f35a

+ 0 - 2
client/.env.dev

@@ -7,8 +7,6 @@ VITE_DEV=false
 # VITE_BASE_URL='http://10.10.9.113:48080'
 VITE_BASE_URL='http://10.10.10.7:18080'
 
-# VITE_BASE_URL='https://oa.zjugis.com:28080'
-
 # 上传路径
 VITE_UPLOAD_URL='/infra/file/upload'
 

+ 23 - 4
client/src/api/oa/workflow/index.ts

@@ -34,6 +34,17 @@ export const getHandlerCaseCenterCount = async (data) => {
     '/workflow'
   )
 }
+// 获取流程模版列表
+export const GetFlowTemplateTreeData = async () => {
+  return await request.postOriginal(
+    {
+      url: '/TFlowTemplate/GetFlowTemplateTreeData',
+      data: null,
+      headersType: 'application/form-data'
+    },
+    '/workflow'
+  )
+}
 // 获取办件中心新建办件模板
 export const getFlowTemplateTreeDataByUser = async (data) => {
   return await request.postOriginal(
@@ -147,13 +158,21 @@ export const isHangUp = async (data: { activityInstanceId: string }) => {
   )
 }
 
-//办件中心“作废”操作
-export const isVoid = async (data: { flowInstanceId: string }) => {
-  // {"flowInstanceId": rowObj.flowInstanceId}
+//效验该流程是否已经作废
+export const isFlowVoid = async (data: { flowInstanceId: string }) => {
+  const keys = Object.keys(data)
+  const formData = new FormData()
+  keys.forEach((key) => {
+    if (data[key] instanceof Object) {
+      formData.append(key, JSON.stringify(data[key]))
+    } else {
+      formData.append(key, data[key])
+    }
+  })
   return await request.postOriginal(
     {
       url: '/Transfer/isVoid',
-      data: data,
+      data: formData,
       headersType: 'application/form-data'
     },
     '/workflow'

+ 10 - 0
client/src/api/system/permission/index.ts

@@ -16,6 +16,11 @@ export interface PermissionAssignRoleDataScopeReqVO {
   dataScopeDeptIds: number[]
 }
 
+export interface PermissionAssignRoleFlowScopeReqVO {
+  roleId: number
+  flowIds: string[]
+}
+
 // 查询角色拥有的菜单权限
 export const getRoleMenuList = async (roleId: number) => {
   return await request.get({ url: '/system/permission/list-role-menus?roleId=' + roleId })
@@ -31,6 +36,11 @@ export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeReq
   return await request.post({ url: '/system/permission/assign-role-data-scope', data })
 }
 
+// 赋予角色流程权限
+export const assignRoleFlowScope = async (data: PermissionAssignRoleFlowScopeReqVO) => {
+  return await request.post({ url: '/system/permission/assign-role-flow', data })
+}
+
 // 查询用户拥有的角色数组
 export const getUserRoleList = async (userId: number) => {
   return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId })

+ 1 - 0
client/src/api/system/role/index.ts

@@ -9,6 +9,7 @@ export interface RoleVO {
   type: number
   dataScope: number
   dataScopeDeptIds: string[]
+  flowIds: string[]
   createTime: Date
 }
 

+ 0 - 2
client/src/views/OaSystem/oaLayout/menus.vue

@@ -305,8 +305,6 @@ onMounted(() => {
   .menus-tabs {
     width: 100%;
     height: calc(100% - 250px);
-    overflow-x: hidden;
-    overflow-y: auto;
     .menuDiv {
       position: relative;
 

+ 7 - 0
client/src/views/OaSystem/officeCenter/mainOfficeCenter/index.vue

@@ -182,6 +182,7 @@ import {
   addIHangUp,
   addINullyApply,
   completelyVoidINullyApply,
+  isFlowVoid,
   saveINullyApply,
   openOfficeTip,
   saveAndGetUrl
@@ -297,6 +298,11 @@ const switchTabHandle = (item) => {
   pageParam['pageNo'] = 1
   queryHandlerCaseCenterList()
 }
+
+const initHandleCaseCenterData = () => {
+  queryHandlerCaseCenterCount()
+  queryHandlerCaseCenterList()
+}
 /**
  * 初始化新建流程中流程模板Tree
  */
@@ -454,6 +460,7 @@ const recoverActivityHandle = (item: any) => {
   }).then((res) => {
     if (res) {
       message.success('追回成功!')
+      initHandleCaseCenterData()
     }
   })
 }

+ 23 - 41
client/src/views/system/role/ProcessDataPermissionForm.vue

@@ -7,22 +7,8 @@
       <el-form-item label="角色标识">
         <el-tag>{{ formData.code }}</el-tag>
       </el-form-item>
-      <el-form-item label="权限范围">
-        <el-select v-model="formData.dataScope">
-          <el-option
-            v-for="item in getIntDictOptions(DICT_TYPE.SYSTEM_DATA_SCOPE)"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value"
-          />
-        </el-select>
-      </el-form-item>
     </el-form>
-    <el-form-item
-      v-if="formData.dataScope === SystemDataScopeEnum.DEPT_CUSTOM"
-      label="权限范围"
-      style="display: flex"
-    >
+    <el-form-item label="权限范围" style="display: flex">
       <el-card class="card" shadow="never">
         <template #header>
           全选/全不选:
@@ -47,7 +33,7 @@
         <el-tree
           ref="treeRef"
           :check-strictly="!checkStrictly"
-          :data="deptOptions"
+          :data="flowTemplates"
           :props="defaultProps"
           default-expand-all
           empty-text="加载中,请稍后"
@@ -63,11 +49,10 @@
   </Dialog>
 </template>
 <script lang="ts" setup>
-import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { GetFlowTemplateTreeData } from '@/api/oa/workflow'
 import { defaultProps, handleTree } from '@/utils/tree'
 import { SystemDataScopeEnum } from '@/utils/constants'
 import * as RoleApi from '@/api/system/role'
-import * as DeptApi from '@/api/system/dept'
 import * as PermissionApi from '@/api/system/permission'
 
 defineOptions({ name: 'SystemRoleDataPermissionForm' })
@@ -81,11 +66,10 @@ const formData = reactive({
   id: 0,
   name: '',
   code: '',
-  dataScope: undefined,
-  dataScopeDeptIds: []
+  flowIds: []
 })
 const formRef = ref() // 表单 Ref
-const deptOptions = ref<any[]>([]) // 部门树形结构
+const flowTemplates = ref<any[]>([]) // 流程模版树形结构
 const deptExpand = ref(false) // 展开/折叠
 const treeRef = ref() // 菜单树组件 Ref
 const treeNodeAll = ref(false) // 全选/全不选
@@ -96,17 +80,19 @@ const open = async (row: RoleApi.RoleVO) => {
   dialogVisible.value = true
   resetForm()
   // 加载 Dept 列表。注意,必须放在前面,不然下面 setChecked 没数据节点
-  deptOptions.value = handleTree(await DeptApi.getSimpleDeptList())
-  // 设置数据
-  formData.id = row.id
-  formData.name = row.name
-  formData.code = row.code
-  formData.dataScope = row.dataScope
-  setTimeout(() => {
-    row.dataScopeDeptIds?.forEach((deptId: string) => {
-      treeRef.value.setChecked(deptId, true, false)
-    })
-  }, 100)
+
+  GetFlowTemplateTreeData().then((result: any) => {
+    formData.id = row.id
+    formData.name = row.name
+    formData.code = row.code
+    if (result.length === 0) return
+    flowTemplates.value = handleTree(result, 'id', 'pid')
+    setTimeout(() => {
+      row.flowIds?.forEach((deptId: string) => {
+        treeRef.value.setChecked(deptId, true, false)
+      })
+    }, 100)
+  })
 }
 defineExpose({ open }) // 提供 open 方法,用于打开弹窗
 
@@ -117,13 +103,10 @@ const submitForm = async () => {
   try {
     const data = {
       roleId: formData.id,
-      dataScope: formData.dataScope,
-      dataScopeDeptIds:
-        formData.dataScope !== SystemDataScopeEnum.DEPT_CUSTOM
-          ? []
-          : treeRef.value.getCheckedKeys(false)
+      flowIds: treeRef.value.getCheckedKeys(false)
     }
-    await PermissionApi.assignRoleDataScope(data)
+    console.log(data)
+    await PermissionApi.assignRoleFlowScope(data)
     message.success(t('common.updateSuccess'))
     dialogVisible.value = false
     // 发送操作成功的事件
@@ -144,8 +127,7 @@ const resetForm = () => {
     id: 0,
     name: '',
     code: '',
-    dataScope: undefined,
-    dataScopeDeptIds: []
+    flowIds: []
   }
   treeRef.value?.setCheckedNodes([])
   formRef.value?.resetFields()
@@ -153,7 +135,7 @@ const resetForm = () => {
 
 /** 全选/全不选 */
 const handleCheckedTreeNodeAll = () => {
-  treeRef.value.setCheckedNodes(treeNodeAll.value ? deptOptions.value : [])
+  treeRef.value.setCheckedNodes(treeNodeAll.value ? flowTemplates.value : [])
 }
 
 /** 展开/折叠全部 */