feat(@vben/web-antdv-next): BPM拒绝可以添加附件上传功能至审批表单
parent
041e3f6e2d
commit
6951bd68a1
|
|
@ -83,6 +83,7 @@ export namespace BpmProcessInstanceApi {
|
|||
reason: string;
|
||||
signPicUrl: string;
|
||||
status: number;
|
||||
attachments?: string[];
|
||||
}
|
||||
|
||||
/** 抄送流程实例 */
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import {
|
|||
transferTask,
|
||||
} from '#/api/bpm/task';
|
||||
import { setConfAndFields2 } from '#/components/form-create';
|
||||
import { FileUpload } from '#/components/upload';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import Signature from './signature.vue';
|
||||
|
|
@ -120,6 +121,7 @@ const approveReasonForm: any = reactive({
|
|||
reason: '',
|
||||
signPicUrl: '',
|
||||
nextAssignees: {},
|
||||
attachments: [],
|
||||
});
|
||||
const approveReasonRule: Record<string, any> = computed(() => {
|
||||
return {
|
||||
|
|
@ -140,7 +142,8 @@ const approveReasonRule: Record<string, any> = computed(() => {
|
|||
});
|
||||
|
||||
const rejectFormRef = ref<FormInstance>();
|
||||
const rejectReasonForm = reactive({
|
||||
const rejectReasonForm = reactive<{ attachments: string[]; reason: string }>({
|
||||
attachments: [],
|
||||
reason: '',
|
||||
}); // 拒绝表单
|
||||
const rejectReasonRule: any = computed(() => {
|
||||
|
|
@ -290,6 +293,14 @@ function closePopover(type: string, formRef: any | FormInstance) {
|
|||
if (formRef) {
|
||||
formRef.resetFields();
|
||||
}
|
||||
if (type === 'approve') {
|
||||
approveReasonForm.reason = '';
|
||||
approveReasonForm.attachments = [];
|
||||
approveReasonForm.signPicUrl = '';
|
||||
} else if (type === 'reject') {
|
||||
rejectReasonForm.reason = '';
|
||||
rejectReasonForm.attachments = [];
|
||||
}
|
||||
if (popOverVisible.value[type]) popOverVisible.value[type] = false;
|
||||
nextAssigneesActivityNode.value = [];
|
||||
// 清理 Timeline 组件中的自定义审批人数据
|
||||
|
|
@ -401,6 +412,7 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
|
|||
const data = {
|
||||
id: runningTask.value.id,
|
||||
reason: approveReasonForm.reason,
|
||||
attachments: approveReasonForm.attachments,
|
||||
variables, // 审批通过, 把修改的字段值赋于流程实例变量
|
||||
nextAssignees: approveReasonForm.nextAssignees, // 下个自选节点选择的审批人信息
|
||||
} as any;
|
||||
|
|
@ -414,6 +426,9 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
|
|||
await formCreateApi.validate();
|
||||
}
|
||||
await approveTask(data);
|
||||
approveReasonForm.reason = '';
|
||||
approveReasonForm.attachments = [];
|
||||
approveReasonForm.signPicUrl = '';
|
||||
popOverVisible.value.approve = false;
|
||||
nextAssigneesActivityNode.value = [];
|
||||
// 清理 Timeline 组件中的自定义审批人数据
|
||||
|
|
@ -425,9 +440,12 @@ async function handleAudit(pass: boolean, formRef: FormInstance | undefined) {
|
|||
// 审批不通过数据
|
||||
const data = {
|
||||
id: runningTask.value.id,
|
||||
attachments: rejectReasonForm.attachments,
|
||||
reason: rejectReasonForm.reason,
|
||||
};
|
||||
await rejectTask(data);
|
||||
rejectReasonForm.reason = '';
|
||||
rejectReasonForm.attachments = [];
|
||||
popOverVisible.value.reject = false;
|
||||
message.success('审批不通过成功');
|
||||
}
|
||||
|
|
@ -748,6 +766,38 @@ function handleSignFinish(url: string) {
|
|||
approveFormRef.value?.validateFields(['signPicUrl']);
|
||||
}
|
||||
|
||||
/** 附件图片预览 */
|
||||
const imagePreviewOpen = ref(false);
|
||||
const imagePreviewUrl = ref('');
|
||||
|
||||
/** 判断文件是否为图片类型 */
|
||||
function isImageUrl(url: string) {
|
||||
return /\.(bmp|gif|jpe?g|png|svg|webp)$/i.test(url);
|
||||
}
|
||||
|
||||
/** 处理文件预览 */
|
||||
function handleFilePreview(file: any) {
|
||||
if (!file?.url && !file?.response) {
|
||||
message.warning('文件地址不存在,无法预览');
|
||||
return;
|
||||
}
|
||||
const url = file.url || file?.response?.url || file?.response;
|
||||
if (!url) {
|
||||
message.warning('文件地址不存在,无法预览');
|
||||
return;
|
||||
}
|
||||
if (isImageUrl(url)) {
|
||||
imagePreviewUrl.value = url;
|
||||
imagePreviewOpen.value = true;
|
||||
} else {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
function handleImagePreviewOpenChange(open: boolean) {
|
||||
imagePreviewOpen.value = open;
|
||||
}
|
||||
|
||||
/** 处理弹窗可见性 */
|
||||
function handlePopoverVisible(visible: boolean) {
|
||||
if (!visible) {
|
||||
|
|
@ -843,6 +893,15 @@ defineExpose({ loadTodoTask });
|
|||
:rows="4"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="上传附件/图片" name="attachments">
|
||||
<FileUpload
|
||||
v-model:value="approveReasonForm.attachments"
|
||||
:max-number="10"
|
||||
:multiple="true"
|
||||
help-text="支持多文件/图片上传"
|
||||
@preview="handleFilePreview"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Space>
|
||||
<Button
|
||||
|
|
@ -900,6 +959,15 @@ defineExpose({ loadTodoTask });
|
|||
:rows="4"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="上传附件/图片" name="attachments">
|
||||
<FileUpload
|
||||
v-model:value="rejectReasonForm.attachments"
|
||||
:max-number="10"
|
||||
:multiple="true"
|
||||
help-text="支持多文件/图片上传"
|
||||
@preview="handleFilePreview"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Button
|
||||
:disabled="formLoading"
|
||||
|
|
@ -1444,4 +1512,14 @@ defineExpose({ loadTodoTask });
|
|||
|
||||
<!-- 签名弹窗 -->
|
||||
<SignatureModal @success="handleSignFinish" />
|
||||
|
||||
<!-- 图片预览(隐藏的 Image 组件,仅用于附件预览弹窗) -->
|
||||
<Image
|
||||
:preview="{
|
||||
open: imagePreviewOpen,
|
||||
onOpenChange: handleImagePreviewOpenChange,
|
||||
}"
|
||||
:src="imagePreviewUrl"
|
||||
style="display: none"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue