@pisell/pisellos 0.0.31 → 3.0.1

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.
@@ -861,12 +861,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
861
861
  var _loop = function _loop() {
862
862
  var n = _step.value;
863
863
  var canUseTime = n.times.find(function (item) {
864
- return getIsUsableByTimeItem({
864
+ var res = getIsUsableByTimeItem({
865
865
  timeSlice: timeSlots,
866
866
  time: item,
867
867
  resource: n,
868
868
  currentCount: 1
869
869
  });
870
+ return res.usable;
870
871
  });
871
872
  if (canUseTime) {
872
873
  targetResource = n;
@@ -964,12 +965,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
964
965
  var n = _step2.value;
965
966
  var recordCount = countMap[n.id] || 0;
966
967
  var canUseTime = n.times.find(function (item) {
967
- return getIsUsableByTimeItem({
968
+ var res = getIsUsableByTimeItem({
968
969
  timeSlice: timeSlots,
969
970
  time: item,
970
971
  resource: n,
971
972
  currentCount: recordCount + 1
972
973
  });
974
+ return res.usable;
973
975
  });
974
976
  if (canUseTime) {
975
977
  targetResource = n;
@@ -1035,7 +1037,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1035
1037
 
1036
1038
  cartItems.forEach(function (item, index) {
1037
1039
  if (timeSlots) {
1038
- var _item$_origin$resourc2;
1039
1040
  if (index !== 0 && recordTimeSlots) {
1040
1041
  var _item$_productOrigin$, _item$_productOrigin2, _ref8, _item$_productOrigin3, _item$_productOrigin$2, _item$_productOrigin4, _ref9, _item$_productOrigin5;
1041
1042
  var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.duration) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref8 = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes");
@@ -1054,13 +1055,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1054
1055
  timeSlots: recordTimeSlots,
1055
1056
  countMap: selectResourcesMap
1056
1057
  });
1057
- // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1058
- if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
1059
- var _res$selectedResource;
1060
- return n.form_id === (res === null || res === void 0 || (_res$selectedResource = res.selectedResource) === null || _res$selectedResource === void 0 ? void 0 : _res$selectedResource.form_id);
1061
- })) {
1062
- return;
1063
- }
1058
+ // // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1059
+ // if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
1060
+ // return
1061
+ // }
1064
1062
  if (res !== null && res !== void 0 && res.selectedResource) {
1065
1063
  if (!selectResourcesMap[res.selectedResource.id]) {
1066
1064
  selectResourcesMap[res.selectedResource.id] = 1;
@@ -1090,9 +1088,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1090
1088
  return n.code === resources_code;
1091
1089
  })) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
1092
1090
  if (targetRenderList && targetRenderList.length > 0) {
1093
- var _item$_origin$resourc3;
1091
+ var _item$_origin$resourc2;
1094
1092
  // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1095
- if ((_item$_origin$resourc3 = item._origin.resources) !== null && _item$_origin$resourc3 !== void 0 && _item$_origin$resourc3.some(function (n) {
1093
+ if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
1096
1094
  return n.form_id === targetRenderList[0].form_id;
1097
1095
  })) {
1098
1096
  return;
@@ -434,14 +434,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
434
434
  if (timeSlots) {
435
435
  let targetResource = null;
436
436
  for (const n of resources) {
437
- const canUseTime = n.times.find(
438
- (item) => (0, import_resources.getIsUsableByTimeItem)({
437
+ const canUseTime = n.times.find((item) => {
438
+ const res = (0, import_resources.getIsUsableByTimeItem)({
439
439
  timeSlice: timeSlots,
440
440
  time: item,
441
441
  resource: n,
442
442
  currentCount: 1
443
- })
444
- );
443
+ });
444
+ return res.usable;
445
+ });
445
446
  if (canUseTime) {
446
447
  targetResource = n;
447
448
  break;
@@ -504,14 +505,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
504
505
  let targetResource = null;
505
506
  for (const n of resources) {
506
507
  const recordCount = countMap[n.id] || 0;
507
- const canUseTime = n.times.find(
508
- (item) => (0, import_resources.getIsUsableByTimeItem)({
508
+ const canUseTime = n.times.find((item) => {
509
+ const res = (0, import_resources.getIsUsableByTimeItem)({
509
510
  timeSlice: timeSlots,
510
511
  time: item,
511
512
  resource: n,
512
513
  currentCount: recordCount + 1
513
- })
514
- );
514
+ });
515
+ return res.usable;
516
+ });
515
517
  if (canUseTime) {
516
518
  targetResource = n;
517
519
  break;
@@ -555,7 +557,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
555
557
  const allCartItems = this.store.cart.getItems();
556
558
  let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
557
559
  cartItems.forEach((item, index) => {
558
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
560
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
559
561
  if (timeSlots) {
560
562
  if (index !== 0 && recordTimeSlots) {
561
563
  let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0, ((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes");
@@ -573,12 +575,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
573
575
  timeSlots: recordTimeSlots,
574
576
  countMap: selectResourcesMap
575
577
  });
576
- if ((_i = item._origin.resources) == null ? void 0 : _i.some((n) => {
577
- var _a2;
578
- return n.form_id === ((_a2 = res == null ? void 0 : res.selectedResource) == null ? void 0 : _a2.form_id);
579
- })) {
580
- return;
581
- }
582
578
  if (res == null ? void 0 : res.selectedResource) {
583
579
  if (!selectResourcesMap[res.selectedResource.id]) {
584
580
  selectResourcesMap[res.selectedResource.id] = 1;
@@ -603,9 +599,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
603
599
  }
604
600
  } else {
605
601
  const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
606
- const targetRenderList = (_j = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _j.renderList;
602
+ const targetRenderList = (_i = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _i.renderList;
607
603
  if (targetRenderList && targetRenderList.length > 0) {
608
- if ((_k = item._origin.resources) == null ? void 0 : _k.some((n) => n.form_id === targetRenderList[0].form_id)) {
604
+ if ((_j = item._origin.resources) == null ? void 0 : _j.some((n) => n.form_id === targetRenderList[0].form_id)) {
609
605
  return;
610
606
  }
611
607
  const targetResource = targetRenderList[0];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.31",
4
+ "version": "3.0.1",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "docs": "typedoc --out docs src/index.ts",
22
22
  "sync": "node sync.js",
23
23
  "prepublishOnly": "npm run build",
24
- "deploy": "yarn run build && yarn run changeset && yarn run version && npm run release"
24
+ "deploy": "yarn run build && yarn run changeset && yarn run version && yarn run release"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",