@pisell/pisellos 0.0.547 → 0.0.551

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Holder/index.d.ts +42 -0
  3. package/dist/modules/Holder/index.js +500 -0
  4. package/dist/modules/Holder/types.d.ts +115 -0
  5. package/dist/modules/Holder/types.js +1 -0
  6. package/dist/modules/Holder/utils.d.ts +9 -0
  7. package/dist/modules/Holder/utils.js +20 -0
  8. package/dist/modules/Order/index.d.ts +1 -0
  9. package/dist/modules/Order/index.js +14 -1
  10. package/dist/modules/Order/types.d.ts +2 -0
  11. package/dist/modules/Order/utils.d.ts +9 -0
  12. package/dist/modules/Order/utils.js +41 -13
  13. package/dist/modules/Product/types.d.ts +7 -0
  14. package/dist/modules/index.d.ts +1 -0
  15. package/dist/modules/index.js +2 -1
  16. package/dist/plugins/window.d.ts +1 -0
  17. package/dist/solution/BookingByStep/index.d.ts +11 -2
  18. package/dist/solution/BookingByStep/index.js +35 -2
  19. package/dist/solution/BookingByStep/types.d.ts +2 -1
  20. package/dist/solution/BookingByStep/types.js +3 -1
  21. package/dist/solution/VenueBooking/index.d.ts +17 -0
  22. package/dist/solution/VenueBooking/index.js +932 -717
  23. package/dist/solution/VenueBooking/types.d.ts +2 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/lib/modules/Holder/index.d.ts +42 -0
  26. package/lib/modules/Holder/index.js +329 -0
  27. package/lib/modules/Holder/types.d.ts +115 -0
  28. package/lib/modules/Holder/types.js +17 -0
  29. package/lib/modules/Holder/utils.d.ts +9 -0
  30. package/lib/modules/Holder/utils.js +57 -0
  31. package/lib/modules/Order/index.d.ts +1 -0
  32. package/lib/modules/Order/index.js +11 -0
  33. package/lib/modules/Order/types.d.ts +2 -0
  34. package/lib/modules/Order/utils.d.ts +9 -0
  35. package/lib/modules/Order/utils.js +32 -5
  36. package/lib/modules/Product/types.d.ts +7 -0
  37. package/lib/modules/index.d.ts +1 -0
  38. package/lib/modules/index.js +3 -1
  39. package/lib/plugins/window.d.ts +1 -0
  40. package/lib/solution/BookingByStep/index.d.ts +11 -2
  41. package/lib/solution/BookingByStep/index.js +27 -0
  42. package/lib/solution/BookingByStep/types.d.ts +2 -1
  43. package/lib/solution/BookingByStep/types.js +5 -0
  44. package/lib/solution/VenueBooking/index.d.ts +17 -0
  45. package/lib/solution/VenueBooking/index.js +114 -6
  46. package/lib/solution/VenueBooking/types.d.ts +2 -0
  47. package/lib/types/index.d.ts +1 -0
  48. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, DateModule, ScheduleModule, QuotationModule, OpenDataModule } from '../../modules';
2
2
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
+ import { HolderModule } from '../../modules/Holder';
3
4
  export type { ScanOrderOrderProductIdentity, ScanOrderOrderProduct, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder, ScanOrderSubmitPayload, } from '../ScanOrder/types';
4
5
  export declare enum VenueBookingHooks {
5
6
  onInited = "venueBooking:onInited",
@@ -145,6 +146,7 @@ export interface VenueBookingState {
145
146
  passed: boolean | null;
146
147
  failures: QuantityCheckResult[];
147
148
  };
149
+ holder?: HolderModule;
148
150
  }
