@pisell/pisellos 0.0.44 → 0.0.46

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 (127) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +5 -5
  13. package/dist/modules/Cart/index.js +33 -19
  14. package/dist/modules/Cart/types.d.ts +21 -7
  15. package/dist/modules/Cart/utils.d.ts +29 -5
  16. package/dist/modules/Cart/utils.js +72 -26
  17. package/dist/modules/Date/index.d.ts +6 -6
  18. package/dist/modules/Date/index.js +41 -55
  19. package/dist/modules/Date/types.d.ts +22 -6
  20. package/dist/modules/Date/utils.d.ts +4 -3
  21. package/dist/modules/Date/utils.js +74 -23
  22. package/dist/modules/Discount/index.d.ts +4 -4
  23. package/dist/modules/Discount/index.js +11 -11
  24. package/dist/modules/Order/index.d.ts +10 -5
  25. package/dist/modules/Order/index.js +32 -16
  26. package/dist/modules/Order/types.d.ts +10 -3
  27. package/dist/modules/Product/index.d.ts +4 -1
  28. package/dist/modules/Product/index.js +22 -0
  29. package/dist/modules/Product/types.d.ts +7 -3
  30. package/dist/modules/ProductList/index.js +11 -5
  31. package/dist/modules/Resource/utils.js +1 -1
  32. package/dist/modules/Rules/index.d.ts +4 -4
  33. package/dist/modules/Rules/index.js +11 -11
  34. package/dist/modules/Rules/types.d.ts +1 -1
  35. package/dist/modules/Schedule/index.d.ts +8 -3
  36. package/dist/modules/Schedule/index.js +45 -5
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +8 -8
  39. package/dist/modules/Schedule/utils.d.ts +9 -3
  40. package/dist/modules/Schedule/utils.js +77 -48
  41. package/dist/modules/Step/index.d.ts +14 -3
  42. package/dist/modules/Step/index.js +54 -2
  43. package/dist/modules/Summary/index.d.ts +5 -5
  44. package/dist/modules/Summary/index.js +7 -7
  45. package/dist/modules/Summary/types.d.ts +2 -2
  46. package/dist/modules/Summary/utils.d.ts +4 -4
  47. package/dist/modules/Summary/utils.js +3 -3
  48. package/dist/plugins/index.d.ts +3 -3
  49. package/dist/plugins/request.d.ts +3 -3
  50. package/dist/plugins/request.js +30 -30
  51. package/dist/plugins/shopStore.d.ts +1 -1
  52. package/dist/solution/BookingByStep/index.d.ts +71 -16
  53. package/dist/solution/BookingByStep/index.js +643 -227
  54. package/dist/solution/BookingByStep/types.d.ts +2 -2
  55. package/dist/solution/BookingByStep/types.js +9 -9
  56. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  57. package/dist/solution/BookingByStep/utils/products.js +3 -0
  58. package/dist/solution/BookingByStep/utils/resources.d.ts +6 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +37 -19
  60. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  61. package/dist/solution/ShopDiscount/index.js +16 -16
  62. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  63. package/dist/solution/ShopDiscount/utils.js +1 -1
  64. package/lib/core/index.js +7 -2
  65. package/lib/modules/Account/index.d.ts +2 -6
  66. package/lib/modules/Account/index.js +15 -30
  67. package/lib/modules/Account/types.d.ts +12 -1
  68. package/lib/modules/AccountList/index.d.ts +20 -1
  69. package/lib/modules/AccountList/index.js +122 -13
  70. package/lib/modules/AccountList/types.d.ts +33 -1
  71. package/lib/modules/AccountList/utils.d.ts +9 -0
  72. package/lib/modules/AccountList/utils.js +39 -0
  73. package/lib/modules/BaseModule.d.ts +2 -2
  74. package/lib/modules/BaseModule.js +14 -3
  75. package/lib/modules/Cart/index.d.ts +5 -5
  76. package/lib/modules/Cart/index.js +28 -6
  77. package/lib/modules/Cart/types.d.ts +21 -7
  78. package/lib/modules/Cart/utils.d.ts +29 -5
  79. package/lib/modules/Cart/utils.js +47 -3
  80. package/lib/modules/Date/index.d.ts +6 -6
  81. package/lib/modules/Date/index.js +6 -6
  82. package/lib/modules/Date/types.d.ts +22 -6
  83. package/lib/modules/Date/utils.d.ts +4 -3
  84. package/lib/modules/Date/utils.js +37 -6
  85. package/lib/modules/Discount/index.d.ts +4 -4
  86. package/lib/modules/Discount/index.js +9 -2
  87. package/lib/modules/Guests/index.js +4 -1
  88. package/lib/modules/Order/index.d.ts +10 -5
  89. package/lib/modules/Order/index.js +11 -1
  90. package/lib/modules/Order/types.d.ts +10 -3
  91. package/lib/modules/Payment/index.js +1 -6
  92. package/lib/modules/Product/index.d.ts +4 -1
  93. package/lib/modules/Product/index.js +16 -0
  94. package/lib/modules/Product/types.d.ts +7 -3
  95. package/lib/modules/ProductList/index.js +21 -7
  96. package/lib/modules/Resource/index.js +4 -1
  97. package/lib/modules/Resource/utils.js +7 -4
  98. package/lib/modules/Rules/index.d.ts +4 -4
  99. package/lib/modules/Rules/types.d.ts +1 -1
  100. package/lib/modules/Schedule/index.d.ts +8 -3
  101. package/lib/modules/Schedule/index.js +33 -2
  102. package/lib/modules/Schedule/type.d.ts +7 -7
  103. package/lib/modules/Schedule/types.d.ts +8 -8
  104. package/lib/modules/Schedule/utils.d.ts +9 -3
  105. package/lib/modules/Schedule/utils.js +32 -4
  106. package/lib/modules/Step/index.d.ts +14 -3
  107. package/lib/modules/Step/index.js +38 -1
  108. package/lib/modules/Summary/index.d.ts +5 -5
  109. package/lib/modules/Summary/types.d.ts +2 -2
  110. package/lib/modules/Summary/utils.d.ts +4 -4
  111. package/lib/plugins/index.d.ts +3 -3
  112. package/lib/plugins/request.d.ts +3 -3
  113. package/lib/plugins/request.js +48 -11
  114. package/lib/plugins/shopStore.d.ts +1 -1
  115. package/lib/solution/BookingByStep/index.d.ts +71 -16
  116. package/lib/solution/BookingByStep/index.js +396 -48
  117. package/lib/solution/BookingByStep/types.d.ts +2 -2
  118. package/lib/solution/BookingByStep/types.js +36 -9
  119. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  120. package/lib/solution/BookingByStep/utils/products.js +3 -0
  121. package/lib/solution/BookingByStep/utils/resources.d.ts +6 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +128 -58
  123. package/lib/solution/BuyTickets/index.js +34 -20
  124. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  125. package/lib/solution/ShopDiscount/index.js +10 -2
  126. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  127. package/package.json +4 -2
