BPM:调整抄送逻辑的实现,改成审批通过、不通过时,可选择抄送

This commit is contained in:
YunaiV 2024-03-17 22:14:28 +08:00
parent de29528165
commit 03b8bd5e22
7 changed files with 95 additions and 377 deletions

View File

@ -20,14 +20,14 @@ export type ProcessInstanceVO = {
endTime: string endTime: string
} }
export type ProcessInstanceCCVO = { export type ProcessInstanceCopyVO = {
type: number, type: number
taskName: string, taskName: string
taskKey: string, taskKey: string
processInstanceName: string, processInstanceName: string
processInstanceKey: string, processInstanceKey: string
startUserId: string, startUserId: string
options:string [], options: string[]
reason: string reason: string
} }
@ -51,20 +51,6 @@ export const getProcessInstance = async (id: number) => {
return await request.get({ url: '/bpm/process-instance/get?id=' + id }) return await request.get({ url: '/bpm/process-instance/get?id=' + id })
} }
/** export const getProcessInstanceCopyPage = async (params: any) => {
* return await request.get({ url: '/bpm/process-instance/copy/page', params })
* @param data
* @returns
*/
export const createProcessInstanceCC = async (data) => {
return await request.post({ url: '/bpm/process-instance/cc/create', data: data })
}
/**
*
* @param params
* @returns
*/
export const getProcessInstanceCCPage = async (params) => {
return await request.get({ url: '/bpm/process-instance/cc/my-page', params })
} }

View File

@ -175,18 +175,18 @@ export function formatPast2(ms: number): string {
const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60) const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60)
const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60) const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60)
if (day > 0) { if (day > 0) {
return day + '天' + hour + '小时' + minute + '分钟' return day + ' 天' + hour + ' 小时 ' + minute + ' 分钟'
} }
if (hour > 0) { if (hour > 0) {
return hour + '小时' + minute + '分钟' return hour + ' 小时 ' + minute + ' 分钟'
} }
if (minute > 0) { if (minute > 0) {
return minute + '分钟' return minute + ' 分钟'
} }
if (second > 0) { if (second > 0) {
return second + '秒' return second + ' 秒'
} else { } else {
return 0 + '秒' return 0 + ' 秒'
} }
} }

View File

@ -1,242 +0,0 @@
<!-- TODO @kyle需要在讨论下可能直接选人更合适 -->
<template>
<Dialog v-model="dialogVisible" title="修改任务规则" width="600">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
<el-form-item label="任务名称" prop="taskName">
<el-input v-model="formData.taskName" disabled placeholder="请输入任务名称" />
</el-form-item>
<el-form-item label="任务标识" prop="taskKey">
<el-input v-model="formData.taskKey" disabled placeholder="请输入任务标识" />
</el-form-item>
<el-form-item label="流程名称" prop="processInstanceName">
<el-input v-model="formData.processInstanceName" disabled placeholder="请输入流程名称" />
</el-form-item>
<el-form-item label="流程标识" prop="processInstanceKey">
<el-input v-model="formData.processInstanceKey" disabled placeholder="请输入流程标识" />
</el-form-item>
<el-form-item label="规则类型" prop="type">
<el-select v-model="formData.type" clearable style="width: 100%">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_CANDIDATE_STRATEGY)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 10" label="指定角色" prop="roleIds">
<el-select v-model="formData.roleIds" clearable multiple style="width: 100%">
<el-option
v-for="item in roleOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="formData.type === 20 || formData.type === 21"
label="指定部门"
prop="deptIds"
span="24"
>
<el-tree-select
ref="treeRef"
v-model="formData.deptIds"
:data="deptTreeOptions"
:props="defaultProps"
empty-text="加载中,请稍后"
multiple
node-key="id"
show-checkbox
/>
</el-form-item>
<el-form-item v-if="formData.type === 22" label="指定岗位" prop="postIds" span="24">
<el-select v-model="formData.postIds" clearable multiple style="width: 100%">
<el-option
v-for="item in postOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item
v-if="formData.type === 30 || formData.type === 31 || formData.type === 32"
label="指定用户"
prop="userIds"
span="24"
>
<el-select v-model="formData.userIds" clearable multiple style="width: 100%">
<el-option
v-for="item in userOptions"
:key="parseInt(item.id)"
:label="item.nickname"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 40" label="指定用户组" prop="userGroupIds">
<el-select v-model="formData.userGroupIds" clearable multiple style="width: 100%">
<el-option
v-for="item in userGroupOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.type === 50" label="指定脚本" prop="scripts">
<el-select v-model="formData.scripts" clearable multiple style="width: 100%">
<el-option
v-for="dict in taskAssignScriptDictDatas"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="抄送原因" prop="reason">
<el-input v-model="formData.reason" placeholder="请输入抄送原因" type="textarea" />
</el-form-item>
</el-form>
<!-- 操作按钮 -->
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as PostApi from '@/api/system/post'
import * as UserApi from '@/api/system/user'
import * as UserGroupApi from '@/api/bpm/userGroup'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
type: Number(undefined),
taskName: '',
taskKey: '',
processInstanceName: '',
processInstanceKey: '',
startUserId: '',
options: [],
roleIds: [],
deptIds: [],
postIds: [],
userIds: [],
userGroupIds: [],
scripts: [],
reason: ''
})
const formRules = reactive({
type: [{ required: true, message: '规则类型不能为空', trigger: 'change' }],
roleIds: [{ required: true, message: '指定角色不能为空', trigger: 'change' }],
deptIds: [{ required: true, message: '指定部门不能为空', trigger: 'change' }],
postIds: [{ required: true, message: '指定岗位不能为空', trigger: 'change' }],
userIds: [{ required: true, message: '指定用户不能为空', trigger: 'change' }],
userGroupIds: [{ required: true, message: '指定用户组不能为空', trigger: 'change' }],
scripts: [{ required: true, message: '指定脚本不能为空', trigger: 'change' }],
reason: [{ required: true, message: '抄送原因不能为空', trigger: 'change' }]
})
const formRef = ref() // Ref
const roleOptions = ref<RoleApi.RoleVO[]>([]) //
const deptOptions = ref<DeptApi.DeptVO[]>([]) //
const deptTreeOptions = ref() //
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const taskAssignScriptDictDatas = getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
/** 打开弹窗 */
const open = async (row) => {
// 1.
resetForm()
// 2.
if (row != null) {
formData.value.type = undefined as unknown as number
formData.value.taskName = row.name
formData.value.taskKey = row.id
formData.value.processInstanceName = row.processInstance.name
formData.value.processInstanceKey = row.processInstance.id
formData.value.startUserId = row.processInstance.startUserId
}
//
dialogVisible.value = true
//
roleOptions.value = await RoleApi.getSimpleRoleList()
//
deptOptions.value = await DeptApi.getSimpleDeptList()
deptTreeOptions.value = handleTree(deptOptions.value, 'id')
//
postOptions.value = await PostApi.getSimplePostList()
//
userOptions.value = await UserApi.getSimpleUserList()
//
userGroupOptions.value = await UserGroupApi.getSimpleUserGroupList()
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
const form = {
...formData.value
}
// roleIds options
if (form.type === 10) {
form.options = form.roleIds
} else if (form.type === 20 || form.type === 21) {
form.options = form.deptIds
} else if (form.type === 22) {
form.options = form.postIds
} else if (form.type === 30 || form.type === 31 || form.type === 32) {
form.options = form.userIds
} else if (form.type === 40) {
form.options = form.userGroupIds
} else if (form.type === 50) {
form.options = form.scripts
}
form.roleIds = undefined
form.deptIds = undefined
form.postIds = undefined
form.userIds = undefined
form.userGroupIds = undefined
form.scripts = undefined
//
formLoading.value = true
try {
const data = form as unknown as ProcessInstanceApi.ProcessInstanceCCVO
await ProcessInstanceApi.createProcessInstanceCC(data)
console.log(data)
message.success(t('common.createSuccess'))
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formRef.value?.resetFields()
}
</script>

View File

@ -31,6 +31,16 @@
type="textarea" type="textarea"
/> />
</el-form-item> </el-form-item>
<el-form-item label="抄送人" prop="copyUserIds">
<el-select v-model="auditForms[index].copyUserIds" multiple placeholder="请选择抄送人">
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form> </el-form>
<div style="margin-bottom: 20px; margin-left: 10%; font-size: 14px"> <div style="margin-bottom: 20px; margin-left: 10%; font-size: 14px">
<el-button type="success" @click="handleAudit(item, true)"> <el-button type="success" @click="handleAudit(item, true)">
@ -118,6 +128,7 @@ import TaskDelegateForm from './TaskDelegateForm.vue'
import TaskAddSignDialogForm from './TaskAddSignDialogForm.vue' import TaskAddSignDialogForm from './TaskAddSignDialogForm.vue'
import { registerComponent } from '@/utils/routerHelper' import { registerComponent } from '@/utils/routerHelper'
import { isEmpty } from '@/utils/is' import { isEmpty } from '@/utils/is'
import * as UserApi from '@/api/system/user'
defineOptions({ name: 'BpmProcessInstanceDetail' }) defineOptions({ name: 'BpmProcessInstanceDetail' })
@ -161,7 +172,8 @@ const handleAudit = async (task, pass) => {
// 2.1 // 2.1
const data = { const data = {
id: task.id, id: task.id,
reason: auditForms.value[index].reason reason: auditForms.value[index].reason,
copyUserIds: auditForms.value[index].copyUserIds
} }
if (pass) { if (pass) {
await TaskApi.approveTask(data) await TaskApi.approveTask(data)
@ -180,21 +192,20 @@ const openTaskUpdateAssigneeForm = (id: string) => {
taskUpdateAssigneeFormRef.value.open(id) taskUpdateAssigneeFormRef.value.open(id)
} }
const taskDelegateForm = ref()
/** 处理审批退回的操作 */ /** 处理审批退回的操作 */
const taskDelegateForm = ref()
const handleDelegate = async (task) => { const handleDelegate = async (task) => {
taskDelegateForm.value.open(task.id) taskDelegateForm.value.open(task.id)
} }
//退
const taskReturnDialogRef = ref()
/** 处理审批退回的操作 */ /** 处理审批退回的操作 */
const taskReturnDialogRef = ref()
const handleBack = async (task) => { const handleBack = async (task) => {
taskReturnDialogRef.value.open(task.id) taskReturnDialogRef.value.open(task.id)
} }
const taskAddSignDialogForm = ref()
/** 处理审批加签的操作 */ /** 处理审批加签的操作 */
const taskAddSignDialogForm = ref()
const handleSign = async (task) => { const handleSign = async (task) => {
taskAddSignDialogForm.value.open(task.id) taskAddSignDialogForm.value.open(task.id)
} }
@ -304,13 +315,17 @@ const loadRunningTask = (tasks) => {
// 2.3 // 2.3
runningTasks.value.push({ ...task }) runningTasks.value.push({ ...task })
auditForms.value.push({ auditForms.value.push({
reason: '' reason: '',
copyUserIds: []
}) })
}) })
} }
/** 初始化 */ /** 初始化 */
onMounted(() => { const userOptions = ref<UserApi.UserVO[]>([]) //
onMounted(async () => {
getDetail() getDetail()
//
userOptions.value = await UserApi.getSimpleUserList()
}) })
</script> </script>

