add event option
This commit is contained in:
@@ -71,6 +71,11 @@
|
||||
:event-list="eventList"
|
||||
/>
|
||||
</t-form-item>
|
||||
<event-option-selector
|
||||
v-model="selectedOptionSelectionMap"
|
||||
:event-list="eventList"
|
||||
:selected-event-id-list="selectedEventIdList"
|
||||
/>
|
||||
<div v-if="selectedNumberEventList.length" class="event-value-list">
|
||||
<t-form-item
|
||||
v-for="item in selectedNumberEventList"
|
||||
@@ -152,14 +157,16 @@ import CustomerAPI from "@/api/CustomerAPI";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import CodeScanner from "@/components/CodeScanner.vue";
|
||||
import CustomerSelector from "@/components/CustomerSelector.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 { PointAction } from "@/types/Point";
|
||||
import { getEventNumberValuePlaceholder, resolveEventNumberValue } from "@/utils/eventValue";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { hasPhotoAttachment } from "@/utils/eventRecord";
|
||||
import { resolveSelectedOptionGroupList, validateEventOptionSelection } from "@/utils/eventOption";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { loadSourceValueConfig, type SourceValueConfig } from "@/utils/point";
|
||||
import { compressUploadImage, compressUploadImageList } from "@/utils/imageCompression";
|
||||
@@ -180,6 +187,7 @@ const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(perm
|
||||
const eventList = ref<EventItem[]>([]);
|
||||
|
||||
const selectedEventIdList = ref<string[]>([]);
|
||||
const selectedOptionSelectionMap = reactive<EventOptionSelectionMap>({});
|
||||
const numberValueTextMap = reactive<Record<string, string>>({});
|
||||
const selectedNumberEventList = computed(() => selectedEventIdList.value
|
||||
.map(eventId => eventList.value.find(item => item.id === eventId))
|
||||
@@ -669,6 +677,7 @@ async function saveRecord(): Promise<void> {
|
||||
name: customerName.value.trim(),
|
||||
eventRecordList: selectedEventIdList.value.map(eventId => ({
|
||||
eventId,
|
||||
selectedOptionGroupList: resolveRecordOptionGroupList(eventId),
|
||||
numberValue: resolveNumberValue(eventId),
|
||||
pointValue: showSourceValueInput.value ? resolveSourceValue() : undefined,
|
||||
remark: note.value || "快速补录登记"
|
||||
@@ -720,6 +729,9 @@ function resetFormAfterSubmit(): void {
|
||||
for (const eventId of Object.keys(numberValueTextMap)) {
|
||||
delete numberValueTextMap[eventId];
|
||||
}
|
||||
for (const eventId of Object.keys(selectedOptionSelectionMap)) {
|
||||
delete selectedOptionSelectionMap[eventId];
|
||||
}
|
||||
refreshInputTips();
|
||||
}
|
||||
|
||||
@@ -757,6 +769,9 @@ function validateForm(): string {
|
||||
if (!validateRequiredPhotoList()) {
|
||||
return "";
|
||||
}
|
||||
if (!validateEventOptionSelectionList()) {
|
||||
return "";
|
||||
}
|
||||
if (!validateNumberValueList()) {
|
||||
return "";
|
||||
}
|
||||
@@ -780,6 +795,26 @@ function validateRequiredPhotoList(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function resolveRecordOptionGroupList(eventId: string) {
|
||||
const event = eventList.value.find(item => item.id === eventId);
|
||||
return event ? resolveSelectedOptionGroupList(event, selectedOptionSelectionMap) : [];
|
||||
}
|
||||
|
||||
function validateEventOptionSelectionList(): boolean {
|
||||
for (const eventId of selectedEventIdList.value) {
|
||||
const event = eventList.value.find(item => item.id === eventId);
|
||||
if (!event) {
|
||||
continue;
|
||||
}
|
||||
const optionError = validateEventOptionSelection(event, selectedOptionSelectionMap);
|
||||
if (optionError) {
|
||||
Message.warning(optionError);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------- 初始化 ----------
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -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