@@ -23,8 +23,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
23
23
  var _this;
24
24
  _classCallCheck(this, OrderModule);
25
25
  _this = _super.call(this, name, version);
26
- _defineProperty(_assertThisInitialized(_this), "defaultName", "order");
27
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
26
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
27
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
28
28
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
29
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
30
30
  return _this;
@@ -38,7 +38,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
38
38
  case 0:
39
39
  this.core = core;
40
40
  this.store = options.store;
41
- this.request = this.core.getPlugin("request");
41
+ this.request = this.core.getPlugin('request');
42
42
  case 3:
43
43
  case "end":
44
44
  return _context.stop();
@@ -54,13 +54,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
54
54
  key: "createOrder",
55
55
  value: function createOrder(params) {
56
56
  var order = {
57
- type: "appointment_booking",
58
- platform: "H5",
59
- sales_channel: "my_pisel",
60
- order_sales_channel: "online_store",
57
+ type: 'appointment_booking',
58
+ platform: 'H5',
59
+ sales_channel: 'my_pisel',
60
+ order_sales_channel: 'online_store',
61
61
  bookings: [],
62
- shop_note: "",
63
- schedule_date: "",
62
+ shop_note: '',
63
+ schedule_date: '',
64
64
  is_deposit: 0
65
65
  };
66
66
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
@@ -72,21 +72,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
72
72
  }
73
73
  });
74
74
  var firstCartItem = params.cartItems[0];
