【功能修改】 整合审批详情接口

pull/582/head
jason 2024-10-16 22:31:20 +08:00
parent 842fe09e8b
commit 3a9197dfdf
5 changed files with 96 additions and 86 deletions

View File

@ -87,14 +87,8 @@ export const getProcessInstanceCopyPage = async (params: any) => {
} }
// 获取审批详情 // 获取审批详情
export const getApprovalDetail = async ( export const getApprovalDetail = async (params: any) => {
processInstanceId?: string, return await request.get({ url: 'bpm/process-instance/get-approval-detail' , params })
processDefinitionId?: string
) => {
const param = processInstanceId
? '?processInstanceId=' + processInstanceId
: '?processDefinitionId=' + processDefinitionId
return await request.get({ url: 'bpm/process-instance/get-approval-detail' + param })
} }
// 获取表单字段权限 // 获取表单字段权限

View File

@ -44,6 +44,7 @@ export const setConfAndFields2 = (
value?: object value?: object
) => { ) => {
if (isRef(detailPreview)) { if (isRef(detailPreview)) {
// @ts-ignore
detailPreview = detailPreview.value detailPreview = detailPreview.value
} }
// @ts-ignore // @ts-ignore

View File

@ -657,7 +657,6 @@ const openChildrenTask = () => {
/** 重新加载数据 */ /** 重新加载数据 */
const reload = () => { const reload = () => {
getMyTodoTask()
emit('success') emit('success')
} }
@ -691,26 +690,23 @@ const getButtonDisplayName = (btnType: OperationButtonType) => {
return displayName return displayName
} }
/** 获取我的待办任务 */ const loadTodoTask = (task: any) => {
const getMyTodoTask = async () => {
genericForm.value = {} genericForm.value = {}
approveForm.value = {} approveForm.value = {}
approveFormFApi.value = {} approveFormFApi.value = {}
const data = await TaskApi.myTodoTask(props.processInstanceId) runningTask.value = task
runningTask.value = data
// approve . // approve .
if (data && data.formId && data.formConf) { if (task && task.formId && task.formConf) {
const tempApproveForm = {} const tempApproveForm = {}
setConfAndFields2(tempApproveForm, data.formConf, data.formFields, data.formVariables) setConfAndFields2(tempApproveForm, task.formConf, task.formFields, task.formVariables)
approveForm.value = tempApproveForm approveForm.value = tempApproveForm
} else { } else {
approveForm.value = {} // approveForm.value = {} //
} }
} }
onMounted(async () => { defineExpose({ loadTodoTask })
await getMyTodoTask()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -134,23 +134,31 @@ import { TaskStatusEnum } from '@/api/bpm/task'
import { NodeType } from '@/components/SimpleProcessDesignerV2/src/consts' import { NodeType } from '@/components/SimpleProcessDesignerV2/src/consts'
import { Check, Close, Loading, Clock, Minus, Delete } from '@element-plus/icons-vue' import { Check, Close, Loading, Clock, Minus, Delete } from '@element-plus/icons-vue'
defineOptions({ name: 'BpmProcessInstanceTimeline' }) defineOptions({ name: 'BpmProcessInstanceTimeline' })
const props = defineProps({ // const props = defineProps({
// // //
processInstanceId: { // processInstanceId: {
type: String, // type: String,
required: false, // required: false,
default: '' // default: ''
}, // },
// // //
processDefinitionId: { // processDefinitionId: {
type: String, // type: String,
required: false, // required: false,
default: '' // default: ''
} // },
}) // approveNodes : {
// type: ProcessInstanceApi.ApprovalNodeInfo[],
// required: false,
// default: ''
// }
// })
defineProps<{
approveNodes: ProcessInstanceApi.ApprovalNodeInfo[] //
}>()
// //
const approveNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([])
const statusIconMap2 = { const statusIconMap2 = {
// //
@ -194,13 +202,13 @@ const statusIconMap = {
} }
/** 获得审批详情 */ /** 获得审批详情 */
const getApprovalDetail = async () => { // const getApprovalDetail = async () => {
const data = await ProcessInstanceApi.getApprovalDetail( // const data = await ProcessInstanceApi.getApprovalDetail(
props.processInstanceId, // props.processInstanceId,
props.processDefinitionId // props.processDefinitionId
) // )
approveNodes.value = data.approveNodes // approveNodes.value = data.approveNodes
} // }
const getApprovalNodeIcon = (taskStatus: number, nodeType: NodeType) => { const getApprovalNodeIcon = (taskStatus: number, nodeType: NodeType) => {
if (taskStatus == TaskStatusEnum.NOT_START) { if (taskStatus == TaskStatusEnum.NOT_START) {
@ -226,13 +234,13 @@ const getApprovalNodeTime = (node: ProcessInstanceApi.ApprovalNodeInfo) => {
} }
/** 重新刷新审批详情 */ /** 重新刷新审批详情 */
const refresh = () => { // const refresh = () => {
getApprovalDetail() // getApprovalDetail()
} // }
defineExpose({ refresh }) // defineExpose({ refresh })
onMounted(async () => { // onMounted(async () => {
await getApprovalDetail() // await getApprovalDetail()
}) // })
</script> </script>

View File

@ -23,7 +23,6 @@
<div <div
class="bg-gray-100 h-35px rounded-3xl flex items-center p-8px gap-2 dark:color-gray-600" class="bg-gray-100 h-35px rounded-3xl flex items-center p-8px gap-2 dark:color-gray-600"
> >
<!-- <img class="rounded-full h-28px" src="@/assets/imgs/avatar.jpg" alt="" /> -->
<el-avatar <el-avatar
:size="28" :size="28"
v-if="processInstance?.startUser?.avatar" v-if="processInstance?.startUser?.avatar"
@ -50,7 +49,7 @@
class="form-box flex flex-col mb-30px flex-1" class="form-box flex flex-col mb-30px flex-1"
> >
<!-- 情况一流程表单 --> <!-- 情况一流程表单 -->
<el-col v-if="processInstance?.processDefinition?.formType === 10"> <el-col v-if="processDefinition?.formType === 10">
<form-create <form-create
v-model="detailForm.value" v-model="detailForm.value"
v-model:api="fApi" v-model:api="fApi"
@ -59,14 +58,14 @@
/> />
</el-col> </el-col>
<!-- 情况二业务表单 --> <!-- 情况二业务表单 -->
<div v-if="processInstance?.processDefinition?.formType === 20"> <div v-if="processDefinition?.formType === 20">
<BusinessFormComponent :id="processInstance.businessKey" /> <BusinessFormComponent :id="processInstance.businessKey" />
</div> </div>
</div> </div>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<!-- 审批记录时间线 --> <!-- 审批记录时间线 -->
<ProcessInstanceTimeline ref="timelineRef" :process-instance-id="id" /> <ProcessInstanceTimeline ref="timelineRef" :approve-nodes="approveNodes" />
</el-col> </el-col>
</el-row> </el-row>
</el-scrollbar> </el-scrollbar>
@ -104,6 +103,7 @@
<div class="b-t-solid border-t-1px border-[var(--el-border-color)]"> <div class="b-t-solid border-t-1px border-[var(--el-border-color)]">
<!-- 操作栏按钮 --> <!-- 操作栏按钮 -->
<ProcessInstanceOperationButton <ProcessInstanceOperationButton
ref="operationButtonRef"
:process-instance-id="id" :process-instance-id="id"
:userOptions="userOptions" :userOptions="userOptions"
@success="refresh" @success="refresh"
@ -124,7 +124,6 @@ import ProcessInstanceBpmnViewer from './ProcessInstanceBpmnViewer.vue'
import ProcessInstanceTaskList from './ProcessInstanceTaskList.vue' import ProcessInstanceTaskList from './ProcessInstanceTaskList.vue'
import ProcessInstanceOperationButton from './ProcessInstanceOperationButton.vue' import ProcessInstanceOperationButton from './ProcessInstanceOperationButton.vue'
import ProcessInstanceTimeline from './ProcessInstanceTimeline.vue' import ProcessInstanceTimeline from './ProcessInstanceTimeline.vue'
import { registerComponent } from '@/utils/routerHelper'
import * as UserApi from '@/api/system/user' import * as UserApi from '@/api/system/user'
import { FieldPermissionType } from '@/components/SimpleProcessDesignerV2/src/consts' import { FieldPermissionType } from '@/components/SimpleProcessDesignerV2/src/consts'
import audit1 from '@/assets/svgs/bpm/audit1.svg' import audit1 from '@/assets/svgs/bpm/audit1.svg'
@ -141,7 +140,10 @@ const props = defineProps<{
const message = useMessage() // const message = useMessage() //
const processInstanceLoading = ref(false) // const processInstanceLoading = ref(false) //
const processInstance = ref<any>({}) // const processInstance = ref<any>({}) //
const processDefinition = ref<any>({}) //
const timelineRef = ref() const timelineRef = ref()
// ref
const operationButtonRef = ref()
const tasksLoad = ref(true) // const tasksLoad = ref(true) //
const tasks = ref<any[]>([]) // const tasks = ref<any[]>([]) //
const auditIcons = { const auditIcons = {
@ -161,78 +163,92 @@ const detailForm = ref({
/** 获得详情 */ /** 获得详情 */
const getDetail = async () => { const getDetail = async () => {
// 1. // 1.
getProcessInstance() getApprovalDetail()
// 2. // 2.
getTaskList() getTaskList()
} }
/** 加载流程实例 */ /** 加载流程实例 */
const BusinessFormComponent = ref<any>(null) // const BusinessFormComponent = ref<any>(null) //
const getProcessInstance = async () => { /** 获取审批详情 */
const getApprovalDetail = async () => {
processInstanceLoading.value = true
try { try {
processInstanceLoading.value = true const param = {
const data = await ProcessInstanceApi.getProcessInstance(props.id) processInstanceId: props.id,
activityId: props.activityId,
taskId: props.taskId
}
const data = await ProcessInstanceApi.getApprovalDetail(param);
if (!data) { if (!data) {
message.error('查询不到审批详情信息!')
return
}
if(!data.processDefinition || !data.processInstance) {
message.error('查询不到流程信息!') message.error('查询不到流程信息!')
return return
} }
processInstance.value = data processInstance.value = data.processInstance
processDefinition.value = data.processDefinition
// //
const processDefinition = data.processDefinition if (processDefinition.value.formType === 10) {
if (processDefinition.formType === 10) {
// //
let fieldsPermission = undefined const formFieldsPermission = data.formFieldsPermission
if (props.taskId || props.activityId) {
fieldsPermission = await ProcessInstanceApi.getFormFieldsPermission({ if (detailForm.value.rule.length > 0) { // form-create
processInstanceId: props.id, detailForm.value.value = processInstance.value.formVariables
taskId: props.taskId,
activityId: props.activityId
})
}
if (detailForm.value.rule.length > 0) { // form-create
detailForm.value.value = data.formVariables
} else { } else {
setConfAndFields2( setConfAndFields2(
detailForm, detailForm,
processDefinition.formConf, processDefinition.value.formConf,
processDefinition.formFields, processDefinition.value.formFields,
data.formVariables processInstance.value.formVariables
) )
} }
nextTick().then(() => { nextTick().then(() => {
fApi.value?.btn.show(false) fApi.value?.btn.show(false)
fApi.value?.resetBtn.show(false) fApi.value?.resetBtn.show(false)
//@ts-ignore
fApi.value?.disabled(true) fApi.value?.disabled(true)
if (fieldsPermission) { //
Object.keys(fieldsPermission).forEach((item) => { if (formFieldsPermission) {
setFieldPermission(item, fieldsPermission[item]) Object.keys(data.formFieldsPermission).forEach((item) => {
setFieldPermission(item, formFieldsPermission[item])
}) })
} }
}) })
} else {
// data.processDefinition.formCustomViewPath /crm/contract/detail/index.vue
BusinessFormComponent.value = registerComponent(data.processDefinition.formCustomViewPath)
} }
// Timeline
approveNodes.value = data.approveNodes
//
operationButtonRef.value?.loadTodoTask(data.todoTask)
} finally { } finally {
processInstanceLoading.value = false processInstanceLoading.value = false
} }
} }
//
const approveNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([])
/** /**
* 设置表单权限 * 设置表单权限
*/ */
const setFieldPermission = (field: string, permission: string) => { const setFieldPermission = (field: string, permission: string) => {
if (permission === FieldPermissionType.READ) { if (permission === FieldPermissionType.READ) {
//@ts-ignore
fApi.value?.disabled(true, field) fApi.value?.disabled(true, field)
} }
if (permission === FieldPermissionType.WRITE) { if (permission === FieldPermissionType.WRITE) {
//@ts-ignore
fApi.value?.disabled(false, field) fApi.value?.disabled(false, field)
} }
if (permission === FieldPermissionType.NONE) { if (permission === FieldPermissionType.NONE) {
//@ts-ignore
fApi.value?.hidden(true, field) fApi.value?.hidden(true, field)
} }
} }
@ -264,9 +280,6 @@ const getTaskList = async () => {
return b.createTime - a.createTime return b.createTime - a.createTime
} }
}) })
//
//operationButtonRef.value?.loadRunningTask(tasks.value)
} finally { } finally {
tasksLoad.value = false tasksLoad.value = false
} }
@ -278,8 +291,6 @@ const getTaskList = async () => {
const refresh = () => { const refresh = () => {
// //
getDetail() getDetail()
// Timeline
timelineRef.value?.refresh()
} }
/** 当前的Tab */ /** 当前的Tab */