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