@pisell/pisellos 3.0.7 → 3.0.9

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.
@@ -144,6 +144,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
144
144
  end_date: end_date,
145
145
  resource_ids: resource_ids,
146
146
  front_end_cache_id: this.cacheId
147
+ }, {
148
+ useCache: true
147
149
  });
148
150
  case 11:
149
151
  res = _context3.sent;
@@ -1216,6 +1216,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1216
1216
  return canUseTime;
1217
1217
  });
1218
1218
  });
1219
+ } else {
1220
+ productResources.forEach(function (item) {
1221
+ // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1222
+ item.renderList = item.renderList.filter(function (n) {
1223
+ var recordCount = n.capacity || 0;
1224
+ return recordCount >= currentCapacity;
1225
+ });
1226
+ });
1219
1227
  }
1220
1228
  arr.push({
1221
1229
  id: cartItem.id,
@@ -1510,6 +1518,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1510
1518
  _resources.forEach(function (n) {
1511
1519
  var _n$renderList;
1512
1520
  if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1521
+ // 过滤掉 capacity 小于 currentCapacity 的资源
1522
+ n.renderList = n.renderList.filter(function (m) {
1523
+ var recordCount = m.capacity || 0;
1524
+ return recordCount >= currentCapacity;
1525
+ });
1513
1526
  currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1514
1527
  }
1515
1528
  });
@@ -1568,7 +1581,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1568
1581
  }, {
1569
1582
  key: "getTimeSlotByAllResources",
1570
1583
  value: function getTimeSlotByAllResources(resources_code) {
1571
- var _this9 = this,
1584
+ var _dateRange,
1585
+ _this9 = this,
1572
1586
  _cartItems$,
1573
1587
  _cartItems$2;
1574
1588
  var dateRange = this.store.date.getDateRange();
@@ -1577,8 +1591,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1577
1591
  var cartItems = cloneDeep(this.store.cart.getItems());
1578
1592
  // if (cartItems?.[0].start_date) return [];
1579
1593
  var resourceIds = [];
1594
+ var resourcesTypeId = undefined;
1580
1595
  cartItems.forEach(function (item) {
1581
- var _item$_productOrigin9;
1596
+ var _item$_productOrigin9, _item$_productOrigin10;
1582
1597
  (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
1583
1598
  if (n.code === resources_code) {
1584
1599
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
@@ -1590,7 +1605,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1590
1605
  if (item.resource_id) {
1591
1606
  resourceIds.push(item.resource_id);
1592
1607
  }
1608
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.find(function (n) {
1609
+ return n.code === resources_code;
1610
+ })) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
1593
1611
  });
1612
+ // 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
1613
+ if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
1614
+ // resources.push(...dateRange[0].resource);
1615
+ dateRange[0].resource.forEach(function (n) {
1616
+ if (n.form_id === resourcesTypeId) {
1617
+ resources.push(n);
1618
+ }
1619
+ });
1620
+ }
1594
1621
  var resourcesMap = getResourcesMap(resources);
1595
1622
  var duration = 0;
1596
1623
  // duration = 不同账号的最长时间
@@ -1598,8 +1625,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1598
1625
  var checkDuration = function checkDuration(cartItems) {
1599
1626
  var accountDuration = 0;
1600
1627
  cartItems.forEach(function (item) {
1601
- var _item$_productOrigin$3, _item$_productOrigin10;
1602
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1628
+ var _item$_productOrigin$3, _item$_productOrigin11;
1629
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1603
1630
  });
1604
1631
  if (accountDuration > duration) {
1605
1632
  duration = accountDuration;
@@ -1668,9 +1695,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1668
1695
  accountItems.forEach(function (item, index) {
1669
1696
  var newResources = cloneDeep(item._origin.resources);
1670
1697
  newResources.forEach(function (resource) {
1671
- var _item$_productOrigin$4, _item$_productOrigin11, _ref11, _item$_productOrigin12;
1698
+ var _item$_productOrigin$4, _item$_productOrigin12, _ref11, _item$_productOrigin13;
1672
1699
  resource.startTime = currentStartTime;
1673
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
1700
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
1674
1701
  delete resource.times;
1675
1702
  });
1676
1703
  _this10.store.cart.updateItem({
@@ -83,6 +83,8 @@ var DateModule = class extends import_BaseModule.BaseModule {
83
83
  end_date,
84
84
  resource_ids,
85
85
  front_end_cache_id: this.cacheId
86
+ }, {
87
+ useCache: true
86
88
  });
87
89
  if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
88
90
  return (0, import_utils.disableAllDates)(dates);
@@ -667,6 +667,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
667
667
  return canUseTime;
668
668
  });
669
669
  });
670
+ } else {
671
+ productResources.forEach((item) => {
672
+ item.renderList = item.renderList.filter((n) => {
673
+ const recordCount = n.capacity || 0;
674
+ return recordCount >= currentCapacity;
675
+ });
676
+ });
670
677
  }
671
678
  arr.push({
672
679
  id: cartItem.id,
@@ -918,6 +925,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
918
925
  resources2.forEach((n) => {
919
926
  var _a3;
920
927
  if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
928
+ n.renderList = n.renderList.filter((m) => {
929
+ const recordCount = m.capacity || 0;
930
+ return recordCount >= currentCapacity;
931
+ });
921
932
  currentResourcesRenderList.push(...n.renderList || []);
922
933
  }
923
934
  });
@@ -981,13 +992,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
981
992
  }
982
993
  // 从购物车中获取已经分配好第一步资源的所有时间片
983
994
  getTimeSlotByAllResources(resources_code) {
984
- var _a, _b, _c, _d;
995
+ var _a, _b, _c, _d, _e, _f;
985
996
  let dateRange = this.store.date.getDateRange();
986
997
  const resources = [];
987
998
  const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
988
999
  const resourceIds = [];
1000
+ let resourcesTypeId = void 0;
989
1001
  cartItems.forEach((item) => {
990
- var _a2, _b2, _c2;
1002
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
991
1003
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
992
1004
  if (n.code === resources_code) {
993
1005
  resources.push(...n.renderList || []);
@@ -996,7 +1008,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
996
1008
  if (item.resource_id) {
997
1009
  resourceIds.push(item.resource_id);
998
1010
  }
1011
+ resourcesTypeId = (_g = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find((n) => n.code === resources_code)) == null ? void 0 : _g.id;
999
1012
  });
1013
+ if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
1014
+ dateRange[0].resource.forEach((n) => {
1015
+ if (n.form_id === resourcesTypeId) {
1016
+ resources.push(n);
1017
+ }
1018
+ });
1019
+ }
1000
1020
  const resourcesMap = (0, import_utils.getResourcesMap)(resources);
1001
1021
  let duration = 0;
1002
1022
  const accountList = this.store.accountList.getAccounts();
@@ -1018,7 +1038,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1018
1038
  } else {
1019
1039
  checkDuration(cartItems);
1020
1040
  }
1021
- if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1041
+ if (!((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) && !((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1022
1042
  return [];
1023
1043
  }
1024
1044
  if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
@@ -1030,7 +1050,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1030
1050
  weekNum: 0
1031
1051
  },
1032
1052
  {
1033
- date: ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.end_date) || ((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.start_date) || "",
1053
+ date: ((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.end_date) || ((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.start_date) || "",
1034
1054
  status: "available",
1035
1055
  week: "",
1036
1056
  weekNum: 0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.7",
4
+ "version": "3.0.9",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",