@pisell/private-materials 3.0.98 → 3.0.100

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.
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  interface CustomSelectProps {
4
4
  options: any[];
5
5
  onValueChange: (value: any[]) => void;
@@ -15,7 +15,7 @@ interface CustomSelectProps {
15
15
  loading?: boolean;
16
16
  previewItemClassName?: string;
17
17
  optionClassName?: string;
18
- mode?: "single" | "multiple" | "form";
18
+ mode?: 'single' | 'multiple' | 'form';
19
19
  filterItem?: (item: any, search: string) => boolean;
20
20
  isPreview?: boolean;
21
21
  name?: string;
@@ -13,17 +13,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  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; }
14
14
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
- import React, { useEffect, useMemo, useState, useImperativeHandle, forwardRef, useRef } from "react";
17
- import PlusCircle from "@pisell/icon/es/PlusCircle";
18
- import SearchLg from "@pisell/icon/es/SearchLg";
19
- import DotsVertical from "@pisell/icon/es/DotsVertical";
20
- import { changeArray, getItemByArray } from "@pisell/utils";
16
+ import React, { useEffect, useMemo, useState, useImperativeHandle, forwardRef, useRef } from 'react';
17
+ import PlusCircle from '@pisell/icon/es/PlusCircle';
18
+ import SearchLg from '@pisell/icon/es/SearchLg';
19
+ import DotsVertical from '@pisell/icon/es/DotsVertical';
20
+ import { changeArray, getItemByArray } from '@pisell/utils';
21
21
  import Drawer from "../drawer";
22
22
  import AddButton from "../addButton";
23
- import classNames from "classnames";
24
- import { Input, List, Skeleton, Dropdown, Checkbox, Button } from "antd";
23
+ import classNames from 'classnames';
24
+ import { Input, List, Skeleton, Dropdown, Checkbox, Button } from 'antd';
25
25
  import "./index.less";
26
- import { locales } from "@pisell/utils";
26
+ import { locales } from '@pisell/utils';
27
27
  /**
28
28
  * @title: 选择器
29
29
  * @description:
@@ -39,11 +39,11 @@ var CustomSelect = function CustomSelect(props, ref) {
39
39
  onValueChange = props.onValueChange,
40
40
  value = props.value,
41
41
  _props$rowKey = props.rowKey,
42
- rowKey = _props$rowKey === void 0 ? "id" : _props$rowKey,
42
+ rowKey = _props$rowKey === void 0 ? 'id' : _props$rowKey,
43
43
  addButtonProps = props.addButtonProps,
44
44
  drawerProps = props.drawerProps,
45
45
  _props$createItemText = props.createItemText,
46
- createItemText = _props$createItemText === void 0 ? "" : _props$createItemText,
46
+ createItemText = _props$createItemText === void 0 ? '' : _props$createItemText,
47
47
  previewItemRender = props.previewItemRender,
48
48
  previewItemTitleRender = props.previewItemTitleRender,
49
49
  addButtonRender = props.addButtonRender,
@@ -52,11 +52,11 @@ var CustomSelect = function CustomSelect(props, ref) {
52
52
  previewItemClassName = props.previewItemClassName,
53
53
  optionClassName = props.optionClassName,
54
54
  _props$mode = props.mode,
55
- mode = _props$mode === void 0 ? "single" : _props$mode,
55
+ mode = _props$mode === void 0 ? 'single' : _props$mode,
56
56
  _props$isPreview = props.isPreview,
57
57
  isPreview = _props$isPreview === void 0 ? true : _props$isPreview,
58
58
  _props$name = props.name,
59
- name = _props$name === void 0 ? "item" : _props$name,
59
+ name = _props$name === void 0 ? 'item' : _props$name,
60
60
  handleCreateItem = props.handleCreateItem,
61
61
  handleViewItem = props.handleViewItem,
62
62
  _props$virtualListHei = props.virtualListHeight,
@@ -81,7 +81,7 @@ var CustomSelect = function CustomSelect(props, ref) {
81
81
  _value = _useState2[0],
82
82
  set_value = _useState2[1];
83
83
  // 搜索值
84
- var _useState3 = useState(""),
84
+ var _useState3 = useState(''),
85
85
  _useState4 = _slicedToArray(_useState3, 2),
86
86
  search = _useState4[0],
87
87
  setSearch = _useState4[1];
@@ -97,11 +97,14 @@ var CustomSelect = function CustomSelect(props, ref) {
97
97
  setOpen(false);
98
98
  }
99
99
  }, [modalOpen]);
100
+ var strValue = useMemo(function () {
101
+ return JSON.stringify(value);
102
+ }, [value]);
100
103
 
101
104
  // 当value 发生变化时, 将外部value 处理成内部value
102
105
  useEffect(function () {
103
106
  initValue();
104
- }, [value]);
107
+ }, [strValue]);
105
108
 
106
109
  /**
107
110
  * @title: 转换value到内部
@@ -133,7 +136,7 @@ var CustomSelect = function CustomSelect(props, ref) {
133
136
  // 关闭
134
137
  setOpen(false);
135
138
  // 清空搜索
136
- setSearch("");
139
+ setSearch('');
137
140
  // 如果直接关闭弹窗, 则将value恢复到上一次的数据
138
141
  if (reset) {
139
142
  initValue();
@@ -211,7 +214,7 @@ var CustomSelect = function CustomSelect(props, ref) {
211
214
  var _val = changeArray(_value, item, rowKey);
212
215
 
213
216
  // 单选则直接返回
214
- if (mode === "single") {
217
+ if (mode === 'single') {
215
218
  handleApply([item]);
216
219
  }
217
220
  set_value(_val);
@@ -270,7 +273,7 @@ var CustomSelect = function CustomSelect(props, ref) {
270
273
  if (filterItem) {
271
274
  return filterItem(d, search);
272
275
  }
273
- return isIncludes(d.main_field || "");
276
+ return isIncludes(d.main_field || '');
274
277
  });
275
278
  }
276
279
  return _list;
@@ -332,19 +335,19 @@ var CustomSelect = function CustomSelect(props, ref) {
332
335
  */
333
336
  var menuItems = useMemo(function () {
334
337
  var list = [{
335
- key: "view",
336
- label: "".concat(locales.getText("pisell2.text.view"), " ").concat(name)
338
+ key: 'view',
339
+ label: "".concat(locales.getText('pisell2.text.view'), " ").concat(name)
337
340
  }, {
338
- key: "change",
339
- label: "".concat(locales.getText("pisell2.text.change"), " ").concat(name)
341
+ key: 'change',
342
+ label: "".concat(locales.getText('pisell2.text.change'), " ").concat(name)
340
343
  }, {
341
- key: "remove",
342
- label: "".concat(locales.getText("pisell2.text.remove"), " ").concat(name)
344
+ key: 'remove',
345
+ label: "".concat(locales.getText('pisell2.text.remove'), " ").concat(name)
343
346
  }];
344
347
  // 禁止编辑时 只展示view
345
348
  if (disabled) {
346
349
  list = list.filter(function (d) {
347
- return d.key === "view";
350
+ return d.key === 'view';
348
351
  });
349
352
  }
350
353
  return list;
@@ -360,13 +363,13 @@ var CustomSelect = function CustomSelect(props, ref) {
360
363
  */
361
364
  var isShowAddButton = useMemo(function () {
362
365
  // (多选 || (单选 && 没有选择值)) && 没有禁止点击
363
- return (mode === "multiple" || mode === "single" && !isMore) && !disabled;
366
+ return (mode === 'multiple' || mode === 'single' && !isMore) && !disabled;
364
367
  }, [mode, isMore, disabled]);
365
368
  return /*#__PURE__*/React.createElement("div", null, isPreview ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
366
369
  className: "pisell-lowcode__custom-select-cards"
367
370
  }, _value.map(function (d, index) {
368
371
  return /*#__PURE__*/React.createElement(React.Fragment, null, previewItemTitleRender === null || previewItemTitleRender === void 0 ? void 0 : previewItemTitleRender(d, index, _value), /*#__PURE__*/React.createElement("div", {
369
- className: classNames("pisell-lowcode__custom-select-card", previewItemClassName),
372
+ className: classNames('pisell-lowcode__custom-select-card', previewItemClassName),
370
373
  key: d[rowKey]
371
374
  }, previewItemRender === null || previewItemRender === void 0 ? void 0 : previewItemRender(d), showDropDown && /*#__PURE__*/React.createElement("div", {
372
375
  onClick: function onClick(e) {
@@ -415,7 +418,7 @@ var CustomSelect = function CustomSelect(props, ref) {
415
418
  marginTop: 16,
416
419
  height: 44
417
420
  },
418
- placeholder: locales.getText("pisell2.text.search"),
421
+ placeholder: locales.getText('pisell2.text.search'),
419
422
  value: search,
420
423
  allowClear: true,
421
424
  onChange: function onChange(e) {
@@ -430,7 +433,7 @@ var CustomSelect = function CustomSelect(props, ref) {
430
433
  handleCreateItem === null || handleCreateItem === void 0 ? void 0 : handleCreateItem();
431
434
  },
432
435
  style: {
433
- padding: createItemText ? 16 : "16px 0 0 0"
436
+ padding: createItemText ? 16 : '16px 0 0 0'
434
437
  }
435
438
  }, createItemText && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PlusCircle, {
436
439
  className: "pisell-lowcode__custom-select-create-icon"
@@ -438,16 +441,16 @@ var CustomSelect = function CustomSelect(props, ref) {
438
441
  className: "pisell-lowcode__custom-select-create-txt"
439
442
  }, createItemText))))
440
443
  }, drawerProps, {
441
- footer: mode === "multiple" && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
444
+ footer: mode === 'multiple' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
442
445
  style: {
443
- width: "100%"
446
+ width: '100%'
444
447
  },
445
448
  type: "primary",
446
449
  size: "large",
447
450
  onClick: function onClick() {
448
451
  handleApply();
449
452
  }
450
- }, locales.getText("pisell2.text.apply")))
453
+ }, locales.getText('pisell2.text.apply')))
451
454
  }), /*#__PURE__*/React.createElement(List, {
452
455
  itemLayout: "horizontal",
453
456
  dataSource: renderList,
@@ -455,8 +458,8 @@ var CustomSelect = function CustomSelect(props, ref) {
455
458
  loadMore: loadMore,
456
459
  renderItem: function renderItem(item) {
457
460
  return /*#__PURE__*/React.createElement(List.Item, {
458
- className: classNames("pisell-lowcode__custom-select-card-list-item", optionClassName, {
459
- "pisell-lowcode__custom-select-card-list-item-active": getItemByArray(_value, item, rowKey)
461
+ className: classNames('pisell-lowcode__custom-select-card-list-item', optionClassName, {
462
+ 'pisell-lowcode__custom-select-card-list-item-active': getItemByArray(_value, item, rowKey)
460
463
  }),
461
464
  onClick: function onClick() {
462
465
  handleSelectItem(item);
@@ -470,7 +473,7 @@ var CustomSelect = function CustomSelect(props, ref) {
470
473
  paragraph: false
471
474
  }) : /*#__PURE__*/React.createElement("div", {
472
475
  className: "pisell-lowcode__custom-select-card-list-item-content"
473
- }, mode === "multiple" && /*#__PURE__*/React.createElement(Checkbox, {
476
+ }, mode === 'multiple' && /*#__PURE__*/React.createElement(Checkbox, {
474
477
  className: "custom-select-checkbox",
475
478
  checked: getItemByArray(_value, item, rowKey)
476
479
  }), optionRender(item)));
@@ -205,6 +205,7 @@ var Info = function Info() {
205
205
  var handleSelectProduct = function handleSelectProduct(item, type) {
206
206
  // 是否有单规格 组合规格 套餐, 如果没有不需要打开弹窗
207
207
  var isEject = type === 'detail' || item.bundle_group_count > 0;
208
+ var lock = false;
208
209
  state.action({
209
210
  type: 'pisell1.handleOpenProductModal',
210
211
  data: {
@@ -219,6 +220,16 @@ var Info = function Info() {
219
220
  is_eject: isEject ? 1 : 0
220
221
  },
221
222
  callback: function callback(e) {
223
+ // 防止选择商品弹窗多次触发callback
224
+ if (lock) {
225
+ return;
226
+ }
227
+ lock = true;
228
+
229
+ // 1秒后解除
230
+ setTimeout(function () {
231
+ lock = false;
232
+ }, 1000);
222
233
  var cacheItem = _objectSpread(_objectSpread({}, item), {}, {
223
234
  product_id: item.id,
224
235
  _id: getUniqueId(),
@@ -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
+ var submitLock = false;
37
38
  var Info = function Info() {
38
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;
39
40
  var _Form$useForm = Form.useForm(),
@@ -324,6 +325,7 @@ var Info = function Info() {
324
325
  discount: discount
325
326
  });
326
327
  };
328
+
327
329
  /**
328
330
  * @title: 提交,
329
331
  * @description:
@@ -334,6 +336,16 @@ var Info = function Info() {
334
336
  */
335
337
  var onFinish = function onFinish(values) {
336
338
  var _currentResource$_ext;
339
+ // 防止多次提交, 增加锁
340
+ if (submitLock) {
341
+ return;
342
+ }
343
+ submitLock = true;
344
+
345
+ // 1500毫秒后解除
346
+ setTimeout(function () {
347
+ submitLock = false;
348
+ }, 1500);
337
349
  var _list = _toConsumableArray(state.service.value);
338
350
  var _item = _objectSpread(_objectSpread({}, state.service.cacheItem), {}, {
339
351
  autoClose: false,
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  interface CustomSelectProps {
4
4
  options: any[];
5
5
  onValueChange: (value: any[]) => void;
@@ -15,7 +15,7 @@ interface CustomSelectProps {
15
15
  loading?: boolean;
16
16
  previewItemClassName?: string;
17
17
  optionClassName?: string;
18
- mode?: "single" | "multiple" | "form";
18
+ mode?: 'single' | 'multiple' | 'form';
19
19
  filterItem?: (item: any, search: string) => boolean;
20
20
  isPreview?: boolean;
21
21
  name?: string;
@@ -86,9 +86,12 @@ var CustomSelect = (props, ref) => {
86
86
  setOpen(false);
87
87
  }
88
88
  }, [modalOpen]);
89
+ const strValue = (0, import_react.useMemo)(() => {
90
+ return JSON.stringify(value);
91
+ }, [value]);
89
92
  (0, import_react.useEffect)(() => {
90
93
  initValue();
91
- }, [value]);
94
+ }, [strValue]);
92
95
  const initValue = () => {
93
96
  let _val = value;
94
97
  if (!value) {
@@ -162,6 +162,7 @@ var Info = () => {
162
162
  };
163
163
  const handleSelectProduct = (item, type) => {
164
164
  const isEject = type === "detail" || item.bundle_group_count > 0;
165
+ let lock = false;
165
166
  state.action({
166
167
  type: "pisell1.handleOpenProductModal",
167
168
  data: {
@@ -177,6 +178,13 @@ var Info = () => {
177
178
  },
178
179
  callback: (e) => {
179
180
  var _a2, _b2;
181
+ if (lock) {
182
+ return;
183
+ }
184
+ lock = true;
185
+ setTimeout(() => {
186
+ lock = false;
187
+ }, 1e3);
180
188
  let cacheItem = {
181
189
  ...item,
182
190
  product_id: item.id,
@@ -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 submitLock = false;
50
51
  var Info = () => {
51
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;
52
53
  const [form] = import_antd.Form.useForm();
@@ -214,6 +215,13 @@ var Info = () => {
214
215
  };
215
216
  const onFinish = (values) => {
216
217
  var _a2;
218
+ if (submitLock) {
219
+ return;
220
+ }
221
+ submitLock = true;
222
+ setTimeout(() => {
223
+ submitLock = false;
224
+ }, 1500);
217
225
  let _list = [...state.service.value];
218
226
  let _item = {
219
227
  ...state.service.cacheItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.98",
3
+ "version": "3.0.100",
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
63
  "@pisell/date-picker": "1.0.91",
63
- "@pisell/icon": "0.0.11",
64
- "@pisell/utils": "1.0.27"
64
+ "@pisell/icon": "0.0.11"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^18.0.0",