View File

@ -11,14 +11,6 @@
placeholder="请输入流程名称" placeholder="请输入流程名称"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属流程" prop="processDefinitionId">
<el-input
v-model="queryParams.processInstanceId"
placeholder="请输入流程定义的编号"
clearable
class="!w-240px"
/>
</el-form-item>
<el-form-item label="抄送时间" prop="createTime"> <el-form-item label="抄送时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
@ -46,12 +38,17 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column align="center" label="所属流程" prop="processInstanceId" width="300px" /> <el-table-column align="center" label="流程名" prop="processInstanceName" min-width="180" />
<el-table-column align="center" label="流程名称" prop="processInstanceName" /> <el-table-column align="center" label="流程发起人" prop="startUserName" min-width="100" />
<el-table-column align="center" label="任务名称" prop="taskName" /> <el-table-column
<el-table-column align="center" label="流程发起人" prop="startUserNickname" /> :formatter="dateFormatter"
<el-table-column align="center" label="抄送发起人" prop="creatorNickname" /> align="center"
<el-table-column align="center" label="抄送原因" prop="reason" /> label="流程发起时间"
prop="processInstanceStartTime"
width="180"
/>
<el-table-column align="center" label="抄送任务" prop="taskName" min-width="180" />
<el-table-column align="center" label="抄送人" prop="creatorName" min-width="100" />
<el-table-column <el-table-column
align="center" align="center"
label="抄送时间" label="抄送时间"
@ -59,9 +56,9 @@
width="180" width="180"
:formatter="dateFormatter" :formatter="dateFormatter"
/> />
<el-table-column align="center" label="操作"> <el-table-column align="center" label="操作" fixed="right" width="80">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="handleAudit(scope.row)">跳转待办</el-button> <el-button link type="primary" @click="handleAudit(scope.row)">详情</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -78,14 +75,14 @@
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as ProcessInstanceApi from '@/api/bpm/processInstance' import * as ProcessInstanceApi from '@/api/bpm/processInstance'
defineOptions({ name: 'BpmCCProcessInstance' }) defineOptions({ name: 'BpmProcessInstanceCopy' })
const { push } = useRouter() // const { push } = useRouter() //
const loading = ref(false) // const loading = ref(false) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = ref({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
processInstanceId: '', processInstanceId: '',
@ -98,7 +95,7 @@ const queryFormRef = ref() // 搜索的表单
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await ProcessInstanceApi.getProcessInstanceCCPage(queryParams) const data = await ProcessInstanceApi.getProcessInstanceCopyPage(queryParams)
list.value = data.list list.value = data.list
total.value = data.total total.value = data.total
} finally { } finally {
@ -118,7 +115,7 @@ const handleAudit = (row: any) => {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNo = 1 queryParams.pageNo = 1
getList() getList()
} }

