fix require photo event
This commit is contained in:
@@ -114,6 +114,8 @@
|
||||
|
||||
<div class="photo-part">
|
||||
<photo-scroller
|
||||
title="登记事件照片"
|
||||
:required="selectedRequiredPhotoEventList.length > 0"
|
||||
v-model="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
:edit-mode="true"
|
||||
@@ -209,7 +211,7 @@ import type { EventItem } from "@/types/EventItem";
|
||||
import type { EventRecord } from "@/types/EventRecord";
|
||||
import type { PointAction } from "@/types/Point";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getEventRecordPhotoURL } from "@/utils/eventRecord";
|
||||
import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord";
|
||||
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { loadSourceValueConfig, type SourceValueConfig } from "@/utils/point";
|
||||
@@ -408,6 +410,9 @@ const numberValueTextMap = reactive<Record<string, string>>({});
|
||||
const selectedNumberEventList = computed(() => selectedEventIdList.value
|
||||
.map(eventId => eventList.value.find(item => item.id === eventId))
|
||||
.filter((item): item is EventItem => item?.valueType === "NUMBER"));
|
||||
const selectedRequiredPhotoEventList = computed(() => selectedEventIdList.value
|
||||
.map(eventId => eventList.value.find(item => item.id === eventId))
|
||||
.filter((item): item is EventItem => item?.requirePhoto === true));
|
||||
|
||||
const eventNameMap = computed(() => {
|
||||
const map = new Map<string, string>();
|
||||
@@ -604,6 +609,10 @@ async function submitRecord(): Promise<void> {
|
||||
if (isSaving.value) {
|
||||
return;
|
||||
}
|
||||
if (isPhotoUploading.value) {
|
||||
Message.warning("照片正在上传,请稍候");
|
||||
return;
|
||||
}
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
@@ -616,21 +625,19 @@ async function submitRecord(): Promise<void> {
|
||||
}
|
||||
|
||||
const customerIdList = selectedCustomerList.value.map(customer => customer.id).filter((item): item is string => !!item);
|
||||
// 多个事件按选择顺序逐条提交,避免把有累计积分顺序依赖的事件混入同一批次。
|
||||
for (const eventId of selectedEventIdList.value) {
|
||||
await EventRecordAPI.create({
|
||||
eventId,
|
||||
customerIdList,
|
||||
remark: note.value || "客户现场登记",
|
||||
registeredAt: buildRegisteredAt(),
|
||||
pointValue: showSourceValueInput.value ? resolveSourceValue() : undefined,
|
||||
numberValue: resolveNumberValue(eventId),
|
||||
attachmentList: buildTempFileIdList().map(tempFileId => ({
|
||||
tempFileId,
|
||||
attachType: "PHOTO"
|
||||
}))
|
||||
});
|
||||
}
|
||||
// 后端批量接口仍按选择顺序逐条处理,并为重复临时附件生成副本。
|
||||
await EventRecordAPI.createBatch(selectedEventIdList.value.map(eventId => ({
|
||||
eventId,
|
||||
customerIdList,
|
||||
remark: note.value || "客户现场登记",
|
||||
registeredAt: buildRegisteredAt(),
|
||||
pointValue: showSourceValueInput.value ? resolveSourceValue() : undefined,
|
||||
numberValue: resolveNumberValue(eventId),
|
||||
attachmentList: buildTempFileIdList().map(tempFileId => ({
|
||||
tempFileId,
|
||||
attachType: "PHOTO"
|
||||
}))
|
||||
})));
|
||||
selectedCustomerList.value = [];
|
||||
selectedCustomerIdList.value = [];
|
||||
note.value = "";
|
||||
@@ -657,6 +664,9 @@ function validateForm(): boolean {
|
||||
Message.warning("请至少选择一个登记事件");
|
||||
return false;
|
||||
}
|
||||
if (!validateRequiredPhotoList()) {
|
||||
return false;
|
||||
}
|
||||
if (!isEditMode.value && !validateNumberValueList()) {
|
||||
return false;
|
||||
}
|
||||
@@ -672,6 +682,15 @@ function validateForm(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateRequiredPhotoList(): boolean {
|
||||
const event = selectedRequiredPhotoEventList.value[0];
|
||||
if (event && !hasPhotoAttachment(photoItemList.value)) {
|
||||
Message.warning(`请上传${event.name || "当前事件"}照片`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function updateRecord(): Promise<void> {
|
||||
if (!editingRecord.value?.id || !editingRecord.value.customerId || !editingRecord.value.eventId) {
|
||||
Message.warning("登记事件记录不存在");
|
||||
|
||||
Reference in New Issue
Block a user