@pisell/private-materials 3.0.133 → 3.0.135

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.
@@ -144,25 +144,26 @@ var eftpos_default = (props) => {
144
144
  const onDelDevice = (id) => {
145
145
  return onDel(id);
146
146
  };
147
- const onEditDevice = (device) => {
148
- if (!device) {
149
- setStatus(import_const.DeviceEnum.Add);
150
- const field = getField(type);
151
- const list = (0, import_const.getCommByFields)({ field, getComm });
152
- console.log(list);
153
- setDeviceCommList(list);
154
- } else {
147
+ const onEditDevice = async (device) => {
148
+ if (device) {
155
149
  deviceIdRef.current = device.id;
156
- const field = getField(type, import_const.DeviceEnum.Edit);
157
- const list = (0, import_const.getCommByFields)({ field, value: device, getComm });
150
+ const field2 = getField(type, import_const.DeviceEnum.Edit);
151
+ const list2 = await (0, import_const.getCommByFields)({ field: field2, value: device, getComm });
158
152
  setStatus(import_const.DeviceEnum.Edit);
159
- setDeviceCommList(list);
153
+ setDeviceCommList(list2);
154
+ setPage("edit");
155
+ return;
160
156
  }
157
+ setStatus(import_const.DeviceEnum.Add);
158
+ const field = getField(type);
159
+ const list = await (0, import_const.getCommByFields)({ field, getComm });
160
+ console.log(list);
161
+ setDeviceCommList(list);
161
162
  setPage("edit");
162
163
  };
163
- const onRepair = (device) => {
164
+ const onRepair = async (device) => {
164
165
  const field = getField(type, import_const.DeviceEnum.Repair);
165
- const list = (0, import_const.getCommByFields)({ field, value: device, getComm });
166
+ const list = await (0, import_const.getCommByFields)({ field, value: device, getComm });
166
167
  deviceIdRef.current = device.id;
167
168
  setDeviceCommList(list);
168
169
  setStatus(import_const.DeviceEnum.Repair);
@@ -238,7 +239,14 @@ var eftpos_default = (props) => {
238
239
  spinning: loading,
239
240
  wrapperClassName: "pisell-lowcode__pos_box"
240
241
  },
241
- /* @__PURE__ */ import_react.default.createElement(import_device.default, { formItemList: deviceItemList, onSave, key: `posdevice${type}` })
242
+ /* @__PURE__ */ import_react.default.createElement(
243
+ import_device.default,
244
+ {
245
+ formItemList: deviceItemList,
246
+ onSave,
247
+ key: `posdevice${type}`
248
+ }
249
+ )
242
250
  )
243
251
  ));
244
252
  }
@@ -273,7 +281,14 @@ var eftpos_default = (props) => {
273
281
  spinning: loading,
274
282
  wrapperClassName: "pisell-lowcode__pos_box"
275
283
  },
276
- /* @__PURE__ */ import_react.default.createElement(import_device.default, { formItemList: deviceItemList, onSave, key: `device${type}` })
284
+ /* @__PURE__ */ import_react.default.createElement(
285
+ import_device.default,
286
+ {
287
+ formItemList: deviceItemList,
288
+ onSave,
289
+ key: `device${type}`
290
+ }
291
+ )
277
292
  )
278
293
  ));
279
294
  };
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { PayProps, PosProps } from './const';
3
3
  import './device.less';
