@pisell/pisellos 0.0.205 → 0.0.208

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.
@@ -40,9 +40,15 @@ export var mergeRelationForms = function mergeRelationForms(relationForms) {
40
40
 
41
41
  // 兼容 form_record_id 可能是数组或单个数字
42
42
  var ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
43
- (_acc$form_id$form_rec = acc[form_id].form_record_ids).push.apply(_acc$form_id$form_rec, _toConsumableArray(ids));
43
+ // 过滤掉空值(null、undefined等)
44
+ var validIds = ids.filter(function (id) {
45
+ return id != null;
46
+ });
47
+ (_acc$form_id$form_rec = acc[form_id].form_record_ids).push.apply(_acc$form_id$form_rec, _toConsumableArray(validIds));
44
48
  // 去重
45
49
  acc[form_id].form_record_ids = _toConsumableArray(new Set(acc[form_id].form_record_ids));
46
50
  return acc;
47
- }, {}));
51
+ }, {})).filter(function (item) {
52
+ return item.form_record_ids.length > 0;
53
+ }); // 过滤掉没有有效记录的表单
48
54
  };
@@ -21,6 +21,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
21
21
  private otherParams;
22
22
  private cacheId;
23
23
  private otherData;
24
+ private platform;
24
25
  initialize(core: PisellCore, options: any): Promise<void>;
25
26
  initStep(stepList: (keyof BookingByStepState)[]): void;
26
27
  getCurrentStep(): {
@@ -61,15 +61,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
61
61
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
62
62
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
63
63
  _defineProperty(_assertThisInitialized(_this), "otherData", {});
64
+ // 提供给 UI 层的临时数据存储,会进缓存
65
+ _defineProperty(_assertThisInitialized(_this), "platform", void 0);
64
66
  return _this;
65
67
  }
66
68
  _createClass(BookingByStepImpl, [{
67
69
  key: "initialize",
68
- value: // 提供给 UI 层的临时数据存储,会进缓存
70
+ value: // 平台类型,用于判断是 PC / H5
69
71
  function () {
70
72
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
71
73
  var _this$otherParams,
72
74
  _this$otherParams2,
75
+ _this$otherParams3,
73
76
  _this2 = this;
74
77
  var targetCacheData, sessionData, _data$this$otherParam, data, moduleArr;
75
78
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -99,7 +102,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
99
102
  // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
100
103
  targetCacheData = {};
101
104
  this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
102
- if ((_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.cacheId) {
105
+ this.platform = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform;
106
+ if ((_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.cacheId) {
103
107
  sessionData = this.window.sessionStorage.getItem(this.name);
104
108
  if (sessionData) {
105
109
  data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
@@ -128,7 +132,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
128
132
  });
129
133
  this.store.schedule.loadAllSchedule();
130
134
  this.core.effects.emit(BookingByStepHooks.onInited, {});
131
- case 18:
135
+ case 19:
132
136
  case "end":
133
137
  return _context.stop();
134
138
  }
@@ -954,7 +958,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
954
958
  key: "submitOrder",
955
959
  value: function () {
956
960
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
957
- var _this$otherParams3;
958
961
  var cartItems, newCartItems, type;
959
962
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
960
963
  while (1) switch (_context19.prev = _context19.next) {
@@ -991,7 +994,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
991
994
  query: {
992
995
  cartItems: newCartItems,
993
996
  type: type,
994
- platform: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform
997
+ platform: this.platform
995
998
  }
996
999
  }));
997
1000
  case 6:
@@ -48,11 +48,12 @@ var mergeRelationForms = (relationForms) => {
48
48
  acc[form_id] = { form_id, form_record_ids: [] };
49
49
  }
50
50
  const ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
51
- acc[form_id].form_record_ids.push(...ids);
51
+ const validIds = ids.filter((id) => id != null);
52
+ acc[form_id].form_record_ids.push(...validIds);
52
53
  acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
53
54
  return acc;
54
55
  }, {})
55
- );
56
+ ).filter((item) => item.form_record_ids.length > 0);
56
57
  };
57
58
  // Annotate the CommonJS export names for ESM import in node:
58
59
  0 && (module.exports = {
@@ -21,6 +21,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
21
21
  private otherParams;
22
22
  private cacheId;
23
23
  private otherData;
24
+ private platform;
24
25
  initialize(core: PisellCore, options: any): Promise<void>;
25
26
  initStep(stepList: (keyof BookingByStepState)[]): void;
26
27
  getCurrentStep(): {
@@ -58,9 +58,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
58
58
  this.otherParams = {};
59
59
  this.otherData = {};
60
60
  }
61
- // 提供给 UI 层的临时数据存储,会进缓存
61
+ // 平台类型,用于判断是 PC / H5
62
62
  async initialize(core, options) {
63
- var _a, _b, _c, _d;
63
+ var _a, _b, _c, _d, _e;
64
64
  this.core = core;
65
65
  this.store = options.store || {};
66
66
  this.otherParams = options.otherParams || {};
@@ -76,12 +76,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
76
76
  }
77
77
  let targetCacheData = {};
78
78
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
79
- if ((_b = this.otherParams) == null ? void 0 : _b.cacheId) {
79
+ this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
80
+ if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
80
81
  const sessionData = this.window.sessionStorage.getItem(this.name);
81
82
  if (sessionData) {
82
83
  const data = JSON.parse(sessionData);
83
84
  targetCacheData = data[this.otherParams.cacheId];
84
- this.otherData = ((_d = (_c = data[this.otherParams.cacheId]) == null ? void 0 : _c[this.name]) == null ? void 0 : _d["otherData"]) || {};
85
+ this.otherData = ((_e = (_d = data[this.otherParams.cacheId]) == null ? void 0 : _d[this.name]) == null ? void 0 : _e["otherData"]) || {};
85
86
  }
86
87
  }
87
88
  const moduleArr = [
@@ -501,11 +502,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
501
502
  }
502
503
  // 购物车提交订单
503
504
  async submitOrder() {
504
- var _a;
505
505
  const cartItems = this.store.cart.getItems();
506
506
  const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
507
507
  newCartItems.forEach((item) => {
508
- var _a2;
508
+ var _a;
509
509
  if (item._origin.resources && item._origin.resources.length) {
510
510
  item._origin.resources = item._origin.resources.map((n) => {
511
511
  const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
@@ -515,7 +515,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
515
515
  return { ...newResourcesItem };
516
516
  });
517
517
  const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
518
- if (!((_a2 = item._origin) == null ? void 0 : _a2.metadata)) {
518
+ if (!((_a = item._origin) == null ? void 0 : _a.metadata)) {
519
519
  item._origin.metadata = {};
520
520
  }
521
521
  item._origin.metadata.capacity = formatCapacity;
@@ -532,7 +532,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
532
532
  query: {
533
533
  cartItems: newCartItems,
534
534
  type,
535
- platform: (_a = this.otherParams) == null ? void 0 : _a.platform
535
+ platform: this.platform
536
536
  }
537
537
  });
538
538
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.205",
4
+ "version": "0.0.208",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",