提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<Dialog v-model="dialogVisible" title="回退任务" width="500"> |
|
3 |
<el-form |
|
4 |
ref="formRef" |
|
5 |
v-loading="formLoading" |
|
6 |
:model="formData" |
|
7 |
:rules="formRules" |
|
8 |
label-width="110px" |
|
9 |
> |
|
10 |
<el-form-item label="退回节点" prop="targetTaskDefinitionKey"> |
|
11 |
<el-select v-model="formData.targetTaskDefinitionKey" clearable style="width: 100%"> |
|
12 |
<el-option |
|
13 |
v-for="item in returnList" |
|
14 |
:key="item.taskDefinitionKey" |
|
15 |
:label="item.name" |
|
16 |
:value="item.taskDefinitionKey" |
|
17 |
/> |
|
18 |
</el-select> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="回退理由" prop="reason"> |
|
21 |
<el-input v-model="formData.reason" clearable placeholder="请输入回退理由" /> |
|
22 |
</el-form-item> |
|
23 |
</el-form> |
|
24 |
<template #footer> |
|
25 |
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|
26 |
<el-button @click="dialogVisible = false">取 消</el-button> |
|
27 |
</template> |
|
28 |
</Dialog> |
|
29 |
</template> |
|
30 |
<script lang="ts" name="TaskRollbackDialogForm" setup> |
|
31 |
import * as TaskApi from '@/api/bpm/task' |
|
32 |
|
|
33 |
const message = useMessage() // 消息弹窗 |
|
34 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
35 |
const formLoading = ref(false) // 表单的加载中 |
|
36 |
const formData = ref({ |
|
37 |
id: '', |
|
38 |
targetTaskDefinitionKey: undefined, |
|
39 |
reason: '' |
|
40 |
}) |
|
41 |
const formRules = ref({ |
|
42 |
targetTaskDefinitionKey: [{ required: true, message: '必须选择回退节点', trigger: 'change' }], |
|
43 |
reason: [{ required: true, message: '回退理由不能为空', trigger: 'blur' }] |
|
44 |
}) |
|
45 |
|
|
46 |
const formRef = ref() // 表单 Ref |
|
47 |
const returnList = ref([] as any) |
|
48 |
/** 打开弹窗 */ |
|
49 |
const open = async (id: string) => { |
|
50 |
returnList.value = await TaskApi.getTaskListByReturn(id) |
|
51 |
if (returnList.value.length === 0) { |
|
52 |
message.warning('当前没有可回退的节点') |
|
53 |
return false |
|
54 |
} |
|
55 |
dialogVisible.value = true |
|
56 |
resetForm() |
|
57 |
formData.value.id = id |
|
58 |
} |
|
59 |
defineExpose({ open }) // 提供 openModal 方法,用于打开弹窗 |
|
60 |
|
|
61 |
/** 提交表单 */ |
|
62 |
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
63 |
const submitForm = async () => { |
|
64 |
// 校验表单 |
|
65 |
if (!formRef) return |
|
66 |
const valid = await formRef.value.validate() |
|
67 |
if (!valid) return |
|
68 |
// 提交请求 |
|
69 |
formLoading.value = true |
|
70 |
try { |
|
71 |
await TaskApi.returnTask(formData.value) |
|
72 |
message.success('回退成功') |
|
73 |
dialogVisible.value = false |
|
74 |
// 发送操作成功的事件 |
|
75 |
emit('success') |
|
76 |
} finally { |
|
77 |
formLoading.value = false |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
/** 重置表单 */ |
|
82 |
const resetForm = () => { |
|
83 |
formData.value = { |
|
84 |
id: '', |
|
85 |
targetTaskDefinitionKey: undefined, |
|
86 |
reason: '' |
|
87 |
} |
|
88 |
formRef.value?.resetFields() |
|
89 |
} |
|
90 |
</script> |