@pisell/private-materials 3.0.19 → 3.0.21

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.
@@ -39,6 +39,10 @@ var Info = function Info() {
39
39
  var _useContext = useContext(Context),
40
40
  state = _useContext.state,
41
41
  dispatch = _useContext.dispatch;
42
+ var _useState3 = useState(false),
43
+ _useState4 = _slicedToArray(_useState3, 2),
44
+ loading = _useState4[0],
45
+ setLoading = _useState4[1];
42
46
  var context = useEngineContext();
43
47
  request.setRequest(context.appHelper.utils.request);
44
48
  var setDefaultService = /*#__PURE__*/function () {
@@ -72,21 +76,25 @@ var Info = function Info() {
72
76
  }
73
77
  return _context.abrupt("return");
74
78
  case 9:
79
+ setLoading(true);
75
80
  product = list[0];
76
- _context.next = 12;
81
+ _context.next = 13;
77
82
  return getProductDetail(product.id, {
78
83
  schedule_date: state.date.value.format("YYYY-MM-DD")
79
84
  });
80
- case 12:
85
+ case 13:
81
86
  detail = _context.sent;
82
87
  // 商品是套餐或单规格多规格
83
- isBundleOrCombination = getIsBundleOrCombination(detail.data); // 套餐商品单规格多规格不设置默认
88
+ isBundleOrCombination = getIsBundleOrCombination(detail.data);
89
+ setLoading(false);
90
+
91
+ // 套餐商品单规格多规格不设置默认
84
92
  if (!isBundleOrCombination) {
85
- _context.next = 16;
93
+ _context.next = 18;
86
94
  break;
87
95
  }
88
96
  return _context.abrupt("return");
89
- case 16:
97
+ case 18:
90
98
  _item = _objectSpread(_objectSpread({}, product), {}, {
91
99
  product_id: product.id,
92
100
  _id: getUniqueId(),
@@ -111,7 +119,7 @@ var Info = function Info() {
111
119
  edit: true
112
120
  }
113
121
  });
114
- case 19:
122
+ case 21:
115
123
  case "end":
116
124
  return _context.stop();
117
125
  }
@@ -128,7 +136,8 @@ var Info = function Info() {
128
136
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
129
137
  while (1) switch (_context2.prev = _context2.next) {
130
138
  case 0:
131
- _context2.next = 2;
139
+ setLoading(true);
140
+ _context2.next = 3;
132
141
  return state.apis.getServices({
133
142
  skip: 1,
134
143
  num: 500,
@@ -142,8 +151,9 @@ var Info = function Info() {
142
151
  open_quotation: 1,
143
152
  with_schedule: 1
144
153
  });
145
- case 2:
154
+ case 3:
146
155
  data = _context2.sent;
156
+ setLoading(false);
147
157
  setDefaultService(data === null || data === void 0 ? void 0 : data.list);
148
158
  dispatch({
149
159
  type: "setService",
@@ -151,7 +161,7 @@ var Info = function Info() {
151
161
  services: (data === null || data === void 0 ? void 0 : data.list) || []
152
162
  }
153
163
  });
154
- case 5:
164
+ case 7:
155
165
  case "end":
156
166
  return _context2.stop();
157
167
  }
@@ -254,6 +264,7 @@ var Info = function Info() {
254
264
  height: 20
255
265
  }
256
266
  }) : /*#__PURE__*/React.createElement(AddButton, {
267
+ loading: loading,
257
268
  showSub: false,
258
269
  title: locales.getText("pisell2.text.add-a-service"),
259
270
  subTitle: locales.getText("pisell2.text.add-another-service"),
@@ -270,7 +281,7 @@ var Info = function Info() {
270
281
  height: 20
271
282
  }
272
283
  });
273
- }, [state.renderType, showAddButton, isService, state.service.value]);
284
+ }, [state.renderType, showAddButton, isService, state.service.value, loading]);
274
285
  return /*#__PURE__*/React.createElement(React.Fragment, null, addButton, /*#__PURE__*/React.createElement(Drawer, {
275
286
  open: state.service.addModal,
276
287
  title: locales.getText("pisell2.text.select-service"),
@@ -27,7 +27,7 @@ var sortArrayByOrder = function sortArrayByOrder(arr1, arr2, reverse) {
27
27
  var _b = arr2.findIndex(function (item) {
28
28
  return item.form_id === b.form_id;
29
29
  });
30
- return reverse ? _a - _b : _b - _a;
30
+ return reverse ? _b - _a : _a - _b;
31
31
  });
32
32
  };
33
33
  var SelectResourcesTable = function SelectResourcesTable(_ref) {
@@ -49,6 +49,7 @@ var Info = () => {
49
49
  var _a;
50
50
  const [search, setSearch] = (0, import_react.useState)("");
51
51
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
52
+ const [loading, setLoading] = (0, import_react.useState)(false);
52
53
  const context = (0, import_useEngineContext.default)();
53
54
  import_utils2.request.setRequest(context.appHelper.utils.request);
54
55
  const setDefaultService = async (list) => {
@@ -65,11 +66,13 @@ var Info = () => {
65
66
  if (_list.length !== 0) {
66
67
  return;
67
68
  }
69
+ setLoading(true);
68
70
  let product = list[0];
69
71
  const detail = await (0, import_serve.getProductDetail)(product.id, {
70
72
  schedule_date: state.date.value.format("YYYY-MM-DD")
71
73
  });
72
74
  const isBundleOrCombination = (0, import_utils.getIsBundleOrCombination)(detail.data);
75
+ setLoading(false);
73
76
  if (isBundleOrCombination)
74
77
  return;
75
78
  let _item = {
@@ -100,6 +103,7 @@ var Info = () => {
100
103
  };
101
104
  const getServices = async () => {
102
105
  var _a2;
106
+ setLoading(true);
103
107
  let data = await state.apis.getServices({
104
108
  skip: 1,
105
109
  num: 500,
@@ -113,6 +117,7 @@ var Info = () => {
113
117
  open_quotation: 1,
114
118
  with_schedule: 1
115
119
  });
120
+ setLoading(false);
116
121
  setDefaultService(data == null ? void 0 : data.list);
117
122
  dispatch({
118
123
  type: "setService",
@@ -208,6 +213,7 @@ var Info = () => {
208
213
  return isService ? /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 20 } }) : /* @__PURE__ */ import_react.default.createElement(
209
214
  import_addButton.default,
210
215
  {
216
+ loading,
211
217
  showSub: false,
212
218
  title: import_utils3.locales.getText("pisell2.text.add-a-service"),
213
219
  subTitle: import_utils3.locales.getText("pisell2.text.add-another-service"),
@@ -224,7 +230,7 @@ var Info = () => {
224
230
  onClick: handleSelectService
225
231
  }
226
232
  ) : /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 20 } });
227
- }, [state.renderType, showAddButton, isService, state.service.value]);
233
+ }, [state.renderType, showAddButton, isService, state.service.value, loading]);
228
234
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, addButton, /* @__PURE__ */ import_react.default.createElement(
229
235
  import_drawer.default,
230
236
  {
@@ -41,7 +41,7 @@ var sortArrayByOrder = (arr1, arr2, reverse) => {
41
41
  return (arr1 || []).sort((a, b) => {
42
42
  let _a = arr2.findIndex((item) => item.form_id === a.form_id);
43
43
  let _b = arr2.findIndex((item) => item.form_id === b.form_id);
44
- return reverse ? _a - _b : _b - _a;
44
+ return reverse ? _b - _a : _a - _b;
45
45
  });
46
46
  };
47
47
  var SelectResourcesTable = ({ value, onChange }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",