add event option
This commit is contained in:
@@ -16,6 +16,11 @@
|
||||
</div>
|
||||
<div class="tips red">事件可多选,请注意勾选的登记事件</div>
|
||||
</div>
|
||||
<event-option-selector
|
||||
v-model="selectedOptionSelectionMap"
|
||||
:event-list="eventList"
|
||||
:selected-event-id-list="selectedEventIdList"
|
||||
/>
|
||||
<code-scanner
|
||||
visible
|
||||
:session-key="scannerSessionKey"
|
||||
@@ -133,14 +138,16 @@ import EventAPI from "@/api/EventAPI";
|
||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
import CodeScanner from "@/components/CodeScanner.vue";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||
import PhotoScroller from "@/components/PhotoScroller.vue";
|
||||
import { useSettingStore } from "@/store/settingStore";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
import type { EventItem, EventOptionSelectionMap } from "@/types/EventItem";
|
||||
import type { EventRecord } from "@/types/EventRecord";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import type { PointAction } from "@/types/Point";
|
||||
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
|
||||
import { resolveSelectedOptionGroupList, validateEventOptionSelection } from "@/utils/eventOption";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
@@ -163,6 +170,7 @@ const settingStore = useSettingStore();
|
||||
const EventItemStorageKey = "quick-scan-event-id";
|
||||
const selectedEventIdList = ref<string[]>([]);
|
||||
const eventList = ref<EventItem[]>([]);
|
||||
const selectedOptionSelectionMap = reactive<EventOptionSelectionMap>({});
|
||||
const isEventLoading = ref(false);
|
||||
const eventLoadFailed = ref(false);
|
||||
const selectedEventList = computed(() => selectedEventIdList.value
|
||||
@@ -225,6 +233,26 @@ async function handleEventSelectionChange(eventIdList: string[]): Promise<void>
|
||||
await loadSourceValueRule();
|
||||
}
|
||||
|
||||
function resolveRecordOptionGroupList(eventId: string) {
|
||||
const event = eventList.value.find(item => normalizeEventId(item) === eventId);
|
||||
return event ? resolveSelectedOptionGroupList(event, selectedOptionSelectionMap) : [];
|
||||
}
|
||||
|
||||
function validateEventOptionSelectionList(): boolean {
|
||||
for (const eventId of selectedEventIdList.value) {
|
||||
const event = eventList.value.find(item => normalizeEventId(item) === eventId);
|
||||
if (!event) {
|
||||
continue;
|
||||
}
|
||||
const optionError = validateEventOptionSelection(event, selectedOptionSelectionMap);
|
||||
if (optionError) {
|
||||
Message.warning(optionError);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function syncStoredEventId(): void {
|
||||
const firstEventId = selectedEventIdList.value[0];
|
||||
if (firstEventId) {
|
||||
@@ -449,6 +477,9 @@ async function doSubmit(): Promise<void> {
|
||||
if (!validateRequiredPhotoList()) {
|
||||
return;
|
||||
}
|
||||
if (!validateEventOptionSelectionList()) {
|
||||
return;
|
||||
}
|
||||
if (!validateNumberValueList()) {
|
||||
return;
|
||||
}
|
||||
@@ -463,6 +494,7 @@ async function doSubmit(): Promise<void> {
|
||||
await EventRecordAPI.createBatch(selectedEventIdList.value.map(eventId => ({
|
||||
eventId,
|
||||
customerId: customer.id,
|
||||
selectedOptionGroupList: resolveRecordOptionGroupList(eventId),
|
||||
pointValue: showSourceValueInput.value ? pointValue : undefined,
|
||||
numberValue: resolveNumberValue(eventId),
|
||||
remark: "客户快速扫码登记",
|
||||
@@ -476,6 +508,9 @@ async function doSubmit(): Promise<void> {
|
||||
for (const eventId of Object.keys(numberValueTextMap)) {
|
||||
delete numberValueTextMap[eventId];
|
||||
}
|
||||
for (const eventId of Object.keys(selectedOptionSelectionMap)) {
|
||||
delete selectedOptionSelectionMap[eventId];
|
||||
}
|
||||
recentRecordList.value = [];
|
||||
latestDecodedText = "";
|
||||
scannerSessionKey.value += 1;
|
||||
|
||||
Reference in New Issue
Block a user