@pisell/private-materials 3.0.104 → 3.0.106

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.
@@ -34,6 +34,7 @@ import { getErrorList, getServiceTimes, deleteCacheParams } from "../../../utils
34
34
  import Like from "../like";
35
35
  import { getNoResource } from "../../../mock";
36
36
  import { formatResources, getDurationProps, getFlexibleOption, getTimeObj } from "../addService/utils";
37
+ import { checkProductByTime } from "../../utils";
37
38
  var submitLock = false;
38
39
  var Info = function Info() {
39
40
  var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$service$cacheI6, _state$service3, _state$service3$cache, _state$service5, _state$service5$cache, _state$service5$cache2, _state$service5$cache3, _window$BaseMaterials, _state$service$cacheI7, _state$service6, _state$service6$cache, _state$service6$cache2, _state$service$cacheI8, _state$service$cacheI9, _state$service$cacheI10, _state$service$cacheI11, _state$bookingConfig5, _state$bookingConfig6, _state$bookingConfig7, _state$bookingConfig8;
@@ -370,13 +371,17 @@ var Info = function Info() {
370
371
  _extend.bundle_edit = 1;
371
372
  }
372
373
  _item._extend = _extend;
374
+ _item._time = new Date().getTime();
373
375
  var _id = _item === null || _item === void 0 ? void 0 : _item._id;
374
376
 
375
377
  // 判断是新增还是编辑
376
378
  if (!_list.some(function (d) {
377
379
  return d._id === _id;
378
380
  })) {
379
- _list.push(_item);
381
+ // 检查列表最后的商品添加时间是否在指定间隔内 如果在 则不添加新商品
382
+ if (checkProductByTime(_list)) {
383
+ _list.push(_item);
384
+ }
380
385
  } else {
381
386
  _list = _list.map(function (d) {
382
387
  return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useContext, useMemo } from 'react';
2
2
  import AddService from "./addService";
3
- import { Context } from "../../model";
3
+ import { Context } from "../model";
4
4
  import EditService from "./editService";
5
5
  import "./index.less";
6
6
  import ServiceList from "./serviceList";
@@ -20,12 +20,12 @@ var Service = function Service() {
20
20
  }, [state === null || state === void 0 ? void 0 : (_state$bookingConfig2 = state.bookingConfig) === null || _state$bookingConfig2 === void 0 ? void 0 : (_state$bookingConfig3 = _state$bookingConfig2.config) === null || _state$bookingConfig3 === void 0 ? void 0 : _state$bookingConfig3.information_tab]);
21
21
  var showAddTimeModal = useMemo(function () {
22
22
  // event预约不需要
23
- if (state.renderType === 'eventBooking') {
23
+ if ((state === null || state === void 0 ? void 0 : state.renderType) === 'eventBooking') {
24
24
  return false;
25
25
  }
26
26
 
27
27
  // 禁止编辑
28
- if (state.disabledEdit) {
28
+ if (state !== null && state !== void 0 && state.disabledEdit) {
29
29
  return false;
30
30
  }
31
31
 
@@ -1,3 +1,13 @@
1
1
  export declare const getIsBundleOrCombination: (productDetail: any) => boolean;
2
2
  export declare const uniqueByField: (arr: any[], field: string) => any[];
3
3
  export declare const moveItemToFront: (arr: any[], targetId: string | number) => any[];
4
+ /**
5
+ * @title: 检查列表最后的商品添加时间是否在指定间隔内
6
+ * @description:
7
+ * @param {any} list
8
+ * @param {number} interval
9
+ * @return {*}
10
+ * @Author: zhiwei.Wang
11
+ * @Date: 2024-08-13 18:35
12
+ */
13
+ export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
@@ -28,4 +28,29 @@ export var moveItemToFront = function moveItemToFront(arr, targetId) {
28
28
  arr.unshift(targetItem);
29
29
  }
30
30
  return arr;
31
+ };
32
+
33
+ /**
34
+ * @title: 检查列表最后的商品添加时间是否在指定间隔内
35
+ * @description:
36
+ * @param {any} list
37
+ * @param {number} interval
38
+ * @return {*}
39
+ * @Author: zhiwei.Wang
40
+ * @Date: 2024-08-13 18:35
41
+ */
42
+ export var checkProductByTime = function checkProductByTime(list) {
43
+ var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
44
+ var bol = true;
45
+ try {
46
+ if (list.length) {
47
+ var _list;
48
+ var last = (_list = list[list.length - 1]) === null || _list === void 0 ? void 0 : _list._time;
49
+ var currentTime = new Date().getTime();
50
+ if (last && currentTime - last < interval) {
51
+ bol = false;
52
+ }
53
+ }
54
+ } catch (err) {}
55
+ return bol;
31
56
  };
@@ -47,6 +47,7 @@ var import_utils3 = require("../../../utils");
47
47
  var import_like = __toESM(require("../like"));
48
48
  var import_mock = require("../../../mock");
49
49
  var import_utils4 = require("../addService/utils");
50
+ var import_utils5 = require("../../utils");
50
51
  var submitLock = false;
51
52
  var Info = () => {
52
53
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
@@ -243,9 +244,12 @@ var Info = () => {
243
244
  _extend.bundle_edit = 1;
244
245
  }
245
246
  _item._extend = _extend;
247
+ _item._time = (/* @__PURE__ */ new Date()).getTime();
246
248
  let _id = _item == null ? void 0 : _item._id;
247
249
  if (!_list.some((d) => d._id === _id)) {
248
- _list.push(_item);
250
+ if ((0, import_utils5.checkProductByTime)(_list)) {
251
+ _list.push(_item);
252
+ }
249
253
  } else {
250
254
  _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
251
255
  }
@@ -34,7 +34,7 @@ __export(service_exports, {
34
34
  module.exports = __toCommonJS(service_exports);
35
35
  var import_react = __toESM(require("react"));
36
36
  var import_addService = __toESM(require("./addService"));
37
- var import_model = require("../../model");
37
+ var import_model = require("../model");
38
38
  var import_editService = __toESM(require("./editService"));
39
39
  var import_index = require("./index.less");
40
40
  var import_serviceList = __toESM(require("./serviceList"));
@@ -52,10 +52,10 @@ var Service = () => {
52
52
  };
53
53
  }, [(_b = (_a = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.information_tab]);
54
54
  const showAddTimeModal = (0, import_react.useMemo)(() => {
55
- if (state.renderType === "eventBooking") {
55
+ if ((state == null ? void 0 : state.renderType) === "eventBooking") {
56
56
  return false;
57
57
  }
58
- if (state.disabledEdit) {
58
+ if (state == null ? void 0 : state.disabledEdit) {
59
59
  return false;
60
60
  }
61
61
  if (appointment_card.quick_time !== 1) {
@@ -1,3 +1,13 @@
1
1
  export declare const getIsBundleOrCombination: (productDetail: any) => boolean;
2
2
  export declare const uniqueByField: (arr: any[], field: string) => any[];
3
3
  export declare const moveItemToFront: (arr: any[], targetId: string | number) => any[];
4
+ /**
5
+ * @title: 检查列表最后的商品添加时间是否在指定间隔内
6
+ * @description:
7
+ * @param {any} list
8
+ * @param {number} interval
9
+ * @return {*}
10
+ * @Author: zhiwei.Wang
11
+ * @Date: 2024-08-13 18:35
12
+ */
13
+ export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/booking/info/utils.ts
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
+ checkProductByTime: () => checkProductByTime,
22
23
  getIsBundleOrCombination: () => getIsBundleOrCombination,
23
24
  moveItemToFront: () => moveItemToFront,
24
25
  uniqueByField: () => uniqueByField
@@ -52,8 +53,24 @@ var moveItemToFront = (arr, targetId) => {
52
53
  }
53
54
  return arr;
54
55
  };
56
+ var checkProductByTime = (list, interval = 1e3) => {
57
+ var _a;
58
+ let bol = true;
59
+ try {
60
+ if (list.length) {
61
+ let last = (_a = list[list.length - 1]) == null ? void 0 : _a._time;
62
+ let currentTime = (/* @__PURE__ */ new Date()).getTime();
63
+ if (last && currentTime - last < interval) {
64
+ bol = false;
65
+ }
66
+ }
67
+ } catch (err) {
68
+ }
69
+ return bol;
70
+ };
55
71
  // Annotate the CommonJS export names for ESM import in node:
56
72
  0 && (module.exports = {
73
+ checkProductByTime,
57
74
  getIsBundleOrCombination,
58
75
  moveItemToFront,
59
76
  uniqueByField
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.104",
3
+ "version": "3.0.106",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -60,8 +60,8 @@
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
62
  "@pisell/icon": "0.0.11",
63
- "@pisell/utils": "1.0.27",
64
- "@pisell/date-picker": "1.0.91"
63
+ "@pisell/date-picker": "1.0.91",
64
+ "@pisell/utils": "1.0.27"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^18.0.0",