提交 | 用户 | 时间
|
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="userIds"> |
|
11 |
<el-select v-model="formData.userIds" multiple clearable style="width: 100%"> |
|
12 |
<el-option |
|
13 |
v-for="item in userList" |
|
14 |
:key="item.id" |
|
15 |
:label="item.nickname" |
|
16 |
:value="item.id" |
|
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('before')"> |
|
26 |
向前加签 |
|
27 |
</el-button> |
|
28 |
<el-button :disabled="formLoading" type="primary" @click="submitForm('after')"> |
|
29 |
向后加签 |
|
30 |
</el-button> |
|
31 |
<el-button @click="dialogVisible = false">取 消</el-button> |
|
32 |
</template> |
|
33 |
</Dialog> |
|
34 |
</template> |
|
35 |
<script lang="ts" setup> |
|
36 |
import * as TaskApi from '@/api/bpm/task' |
|
37 |
import * as UserApi from '@/api/system/user' |
|
38 |
|
|
39 |
defineOptions({ name: 'TaskSignCreateForm' }) |
|
40 |
|
|
41 |
const message = useMessage() // 消息弹窗 |
|
42 |
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
43 |
const formLoading = ref(false) // 表单的加载中 |
|
44 |
const formData = ref({ |
|
45 |
id: '', |
|
46 |
userIds: [], |
|
47 |
type: '', |
|
48 |
reason: '' |
|
49 |
}) |
|
50 |
const formRules = ref({ |
|
51 |
userIds: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }], |
|
52 |
reason: [{ required: true, message: '加签理由不能为空', trigger: 'change' }] |
|
53 |
}) |
|
54 |
|
|
55 |
const formRef = ref() // 表单 Ref |
|
56 |
const userList = ref<any[]>([]) // 用户列表 |
|
57 |
|
|
58 |
/** 打开弹窗 */ |
|
59 |
const open = async (id: string) => { |
|
60 |
dialogVisible.value = true |
|
61 |
resetForm() |
|
62 |
formData.value.id = id |
|
63 |
// 获得用户列表 |
|
64 |
userList.value = await UserApi.getSimpleUserList() |
|
65 |
} |
|
66 |
defineExpose({ open }) // 提供 openModal 方法,用于打开弹窗 |
|
67 |
|
|
68 |
/** 提交表单 */ |
|
69 |
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
70 |
const submitForm = async (type: string) => { |
|
71 |
// 校验表单 |
|
72 |
if (!formRef) return |
|
73 |
const valid = await formRef.value.validate() |
|
74 |
if (!valid) return |
|
75 |
// 提交请求 |
|
76 |
formLoading.value = true |
|
77 |
formData.value.type = type |
|
78 |
try { |
|
79 |
await TaskApi.signCreateTask(formData.value) |
|
80 |
message.success('加签成功') |
|
81 |
dialogVisible.value = false |
|
82 |
// 发送操作成功的事件 |
|
83 |
emit('success') |
|
84 |
} finally { |
|
85 |
formLoading.value = false |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/** 重置表单 */ |
|
90 |
const resetForm = () => { |
|
91 |
formData.value = { |
|
92 |
id: '', |
|
93 |
userIds: [], |
|
94 |
type: '', |
|
95 |
reason: '' |
|
96 |
} |
|
97 |
formRef.value?.resetFields() |
|
98 |
} |
|
99 |
</script> |