@pisell/private-materials 3.4.156 → 3.4.158
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +14 -14
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +14 -14
- package/es/index.d.ts +7 -1
- package/es/index.js +5 -1
- package/es/plus/inventory/BindingModal.js +94 -0
- package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryItemManagement.js +204 -0
- package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryLocationManagement.js +296 -0
- package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/es/plus/inventory/InventoryUnitManagement.js +144 -0
- package/es/plus/inventory/ItemDrawer.js +266 -0
- package/es/plus/inventory/RecordDialog.js +141 -0
- package/es/plus/inventory/StockList.js +132 -0
- package/es/plus/inventory/api.js +66 -0
- package/es/plus/inventory/components.js +172 -0
- package/es/plus/inventory/context.js +118 -0
- package/es/plus/inventory/forms.js +46 -0
- package/es/plus/inventory/hooks.js +235 -0
- package/es/plus/inventory/index.less +559 -0
- package/es/plus/inventory/locales.js +277 -0
- package/es/plus/inventory/types.d.ts +10 -0
- package/es/plus/inventory/utils.js +24 -0
- package/es/plus/pisellSupersetDashboard/README.md +291 -0
- package/es/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/es/plus/pisellSupersetDashboard/index.js +187 -0
- package/es/plus/pisellSupersetDashboard/index.less +83 -0
- package/es/plus/pisellSupersetDashboard/locales.js +36 -0
- package/es/plus/pisellSupersetDashboard/serve.js +51 -0
- package/es/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
- package/lib/index.d.ts +7 -1
- package/lib/index.js +134 -126
- package/lib/plus/inventory/BindingModal.js +96 -0
- package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryItemManagement.js +206 -0
- package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
- package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
- package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
- package/lib/plus/inventory/ItemDrawer.js +268 -0
- package/lib/plus/inventory/RecordDialog.js +143 -0
- package/lib/plus/inventory/StockList.js +134 -0
- package/lib/plus/inventory/api.js +66 -0
- package/lib/plus/inventory/components.js +181 -0
- package/lib/plus/inventory/context.js +121 -0
- package/lib/plus/inventory/forms.js +50 -0
- package/lib/plus/inventory/hooks.js +240 -0
- package/lib/plus/inventory/index.less +559 -0
- package/lib/plus/inventory/locales.js +277 -0
- package/lib/plus/inventory/types.d.ts +10 -0
- package/lib/plus/inventory/utils.js +30 -0
- package/lib/plus/pisellSupersetDashboard/README.md +291 -0
- package/lib/plus/pisellSupersetDashboard/index.d.ts +15 -0
- package/lib/plus/pisellSupersetDashboard/index.js +189 -0
- package/lib/plus/pisellSupersetDashboard/index.less +83 -0
- package/lib/plus/pisellSupersetDashboard/locales.js +36 -0
- package/lib/plus/pisellSupersetDashboard/serve.js +52 -0
- package/lib/plus/pisellSupersetDashboard/types.d.ts +17 -0
- package/lowcode/inventory-item-management/meta.ts +20 -0
- package/lowcode/inventory-location-management/meta.ts +20 -0
- package/lowcode/inventory-unit-management/meta.ts +20 -0
- package/lowcode/pisell-superset-dashboard/meta.ts +75 -0
- package/package.json +5 -3
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
+
import { inventoryQuantity } from "./utils.js";
|
|
4
|
+
import { InventoryProvider, useInventory } from "./context.js";
|
|
5
|
+
import { useInventoryList, useInventoryMutation, useInventoryOptions, useInventoryQuery } from "./hooks.js";
|
|
6
|
+
import { InventoryHeader, InventoryNavLoading, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
|
|
7
|
+
import RecordDialog from "./RecordDialog.js";
|
|
8
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
9
|
+
import { Breadcrumb, Button, Space, Tooltip } from "antd";
|
|
10
|
+
import { useDebounce } from "ahooks";
|
|
11
|
+
import { CaretRightOutlined, PlusOutlined, ReloadOutlined, RightOutlined } from "@ant-design/icons";
|
|
12
|
+
//#region src/plus/inventory/InventoryLocationManagement.tsx
|
|
13
|
+
function NavigationLocation({ record, expanded, onToggle, selection, onSelect, revision, selectedShelf }) {
|
|
14
|
+
const { t, name } = useInventory();
|
|
15
|
+
const shelves = useInventoryOptions("shelf", { location_id: record.id }, expanded, revision);
|
|
16
|
+
const rows = (selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id) === record.id && !shelves.rows.some((shelf) => shelf.id === selectedShelf.id) ? [selectedShelf, ...shelves.rows] : shelves.rows;
|
|
17
|
+
return /* @__PURE__ */ React.createElement("div", { className: "inventory-nav-location" }, /* @__PURE__ */ React.createElement("div", { className: `inventory-nav-row ${selection.kind === "location" && selection.id === record.id ? "is-selected" : ""}` }, /* @__PURE__ */ React.createElement(Button, {
|
|
18
|
+
type: "text",
|
|
19
|
+
"aria-expanded": expanded,
|
|
20
|
+
"aria-label": t(expanded ? "collapse" : "expand"),
|
|
21
|
+
icon: /* @__PURE__ */ React.createElement(CaretRightOutlined, {
|
|
22
|
+
rotate: expanded ? 90 : 0,
|
|
23
|
+
style: { fontSize: 12 }
|
|
24
|
+
}),
|
|
25
|
+
onClick: onToggle
|
|
26
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
className: "inventory-nav-label",
|
|
29
|
+
onClick: () => onSelect({
|
|
30
|
+
kind: "location",
|
|
31
|
+
id: record.id
|
|
32
|
+
}),
|
|
33
|
+
title: name(record)
|
|
34
|
+
}, name(record), record.status === "inactive" && /* @__PURE__ */ React.createElement("span", {
|
|
35
|
+
className: "inventory-inactive-dot",
|
|
36
|
+
title: t("inactive")
|
|
37
|
+
}, " ", "· ", t("inactive")))), expanded && /* @__PURE__ */ React.createElement("div", { className: "inventory-nav-shelves" }, /* @__PURE__ */ React.createElement(RequestError, {
|
|
38
|
+
error: shelves.error,
|
|
39
|
+
retry: () => void shelves.reload()
|
|
40
|
+
}), rows.map((shelf) => /* @__PURE__ */ React.createElement("button", {
|
|
41
|
+
type: "button",
|
|
42
|
+
key: shelf.id,
|
|
43
|
+
className: `inventory-nav-row inventory-nav-shelf ${selection.kind === "shelf" && selection.id === shelf.id ? "is-selected" : ""}`,
|
|
44
|
+
onClick: () => onSelect({
|
|
45
|
+
kind: "shelf",
|
|
46
|
+
id: shelf.id
|
|
47
|
+
}),
|
|
48
|
+
title: name(shelf)
|
|
49
|
+
}, name(shelf), shelf.status === "inactive" && /* @__PURE__ */ React.createElement("span", { className: "inventory-inactive-dot" }, " ", "· ", t("inactive")))), shelves.loading && !shelves.hasMore && /* @__PURE__ */ React.createElement(InventoryNavLoading, null), !shelves.loading && !shelves.error && !rows.length && /* @__PURE__ */ React.createElement("span", { className: "inventory-nav-empty" }, t("empty")), shelves.hasMore && /* @__PURE__ */ React.createElement(Button, {
|
|
50
|
+
type: "text",
|
|
51
|
+
block: true,
|
|
52
|
+
loading: shelves.loading,
|
|
53
|
+
onClick: () => void shelves.loadMore()
|
|
54
|
+
}, t("loadMore"))));
|
|
55
|
+
}
|
|
56
|
+
function LocationPage({ className, style }) {
|
|
57
|
+
const { api, t, name, confirm, success, report } = useInventory();
|
|
58
|
+
const [selection, setSelection] = useState({ kind: "root" });
|
|
59
|
+
const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
|
|
60
|
+
const [navigationRevision, setNavigationRevision] = useState(0);
|
|
61
|
+
const [target, setTarget] = useState();
|
|
62
|
+
const selectionKey = JSON.stringify(selection);
|
|
63
|
+
const [filter, setFilter] = useState({
|
|
64
|
+
key: selectionKey,
|
|
65
|
+
search: ""
|
|
66
|
+
});
|
|
67
|
+
const search = filter.key === selectionKey ? filter.search : "";
|
|
68
|
+
const status = filter.key === selectionKey ? filter.status : void 0;
|
|
69
|
+
const debouncedSearch = useDebounce(useMemo(() => ({
|
|
70
|
+
key: selectionKey,
|
|
71
|
+
search
|
|
72
|
+
}), [selectionKey, search]), { wait: 300 });
|
|
73
|
+
const keyword = debouncedSearch.key === selectionKey ? debouncedSearch.search : "";
|
|
74
|
+
const mutation = useInventoryMutation();
|
|
75
|
+
const locations = useInventoryOptions("location", {}, true, navigationRevision);
|
|
76
|
+
const selected = useInventoryQuery(() => selection.kind === "root" ? Promise.resolve(null) : api.detail(selection.kind, selection.id, selection.kind === "shelf" ? ["location"] : void 0), selectionKey, selection.kind !== "root");
|
|
77
|
+
const selectedShelf = selection.kind === "shelf" ? selected.data : void 0;
|
|
78
|
+
const selectedLocation = selection.kind === "location" ? selected.data : selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location;
|
|
79
|
+
const resource = selection.kind === "root" ? "location" : selection.kind === "location" ? "shelf" : "space";
|
|
80
|
+
const list = useInventoryList(resource, _objectSpread2({
|
|
81
|
+
search: keyword || void 0,
|
|
82
|
+
status
|
|
83
|
+
}, selection.kind === "location" ? { location_id: selection.id } : selection.kind === "shelf" ? { shelf_id: selection.id } : {}), selection.kind === "root" || !!selected.data);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (selection.kind !== "root" && selected.data === null) {
|
|
86
|
+
report(new Error(t("missing")));
|
|
87
|
+
setSelection({ kind: "root" });
|
|
88
|
+
}
|
|
89
|
+
}, [
|
|
90
|
+
selected.data,
|
|
91
|
+
selectionKey,
|
|
92
|
+
report,
|
|
93
|
+
t
|
|
94
|
+
]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id) setExpanded((previous) => new Set([...previous, selectedShelf.location_id]));
|
|
97
|
+
}, [selectedShelf === null || selectedShelf === void 0 ? void 0 : selectedShelf.location_id]);
|
|
98
|
+
const refresh = () => {
|
|
99
|
+
list.reload();
|
|
100
|
+
selected.reload();
|
|
101
|
+
setNavigationRevision((value) => value + 1);
|
|
102
|
+
};
|
|
103
|
+
const open = (mode, kind = resource, id) => {
|
|
104
|
+
setTarget({
|
|
105
|
+
resource: kind,
|
|
106
|
+
mode,
|
|
107
|
+
id,
|
|
108
|
+
location: selectedLocation || void 0,
|
|
109
|
+
shelf: selectedShelf || void 0
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const remove = (kind, record) => void mutation.run(_asyncToGenerator(function* () {
|
|
113
|
+
if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
|
|
114
|
+
try {
|
|
115
|
+
yield api.remove(kind, record.id);
|
|
116
|
+
success("deleted");
|
|
117
|
+
if (selection.kind === kind && selection.id === record.id) setSelection({ kind: "root" });
|
|
118
|
+
} finally {
|
|
119
|
+
refresh();
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
const columns = useMemo(() => [
|
|
123
|
+
{
|
|
124
|
+
title: t("name"),
|
|
125
|
+
key: "name",
|
|
126
|
+
dataIndex: "name",
|
|
127
|
+
width: 250,
|
|
128
|
+
render: (_, record) => /* @__PURE__ */ React.createElement(Button, {
|
|
129
|
+
type: "link",
|
|
130
|
+
onClick: () => {
|
|
131
|
+
if (resource === "space") open("view", resource, record.id);
|
|
132
|
+
else setSelection({
|
|
133
|
+
kind: resource,
|
|
134
|
+
id: record.id
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, name(record), resource !== "space" && /* @__PURE__ */ React.createElement(RightOutlined, null))
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
title: t("status"),
|
|
141
|
+
key: "status",
|
|
142
|
+
dataIndex: "status",
|
|
143
|
+
render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
title: t("sort"),
|
|
147
|
+
key: "sort",
|
|
148
|
+
dataIndex: "sort"
|
|
149
|
+
},
|
|
150
|
+
...resource === "space" ? [{
|
|
151
|
+
title: t("totalQuantity"),
|
|
152
|
+
key: "stock_quantity",
|
|
153
|
+
dataIndex: "stock_quantity",
|
|
154
|
+
render: inventoryQuantity
|
|
155
|
+
}] : [],
|
|
156
|
+
{
|
|
157
|
+
title: t("updated"),
|
|
158
|
+
key: "updated_at",
|
|
159
|
+
dataIndex: "updated_at",
|
|
160
|
+
render: (value) => value || "—"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
title: t("actions"),
|
|
164
|
+
key: "actions",
|
|
165
|
+
dataIndex: "actions",
|
|
166
|
+
width: 210,
|
|
167
|
+
fixed: "right",
|
|
168
|
+
render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
|
|
169
|
+
type: "link",
|
|
170
|
+
disabled: mutation.busy,
|
|
171
|
+
onClick: () => open("view", resource, record.id)
|
|
172
|
+
}, t("view")), /* @__PURE__ */ React.createElement(Button, {
|
|
173
|
+
type: "link",
|
|
174
|
+
disabled: mutation.busy,
|
|
175
|
+
onClick: () => open("edit", resource, record.id)
|
|
176
|
+
}, t("edit")), /* @__PURE__ */ React.createElement(Button, {
|
|
177
|
+
type: "link",
|
|
178
|
+
danger: true,
|
|
179
|
+
disabled: mutation.busy,
|
|
180
|
+
onClick: () => remove(resource, record)
|
|
181
|
+
}, t("remove")))
|
|
182
|
+
}
|
|
183
|
+
], [
|
|
184
|
+
t,
|
|
185
|
+
name,
|
|
186
|
+
resource,
|
|
187
|
+
mutation.busy,
|
|
188
|
+
selectedLocation,
|
|
189
|
+
selectedShelf,
|
|
190
|
+
selectionKey,
|
|
191
|
+
api,
|
|
192
|
+
confirm
|
|
193
|
+
]);
|
|
194
|
+
const navigationLocations = selectedLocation && !locations.rows.some((record) => record.id === selectedLocation.id) ? [selectedLocation, ...locations.rows] : locations.rows;
|
|
195
|
+
const breadcrumbs = [{ title: /* @__PURE__ */ React.createElement("button", {
|
|
196
|
+
className: "inventory-text-button",
|
|
197
|
+
onClick: () => setSelection({ kind: "root" })
|
|
198
|
+
}, t("allLocations")) }];
|
|
199
|
+
if (selectedLocation) breadcrumbs.push({ title: /* @__PURE__ */ React.createElement("button", {
|
|
200
|
+
className: "inventory-text-button",
|
|
201
|
+
onClick: () => setSelection({
|
|
202
|
+
kind: "location",
|
|
203
|
+
id: selectedLocation.id
|
|
204
|
+
})
|
|
205
|
+
}, name(selectedLocation)) });
|
|
206
|
+
if (selectedShelf) breadcrumbs.push({ title: /* @__PURE__ */ React.createElement("span", null, name(selectedShelf)) });
|
|
207
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
208
|
+
className: `inventory-page ${className || ""}`,
|
|
209
|
+
style
|
|
210
|
+
}, /* @__PURE__ */ React.createElement(InventoryHeader, {
|
|
211
|
+
title: t("locations"),
|
|
212
|
+
description: t("hierarchyHint")
|
|
213
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
214
|
+
icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
|
|
215
|
+
disabled: mutation.busy,
|
|
216
|
+
onClick: refresh
|
|
217
|
+
}, t("refresh"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-location-layout" }, /* @__PURE__ */ React.createElement("nav", {
|
|
218
|
+
className: "inventory-navigation",
|
|
219
|
+
"aria-label": t("locations")
|
|
220
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
221
|
+
type: "button",
|
|
222
|
+
className: `inventory-nav-row inventory-nav-root ${selection.kind === "root" ? "is-selected" : ""}`,
|
|
223
|
+
onClick: () => setSelection({ kind: "root" })
|
|
224
|
+
}, t("allLocations")), /* @__PURE__ */ React.createElement(RequestError, {
|
|
225
|
+
error: locations.error,
|
|
226
|
+
retry: () => void locations.reload()
|
|
227
|
+
}), navigationLocations.map((record) => /* @__PURE__ */ React.createElement(NavigationLocation, {
|
|
228
|
+
key: record.id,
|
|
229
|
+
record,
|
|
230
|
+
selection,
|
|
231
|
+
selectedShelf,
|
|
232
|
+
expanded: expanded.has(record.id),
|
|
233
|
+
revision: navigationRevision,
|
|
234
|
+
onSelect: setSelection,
|
|
235
|
+
onToggle: () => setExpanded((previous) => {
|
|
236
|
+
const next = new Set(previous);
|
|
237
|
+
if (next.has(record.id)) next.delete(record.id);
|
|
238
|
+
else next.add(record.id);
|
|
239
|
+
return next;
|
|
240
|
+
})
|
|
241
|
+
})), locations.loading && !locations.hasMore && /* @__PURE__ */ React.createElement(InventoryNavLoading, null), !locations.loading && !locations.error && !locations.rows.length && /* @__PURE__ */ React.createElement("span", { className: "inventory-nav-empty" }, t("empty")), locations.hasMore && /* @__PURE__ */ React.createElement(Button, {
|
|
242
|
+
type: "text",
|
|
243
|
+
block: true,
|
|
244
|
+
loading: locations.loading,
|
|
245
|
+
onClick: () => void locations.loadMore()
|
|
246
|
+
}, t("loadMore"))), /* @__PURE__ */ React.createElement("main", { className: "inventory-location-main" }, /* @__PURE__ */ React.createElement(Breadcrumb, { items: breadcrumbs }), /* @__PURE__ */ React.createElement(RequestError, {
|
|
247
|
+
error: selected.error,
|
|
248
|
+
retry: selected.reload
|
|
249
|
+
}), selected.data && /* @__PURE__ */ React.createElement("div", { className: "inventory-section-heading" }, /* @__PURE__ */ React.createElement(Space, null, /* @__PURE__ */ React.createElement("h3", null, name(selected.data)), /* @__PURE__ */ React.createElement(StatusTag, { status: selected.data.status })), /* @__PURE__ */ React.createElement(Space, null, /* @__PURE__ */ React.createElement(Tooltip, { title: t("edit") }, /* @__PURE__ */ React.createElement(Button, {
|
|
250
|
+
disabled: mutation.busy,
|
|
251
|
+
onClick: () => selection.kind !== "root" && open("edit", selection.kind, selection.id)
|
|
252
|
+
}, t("edit"))), /* @__PURE__ */ React.createElement(Button, {
|
|
253
|
+
danger: true,
|
|
254
|
+
disabled: mutation.busy,
|
|
255
|
+
onClick: () => selection.kind !== "root" && remove(selection.kind, selected.data)
|
|
256
|
+
}, t("remove")))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(SearchInput, {
|
|
257
|
+
value: search,
|
|
258
|
+
onChange: (value) => setFilter({
|
|
259
|
+
key: selectionKey,
|
|
260
|
+
search: value,
|
|
261
|
+
status
|
|
262
|
+
})
|
|
263
|
+
}), /* @__PURE__ */ React.createElement(StatusSelect, {
|
|
264
|
+
value: status,
|
|
265
|
+
onChange: (value) => setFilter({
|
|
266
|
+
key: selectionKey,
|
|
267
|
+
search,
|
|
268
|
+
status: value
|
|
269
|
+
})
|
|
270
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
271
|
+
type: "primary",
|
|
272
|
+
className: "inventory-toolbar-primary",
|
|
273
|
+
icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
|
|
274
|
+
disabled: mutation.busy || selected.loading || !!selected.error || selection.kind !== "root" && !selected.data,
|
|
275
|
+
onClick: () => open("create")
|
|
276
|
+
}, t("add"), " ", t(resource))), /* @__PURE__ */ React.createElement(RequestError, {
|
|
277
|
+
error: list.error,
|
|
278
|
+
retry: list.reload
|
|
279
|
+
}), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
|
|
280
|
+
loading: list.loading || selected.loading || mutation.busy,
|
|
281
|
+
columns,
|
|
282
|
+
tableKey: `locations-${resource}`
|
|
283
|
+
})))), target && /* @__PURE__ */ React.createElement(RecordDialog, {
|
|
284
|
+
target,
|
|
285
|
+
onClose: () => setTarget(void 0),
|
|
286
|
+
onSaved: () => {
|
|
287
|
+
setTarget(void 0);
|
|
288
|
+
refresh();
|
|
289
|
+
}
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
function InventoryLocationManagement(props) {
|
|
293
|
+
return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(LocationPage, props));
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { InventoryLocationManagement as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InventoryPageProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/plus/inventory/InventoryUnitManagement.d.ts
|
|
5
|
+
declare function InventoryUnitManagement(props: InventoryPageProps): React.JSX.Element;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { InventoryUnitManagement };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
+
import { InventoryProvider, useInventory } from "./context.js";
|
|
4
|
+
import { useInventoryList, useInventoryMutation } from "./hooks.js";
|
|
5
|
+
import { InventoryHeader, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
|
|
6
|
+
import RecordDialog from "./RecordDialog.js";
|
|
7
|
+
import React, { useMemo, useState } from "react";
|
|
8
|
+
import { Button, Space } from "antd";
|
|
9
|
+
import { useDebounce } from "ahooks";
|
|
10
|
+
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
|
|
11
|
+
//#region src/plus/inventory/InventoryUnitManagement.tsx
|
|
12
|
+
function UnitPage({ className, style }) {
|
|
13
|
+
const { api, t, name, confirm, success } = useInventory();
|
|
14
|
+
const [search, setSearch] = useState("");
|
|
15
|
+
const keyword = useDebounce(search, { wait: 300 });
|
|
16
|
+
const [status, setStatus] = useState();
|
|
17
|
+
const [target, setTarget] = useState();
|
|
18
|
+
const mutation = useInventoryMutation();
|
|
19
|
+
const list = useInventoryList("item-unit", {
|
|
20
|
+
search: keyword || void 0,
|
|
21
|
+
status
|
|
22
|
+
});
|
|
23
|
+
const remove = (record) => void mutation.run(_asyncToGenerator(function* () {
|
|
24
|
+
if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
|
|
25
|
+
try {
|
|
26
|
+
yield api.remove("item-unit", record.id);
|
|
27
|
+
success("deleted");
|
|
28
|
+
} finally {
|
|
29
|
+
list.reload();
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
const columns = useMemo(() => [
|
|
33
|
+
{
|
|
34
|
+
title: t("name"),
|
|
35
|
+
key: "name",
|
|
36
|
+
dataIndex: "name",
|
|
37
|
+
width: 260,
|
|
38
|
+
render: (_, record) => /* @__PURE__ */ React.createElement(Button, {
|
|
39
|
+
type: "link",
|
|
40
|
+
onClick: () => setTarget({
|
|
41
|
+
resource: "item-unit",
|
|
42
|
+
id: record.id,
|
|
43
|
+
mode: "view"
|
|
44
|
+
})
|
|
45
|
+
}, name(record))
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: t("status"),
|
|
49
|
+
key: "status",
|
|
50
|
+
dataIndex: "status",
|
|
51
|
+
render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: t("sort"),
|
|
55
|
+
key: "sort",
|
|
56
|
+
dataIndex: "sort"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: t("updated"),
|
|
60
|
+
key: "updated_at",
|
|
61
|
+
dataIndex: "updated_at",
|
|
62
|
+
render: (value) => value || "—"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: t("actions"),
|
|
66
|
+
key: "actions",
|
|
67
|
+
dataIndex: "actions",
|
|
68
|
+
fixed: "right",
|
|
69
|
+
width: 220,
|
|
70
|
+
render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
|
|
71
|
+
type: "link",
|
|
72
|
+
disabled: mutation.busy,
|
|
73
|
+
onClick: () => setTarget({
|
|
74
|
+
resource: "item-unit",
|
|
75
|
+
id: record.id,
|
|
76
|
+
mode: "view"
|
|
77
|
+
})
|
|
78
|
+
}, t("view")), /* @__PURE__ */ React.createElement(Button, {
|
|
79
|
+
type: "link",
|
|
80
|
+
disabled: mutation.busy,
|
|
81
|
+
onClick: () => setTarget({
|
|
82
|
+
resource: "item-unit",
|
|
83
|
+
id: record.id,
|
|
84
|
+
mode: "edit"
|
|
85
|
+
})
|
|
86
|
+
}, t("edit")), /* @__PURE__ */ React.createElement(Button, {
|
|
87
|
+
type: "link",
|
|
88
|
+
danger: true,
|
|
89
|
+
disabled: mutation.busy,
|
|
90
|
+
onClick: () => remove(record)
|
|
91
|
+
}, t("remove")))
|
|
92
|
+
}
|
|
93
|
+
], [
|
|
94
|
+
t,
|
|
95
|
+
name,
|
|
96
|
+
mutation.busy,
|
|
97
|
+
api,
|
|
98
|
+
confirm
|
|
99
|
+
]);
|
|
100
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
101
|
+
className: `inventory-page ${className || ""}`,
|
|
102
|
+
style
|
|
103
|
+
}, /* @__PURE__ */ React.createElement(InventoryHeader, {
|
|
104
|
+
title: t("units"),
|
|
105
|
+
description: t("unitHint")
|
|
106
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
107
|
+
type: "primary",
|
|
108
|
+
icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
|
|
109
|
+
disabled: mutation.busy,
|
|
110
|
+
onClick: () => setTarget({
|
|
111
|
+
resource: "item-unit",
|
|
112
|
+
mode: "create"
|
|
113
|
+
})
|
|
114
|
+
}, t("add"), " ", t("unit"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(SearchInput, {
|
|
115
|
+
value: search,
|
|
116
|
+
onChange: setSearch
|
|
117
|
+
}), /* @__PURE__ */ React.createElement(StatusSelect, {
|
|
118
|
+
value: status,
|
|
119
|
+
onChange: setStatus
|
|
120
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
121
|
+
icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
|
|
122
|
+
onClick: list.reload,
|
|
123
|
+
disabled: mutation.busy
|
|
124
|
+
}, t("refresh"))), /* @__PURE__ */ React.createElement(RequestError, {
|
|
125
|
+
error: list.error,
|
|
126
|
+
retry: list.reload
|
|
127
|
+
}), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
|
|
128
|
+
loading: list.loading || mutation.busy,
|
|
129
|
+
columns,
|
|
130
|
+
tableKey: "units"
|
|
131
|
+
})), target && /* @__PURE__ */ React.createElement(RecordDialog, {
|
|
132
|
+
target,
|
|
133
|
+
onClose: () => setTarget(void 0),
|
|
134
|
+
onSaved: () => {
|
|
135
|
+
setTarget(void 0);
|
|
136
|
+
list.reload();
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
function InventoryUnitManagement(props) {
|
|
141
|
+
return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(UnitPage, props));
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { InventoryUnitManagement as default };
|