75
- order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
75
+ order.schedule_date = firstCartItem.start_date + ' ' + firstCartItem.start_time + ':00';
76
76
  order.is_deposit = is_deposit;
77
77
  }
78
78
  return order;
79
79
  }
80
80
  }, {
81
- key: "commitOrder",
81
+ key: "checkBeforeSubmitOrder",
82
+ value: function checkBeforeSubmitOrder(params) {
83
+ var cartItems = params.cartItems,
84
+ type = params.type;
85
+ if (type === 'holder') {
86
+ // 判断cartItems中是否有不存在holder_id的商品,如果有则返回false
87
+ var hasNoHolderId = cartItems.some(function (item) {
88
+ return !item.holder_id;
89
+ });
90
+ if (hasNoHolderId) {
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ }
96
+ }, {
97
+ key: "submitOrder",
82
98
  value: function () {
83
- var _commitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
99
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
84
100
  var url, query, fetchUrl, params;
85
101
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
86
102
  while (1) switch (_context2.prev = _context2.next) {
87
103
  case 0:
88
104
  url = order.url, query = order.query;
89
- fetchUrl = url || "/order/appointment";
105
+ fetchUrl = url || '/order/appointment';
90
106
  params = this.createOrder(query);
91
107
  return _context2.abrupt("return", this.request.post(fetchUrl, params));
92
108
  case 4:
@@ -95,10 +111,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
95
111
  }
96
112
  }, _callee2, this);
97
113
  }));
98
- function commitOrder(_x3) {
99
- return _commitOrder.apply(this, arguments);
114
+ function submitOrder(_x3) {
115
+ return _submitOrder.apply(this, arguments);
100
116
  }
101
- return commitOrder;
117
+ return submitOrder;
102
118
  }()
103
119
  }]);
104
120
  return OrderModule;
@@ -1,4 +1,4 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export declare enum OrderHooks {
3
3
  OnOrderCreate = "order:onOrderCreate",
4
4
  OnOrderUpdate = "order:onOrderUpdate",
@@ -25,10 +25,17 @@ export interface OrderModuleAPI {
25
25
  * @param params 订单信息
26
26
  * @returns 订单信息
27
27
  */
28
- createOrder: (params: CommitOrderParams["query"]) => any;
28
+ createOrder: (params: CommitOrderParams['query']) => any;
29
+ /**
30
+ * 检查购物车提交订单前是否符合条件
31
+ */
32
+ checkBeforeSubmitOrder: (params: {
33
+ cartItems: CartItem[];
34
+ type: 'holder' | 'account';
35
+ }) => boolean;
29
36
  /**
30
37
  * 提交订单
31
38
  * @param params 订单信息
32
39
  */
33
- commitOrder: (params: CommitOrderParams) => Promise<void>;
40
+ submitOrder: (params: CommitOrderParams) => Promise<void>;
34
41
  }
@@ -21,7 +21,7 @@ export declare class Product extends BaseModule implements Module {
21
21
  /**
22
22
  * 获取商品数据
23
23
  */
24
- getData(): ProductData | null;
24
+ getData(): ProductData;
25
25
  /**
26
26
  * 获取商品ID
27
27
  */
@@ -46,4 +46,7 @@ export declare class Product extends BaseModule implements Module {
46
46
  * 获取商品分类
47
47
  */
48
48
  getCategories(): ProductCategory[];
49
+ setOtherParams(key: string, value: any): void;
50
+ getOtherParams(): any;
51
+ getProductType(): "duration" | "session" | "normal";
49
52
  }
@@ -126,6 +126,28 @@ export var Product = /*#__PURE__*/function (_BaseModule) {
126
126
  value: function getCategories() {
127
127
  return this.store.categories;
128
128
  }
129
+ }, {
130
+ key: "setOtherParams",
131
+ value: function setOtherParams(key, value) {
132
+ this.otherParams[key] = value;
133
+ }
134
+ }, {
135
+ key: "getOtherParams",
136
+ value: function getOtherParams() {
137
+ return this.otherParams;
138
+ }
139
+ }, {
140
+ key: "getProductType",
141
+ value: function getProductType() {
142
+ var _this$store$schedule;
143
+ if (this.store.duration) {
144
+ return 'duration';
145
+ }
146
+ if ((_this$store$schedule = this.store['schedule.ids']) !== null && _this$store$schedule !== void 0 && _this$store$schedule.length) {
147
+ return 'session';
148
+ }
149
+ return 'normal';
150
+ }
129
151
  }]);
