@pisell/pisellos 0.0.62 → 0.0.63
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.
|
@@ -132,6 +132,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
132
132
|
*/
|
|
133
133
|
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
134
|
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 检查购物车商品是否符合条件
|
|
137
|
+
* @param type 类型
|
|
138
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
139
|
+
*/
|
|
140
|
+
checkCartItems(type: ECartItemCheckType): string[];
|
|
135
141
|
destroy(): void;
|
|
136
142
|
getResourcesList(): any[];
|
|
137
143
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -1104,6 +1104,26 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1104
1104
|
value: function checkCartItemByType(cartItem, type) {
|
|
1105
1105
|
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
1106
1106
|
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* 检查购物车商品是否符合条件
|
|
1110
|
+
* @param type 类型
|
|
1111
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
1112
|
+
*/
|
|
1113
|
+
}, {
|
|
1114
|
+
key: "checkCartItems",
|
|
1115
|
+
value: function checkCartItems(type) {
|
|
1116
|
+
var _this7 = this;
|
|
1117
|
+
var cartItems = this.store.cart.getItems();
|
|
1118
|
+
var errorCartItemIds = [];
|
|
1119
|
+
cartItems.forEach(function (cartItem) {
|
|
1120
|
+
var result = _this7.store.cart.checkCartItemByType(cartItem, type);
|
|
1121
|
+
if (!result) {
|
|
1122
|
+
errorCartItemIds.push(cartItem._id);
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
return errorCartItemIds;
|
|
1126
|
+
}
|
|
1107
1127
|
}, {
|
|
1108
1128
|
key: "destroy",
|
|
1109
1129
|
value: function destroy() {
|
|
@@ -1398,7 +1418,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1398
1418
|
key: "autoSelectAllProductResources",
|
|
1399
1419
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1400
1420
|
var _dateRange$,
|
|
1401
|
-
|
|
1421
|
+
_this8 = this;
|
|
1402
1422
|
var dateRange = this.store.date.getDateRange();
|
|
1403
1423
|
var resources = [];
|
|
1404
1424
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange$.date) {
|
|
@@ -1448,7 +1468,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1448
1468
|
};
|
|
1449
1469
|
}
|
|
1450
1470
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1451
|
-
var res =
|
|
1471
|
+
var res = _this8.autoSelectAccountResources({
|
|
1452
1472
|
holder_id: item.holder_id,
|
|
1453
1473
|
resources_code: resources_code,
|
|
1454
1474
|
timeSlots: recordTimeSlots,
|
|
@@ -1467,7 +1487,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1467
1487
|
}
|
|
1468
1488
|
res.selectedResource.capacity = currentCapacity;
|
|
1469
1489
|
checkSubResourcesCapacity(res.selectedResource);
|
|
1470
|
-
|
|
1490
|
+
_this8.store.cart.updateItem({
|
|
1471
1491
|
_id: item._id,
|
|
1472
1492
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1473
1493
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -1481,7 +1501,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1481
1501
|
} else {
|
|
1482
1502
|
var _item$_productOrigin8, _productResources$fin;
|
|
1483
1503
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1484
|
-
var allCartItems = cloneDeep(
|
|
1504
|
+
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1485
1505
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1486
1506
|
var selectedResources = [];
|
|
1487
1507
|
if (item.holder_id) {
|
|
@@ -1506,7 +1526,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1506
1526
|
targetResource.capacity = currentCapacity;
|
|
1507
1527
|
// 在这里处理 children 的数据
|
|
1508
1528
|
checkSubResourcesCapacity(targetResource);
|
|
1509
|
-
|
|
1529
|
+
_this8.store.cart.updateItem({
|
|
1510
1530
|
_id: item._id,
|
|
1511
1531
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1512
1532
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -1524,7 +1544,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1524
1544
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1525
1545
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1526
1546
|
accountList.forEach(function (account) {
|
|
1527
|
-
var cartItems =
|
|
1547
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1528
1548
|
selectForCartResources(cartItems);
|
|
1529
1549
|
});
|
|
1530
1550
|
} else {
|
|
@@ -1538,7 +1558,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1538
1558
|
}, {
|
|
1539
1559
|
key: "getTimeSlotByAllResources",
|
|
1540
1560
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1541
|
-
var
|
|
1561
|
+
var _this9 = this,
|
|
1542
1562
|
_cartItems$,
|
|
1543
1563
|
_cartItems$2;
|
|
1544
1564
|
var dateRange = this.store.date.getDateRange();
|
|
@@ -1577,7 +1597,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1577
1597
|
};
|
|
1578
1598
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1579
1599
|
accountList.forEach(function (account) {
|
|
1580
|
-
var cartItems =
|
|
1600
|
+
var cartItems = _this9.store.cart.getCartByAccount(account.getId());
|
|
1581
1601
|
checkDuration(cartItems);
|
|
1582
1602
|
});
|
|
1583
1603
|
} else {
|
|
@@ -1618,7 +1638,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1618
1638
|
}, {
|
|
1619
1639
|
key: "submitTimeSlot",
|
|
1620
1640
|
value: function submitTimeSlot(timeSlots) {
|
|
1621
|
-
var
|
|
1641
|
+
var _this10 = this;
|
|
1622
1642
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
1623
1643
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1624
1644
|
|
|
@@ -1643,7 +1663,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1643
1663
|
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');
|
|
1644
1664
|
delete resource.times;
|
|
1645
1665
|
});
|
|
1646
|
-
|
|
1666
|
+
_this10.store.cart.updateItem({
|
|
1647
1667
|
_id: item._id,
|
|
1648
1668
|
resources: newResources
|
|
1649
1669
|
});
|
|
@@ -1805,7 +1825,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1805
1825
|
}, {
|
|
1806
1826
|
key: "addProductToCart",
|
|
1807
1827
|
value: function addProductToCart(_ref13) {
|
|
1808
|
-
var
|
|
1828
|
+
var _this11 = this;
|
|
1809
1829
|
var product = _ref13.product,
|
|
1810
1830
|
date = _ref13.date,
|
|
1811
1831
|
account = _ref13.account;
|
|
@@ -1838,7 +1858,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1838
1858
|
});
|
|
1839
1859
|
if (cartItemsByDate.length) {
|
|
1840
1860
|
cartItemsByDate.forEach(function (n) {
|
|
1841
|
-
|
|
1861
|
+
_this11.store.cart.removeItem(n._id);
|
|
1842
1862
|
});
|
|
1843
1863
|
}
|
|
1844
1864
|
}
|
|
@@ -132,6 +132,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
132
132
|
*/
|
|
133
133
|
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
134
|
checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 检查购物车商品是否符合条件
|
|
137
|
+
* @param type 类型
|
|
138
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
139
|
+
*/
|
|
140
|
+
checkCartItems(type: ECartItemCheckType): string[];
|
|
135
141
|
destroy(): void;
|
|
136
142
|
getResourcesList(): any[];
|
|
137
143
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -548,6 +548,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
548
548
|
checkCartItemByType(cartItem, type) {
|
|
549
549
|
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
550
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* 检查购物车商品是否符合条件
|
|
553
|
+
* @param type 类型
|
|
554
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
555
|
+
*/
|
|
556
|
+
checkCartItems(type) {
|
|
557
|
+
const cartItems = this.store.cart.getItems();
|
|
558
|
+
const errorCartItemIds = [];
|
|
559
|
+
cartItems.forEach((cartItem) => {
|
|
560
|
+
const result = this.store.cart.checkCartItemByType(cartItem, type);
|
|
561
|
+
if (!result) {
|
|
562
|
+
errorCartItemIds.push(cartItem._id);
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
return errorCartItemIds;
|
|
566
|
+
}
|
|
551
567
|
destroy() {
|
|
552
568
|
var _a, _b, _c, _d, _e, _f;
|
|
553
569
|
(_a = this.store.cart) == null ? void 0 : _a.destroy();
|