Vue3 重构:流程实例的详情

This commit is contained in:
YunaiV 2023-03-28 00:10:42 +08:00
parent 1a4311309d
commit c5a3fa1f94
4 changed files with 107 additions and 114 deletions

View File

@ -284,7 +284,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
},
{
path: '/process-instance/detail',
component: () => import('@/views/bpm/processInstance/detail.vue'),
component: () => import('@/views/bpm/processInstance/detail/index.vue'),
name: 'BpmProcessInstanceDetail',
meta: {
noCache: true,

View File

@ -73,6 +73,8 @@ declare module '@vue/runtime-core' {
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTransfer: typeof import('element-plus/es')['ElTransfer']
ElTree: typeof import('element-plus/es')['ElTree']

View File

@ -0,0 +1,81 @@
<template>
<Dialog title="转派审批人" v-model="modelVisible" width="500">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="110px"
v-loading="formLoading"
>
<el-form-item label="新审批人" prop="assigneeUserId">
<el-select v-model="formData.assigneeUserId" clearable style="width: 100%">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="modelVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as TaskApi from '@/api/bpm/task'
import * as UserApi from '@/api/system/user'
const modelVisible = ref(false) //
const formLoading = ref(false) //
const formData = ref({
id: '',
assigneeUserId: undefined
})
const formRules = ref({
assigneeUserId: [{ required: true, message: '新审批人不能为空', trigger: 'change' }]
})
const formRef = ref() // Ref
const userList = ref<any[]>([]) //
/** 打开弹窗 */
const open = async (id: string) => {
modelVisible.value = true
resetForm()
formData.value.id = id
//
userList.value = await UserApi.getSimpleUserList()
}
defineExpose({ open }) // openModal
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
await TaskApi.updateTaskAssignee(formData.value)
modelVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: '',
assigneeUserId: undefined
}
formRef.value?.resetFields()
}
</script>

View File

@ -33,31 +33,21 @@
</el-form-item>
</el-form>
<div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
<XButton
pre-icon="ep:select"
type="success"
title="通过"
@click="handleAudit(item, true)"
/>
<XButton
pre-icon="ep:close"
type="danger"
title="不通过"
@click="handleAudit(item, false)"
/>
<XButton
pre-icon="ep:edit"
type="primary"
title="转办"
@click="handleUpdateAssignee(item)"
/>
<XButton
pre-icon="ep:position"
type="primary"
title="委派"
@click="handleDelegate(item)"
/>
<XButton pre-icon="ep:back" type="warning" title="委派" @click="handleBack(item)" />
<el-button type="success" @click="handleAudit(item, true)">
<Icon icon="ep:select" /> 通过
</el-button>
<el-button type="danger" @click="handleAudit(item, false)">
<Icon icon="ep:close" /> 不通过
</el-button>
<el-button type="primary" @click="openTaskUpdateAssigneeForm(item.id)">
<Icon icon="ep:edit" /> 转办
</el-button>
<el-button type="primary" @click="handleDelegate(item)">
<Icon icon="ep:position" /> 委派
</el-button>
<el-button type="warning" @click="handleBack(item)">
<Icon icon="ep:back" /> 回退
</el-button>
</div>
</el-col>
</el-card>
@ -85,7 +75,7 @@
processInstance.businessKey
"
>
<XButton type="primary" preIcon="ep:view" title="点击查看" />
<el-button type="primary"><Icon icon="ep:view" /> 点击查看</el-button>
</router-link>
</div>
</el-card>
@ -153,42 +143,8 @@
/>
</el-card>
<!-- 对话框(转派审批人) -->
<XModal v-model="updateAssigneeVisible" title="转派审批人" width="500">
<el-form
ref="updateAssigneeFormRef"
:model="updateAssigneeForm"
:rules="updateAssigneeRules"
label-width="110px"
>
<el-form-item label="新审批人" prop="assigneeUserId">
<el-select v-model="updateAssigneeForm.assigneeUserId" clearable 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>
<!-- 操作按钮 -->
<template #footer>
<!-- 按钮保存 -->
<XButton
type="primary"
:title="t('action.save')"
:loading="updateAssigneeLoading"
@click="submitUpdateAssigneeForm"
/>
<!-- 按钮关闭 -->
<XButton
:loading="updateAssigneeLoading"
:title="t('dialog.close')"
@click="updateAssigneeLoading = false"
/>
</template>
</XModal>
<!-- 弹窗转派审批人 -->
<TaskUpdateAssigneeForm ref="taskUpdateAssigneeFormRef" @success="getDetail" />
</ContentWrap>
</template>
<script setup lang="ts">
@ -200,13 +156,12 @@ import * as TaskApi from '@/api/bpm/task'
import * as ActivityApi from '@/api/bpm/activity'
import { formatPast2 } from '@/utils/formatTime'
import { setConfAndFields2 } from '@/utils/formCreate'
// import { OptionAttrs } from '@form-create/element-ui/types/config'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
import { useUserStore } from '@/store/modules/user'
import TaskUpdateAssigneeForm from './TaskUpdateAssigneeForm.vue'
const { query } = useRoute() //
const message = useMessage() //
const { t } = useI18n() //
const { proxy } = getCurrentInstance() as any
// ========== ==========
@ -294,55 +249,11 @@ const getTimelineItemType = (item) => {
}
// ========== ==========
const updateAssigneeVisible = ref(false)
const updateAssigneeLoading = ref(false)
const updateAssigneeForm = ref({
id: undefined,
assigneeUserId: undefined
})
const updateAssigneeRules = ref({
assigneeUserId: [{ required: true, message: '新审批人不能为空', trigger: 'change' }]
})
const updateAssigneeFormRef = ref()
const userOptions = ref<any[]>([])
//
const handleUpdateAssignee = (task) => {
//
resetUpdateAssigneeForm()
updateAssigneeForm.value.id = task.id
//
updateAssigneeVisible.value = true
}
//
const submitUpdateAssigneeForm = async () => {
// 1.
const elForm = unref(updateAssigneeFormRef)
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
// 2.1
updateAssigneeLoading.value = true
try {
await TaskApi.updateTaskAssignee(updateAssigneeForm.value)
// 2.2
updateAssigneeVisible.value = false
//
getDetail()
} finally {
updateAssigneeLoading.value = false
}
}
//
const resetUpdateAssigneeForm = () => {
updateAssigneeForm.value = {
id: undefined,
assigneeUserId: undefined
}
updateAssigneeFormRef.value?.resetFields()
/** 转派审批人 */
const taskUpdateAssigneeFormRef = ref()
const openTaskUpdateAssigneeForm = (id: string) => {
taskUpdateAssigneeFormRef.value.open(id)
}
/** 处理审批退回的操作 */
@ -375,7 +286,6 @@ const activityList = ref([])
// ========== ==========
onMounted(() => {
//
getDetail()
//
UserApi.getSimpleUserList().then((data) => {