130
152
  return Product;
131
153
  }(BaseModule);
@@ -17,7 +17,7 @@ export interface ProductData {
17
17
  /** 商品slug */
18
18
  slug: string;
19
19
  /** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
20
- status: "draft" | "published" | "pending" | "archived";
20
+ status: 'draft' | 'published' | 'pending' | 'archived';
21
21
  /** 库存数量 */
22
22
  stock_quantity: number;
23
23
  /** 销售数量 */
@@ -156,6 +156,10 @@ export interface ProductData {
156
156
  capacity?: any;
157
157
  /** 商品套餐 */
158
158
  product_bundle?: any;
159
+ /** 日程ids */
160
+ 'schedule.ids'?: number[];
161
+ /** 商品日程信息,前端临时用,随时需要回收的 */
162
+ _schedule?: any;
159
163
  /** 商品定金信息 */
160
164
  custom_deposit_data?: {
161
165
  /** 商品是否包含定金 1:是 0:否 */
@@ -434,7 +438,7 @@ export interface ProductResourceItem {
434
438
  /** 资源标题 */
435
439
  title: string;
436
440
  /** 资源编码 */
437
- code: "resource";
441
+ code: 'resource';
438
442
  /** 默认资源 */
439
443
  default_resource?: number[];
440
444
  /** 可选资源 */
@@ -443,7 +447,7 @@ export interface ProductResourceItem {
443
447
  resource_type_id: number;
444
448
  /** 选择类型 */
445
449
  select_type?: {
446
- type: "single";
450
+ type: 'single';
447
451
  min: 1;
448
452
  max: 1;
449
453
  };
@@ -42,16 +42,22 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
42
42
  key: "initialize",
43
43
  value: function () {
44
44
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
45
+ var _options$initialState;
45
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
47
  while (1) switch (_context.prev = _context.next) {
47
48
  case 0:
48
49
  this.core = core;
49
50
  this.store = options.store;
50
- this.store.productMap = new Map();
51
- this.store.list = [];
52
- this.store.selectProducts = [];
53
- this.storeChange();
54
- case 6:
51
+ if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
52
+ this.store.list = options.initialState.list;
53
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
54
+ this.storeChange();
55
+ } else {
56
+ this.store.list = [];
57
+ this.store.productMap = new Map();
58
+ this.store.selectProducts = [];
59
+ }
60
+ case 3:
55
61
  case "end":
56
62
  return _context.stop();
57
63
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @title: 获取资源map
3
- * @description:
3
+ * @description:
4
4
  * @param {any} resourceList
5
5
  * @return {*}
6
6
  * @Author: zhiwei.Wang
@@ -1,7 +1,7 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
4
- import { Discount } from "../Discount/types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Rules, RulesModuleAPI, DiscountResult } from './types';
4
+ import { Discount } from '../Discount/types';
5
5
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
@@ -34,8 +34,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
34
34
  var _this;
35
35
  _classCallCheck(this, RulesModule);
36
36
  _this = _super.call(this, name, version);
37
- _defineProperty(_assertThisInitialized(_this), "defaultName", "rules");
38
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
37
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'rules');
38
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
39
39
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
40
40
  _defineProperty(_assertThisInitialized(_this), "hooks", void 0);
41
41
  _this.hooks = {};
@@ -176,8 +176,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
176
176
  var sortedProductList = _toConsumableArray(productList).sort(function (a, b) {
177
177
  var aProduct = _this3.hooks.getProduct(a);
178
178
  var bProduct = _this3.hooks.getProduct(b);
179
- var priceA = parseFloat(aProduct.price || "0");
180
- var priceB = parseFloat(bProduct.price || "0");
179
+ var priceA = parseFloat(aProduct.price || '0');
180
+ var priceB = parseFloat(bProduct.price || '0');
181
181
  return priceB - priceA;
182
182
  });
183
183
 
@@ -210,7 +210,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
210
210
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
211
211
 
212
212
  // 是符合折扣的商品
213
- var isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
213
+ var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
214
214
 
215
215
  // 编辑的商品 使用了优惠券不可用
216
216
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
@@ -257,7 +257,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
257
257
  var limitedData = discount.limited_relation_product_data;
258
258
 
259
259
  // 判断优惠券是否适用于该商品
260
- if (limitedData.type === "product_all") {
260
+ if (limitedData.type === 'product_all') {
261
261
  return true;
262
262
  } else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
263
263
  return true;
@@ -269,7 +269,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
269
269
  var selectedDiscount = applicableDiscounts[0];
270
270
 
271
271
  // 如果是手动折扣,则不适用优惠券
272
- var isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && !((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length);
272
+ var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && !((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length);
273
273
 
274
274
  // 勾选时覆盖手动折扣
275
275
  if (options !== null && options !== void 0 && options.discountId && (options === null || options === void 0 ? void 0 : options.discountId) === (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.id)) {
@@ -411,7 +411,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
411
411
  var isAvailable = applicableProducts.length > 0;
412
412
 
413
413
  // 如果此优惠券被明确设置为不选中,保持其状态,但正确设置isAvailable
414
- if (typeof discount.isSelected === "boolean" && discount.isSelected === false && discount.isManualSelect) {
414
+ if (typeof discount.isSelected === 'boolean' && discount.isSelected === false && discount.isManualSelect) {
415
415
  return _objectSpread(_objectSpread({}, discount), {}, {
416
416
  isSelected: false,
417
417
  isAvailable: isAvailable,
@@ -436,7 +436,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
436
436
  appliedProductDetails: appliedProductDetails
437
437
  });
438
438
  }
439
- var isSelected = typeof discount.isSelected === "boolean" ? discount.isSelected : undefined;
439
+ var isSelected = typeof discount.isSelected === 'boolean' ? discount.isSelected : undefined;
440
440
 
441
441
  // 如果是可用的 并且没有手动标记 则设置为选中
442
442
  if (isAvailable && appliedProductDetails.length && !discount.isManualSelect) {
@@ -472,7 +472,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
472
472
  _context3.next = 3;
473
473
  return this.core.effects.emit(RulesHooks.OnDestroy, {});
474
474
  case 3:
475
- console.log("[Rules] 已销毁");
475
+ console.log('[Rules] 已销毁');
476
476
  case 4:
477
477
  case "end":
478
478
  return _context3.stop();
@@ -491,7 +491,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
491
491
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
492
492
  while (1) switch (_context4.prev = _context4.next) {
493
493
  case 0:
494
- console.log("[Rules] clear");
494
+ console.log('[Rules] clear');
495
495
  case 1:
496
496
  case "end":
497
497
  return _context4.stop();
@@ -1,4 +1,4 @@
1
- import { Discount } from "../Discount/types";
1
+ import { Discount } from '../Discount/types';
2
2
  export declare enum RulesHooks {
3
3
  OnRulesListChange = "rules:onRulesListChange",
4
4
  OnDestroy = "rules:onDestroy"
@@ -5,9 +5,14 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
7
7
  private store;
8
+ private cacheId;
9
+ private openCache;
10
+ private fatherModule;
8
11
  constructor(name?: string, version?: string);
9
- initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
12
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
10
13
  setScheduleList(list: ScheduleItem[]): void;
11
- setAvailabilityDateList(list: ScheduleAvailabilityDateItem[]): void;
12
- getAvailabilityDateList(): ScheduleAvailabilityDateItem[];
14
+ getScheduleListByIds(ids: number[]): ScheduleItem[];
15
+ setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
16
+ getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
17
+ storeChange(): void;
13
18
  }
@@ -15,6 +15,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
15
15
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ import { cloneDeep } from 'lodash-es';
18
19
  import { BaseModule } from "../BaseModule";
19
20
  export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
20
21
  _inherits(ScheduleModule, _BaseModule);
@@ -26,12 +27,16 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
26
27
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'schedule');
27
28
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
28
29
  _defineProperty(_assertThisInitialized(_this), "store", {});
30
+ _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
31
+ _defineProperty(_assertThisInitialized(_this), "openCache", false);
32
+ _defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
29
33
  return _this;
30
34
  }
31
35
  _createClass(ScheduleModule, [{
32
36
  key: "initialize",
33
37
  value: function () {
34
38
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
39
+ var _options$otherParams, _options$otherParams2;
35
40
  return _regeneratorRuntime().wrap(function _callee$(_context) {
36
41
  while (1) switch (_context.prev = _context.next) {
37
42
  case 0:
@@ -40,7 +45,21 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
40
45
  // this.state = { ...this.state, ...options.initialState }
41
46
  // }
42
47
  this.store = options === null || options === void 0 ? void 0 : options.store;
43
- case 2:
48
+ if (options.initialState) {
49
+ this.store.scheduleList = options.initialState.scheduleList;
50
+ this.store.availabilityDateList = options.initialState.availabilityDateList;
51
+ } else {
52
+ this.store.scheduleList = [];
53
+ this.store.availabilityDateList = [];
54
+ }
55
+ if ((_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
56
+ this.openCache = options.otherParams.openCache;
57
+ this.cacheId = options.otherParams.cacheId;
58
+ }
59
+ if ((_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
60
+ this.fatherModule = options.otherParams.fatherModule;
61
+ }
62
+ case 5:
44
63
  case "end":
45
64
  return _context.stop();
46
65
  }
@@ -57,15 +76,36 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
57
76
  this.store.scheduleList = list;
58
77
  }
59
78
  }, {
60
- key: "setAvailabilityDateList",
61
- value: function setAvailabilityDateList(list) {
79
+ key: "getScheduleListByIds",
80
+ value: function getScheduleListByIds(ids) {
81
+ return this.store.scheduleList.filter(function (n) {
82
+ return ids.includes(n.id);
83
+ });
84
+ }
85
+ }, {
86
+ key: "setAvailabilityScheduleDateList",
87
+ value: function setAvailabilityScheduleDateList(list) {
62
88
  this.store.availabilityDateList = list;
63
89
  }
64
90
  }, {
65
- key: "getAvailabilityDateList",
66
- value: function getAvailabilityDateList() {
91
+ key: "getAvailabilityScheduleDateList",
92
+ value: function getAvailabilityScheduleDateList() {
67
93
  return this.store.availabilityDateList;
68
94
  }
95
+ }, {
96
+ key: "storeChange",
97
+ value: function storeChange() {
98
+ if (this.openCache) {
99
+ var store = cloneDeep(this.store);
100
+ // store里的 list 要主动基于 id 做下去重,避免重复写入
101
+ this.checkSaveCache({
102
+ cacheId: this.cacheId,
103
+ fatherModule: this.fatherModule,
104
+ store: store,
105
+ cacheKey: ['scheduleList', 'availabilityDateList']
106
+ });
107
+ }
108
+ }
69
109
  }]);
70
110
  return ScheduleModule;
71
111
  }(BaseModule);
@@ -18,7 +18,7 @@ export type ScheduleItem = {
18
18
  repeat_rule: {
19
19
  end: {
20
20
  /** 截止类型 */
21
- type: "date" | "never";
21
+ type: 'date' | 'never';
22
22
  /** 结束时间 */
23
23
  end_date: string | null;
24
24
  occurrence: any | null;
@@ -28,13 +28,13 @@ export type ScheduleItem = {
28
28
  included_date: ExcIncDate[];
29
29
  frequency_date: number[];
30
30
  };
31
- repeat_type: "daily" | "none" | "weekly";
31
+ repeat_type: 'daily' | 'none' | 'weekly';
32
32
  /** 日程类型
33
33
  * standard: 标准日程
34
34
  * time-slots: 时间段日程
35
35
  * designation: 指定日期日程
36
36
  * */
37
- type: "standard" | "time-slots" | "designation";
37
+ type: 'standard' | 'time-slots' | 'designation';
38
38
  conflict?: boolean;
39
39
  time_slot: {
40
40
  start_time: string;
@@ -77,7 +77,7 @@ export type ScheduleFormOtherValue = {
77
77
  excludedStatus: boolean;
78
78
  /** 是否包含排除日期 */
79
79
  includeStatus: boolean;
80
- type: "standard" | "time-slots" | "designation";
80
+ type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
82
  export type ExcIncDate = {
83
83
  start: string;
@@ -89,15 +89,15 @@ export type ScheduleFormData = {
89
89
  /** 日程名称 */
90
90
  name: {
91
91
  en: string;
92
- "zh-CN": string;
93
- "zh-HK": string;
92
+ 'zh-CN': string;
93
+ 'zh-HK': string;
94
94
  original: string;
95
95
  } | string;
96
96
  /** 重复模式
97
97
  * 0:不重复
98
98
  * 1:按天重复
99
99
  * 2:按周重复 */
100
- repeat_type: "0" | "1" | "2";
100
+ repeat_type: '0' | '1' | '2';
101
101
  /** 备注 */
102
102
  note: string;
103
103
  /** 指定的开始时间结束时间 */
@@ -1,4 +1,4 @@
1
- import dayjs from "dayjs";
1
+ import dayjs from 'dayjs';
2
2
  export interface ScheduleState {
3
3
  scheduleList: ScheduleItem[];
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
@@ -29,7 +29,7 @@ export type ScheduleItem = {
29
29
  repeat_rule: {
30
30
  end: {
31
31
  /** 截止类型 */
32
- type: "date" | "never";
32
+ type: 'date' | 'never';
33
33
  /** 结束时间 */
34
34
  end_date: string | null;
35
35
  occurrence: any | null;
@@ -39,13 +39,13 @@ export type ScheduleItem = {
39
39
  included_date: ExcIncDate[];
40
40
  frequency_date: number[];
41
41
  };
42
- repeat_type: "daily" | "none" | "weekly";
42
+ repeat_type: 'daily' | 'none' | 'weekly';
43
43
  /** 日程类型
44
44
  * standard: 标准日程
45
45
  * time-slots: 时间段日程
46
46
  * designation: 指定日期日程
47
47
  * */
48
- type: "standard" | "time-slots" | "designation";
48
+ type: 'standard' | 'time-slots' | 'designation';
49
49
  conflict?: boolean;
50
50
  time_slot: {
51
51
  start_time: string;
@@ -88,7 +88,7 @@ export type ScheduleFormOtherValue = {
88
88
  excludedStatus: boolean;
89
89
  /** 是否包含排除日期 */
90
90
  includeStatus: boolean;
91
- type: "standard" | "time-slots" | "designation";
91
+ type: 'standard' | 'time-slots' | 'designation';
92
92
  };
93
93
  export type ExcIncDate = {
94
94
  start: string;
@@ -100,15 +100,15 @@ export type ScheduleFormData = {
100
100
  /** 日程名称 */
101
101
  name: {
102
102
  en: string;
103
- "zh-CN": string;
104
- "zh-HK": string;
103
+ 'zh-CN': string;
104
+ 'zh-HK': string;
105
105
  original: string;
106
106
  } | string;
107
107
  /** 重复模式
108
108
  * 0:不重复
109
109
  * 1:按天重复
110
110
  * 2:按周重复 */
111
- repeat_type: "0" | "1" | "2";
111
+ repeat_type: '0' | '1' | '2';
112
112
  /** 备注 */
113
113
  note: string;
114
114
  /** 指定的开始时间结束时间 */
@@ -1,11 +1,11 @@
1
- import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from "./types";
1
+ import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from './types';
2
2
  /**
3
3
  * 根据日程配置生成日历数据
4
4
  * @param values
5
5
  * @param others
6
6
  * @param type
7
7
  */
8
- export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?: "standard" | "time-slots" | "designation") => any[];
8
+ export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?: 'standard' | 'time-slots' | 'designation') => any[];
9
9
  /**
10
10
  * 获取开始时间和结束时间之间的所有日期
11
11
  * @param startDate
@@ -46,7 +46,7 @@ export declare const formatScheduleResult: (schedule: ScheduleItem) => {
46
46
  };
47
47
  export declare const calcScheduleDateRange: (schedule: ScheduleItem) => any[];
48
48
  export declare const calcCalendarDataBySchedules: (schedules: ScheduleItem[]) => unknown[];
49
- export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap: ScheduleAllMap, selectDate?: string) => {};
49
+ export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) => {};
50
50
  /**
51
51
  * @title: 格式化日程数据
52
52
  * @description:
@@ -59,3 +59,9 @@ export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[],
59
59
  * @Date: 2024-09-04 11:54
60
60
  */
61
61
  export declare const formatScheduleData: (relation: Array<any>, table_type?: string, item_type?: string, isExcluded?: boolean) => any;
62
+ export interface TimeRange {
63
+ start: string;
64
+ end: string;
65
+ count?: number;
66
+ }
67
+ export declare function getAllSortedDateRanges(schedules: Record<string, any>): TimeRange[];