4
- declare const _default: ({ api, onChange, onClose, className, isIpad, net, }: {
4
+ declare const _default: ({ api, onChange, onClose, className, device_number, isIpad, net, }: {
5
5
  api: PayProps['api'];
6
6
  className?: string | undefined;
7
- onChange?: ((status: "page" | "success" | "fail", params?: string | {
7
+ onChange?: ((status: "fail" | "success" | "page", params?: string | {
8
8
  [keys: string]: unknown;
9
9
  } | undefined) => void) | undefined;
10
10
  onClose: () => void;
11
+ device_number?: string | number | undefined;
11
12
  isIpad: boolean;
12
13
  net: boolean;
13
14
  }) => React.JSX.Element;
@@ -45,6 +45,7 @@ var device_default = ({
45
45
  onChange,
46
46
  onClose,
47
47
  className = "",
48
+ device_number,
48
49
  isIpad,
49
50
  net
50
51
  }) => {
@@ -74,6 +75,30 @@ var device_default = ({
74
75
  (res) => {
75
76
  setLoading(false);
76
77
  if (res && Array.isArray(res.list) && res.list.length > 0) {
78
+ if (device_number) {
79
+ const hostDeviceList = res.list.filter(
80
+ (item) => {
81
+ var _a, _b;
82
+ return (_b = (_a = item == null ? void 0 : item.setting) == null ? void 0 : _a.devices) == null ? void 0 : _b.some(
83
+ (i) => i.number === device_number
84
+ );
85
+ }
86
+ );
87
+ if (hostDeviceList.length >= 1) {
88
+ setDataStaus(true);
89
+ setList(hostDeviceList);
90
+ if (hostDeviceList.length === 1) {
91
+ dispatch((0, import_store.updateDevice)({ device: hostDeviceList[0] }));
92
+ if (typeof api.selectDevice === "function") {
93
+ api.selectDevice(hostDeviceList[0]);
94
+ }
95
+ if (typeof onChange === "function") {
96
+ onChange("page", mode === import_const.ModeEnum.Pay ? "amount" : "pay");
97
+ }
98
+ }
99
+ return;
100
+ }
101
+ }
77
102
  setDataStaus(true);
78
103
  setList(res.list);
79
104
  if (res.list.length === 1) {
@@ -48,6 +48,7 @@ import_utils.locales.init(import_locales.default, localStorage.getItem("umi_loca
48
48
  var App = ({
49
49
  action,
50
50
  getApi,
51
+ device_number,
51
52
  terminal,
52
53
  ...props
53
54
  }) => {
@@ -114,7 +115,8 @@ var App = ({
114
115
  onClose,
115
116
  isIpad,
116
117
  className: isIpad ? "pisell-lowcode__eft-pay-terminal" : "",
117
- net
118
+ net,
119
+ device_number
118
120
  }
119
121
  );
120
122
  }
@@ -144,7 +146,7 @@ var App = ({
144
146
  );
145
147
  };
146
148
  var eftposPay_default = (props) => {
147
- var _a, _b, _c, _d;
149
+ var _a, _b, _c, _d, _e, _f;
148
150
  const context = (0, import_useEngineContext.default)();
149
151
  const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || { store: {} };
150
152
  const mode = (0, import_react.useMemo)(() => {
@@ -180,6 +182,7 @@ var eftposPay_default = (props) => {
180
182
  (0, import_react.useEffect)(() => {
181
183
  document.body.id = "body";
182
184
  }, []);
185
+ console.log("props?.params?.device_number = ", (_e = props == null ? void 0 : props.params) == null ? void 0 : _e.device_number);
183
186
  return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state }, /* @__PURE__ */ import_react.default.createElement(
184
187
  App,
185
188
  {
@@ -187,7 +190,8 @@ var eftposPay_default = (props) => {
187
190
  params: props.params,
188
191
  onChangeStatus,
189
192
  terminal: props.terminal,
190
- action
193
+ action,
194
+ device_number: (_f = props == null ? void 0 : props.params) == null ? void 0 : _f.device_number
191
195
  }
192
196
  ));
193
197
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.133",
3
+ "version": "3.0.135",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -60,9 +60,9 @@
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
62
  "@pisell/utils": "1.0.42",
63
- "@pisell/date-picker": "1.0.100",
64
63
  "@pisell/materials": "3.0.47",
65
- "@pisell/icon": "0.0.11"
64
+ "@pisell/icon": "0.0.11",
65
+ "@pisell/date-picker": "1.0.100"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0",