@pisell/pisellos 0.0.28 → 0.0.30

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.
@@ -1031,6 +1031,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1031
1031
  var allCartItems = _this7.store.cart.getItems();
1032
1032
  cartItems.forEach(function (item) {
1033
1033
  if (timeSlots) {
1034
+ var _item$_origin$resourc2;
1034
1035
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
1035
1036
  var res = _this7.autoSelectAccountResources({
1036
1037
  holder_id: item.holder_id,
@@ -1038,6 +1039,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1038
1039
  timeSlots: timeSlots,
1039
1040
  countMap: selectResourcesMap
1040
1041
  });
1042
+ // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1043
+ if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
1044
+ var _res$selectedResource;
1045
+ return n.form_id === (res === null || res === void 0 || (_res$selectedResource = res.selectedResource) === null || _res$selectedResource === void 0 ? void 0 : _res$selectedResource.form_id);
1046
+ })) {
1047
+ return;
1048
+ }
1041
1049
  if (res !== null && res !== void 0 && res.selectedResource) {
1042
1050
  if (!selectResourcesMap[res.selectedResource.id]) {
1043
1051
  selectResourcesMap[res.selectedResource.id] = 1;
@@ -1045,6 +1053,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1045
1053
  selectResourcesMap[res.selectedResource.id]++;
1046
1054
  }
1047
1055
  console.log(_this7.store.cart.getItems());
1056
+ res.selectedResource.capacity = 1;
1048
1057
  _this7.store.cart.updateItem({
1049
1058
  _id: item._id,
1050
1059
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
@@ -1066,11 +1075,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1066
1075
  return n.code === resources_code;
1067
1076
  })) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
1068
1077
  if (targetRenderList && targetRenderList.length > 0) {
1078
+ var _item$_origin$resourc3;
1079
+ // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1080
+ if ((_item$_origin$resourc3 = item._origin.resources) !== null && _item$_origin$resourc3 !== void 0 && _item$_origin$resourc3.some(function (n) {
1081
+ return n.form_id === targetRenderList[0].form_id;
1082
+ })) {
1083
+ return;
1084
+ }
1085
+ var targetResource = targetRenderList[0];
1086
+ targetResource.capacity = 1;
1069
1087
  _this7.store.cart.updateItem({
1070
1088
  _id: item._id,
1071
1089
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
1072
1090
  return existingRes.resourceType !== targetRenderList[0].resourceType;
1073
- })), [targetRenderList[0]])
1091
+ })), [targetResource])
1074
1092
  });
1075
1093
  } else {
1076
1094
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
@@ -559,7 +559,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
559
559
  const cartItems = this.store.cart.getCartByAccount(account.getId());
560
560
  const allCartItems = this.store.cart.getItems();
561
561
  cartItems.forEach((item) => {
562
- var _a;
562
+ var _a, _b, _c;
563
563
  if (timeSlots) {
564
564
  const res = this.autoSelectAccountResources({
565
565
  holder_id: item.holder_id,
@@ -567,6 +567,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
567
567
  timeSlots,
568
568
  countMap: selectResourcesMap
569
569
  });
570
+ if ((_a = item._origin.resources) == null ? void 0 : _a.some((n) => {
571
+ var _a2;
572
+ return n.form_id === ((_a2 = res == null ? void 0 : res.selectedResource) == null ? void 0 : _a2.form_id);
573
+ })) {
574
+ return;
575
+ }
570
576
  if (res == null ? void 0 : res.selectedResource) {
571
577
  if (!selectResourcesMap[res.selectedResource.id]) {
572
578
  selectResourcesMap[res.selectedResource.id] = 1;
@@ -574,6 +580,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
574
580
  selectResourcesMap[res.selectedResource.id]++;
575
581
  }
576
582
  console.log(this.store.cart.getItems());
583
+ res.selectedResource.capacity = 1;
577
584
  this.store.cart.updateItem({
578
585
  _id: item._id,
579
586
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
@@ -590,15 +597,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
590
597
  }
591
598
  } else {
592
599
  const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
593
- const targetRenderList = (_a = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _a.renderList;
600
+ const targetRenderList = (_b = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _b.renderList;
594
601
  if (targetRenderList && targetRenderList.length > 0) {
602
+ if ((_c = item._origin.resources) == null ? void 0 : _c.some((n) => n.form_id === targetRenderList[0].form_id)) {
603
+ return;
604
+ }
605
+ const targetResource = targetRenderList[0];
606
+ targetResource.capacity = 1;
595
607
  this.store.cart.updateItem({
596
608
  _id: item._id,
597
609
  resources: [
598
610
  ...(item._origin.resources || []).filter(
599
611
  (existingRes) => existingRes.resourceType !== targetRenderList[0].resourceType
600
612
  ),
601
- targetRenderList[0]
613
+ targetResource
602
614
  ]
603
615
  });
604
616
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.28",
4
+ "version": "0.0.30",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",