人脸审批管理

This commit is contained in:
weiwei committed 2025-03-13 15:40:55 +08:00
1 parent f7d24e447e
commit 6cd4046b13
11 files changed
+335 -168

No files matched your search

+96
View File
@@ -0,0 +1,96 @@
<template>
<el-dialog v-model="dialogVisible" title="提交审核" :width="400">
<el-input v-model="submitDesc" type="textarea" maxlength="100" :rows="5" placeholder="请输入审核意见..." show-word-limit />
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确定</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue"
import { completeTask } from "/@/api/flow/task"
import type { FlowFormItem, TaskData, TaskSubmitParam } from "./types"
import { useMessage } from "/@/hooks/message"
import { ElLoading } from "element-plus"
const emit = defineEmits<{
(e: "taskSubmitEvent"): void
}>()
const dialogVisible = ref(false)
const submitDesc = ref("")
const currentData = ref<TaskData>()
const currentOpenFlowForm = ref<FlowFormItem[]>()
const loading = ref()
const handle = (row: TaskData, formData: FlowFormItem[]) => {
submitDesc.value = ""
currentData.value = row
currentOpenFlowForm.value = formData
dialogVisible.value = true
}
defineExpose({ handle })
// 全屏loading
const loadingStart = () => {
loading.value = ElLoading.service({
lock: true,
text: "提交中...",
background: "rgba(0, 0, 0, 0.7)",
})
}
const submit = async () => {
if (!currentData.value || !currentOpenFlowForm.value) return
const formData: Record<string, any> = {}
for (const item of currentOpenFlowForm.value) {
formData[item.id] = item.props.value
if (item.type === "Layout") {
const subList = item.props.value as FlowFormItem[][]
const processedData = subList.map((array) =>
array.reduce(
(acc, subItem) => ({
...acc,
[subItem.id]: subItem.props.value,
}),
{},
),
)
formData[item.id] = processedData
}
}
formData[`${currentData.value.nodeId}_approve_condition`] = true
const param: TaskSubmitParam = {
paramMap: formData,
taskId: currentData.value.taskId,
taskLocalParamMap: {
approveDesc: submitDesc.value,
},
}
try {
loadingStart()
const res = await completeTask(param).finally(() => loading.value.close())
if (res.code === 0) {
dialogVisible.value = false
emit("taskSubmitEvent")
useMessage().success("通过成功")
return
}
useMessage().error("通过失败")
} catch (error) {
useMessage().error("错误")
} finally {
loading.value.close()
}
}
</script>
+112
View File
@@ -0,0 +1,112 @@
<template>
<!-- 流程审批抽屉 -->
<el-drawer v-model="processDrawerVisible" direction="rtl" size="400px">
<template #header>
<h3>{{ curAssignTask?.processName }}</h3>
</template>
<template #default>
<div class="w-full h-full" v-loading="loading">
<el-card class="box-card" v-if="curAssignTask.taskId">
<form-render ref="formRenderRef" :form-list="currentOpenFlowForm" />
</el-card>
<flow-node-format
:disableSelect="true"
:formData="formValue"
:task-id="curAssignTask.taskId"
:processInstanceId="curAssignTask.processInstanceId"
:flow-id="curAssignTask.flowId"
ref="flowNodeFormatRef"
class="mt-4"
/>
</div>
</template>
<template #footer>
<div style="flex: auto">
<el-button size="large" type="danger" icon="Close" @click="refuseTask" :disabled="loading">拒绝</el-button>
<el-button size="large" type="primary" icon="Check" @click="submitTask" :disabled="loading">提交</el-button>
<el-button size="large" type="info" icon="Share" @click="transferTask" :disabled="loading">转办</el-button>
</div>
</template>
</el-drawer>
<!--同意提交处理-->
<agree-handle @taskSubmitEvent="taskSubmitEvent" ref="agreeHandler"></agree-handle>
<!--拒绝审核处理-->
<refuse-handle @taskSubmitEvent="taskSubmitEvent" ref="refuseHandler"></refuse-handle>
<!--转办处理-->
<transfer-handle @taskSubmitEvent="taskSubmitEvent" ref="transferHandler"></transfer-handle>
</template>
<script setup lang="ts">
import { FlowFormItem } from "./types"
import FormRender from "/@/views/flow/form/render/FormRender.vue"
import FlowNodeFormat from "/@/views/flow/form/tools/FlowNodeFormatData.vue"
import AgreeHandle from "./agree.vue"
import RefuseHandle from "./refuse.vue"
import TransferHandle from "./transfer.vue"
import { queryAssignTaskOne, queryTask } from "/@/api/flow/task"
const emit = defineEmits(["taskSubmitEvent"])
const processDrawerVisible = ref<boolean>(false)
const curAssignTask = ref<any>({})
const currentOpenFlowForm = ref<FlowFormItem[]>([])
const loading = ref(false)
const agreeHandler = ref()
const refuseHandler = ref()
const transferHandler = ref()
// 打开流程审批抽屉
const openProcessDrawer = async (row: any) => {
processDrawerVisible.value = true
loading.value = true
try {
const assignTask = await queryAssignTaskOne({ processInstanceId: row.processId })
if (assignTask.code === 0) {
curAssignTask.value = assignTask.data
}
const res = await queryTask(curAssignTask.value.taskId, false).finally(() => (loading.value = false))
if (res.code === 0) {
currentOpenFlowForm.value = res.data.formItems
}
} catch (error) {
curAssignTask.value = {}
currentOpenFlowForm.value = []
} finally {
loading.value = false
}
}
// 提交任务
const submitTask = () => {
agreeHandler.value.handle(curAssignTask.value, currentOpenFlowForm.value)
}
// 拒绝任务
const refuseTask = () => {
refuseHandler.value.handle(curAssignTask.value, currentOpenFlowForm.value)
}
// 转办任务
const transferTask = () => {
transferHandler.value.handle(curAssignTask.value, currentOpenFlowForm.value)
}
// 流程提交
const taskSubmitEvent = () => emit("taskSubmitEvent")
const formValue = computed(() => {
const obj: any = {}
for (let item of currentOpenFlowForm.value) {
obj[item.id] = item.props.value
}
return obj
})
defineExpose({
openProcessDrawer,
})
</script>
+92
View File
@@ -0,0 +1,92 @@
<template>
<el-dialog v-model="dialogVisible" title="拒绝审核" width="400px">
<el-input v-loading="loading" v-model="submitDesc" type="textarea" maxlength="100" :rows="5" placeholder="审核意见" show-word-limit />
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确定</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { defineExpose } from "vue"
import { completeTask } from "/@/api/flow/task"
import { useMessage } from "/@/hooks/message"
import type { FlowFormItem, TaskData, TaskSubmitParam } from "./types"
import { ElLoading } from "element-plus"
const emit = defineEmits(["taskSubmitEvent"])
const dialogVisible = ref(false)
const submitDesc = ref("")
const currentData = ref()
const currentOpenFlowForm = ref()
const loading = ref()
const handle = (row: TaskData, formData: FlowFormItem[]) => {
submitDesc.value = ""
currentData.value = row
currentOpenFlowForm.value = formData
dialogVisible.value = true
}
// 全屏loading
const loadingStart = () => {
loading.value = ElLoading.service({
lock: true,
text: "提交中...",
background: "rgba(0, 0, 0, 0.7)",
})
}
defineExpose({ handle })
const submit = async () => {
let value = currentOpenFlowForm.value
let formData: any = {}
for (var item of value) {
formData[item.id] = item.props.value
if (item.type === "Layout") {
let subList = item.props.value
var d = []
for (var array of subList) {
var v = {}
for (var subItem of array) {
v[subItem.id] = subItem.props.value
}
d.push(v)
}
formData[item.id] = d
}
}
formData[currentData.value.nodeId + "_approve_condition"] = false
const param = {
paramMap: formData,
taskId: currentData.value.taskId,
taskLocalParamMap: {
approveDesc: "拒绝原因:" + submitDesc.value,
},
}
try {
loadingStart()
const res = await completeTask(param).finally(() => loading.value.close())
if (res.code === 0) {
useMessage().success("拒绝成功")
dialogVisible.value = false
emit("taskSubmitEvent")
return
}
useMessage().error("拒绝失败")
} catch (error) {
useMessage().error("错误")
} finally {
loading.value.close()
}
}
</script>
+144
View File
@@ -0,0 +1,144 @@
<template>
<el-dialog v-model="dialogVisible" width="400px" :close-on-click-modal="false" :close-on-press-escape="false">
<label class="block pb-2">
<span class="text-base font-medium after:content-['*'] after:text-red-500 after:ml-1">选择转办人员</span>
</label>
<select-show v-model:orgList="userList" type="user" :multiple="true" />
<label class="block pb-2">
<span class="text-base font-medium after:content-['*'] after:text-red-500 after:ml-1">审核意见</span>
</label>
<el-input v-model="submitDesc" type="textarea" maxlength="100" :rows="5" placeholder="请输入审核意见(2-100字)" show-word-limit />
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确定</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue"
import { transferTask } from "/@/api/flow/task"
import selectShow from "/@/components/OrgSelector/index.vue"
import { ElLoading, ElMessage } from "element-plus"
const emit = defineEmits(["taskSubmitEvent"])
interface FlowFormItem {
id: string
type: string
props: {
value: any
label?: string
}
}
interface TaskData {
taskId: string
nodeId: string
}
const dialogVisible = ref(false)
const submitDesc = ref("")
const userList = ref<Array<{ id: string }>>([])
const currentData = ref<TaskData>()
const currentOpenFlowForm = ref<FlowFormItem[]>()
const loading = ref()
// 全屏loading
const loadingStart = () => {
loading.value = ElLoading.service({
lock: true,
text: "提交中...",
background: "rgba(0, 0, 0, 0.7)",
})
}
const handle = (row: TaskData, formData: FlowFormItem[]) => {
submitDesc.value = ""
currentData.value = row
currentOpenFlowForm.value = formData
dialogVisible.value = true
}
defineExpose({ handle })
const validateForm = (): boolean => {
if (userList.value.length === 0) {
ElMessage.warning("请选择转办人员")
return false
}
if (!submitDesc.value.trim()) {
ElMessage.warning("请输入审核意见")
return false
}
if (submitDesc.value.trim().length < 2) {
ElMessage.warning("审核意见至少需要2个字符")
return false
}
return true
}
const submit = async () => {
if (!currentOpenFlowForm.value || !currentData.value) return
// 表单校验
if (!validateForm()) return
try {
const formData: Record<string, any> = {}
for (const item of currentOpenFlowForm.value) {
formData[item.id] = item.props.value
if (item.type === "Layout") {
const subList = item.props.value as Array<FlowFormItem[]>
const d = subList.map((array) => {
const v: Record<string, any> = {}
for (const subItem of array) {
v[subItem.id] = subItem.props.value
}
return v
})
formData[item.id] = d
}
}
formData[`${currentData.value.nodeId}_approve_condition`] = true
const param = {
paramMap: formData,
taskId: currentData.value.taskId,
targetUserIdList: userList.value.map((user) => user.id),
taskLocalParamMap: {
approveDesc: submitDesc.value.trim(),
},
}
try {
loadingStart()
const res = await transferTask(param).finally(() => loading.value.close())
if (res.code === 0) {
ElMessage.success("转办成功")
dialogVisible.value = false
emit("taskSubmitEvent")
return
}
ElMessage.error("转办失败")
} catch (error) {
loading.value.close()
ElMessage.error("错误")
} finally {
loading.value.close()
}
} catch (error) {
ElMessage.error("转办失败,请重试")
} finally {
loading.value.close()
}
}
</script>
+23
View File
@@ -0,0 +1,23 @@
export interface FlowFormItem {
id: string
type: string
props: {
value: any
[key: string]: any
}
}
export interface TaskData {
processName: string
taskId: string
processInstanceId: string
flowId: string
}
export interface TaskSubmitParam {
paramMap: Record<string, any>
taskId: string
taskLocalParamMap: {
approveDesc: string
}
}