149
151
  export interface VenueBookingLoggerRuntimeConfig {
150
152
  provider?: ScanOrderLoggerProviderType;
@@ -6,6 +6,7 @@ export interface Plugin {
6
6
  version: string;
7
7
  initialize: () => Promise<void> | void;
8
8
  destroy?: () => Promise<void> | void;
9
+ getLocalStorage?: (key: string) => string | null;
9
10
  }
10
11
  export interface PluginOptions {
11
12
  dependencies?: string[];
@@ -0,0 +1,42 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, HolderModuleAPI, HolderFormMap } from './types';
4
+ export * from './types';
5
+ export * from './utils';
6
+ export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
7
+ protected defaultName: string;
8
+ protected defaultVersion: string;
9
+ private store;
10
+ private request;
11
+ private cacheId;
12
+ private openCache;
13
+ private fatherModule;
14
+ private isLoading;
15
+ private error;
16
+ /** 已加载过表单数据的 form_id 缓存标记 */
17
+ private loadedFormIds;
18
+ constructor(name?: string, version?: string);
19
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
20
+ /** 统一提交 formMap,仅此处触发 store changed */
21
+ private commitFormMap;
22
+ /** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
23
+ private notifyFormMapChanged;
24
+ getHolderFormMap(): HolderFormMap;
25
+ getHolderFormData(formId: number | string): IFormItemData | undefined;
26
+ setFormData(formId: number | string, data: Partial<IFormItemData>): void;
27
+ private ensureFormItem;
28
+ private hasFormData;
29
+ private patchFormMap;
30
+ fetchFormInfo(params: IFetchFormInfoParams): Promise<IFormInfo | IFormInfo[]>;
31
+ fetchRecords(params: IFetchFormRecordsParams): Promise<any>;
32
+ ensureFormData(params: IEnsureFormDataParams): Promise<IFormItemData>;
33
+ ensureFormByProduct(params: IEnsureFormByProductParams): Promise<IFormItemData | null>;
34
+ addFormRecord(params: IAddFormRecordParams): Promise<any>;
35
+ /**
36
+ * UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
37
+ */
38
+ appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
39
+ removeFormRecord(formId: number | string, formRecordId: number): void;
40
+ clearFormData(formId?: number | string): void;
41
+ storeChange(path?: string): void;
42
+ }
@@ -0,0 +1,329 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/Holder/index.ts
21
+ var Holder_exports = {};
22
+ __export(Holder_exports, {
23
+ HolderModule: () => HolderModule
24
+ });
25
+ module.exports = __toCommonJS(Holder_exports);
26
+ var import_lodash_es = require("lodash-es");
27
+ var import_BaseModule = require("../BaseModule");
28
+ var import_utils = require("./utils");
29
+ __reExport(Holder_exports, require("./types"), module.exports);
30
+ __reExport(Holder_exports, require("./utils"), module.exports);
31
+ var HolderModule = class extends import_BaseModule.BaseModule {
32
+ constructor(name, version) {
33
+ super(name, version);
34
+ this.defaultName = "holder";
35
+ this.defaultVersion = "1.0.0";
36
+ this.openCache = false;
37
+ this.isLoading = false;
38
+ this.error = null;
39
+ /** 已加载过表单数据的 form_id 缓存标记 */
40
+ this.loadedFormIds = /* @__PURE__ */ new Set();
41
+ }
42
+ async initialize(core, options) {
43
+ var _a, _b, _c;
44
+ this.core = core;
45
+ this.store = options.store;
46
+ this.request = this.core.getPlugin("request");
47
+ if ((_a = options.initialState) == null ? void 0 : _a.holderMap) {
48
+ this.commitFormMap((0, import_lodash_es.cloneDeep)(options.initialState.holderMap));
49
+ Object.keys(this.store.holderMap).forEach((formId) => {
50
+ if (this.hasFormData(formId)) {
51
+ this.loadedFormIds.add(formId);
52
+ }
53
+ });
54
+ }
55
+ if (!this.store.holderMap || typeof this.store.holderMap !== "object") {
56
+ this.store.holderMap = {};
57
+ }
58
+ if ((_b = options.otherParams) == null ? void 0 : _b.cacheId) {
59
+ this.openCache = options.otherParams.openCache;
60
+ this.cacheId = options.otherParams.cacheId;
61
+ }
62
+ if ((_c = options.otherParams) == null ? void 0 : _c.fatherModule) {
63
+ this.fatherModule = options.otherParams.fatherModule;
64
+ }
65
+ }
66
+ /** 统一提交 formMap,仅此处触发 store changed */
67
+ commitFormMap(holderMap) {
68
+ this.store.holderMap = holderMap;
69
+ }
70
+ /** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
71
+ notifyFormMapChanged() {
72
+ this.commitFormMap({ ...this.store.holderMap });
73
+ }
74
+ getHolderFormMap() {
75
+ return (0, import_lodash_es.cloneDeep)(this.store.holderMap);
76
+ }
77
+ getHolderFormData(formId) {
78
+ const formData = this.store.holderMap[(0, import_utils.normalizeFormId)(formId)];
79
+ return formData ? (0, import_lodash_es.cloneDeep)(formData) : void 0;
80
+ }
81
+ setFormData(formId, data) {
82
+ const key = (0, import_utils.normalizeFormId)(formId);
83
+ const current = this.store.holderMap[key] || (0, import_utils.createEmptyFormItemData)();
84
+ this.commitFormMap({
85
+ ...this.store.holderMap,
86
+ [key]: {
87
+ records: data.records ?? current.records,
88
+ form: data.form ?? current.form
89
+ }
90
+ });
91
+ }
92
+ ensureFormItem(formId, holderMap = this.store.holderMap) {
93
+ const key = (0, import_utils.normalizeFormId)(formId);
94
+ if (!holderMap[key]) {
95
+ holderMap[key] = (0, import_utils.createEmptyFormItemData)();
96
+ }
97
+ return holderMap[key];
98
+ }
99
+ hasFormData(formId) {
100
+ const item = this.store.holderMap[formId];
101
+ return !!item && (Object.keys(item.form || {}).length > 0 || item.records.length > 0);
102
+ }
103
+ patchFormMap(holderMap, formId, patch) {
104
+ const current = this.ensureFormItem(formId, holderMap);
105
+ holderMap[formId] = {
106
+ records: patch.records ?? current.records,
107
+ form: patch.form ?? current.form
108
+ };
109
+ }
110
+ async fetchFormInfo(params) {
111
+ const { form_id } = params.query || {};
112
+ const url = params.url || `/form/${form_id}`;
113
+ const useCache = params.useCache !== false;
114
+ this.isLoading = true;
115
+ this.error = null;
116
+ try {
117
+ const res = await this.request.get(url, {}, { useCache });
118
+ const formData = res == null ? void 0 : res.data;
119
+ const formList = Array.isArray(formData == null ? void 0 : formData.list) ? formData.list : formData ? [formData] : [];
120
+ const nextFormMap = { ...this.store.holderMap };
121
+ formList.forEach((form) => {
122
+ const key = (0, import_utils.normalizeFormId)(form.form_id ?? form_id ?? form.id);
123
+ this.patchFormMap(nextFormMap, key, { form });
124
+ });
125
+ if (!formList.length && form_id !== void 0) {
126
+ const key = (0, import_utils.normalizeFormId)(form_id);
127
+ this.patchFormMap(nextFormMap, key, { form: formData || {} });
128
+ }
129
+ this.commitFormMap(nextFormMap);
130
+ return formList.length === 1 ? formList[0] : formList;
131
+ } catch (error) {
132
+ this.error = error instanceof Error ? error.message : String(error);
133
+ throw error;
134
+ } finally {
135
+ this.isLoading = false;
136
+ }
137
+ }
138
+ async fetchRecords(params) {
139
+ var _a;
140
+ const url = params.url || "/form/data/v1";
141
+ const { form_id, shop_id, num, skip, customer_id, ...rest } = params.query || {};
142
+ const formId = (0, import_utils.normalizeFormId)(form_id);
143
+ const useCache = params.useCache !== false;
144
+ this.isLoading = true;
145
+ this.error = null;
146
+ try {
147
+ const res = await this.request.get(
148
+ url,
149
+ {
150
+ customer_id,
151
+ form_id,
152
+ shop_id,
153
+ num: num || 100,
154
+ skip: skip || 1,
155
+ front_end_cache_id: useCache && this.cacheId,
156
+ ...rest
157
+ },
158
+ { useCache }
159
+ );
160
+ const records = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [];
161
+ const nextFormMap = { ...this.store.holderMap };
162
+ this.patchFormMap(nextFormMap, formId, { records });
163
+ this.commitFormMap(nextFormMap);
164
+ return records;
165
+ } catch (error) {
166
+ this.error = error instanceof Error ? error.message : String(error);
167
+ throw error;
168
+ } finally {
169
+ this.isLoading = false;
170
+ }
171
+ }
172
+ async ensureFormData(params) {
173
+ const formId = (0, import_utils.normalizeFormId)(params.form_id);
174
+ const useCache = params.useCache !== false;
175
+ if (useCache && !params.forceRefresh && this.loadedFormIds.has(formId)) {
176
+ this.notifyFormMapChanged();
177
+ return this.ensureFormItem(formId);
178
+ }
179
+ const current = this.ensureFormItem(formId);
180
+ const tasks = [];
181
+ if (params.forceRefresh || !Object.keys(current.form || {}).length) {
182
+ tasks.push(
183
+ this.fetchFormInfo({
184
+ url: params.formInfoUrl,
185
+ query: {
186
+ form_id: params.form_id
187
+ },
188
+ useCache
189
+ })
190
+ );
191
+ }
192
+ if (params.forceRefresh || !current.records.length) {
193
+ tasks.push(
194
+ this.fetchRecords({
195
+ url: params.recordsUrl,
196
+ query: {
197
+ form_id: params.form_id,
198
+ shop_id: params.shop_id,
199
+ customer_id: params.customer_id
200
+ },
201
+ useCache
202
+ })
203
+ );
204
+ }
205
+ if (!tasks.length) {
206
+ this.notifyFormMapChanged();
207
+ } else {
208
+ await Promise.all(tasks);
209
+ }
210
+ this.loadedFormIds.add(formId);
211
+ return this.ensureFormItem(formId);
212
+ }
213
+ async ensureFormByProduct(params) {
214
+ const holderConfig = (0, import_utils.getProductHolderConfig)(params.product);
215
+ if (!holderConfig)
216
+ return null;
217
+ const formId = (0, import_utils.getFormIdFromHolderConfig)(holderConfig);
218
+ const shopId = params.shop_id ?? params.product.shop_id;
219
+ return this.ensureFormData({
220
+ form_id: formId,
221
+ shop_id: shopId,
222
+ customer_id: params.customer_id,
223
+ useCache: params.useCache,
224
+ skip: 1,
225
+ num: 100
226
+ });
227
+ }
228
+ async addFormRecord(params) {
229
+ const url = params.url || "/form/record";
230
+ const formId = (0, import_utils.normalizeFormId)(params.body.form_id);
231
+ this.isLoading = true;
232
+ this.error = null;
233
+ try {
234
+ await this.request.post(url, params.body);
235
+ const records = await this.fetchRecords({
236
+ query: {
237
+ form_id: params.body.form_id,
238
+ shop_id: params.body.shop_id,
239
+ customer_id: params.body.customer_id
240
+ },
241
+ useCache: false
242
+ });
243
+ this.loadedFormIds.add(formId);
244
+ return records[records.length - 1];
245
+ } catch (error) {
246
+ this.error = error instanceof Error ? error.message : String(error);
247
+ throw error;
248
+ } finally {
249
+ this.isLoading = false;
250
+ }
251
+ }
252
+ /**
253
+ * UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
254
+ */
255
+ appendFormRecord(params) {
256
+ let record = params.record;
257
+ if ((record == null ? void 0 : record.data) && record.form_record_id === void 0) {
258
+ record = record.data;
259
+ }
260
+ const normalizedRecord = (0, import_lodash_es.cloneDeep)(record);
261
+ const formId = (0, import_utils.normalizeFormId)(
262
+ params.form_id ?? normalizedRecord.form_id
263
+ );
264
+ if (!formId) {
265
+ throw new Error("[HolderModule] appendFormRecord: form_id is required");
266
+ }
267
+ if (!normalizedRecord.form_record_id) {
268
+ throw new Error(
269
+ "[HolderModule] appendFormRecord: form_record_id is required"
270
+ );
271
+ }
272
+ normalizedRecord.form_id = Number(formId) || normalizedRecord.form_id;
273
+ const nextFormMap = { ...this.store.holderMap };
274
+ const current = this.ensureFormItem(formId, nextFormMap);
275
+ const recordIndex = current.records.findIndex(
276
+ (item) => item.form_record_id === normalizedRecord.form_record_id
277
+ );
278
+ const records = recordIndex >= 0 ? current.records.map(
279
+ (item, index) => index === recordIndex ? { ...item, ...normalizedRecord } : item
280
+ ) : [...current.records, normalizedRecord];
281
+ this.patchFormMap(nextFormMap, formId, { records });
282
+ this.commitFormMap(nextFormMap);
283
+ this.loadedFormIds.add(formId);
284
+ return normalizedRecord;
285
+ }
286
+ removeFormRecord(formId, formRecordId) {
287
+ const key = (0, import_utils.normalizeFormId)(formId);
288
+ const current = this.store.holderMap[key] || (0, import_utils.createEmptyFormItemData)();
289
+ const nextFormMap = { ...this.store.holderMap };
290
+ this.patchFormMap(nextFormMap, key, {
291
+ records: current.records.filter(
292
+ (record) => record.form_record_id !== formRecordId
293
+ )
294
+ });
295
+ this.commitFormMap(nextFormMap);
296
+ }
297
+ clearFormData(formId) {
298
+ if (formId !== void 0) {
299
+ const key = (0, import_utils.normalizeFormId)(formId);
300
+ const nextFormMap = { ...this.store.holderMap };
301
+ delete nextFormMap[key];
302
+ this.loadedFormIds.delete(key);
303
+ this.commitFormMap(nextFormMap);
304
+ } else {
305
+ this.loadedFormIds.clear();
306
+ this.commitFormMap({});
307
+ }
308
+ }
309
+ storeChange(path) {
310
+ if (path !== "holderMap" && path !== void 0) {
311
+ return;
312
+ }
313
+ if (this.openCache) {
314
+ const store = (0, import_lodash_es.cloneDeep)(this.store);
315
+ this.checkSaveCache({
316
+ cacheId: this.cacheId,
317
+ fatherModule: this.fatherModule,
318
+ store,
319
+ cacheKey: ["holderMap"]
320
+ });
321
+ }
322
+ }
323
+ };
324
+ // Annotate the CommonJS export names for ESM import in node:
325
+ 0 && (module.exports = {
326
+ HolderModule,
327
+ ...require("./types"),
328
+ ...require("./utils")
329
+ });
@@ -0,0 +1,115 @@
1
+ import { ProductData } from '../Product/types';
2
+ /**
3
+ * 商品 holder 配置
4
+ */
5
+ export interface IHolderConfig {
6
+ required?: number;
7
+ resource_id: number;
8
+ status?: string;
9
+ [key: string]: any;
10
+ }
11
+ /**
12
+ * 表单记录
13
+ */
14
+ export interface IFormRecord {
15
+ form_id: number;
16
+ form_record_id: number;
17
+ main_field: string;
18
+ customer_cover?: string;
19
+ created_at?: string;
20
+ customer_id?: number;
21
+ [key: string]: any;
22
+ }
23
+ /**
24
+ * 表单配置/定义
25
+ */
26
+ export interface IFormInfo {
27
+ form_id: number;
28
+ name: string;
29
+ fields?: Record<string, any>[];
30
+ [key: string]: any;
31
+ }
32
+ /**
33
+ * 单个 form_id 下的数据结构
34
+ */
35
+ export interface IFormItemData {
36
+ records: IFormRecord[];
37
+ form: IFormInfo | Record<string, any>;
38
+ }
39
+ /**
40
+ * form_id 为 key 的 map 结构,如 948: { records: [], form: {} }
41
+ */
42
+ export type HolderFormMap = Record<string, IFormItemData>;
43
+ /**
44
+ * Holder 模块 reactive store,仅 holderMap 会触发 changed 事件
45
+ */
46
+ export interface HolderState {
47
+ holderMap: HolderFormMap;
48
+ }
49
+ export interface IFetchFormInfoParams {
50
+ url?: string;
51
+ query: {
52
+ form_id: string | number;
53
+ };
54
+ useCache?: boolean;
55
+ }
56
+ export interface IFetchFormRecordsParams {
57
+ url?: string;
58
+ query: {
59
+ customer_id?: number;
60
+ form_id: string | number;
61
+ shop_id: string | number;
62
+ num?: number;
63
+ skip?: number;
64
+ [key: string]: any;
65
+ };
66
+ useCache?: boolean;
67
+ }
68
+ export interface IAddFormRecordParams {
69
+ url?: string;
70
+ body: {
71
+ form_id: number | string;
72
+ shop_id: number | string;
73
+ customer_id?: number;
74
+ [key: string]: any;
75
+ };
76
+ }
77
+ /**
78
+ * UI 层自行调用添加接口后,将返回记录写入 holderMap
79
+ */
80
+ export interface IAppendFormRecordParams {
81
+ /** 接口返回的 data,或完整响应 { data: {...} } */
82
+ record: IFormRecord | Record<string, any>;
83
+ /** 可选,未传则从 record.form_id 读取 */
84
+ form_id?: number | string;
85
+ }
86
+ export interface IEnsureFormDataParams {
87
+ form_id: number | string;
88
+ shop_id: number | string;
89
+ customer_id?: number;
90
+ useCache?: boolean;
91
+ forceRefresh?: boolean;
92
+ formInfoUrl?: string;
93
+ recordsUrl?: string;
94
+ skip?: number;
95
+ num?: number;
96
+ }
97
+ export interface IEnsureFormByProductParams {
98
+ product: ProductData | Record<string, any>;
99
+ customer_id?: number;
100
+ shop_id?: number | string;
101
+ useCache?: boolean;
102
+ }
103
+ export interface HolderModuleAPI {
104
+ getHolderFormMap: () => HolderFormMap;
105
+ getHolderFormData: (formId: number | string) => IFormItemData | undefined;
106
+ setFormData: (formId: number | string, data: Partial<IFormItemData>) => void;
107
+ fetchFormInfo: (params: IFetchFormInfoParams) => Promise<IFormInfo | IFormInfo[]>;
108
+ fetchRecords: (params: IFetchFormRecordsParams) => Promise<IFormRecord[]>;
109
+ ensureFormData: (params: IEnsureFormDataParams) => Promise<IFormItemData>;
110
+ ensureFormByProduct: (params: IEnsureFormByProductParams) => Promise<IFormItemData | null>;
111
+ addFormRecord: (params: IAddFormRecordParams) => Promise<IFormRecord>;
112
+ appendFormRecord: (params: IAppendFormRecordParams) => IFormRecord;
113
+ removeFormRecord: (formId: number | string, formRecordId: number) => void;
114
+ clearFormData: (formId?: number | string) => void;
115
+ }
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/modules/Holder/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,9 @@
1
+ import { ProductData } from '../Product/types';
2
+ import { IHolderConfig } from './types';
3
+ export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
4
+ export declare function getFormIdFromHolderConfig(config: IHolderConfig): string;
5
+ export declare function normalizeFormId(formId: number | string): string;
6
+ export declare function createEmptyFormItemData(): {
7
+ records: any[];
8
+ form: Record<string, any>;
9
+ };
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Holder/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ createEmptyFormItemData: () => createEmptyFormItemData,
23
+ getFormIdFromHolderConfig: () => getFormIdFromHolderConfig,
24
+ getProductHolderConfig: () => getProductHolderConfig,
25
+ normalizeFormId: () => normalizeFormId
26
+ });
27
+ module.exports = __toCommonJS(utils_exports);
28
+ function getProductHolderConfig(product) {
29
+ var _a;
30
+ if (!product)
31
+ return null;
32
+ const config = (product == null ? void 0 : product.holder_config) ?? ((_a = product == null ? void 0 : product.origin) == null ? void 0 : _a.holder_config);
33
+ if ((config == null ? void 0 : config.status) && (config == null ? void 0 : config.status) !== "enable")
34
+ return null;
35
+ if (!(config == null ? void 0 : config.resource_id))
36
+ return null;
37
+ return config;
38
+ }
39
+ function getFormIdFromHolderConfig(config) {
40
+ return String(config == null ? void 0 : config.resource_id);
41
+ }
42
+ function normalizeFormId(formId) {
43
+ return String(formId);
44
+ }
45
+ function createEmptyFormItemData() {
46
+ return {
47
+ records: [],
48
+ form: {}
49
+ };
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ createEmptyFormItemData,
54
+ getFormIdFromHolderConfig,
55
+ getProductHolderConfig,
56
+ normalizeFormId
57
+ });
@@ -57,6 +57,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
57
57
  private getTempOrderStorageKey;
