From 2d16816f3f40f217b08a7223560a68569a8e6f9d Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Wed, 2 Oct 2024 09:49:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E4=BD=9C=E6=B5=81=E3=80=91-?= =?UTF-8?q?=20=E5=AF=B9=E6=8E=A5=E6=96=B0=E8=8E=B7=E5=8F=96=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E5=AD=97=E6=AE=B5=E6=9D=83=E9=99=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/bpm/processInstance/index.ts | 6 ++ src/router/modules/remaining.ts | 9 ++- .../detail/ProcessInstanceTimeline.vue | 1 - .../bpm/processInstance/detail/index_new.vue | 70 +++++++++++++++---- src/views/bpm/task/copy/index.vue | 11 ++- src/views/bpm/task/done/index.vue | 3 +- src/views/bpm/task/todo/index.vue | 3 +- 7 files changed, 82 insertions(+), 21 deletions(-) diff --git a/src/api/bpm/processInstance/index.ts b/src/api/bpm/processInstance/index.ts index df348d62..3d6330a8 100644 --- a/src/api/bpm/processInstance/index.ts +++ b/src/api/bpm/processInstance/index.ts @@ -87,7 +87,13 @@ export const getProcessInstanceCopyPage = async (params: any) => { return await request.get({ url: '/bpm/process-instance/copy/page', params }) } +// 获取审批详情 export const getApprovalDetail = async (processInstanceId?:string, processDefinitionId?:string) => { const param = processInstanceId ? '?processInstanceId='+ processInstanceId : '?processDefinitionId='+ processDefinitionId return await request.get({ url: 'bpm/process-instance/get-approval-detail'+ param }) } + +// 获取表单字段权限 +export const getFormFieldsPermission = async (params: any) => { + return await request.get({ url: '/bpm/process-instance/get-form-fields-permission', params }) +} diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 8e7c731d..ad9cd225 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -300,7 +300,14 @@ const remainingRouter: AppRouteRecordRaw[] = [ canTo: true, title: '流程详情', activeMenu: '/bpm/task/my' - } + }, + props: route => ( + { + id: route.query.id, + taskId: route.query.taskId, + activityId: route.query.activityId + } + ) }, { path: 'oa/leave/create', diff --git a/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue b/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue index 646542db..2c1cad37 100644 --- a/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue +++ b/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue @@ -178,7 +178,6 @@ const getApprovalDetail = async () => { props.processInstanceId, props.processDefinitionId ) - console.log('approveNodes is []', data) approveNodes.value = data.approveNodes } diff --git a/src/views/bpm/processInstance/detail/index_new.vue b/src/views/bpm/processInstance/detail/index_new.vue index 75d8db3f..660bf4d7 100644 --- a/src/views/bpm/processInstance/detail/index_new.vue +++ b/src/views/bpm/processInstance/detail/index_new.vue @@ -88,7 +88,10 @@ 流转评论 -
+
() const message = useMessage() // 消息弹窗 -const id = query.id as unknown as string // 流程实例的编号 const processInstanceLoading = ref(false) // 流程实例的加载中 const processInstance = ref({}) // 流程实例 const operationButtonRef = ref() @@ -157,7 +163,7 @@ const BusinessFormComponent = ref(null) // 异步组件 const getProcessInstance = async () => { try { processInstanceLoading.value = true - const data = await ProcessInstanceApi.getProcessInstance(id) + const data = await ProcessInstanceApi.getProcessInstance(props.id) if (!data) { message.error('查询不到流程信息!') return @@ -167,6 +173,15 @@ const getProcessInstance = async () => { // 设置表单信息 const processDefinition = data.processDefinition if (processDefinition.formType === 10) { + // 获取表单字段权限 + let fieldsPermission = undefined + if (props.taskId || props.activityId) { + fieldsPermission = await ProcessInstanceApi.getFormFieldsPermission({ + processInstanceId: props.id, + taskId: props.taskId, + activityId: props.activityId + }) + } setConfAndFields2( detailForm, processDefinition.formConf, @@ -177,6 +192,11 @@ const getProcessInstance = async () => { fApi.value?.btn.show(false) fApi.value?.resetBtn.show(false) fApi.value?.disabled(true) + if (fieldsPermission) { + Object.keys(fieldsPermission).forEach((item) => { + setFieldPermission(item, fieldsPermission[item]) + }) + } }) } else { // 注意:data.processDefinition.formCustomViewPath 是组件的全路径,例如说:/crm/contract/detail/index.vue @@ -190,12 +210,27 @@ const getProcessInstance = async () => { } } +/** + * 设置表单权限 + */ +const setFieldPermission = (field: string, permission: string) => { + if (permission === FieldPermissionType.READ) { + fApi.value?.disabled(true, field) + } + if (permission === FieldPermissionType.WRITE) { + fApi.value?.disabled(false, field) + } + if (permission === FieldPermissionType.NONE) { + fApi.value?.hidden(true, field) + } +} + /** 加载任务列表 */ const getTaskList = async () => { try { // 获得未取消的任务 tasksLoad.value = true - const data = await TaskApi.getTaskListByProcessInstanceId(id) + const data = await TaskApi.getTaskListByProcessInstanceId(props.id) tasks.value = [] // 1.1 移除已取消的审批 data.forEach((task) => { @@ -238,19 +273,29 @@ onMounted(async () => { diff --git a/src/views/bpm/task/copy/index.vue b/src/views/bpm/task/copy/index.vue index 93f55c68..045e2074 100644 --- a/src/views/bpm/task/copy/index.vue +++ b/src/views/bpm/task/copy/index.vue @@ -111,11 +111,16 @@ const getList = async () => { /** 处理审批按钮 */ const handleAudit = (row: any) => { + const query = { + id: row.processInstanceId, + activityId: undefined + } + if (row.activityId) { + query.activityId = row.activityId + } push({ name: 'BpmProcessInstanceDetail', - query: { - id: row.processInstanceId - } + query: query }) } diff --git a/src/views/bpm/task/done/index.vue b/src/views/bpm/task/done/index.vue index a5137199..98768212 100644 --- a/src/views/bpm/task/done/index.vue +++ b/src/views/bpm/task/done/index.vue @@ -158,7 +158,8 @@ const handleAudit = (row: any) => { push({ name: 'BpmProcessInstanceDetail', query: { - id: row.processInstance.id + id: row.processInstance.id, + taskId: row.id } }) } diff --git a/src/views/bpm/task/todo/index.vue b/src/views/bpm/task/todo/index.vue index 670fc683..bf32ecb1 100644 --- a/src/views/bpm/task/todo/index.vue +++ b/src/views/bpm/task/todo/index.vue @@ -140,7 +140,8 @@ const handleAudit = (row: any) => { push({ name: 'BpmProcessInstanceDetail', query: { - id: row.processInstance.id + id: row.processInstance.id, + taskId: row.id } }) }