97 lines
2.3 KiB
Vue
97 lines
2.3 KiB
Vue
<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>
|