@pisell/pisellos 0.0.78 → 0.0.79

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.
@@ -1196,7 +1196,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1196
1196
  capacity: formatCapacity
1197
1197
  });
1198
1198
  var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
1199
- debugger;
1200
1199
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1201
1200
  if (cartItem._origin.start_time) {
1202
1201
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
@@ -1253,10 +1252,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1253
1252
  } else {
1254
1253
  productResources.forEach(function (item) {
1255
1254
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1255
+ // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1256
1256
  item.renderList = item.renderList.filter(function (n) {
1257
+ var _cartItem$_productOri3;
1257
1258
  var recordCount = n.capacity || 0;
1258
1259
  if (n.onlyComputed) return false;
1259
- return recordCount >= currentCapacity;
1260
+ // 查一下这个资源基于商品的可用时间片
1261
+ var timeSlots = getTimeSlicesByResource({
1262
+ resource: n,
1263
+ duration: ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.value) || 0,
1264
+ split: 10,
1265
+ currentDate: dateRange[0].date
1266
+ });
1267
+ return recordCount >= currentCapacity && timeSlots.length > 0;
1260
1268
  });
1261
1269
  });
1262
1270
  }
@@ -1352,7 +1360,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1352
1360
  }, {
1353
1361
  key: "autoSelectAccountResources",
1354
1362
  value: function autoSelectAccountResources(_ref8) {
1355
- var _cartItem$_productOri3, _allProductResources$;
1363
+ var _cartItem$_productOri4, _allProductResources$;
1356
1364
  var cartItem = _ref8.cartItem,
1357
1365
  holder_id = _ref8.holder_id,
1358
1366
  resources_code = _ref8.resources_code,
@@ -1401,7 +1409,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1401
1409
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1402
1410
  var allCartItems = cloneDeep(this.store.cart.getItems());
1403
1411
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1404
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.product_resource) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.resources) || [], selectedResources, 1);
1412
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.product_resource) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.resources) || [], selectedResources, 1);
1405
1413
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1406
1414
  return n.code === resources_code;
1407
1415
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
@@ -1607,8 +1615,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1607
1615
  if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1608
1616
  // 过滤掉 capacity 小于 currentCapacity 的资源
1609
1617
  n.renderList = n.renderList.filter(function (m) {
1618
+ var _item$duration;
1610
1619
  var recordCount = m.capacity || 0;
1611
- return recordCount >= currentCapacity;
1620
+ var timeSlots = getTimeSlicesByResource({
1621
+ resource: m,
1622
+ duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
1623
+ split: 10,
1624
+ currentDate: dateRange[0].date
1625
+ });
1626
+ return recordCount >= currentCapacity && timeSlots.length > 0;
1612
1627
  });
1613
1628
  currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1614
1629
  }
@@ -638,7 +638,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
638
638
  selectedResources,
639
639
  currentCapacity
640
640
  );
641
- debugger;
642
641
  if (cartItem._origin.start_time) {
643
642
  const startTime = (0, import_dayjs.default)(
644
643
  `${cartItem._origin.start_date} ${cartItem._origin.start_time}`
@@ -692,10 +691,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
692
691
  } else {
693
692
  productResources.forEach((item) => {
694
693
  item.renderList = item.renderList.filter((n) => {
694
+ var _a2, _b2;
695
695
  const recordCount = n.capacity || 0;
696
696
  if (n.onlyComputed)
697
697
  return false;
698
- return recordCount >= currentCapacity;
698
+ const timeSlots = (0, import_resources.getTimeSlicesByResource)({
699
+ resource: n,
700
+ duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
701
+ split: 10,
702
+ currentDate: dateRange[0].date
703
+ });
704
+ return recordCount >= currentCapacity && timeSlots.length > 0;
699
705
  });
700
706
  });
701
707
  }
@@ -994,8 +1000,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
994
1000
  var _a3;
995
1001
  if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
996
1002
  n.renderList = n.renderList.filter((m) => {
1003
+ var _a4;
997
1004
  const recordCount = m.capacity || 0;
998
- return recordCount >= currentCapacity;
1005
+ const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
1006
+ resource: m,
1007
+ duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
1008
+ split: 10,
1009
+ currentDate: dateRange[0].date
1010
+ });
1011
+ return recordCount >= currentCapacity && timeSlots2.length > 0;
999
1012
  });
1000
1013
  currentResourcesRenderList.push(...n.renderList || []);
1001
1014
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.78",
4
+ "version": "0.0.79",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",