View File

@ -1,51 +0,0 @@
<template>
<Dialog v-model="dialogVisible" :max-height="500" :scroll="true" title="详情">
<el-descriptions :column="1" border>
<el-descriptions-item label="任务编号" min-width="120">
{{ detailData.id }}
</el-descriptions-item>
<el-descriptions-item label="任务名称">
{{ detailData.name }}
</el-descriptions-item>
<el-descriptions-item label="所属流程">
{{ detailData.processInstance.name }}
</el-descriptions-item>
<el-descriptions-item label="流程发起人">
{{ detailData.processInstance.startUserNickname }}
</el-descriptions-item>
<el-descriptions-item label="状态">
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="detailData.status" />
</el-descriptions-item>
<el-descriptions-item label="原因">
{{ detailData.reason }}
</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ formatDate(detailData.createTime) }}
</el-descriptions-item>
</el-descriptions>
</Dialog>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import * as TaskApi from '@/api/bpm/task'
defineOptions({ name: 'BpmTaskDetail' })
const dialogVisible = ref(false) //
const detailLoading = ref(false) //
const detailData = ref() //
/** 打开弹窗 */
const open = async (data: TaskApi.TaskVO) => {
dialogVisible.value = true
//
detailLoading.value = true
try {
detailData.value = data
} finally {
detailLoading.value = false
}
}
defineExpose({ open }) // open
</script>

View File

@ -46,27 +46,50 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column align="center" label="任务编号" prop="id" width="300px" /> <el-table-column align="center" label="流程" prop="processInstance.name" width="180" />
<el-table-column align="center" label="任务名称" prop="name" /> <el-table-column
<el-table-column align="center" label="所属流程" prop="processInstance.name" /> align="center"
<el-table-column align="center" label="流程发起人" prop="processInstance.startUserNickname" /> label="发起人"
<el-table-column align="center" label="审批状态" prop="status"> prop="processInstance.startUser.nickname"
width="100"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="发起时间"
prop="createTime"
width="180"
/>
<el-table-column align="center" label="当前任务" prop="name" width="180" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="任务开始时间"
prop="createTime"
width="180"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="任务结束时间"
prop="endTime"
width="180"
/>
<el-table-column align="center" label="耗时" prop="durationInMillis" width="120">
<template #default="scope">
{{ formatPast2(scope.row.durationInMillis) }}
</template>
</el-table-column>
<el-table-column align="center" label="审批状态" prop="status" width="100">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.status" /> <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="原因" prop="reason" /> <el-table-column align="center" label="流程编号" prop="id" :show-overflow-tooltip="true" />
<el-table-column <el-table-column align="center" label="任务编号" prop="id" :show-overflow-tooltip="true" />
:formatter="dateFormatter" <el-table-column align="center" label="操作" fixed="right" width="80">
align="center"
label="创建时间"
prop="createTime"
width="180"
/>
<el-table-column align="center" label="操作">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="openDetail(scope.row)">详情</el-button> <el-button link type="primary" @click="handleAudit(scope.row)">历史</el-button>
<el-button link type="primary" @click="handleAudit(scope.row)">流程</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -78,15 +101,11 @@
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
<!-- 表单弹窗详情 -->
<TaskDetail ref="detailRef" @success="getList" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter, formatPast2 } from '@/utils/formatTime'
import * as TaskApi from '@/api/bpm/task' import * as TaskApi from '@/api/bpm/task'
import TaskDetail from './TaskDetail.vue'
defineOptions({ name: 'BpmTodoTask' }) defineOptions({ name: 'BpmTodoTask' })
@ -127,14 +146,8 @@ const resetQuery = () => {
handleQuery() handleQuery()
} }
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: TaskApi.TaskVO) => {
detailRef.value.open(row)
}
/** 处理审批按钮 */ /** 处理审批按钮 */
const handleAudit = (row) => { const handleAudit = (row: any) => {
push({ push({
name: 'BpmProcessInstanceDetail', name: 'BpmProcessInstanceDetail',
query: { query: {