@pisell/private-materials 3.0.107 → 3.0.109

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.
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import React, { useEffect, useContext } from "react";
7
+ import React, { useEffect, useContext } from 'react';
8
8
  import { Provider, Context } from "./model";
9
9
  import Info from "./info";
10
10
  import Notes from "./notes";
@@ -17,7 +17,7 @@ var Booking = Provider(function () {
17
17
  useEffect(function () {}, []);
18
18
  var setState = function setState(payload) {
19
19
  dispatch({
20
- type: "setState",
20
+ type: 'setState',
21
21
  payload: _objectSpread({}, payload)
22
22
  });
23
23
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FormState } from "../model";
2
+ import { FormState } from '../model';
3
3
  export declare const walkInData: {
4
4
  id: number;
5
5
  nickname: string;
@@ -4,14 +4,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import { miniRedux } from "@pisell/utils";
7
+ import { miniRedux } from '@pisell/utils';
8
+ import { formatServiceListByTime } from "./utils";
8
9
  export var walkInData = {
9
10
  id: 1,
10
- nickname: "Select a customer"
11
+ nickname: 'Select a customer'
11
12
  };
12
13
  var defaultState = {};
13
14
  var _miniRedux = miniRedux({
14
- namespace: "state",
15
+ namespace: 'state',
15
16
  state: defaultState,
16
17
  reducers: {
17
18
  setStateFn: function setStateFn(state, payload) {
@@ -27,8 +28,14 @@ var _miniRedux = miniRedux({
27
28
  // return { ...state, client: { ...state.client, ...payload } };
28
29
  },
29
30
  setService: function setService(state, payload) {
31
+ var obj = {};
32
+
33
+ // 拦截, 如果服务列表里 有两个相近时间的服务, 删除最后一个
34
+ if (payload.value) {
35
+ obj.value = formatServiceListByTime(payload.value);
36
+ }
30
37
  state.setGlobalState({
31
- service: _objectSpread(_objectSpread({}, state.service), payload)
38
+ service: _objectSpread(_objectSpread(_objectSpread({}, state.service), payload), obj)
32
39
  });
33
40
  },
34
41
  setDate: function setDate(state, payload) {
@@ -58,7 +65,7 @@ var _miniRedux = miniRedux({
58
65
  var _val = {
59
66
  appointment_status: payload
60
67
  };
61
- if (payload === "cancelled") {
68
+ if (payload === 'cancelled') {
62
69
  _val.disabledEdit = true;
63
70
  } else {
64
71
  _val.disabledEdit = false;
@@ -32,7 +32,7 @@ import { getProductExtend } from "./utils";
32
32
  import { formatProductListByCategory, getProductTotalPrice, request } from "../../../utils";
33
33
  import { locales, getUniqueId } from '@pisell/utils';
34
34
  import { useUpdateEffect } from 'ahooks';
35
- var shopList = [2886, 4422, 5538, 6930, 6814, 6813, 6812, 6087, 6303, 6080, 6978, 7386, 6848];
35
+ var shopList = [2886, 4422, 5538, 6930, 6814, 6813, 6812, 6087, 6303, 6080, 6978, 7386, 6848, 6305];
36
36
  var Info = function Info() {
37
37
  var _state$service3, _state$service5, _state$service6, _state$service6$cache;
38
38
  var _useState = useState(''),
@@ -34,7 +34,6 @@ 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";
38
37
  var submitLock = false;
39
38
  var Info = function Info() {
40
39
  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;
@@ -378,10 +377,7 @@ var Info = function Info() {
378
377
  if (!_list.some(function (d) {
379
378
  return d._id === _id;
380
379
  })) {
381
- // 检查列表最后的商品添加时间是否在指定间隔内 如果在 则不添加新商品
382
- if (checkProductByTime(_list)) {
383
- _list.push(_item);
384
- }
380
+ _list.push(_item);
385
381
  } else {
386
382
  _list = _list.map(function (d) {
387
383
  return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
@@ -2,12 +2,22 @@ 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
4
  /**
5
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
5
+ * @title: 判断两个时间是否在同一个时间段内
6
6
  * @description:
7
- * @param {any} list
8
- * @param {number} interval
7
+ * @param {number} time1 开始时间
8
+ * @param {number} time2 结束时间
9
+ * @param {number} interval 时间间隔
9
10
  * @return {*}
10
11
  * @Author: zhiwei.Wang
11
- * @Date: 2024-08-13 18:35
12
+ * @Date: 2024-08-13 19:37
12
13
  */
13
- export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
14
+ export declare const isInterval: (time1: number, time2: number, interval?: number) => boolean;
15
+ /**
16
+ * @title: 根据时间间隔格式化服务列表
17
+ * @description: 防止短时间内添加多个相同服务, 如果两个服务的时间间隔小于1秒,则合并为一个服务
18
+ * @param {any} list 服务列表
19
+ * @return {*}
20
+ * @Author: zhiwei.Wang
21
+ * @Date: 2024-08-13 19:36
22
+ */
23
+ export declare const formatServiceListByTime: (list: any[]) => any[];
@@ -1,3 +1,9 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
7
  // 商品是套餐或单规格多规格
2
8
  export var getIsBundleOrCombination = function getIsBundleOrCombination(productDetail) {
3
9
  var _productDetail$bundle;
@@ -31,26 +37,50 @@ export var moveItemToFront = function moveItemToFront(arr, targetId) {
31
37
  };
32
38
 
33
39
  /**
34
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
40
+ * @title: 判断两个时间是否在同一个时间段内
35
41
  * @description:
36
- * @param {any} list
37
- * @param {number} interval
42
+ * @param {number} time1 开始时间
43
+ * @param {number} time2 结束时间
44
+ * @param {number} interval 时间间隔
38
45
  * @return {*}
39
46
  * @Author: zhiwei.Wang
40
- * @Date: 2024-08-13 18:35
47
+ * @Date: 2024-08-13 19:37
41
48
  */
42
- export var checkProductByTime = function checkProductByTime(list) {
43
- var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
44
- var bol = true;
49
+ export var isInterval = function isInterval(time1, time2) {
50
+ var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
51
+ return time2 - time1 < interval;
52
+ };
53
+
54
+ /**
55
+ * @title: 根据时间间隔格式化服务列表
56
+ * @description: 防止短时间内添加多个相同服务, 如果两个服务的时间间隔小于1秒,则合并为一个服务
57
+ * @param {any} list 服务列表
58
+ * @return {*}
59
+ * @Author: zhiwei.Wang
60
+ * @Date: 2024-08-13 19:36
61
+ */
62
+ export var formatServiceListByTime = function formatServiceListByTime(list) {
45
63
  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;
64
+ var _list = _toConsumableArray(list);
65
+ var length = _list.length;
66
+
67
+ // 如果只有一个服务,则直接返回
68
+ if (length > 1) {
69
+ var _list2, _list3;
70
+ var start = (_list2 = _list[length - 2]) === null || _list2 === void 0 ? void 0 : _list2._time;
71
+ var end = (_list3 = _list[length - 1]) === null || _list3 === void 0 ? void 0 : _list3._time;
72
+
73
+ // 如果两个服务都有time 并且在同一个时间段内,则合并为一个服务
74
+ if (start && end && isInterval(start, end)) {
75
+ _list.pop();
76
+ return _list;
77
+ } else {
78
+ return list;
52
79
  }
80
+ } else {
81
+ return list;
53
82
  }
54
- } catch (err) {}
55
- return bol;
83
+ } catch (err) {
84
+ return list;
85
+ }
56
86
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FormState } from "../model";
2
+ import { FormState } from '../model';
3
3
  export declare const walkInData: {
4
4
  id: number;
5
5
  nickname: string;
@@ -25,6 +25,7 @@ __export(model_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(model_exports);
27
27
  var import_utils = require("@pisell/utils");
28
+ var import_utils2 = require("./utils");
28
29
  var walkInData = {
29
30
  id: 1,
30
31
  nickname: "Select a customer"
@@ -44,7 +45,13 @@ var { Provider, Context } = (0, import_utils.miniRedux)({
44
45
  state.setGlobalState({ client: { ...state.client, ...payload } });
45
46
  },
46
47
  setService(state, payload) {
47
- state.setGlobalState({ service: { ...state.service, ...payload } });
48
+ let obj = {};
49
+ if (payload.value) {
50
+ obj.value = (0, import_utils2.formatServiceListByTime)(payload.value);
51
+ }
52
+ state.setGlobalState({
53
+ service: { ...state.service, ...payload, ...obj }
54
+ });
48
55
  },
49
56
  setDate(state, payload) {
50
57
  state.setGlobalState({ date: { ...state.date, ...payload } });
@@ -60,7 +60,8 @@ var shopList = [
60
60
  6080,
61
61
  6978,
62
62
  7386,
63
- 6848
63
+ 6848,
64
+ 6305
64
65
  ];
65
66
  var Info = () => {
66
67
  var _a, _b, _c, _d;
@@ -47,7 +47,6 @@ 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");
51
50
  var submitLock = false;
52
51
  var Info = () => {
53
52
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
@@ -247,9 +246,7 @@ var Info = () => {
247
246
  _item._time = (/* @__PURE__ */ new Date()).getTime();
248
247
  let _id = _item == null ? void 0 : _item._id;
249
248
  if (!_list.some((d) => d._id === _id)) {
250
- if ((0, import_utils5.checkProductByTime)(_list)) {
251
- _list.push(_item);
252
- }
249
+ _list.push(_item);
253
250
  } else {
254
251
  _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
255
252
  }
@@ -2,12 +2,22 @@ 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
4
  /**
5
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
5
+ * @title: 判断两个时间是否在同一个时间段内
6
6
  * @description:
7
- * @param {any} list
8
- * @param {number} interval
7
+ * @param {number} time1 开始时间
8
+ * @param {number} time2 结束时间
9
+ * @param {number} interval 时间间隔
9
10
  * @return {*}
10
11
  * @Author: zhiwei.Wang
11
- * @Date: 2024-08-13 18:35
12
+ * @Date: 2024-08-13 19:37
12
13
  */
13
- export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
14
+ export declare const isInterval: (time1: number, time2: number, interval?: number) => boolean;
15
+ /**
16
+ * @title: 根据时间间隔格式化服务列表
17
+ * @description: 防止短时间内添加多个相同服务, 如果两个服务的时间间隔小于1秒,则合并为一个服务
18
+ * @param {any} list 服务列表
19
+ * @return {*}
20
+ * @Author: zhiwei.Wang
21
+ * @Date: 2024-08-13 19:36
22
+ */
23
+ export declare const formatServiceListByTime: (list: any[]) => any[];
@@ -19,8 +19,9 @@ 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
+ formatServiceListByTime: () => formatServiceListByTime,
23
23
  getIsBundleOrCombination: () => getIsBundleOrCombination,
24
+ isInterval: () => isInterval,
24
25
  moveItemToFront: () => moveItemToFront,
25
26
  uniqueByField: () => uniqueByField
26
27
  });
@@ -53,25 +54,35 @@ var moveItemToFront = (arr, targetId) => {
53
54
  }
54
55
  return arr;
55
56
  };
56
- var checkProductByTime = (list, interval = 1e3) => {
57
- var _a;
58
- let bol = true;
57
+ var isInterval = (time1, time2, interval = 1e3) => {
58
+ return time2 - time1 < interval;
59
+ };
60
+ var formatServiceListByTime = (list) => {
61
+ var _a, _b;
59
62
  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;
63
+ let _list = [...list];
64
+ const length = _list.length;
65
+ if (length > 1) {
66
+ let start = (_a = _list[length - 2]) == null ? void 0 : _a._time;
67
+ let end = (_b = _list[length - 1]) == null ? void 0 : _b._time;
68
+ if (start && end && isInterval(start, end)) {
69
+ _list.pop();
70
+ return _list;
71
+ } else {
72
+ return list;
65
73
  }
74
+ } else {
75
+ return list;
66
76
  }
67
77
  } catch (err) {
78
+ return list;
68
79
  }
69
- return bol;
70
80
  };
71
81
  // Annotate the CommonJS export names for ESM import in node:
72
82
  0 && (module.exports = {
73
- checkProductByTime,
83
+ formatServiceListByTime,
74
84
  getIsBundleOrCombination,
85
+ isInterval,
75
86
  moveItemToFront,
76
87
  uniqueByField
77
88
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.107",
3
+ "version": "3.0.109",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -59,9 +59,9 @@
59
59
  "react-infinite-scroll-component": "^6.1.0",
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
- "@pisell/utils": "1.0.27",
62
+ "@pisell/icon": "0.0.11",
63
63
  "@pisell/date-picker": "1.0.91",
64
- "@pisell/icon": "0.0.11"
64
+ "@pisell/utils": "1.0.27"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^18.0.0",