58
58
  private restoreTempOrderFromStorage;
59
59
  persistTempOrder(): void;
60
+ notifyTempOrderChanged(): void;
60
61
  private createDefaultTempOrderInstance;
61
62
  ensureTempOrder(): ScanOrderTempOrder;
62
63
  restoreOrder(): ScanOrderTempOrder;
@@ -328,6 +328,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
328
328
  return;
329
329
  this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
330
330
  }
331
+ notifyTempOrderChanged() {
332
+ if (!this.store.tempOrder)
333
+ return;
334
+ this.store.tempOrder = {
335
+ ...this.store.tempOrder,
336
+ products: [...this.store.tempOrder.products],
337
+ bookings: this.store.tempOrder.bookings ? [...this.store.tempOrder.bookings] : []
338
+ };
339
+ this.persistTempOrder();
340
+ }
331
341
  // ─── TempOrder: 创建 & 获取 ───
332
342
  createDefaultTempOrderInstance() {
333
343
  return (0, import_utils.createDefaultTempOrder)({
@@ -605,6 +615,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
605
615
  }
606
616
  const discountList = (0, import_utils.getAllDiscountList)(item);
607
617
  item._origin.product.discount_list = discountList;
618
+ (0, import_utils.ensureCartItemOriginHolder)(item);
608
619
  if ((0, import_utils2.isNormalProduct)(item._origin)) {
609
620
  order.relation_products.push(item._origin.product);
610
621
  const relationForms = item._origin.relation_forms || [];
@@ -235,6 +235,8 @@ export interface OrderModuleAPI {
235
235
  updateProductInOrder: (params: UpdateProductInOrderParams) => Promise<ScanOrderOrderProduct[]>;
236
236
  removeProductFromOrder: (identity: ScanOrderOrderProductIdentity) => Promise<ScanOrderOrderProduct[]>;
237
237
  persistTempOrder: () => void;
238
+ /** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
239
+ notifyTempOrderChanged: () => void;
238
240
  submitTempOrder: <T = any>(params?: {
239
241
  cacheId?: string;
240
242
  platform?: string;
@@ -86,6 +86,15 @@ export declare const mergeRelationForms: (relationForms: {
86
86
  form_id: number;
87
87
  form_record_ids: number[];
88
88
  }[];
89
+ export interface CartOrderHolder {
90
+ customer_id?: number;
91
+ form_id: number | string;
92
+ form_record: (number | string)[] | null;
93
+ }
94
+ /**
95
+ * 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
96
+ */
97
+ export declare function ensureCartItemOriginHolder(cartItem: CartItem): void;
89
98
  export declare const getAllDiscountList: (cartItem: CartItem) => any;
90
99
  export declare function createUuidV4(): string;
91
100
  export declare function isTempOrder(data: any): data is ScanOrderTempOrder;