first commit

This commit is contained in:
2025-07-24 20:14:43 +03:00
commit 4423badefd
30 changed files with 131277 additions and 0 deletions

View File

@ -0,0 +1,447 @@
import {r as g, ao as G, j as e, a7 as I, t as k, ap as p, ac as m, aq as M, G as R, ar as S, as as K, a1 as U, a2 as $, a3 as B, a4 as y, a6 as T, a5 as F, at as j, C as D, au as N, V as z, av as V, aw as H, z as b, e as L, ax as _, X as O, ay as Q, az as W, s as X, c as J} from "./index-CdMy-Rhi.js";
import {s as Y} from "./ProductsPage.module-BjEXBNuV.js";
function A(t) {
const s = g.useRef(new Set(t))
, c = G();
return s.current.add = (...l) => {
const a = Set.prototype.add.apply(s.current, l);
return c(),
a
}
,
s.current.clear = (...l) => {
Set.prototype.clear.apply(s.current, l),
c()
}
,
s.current.delete = (...l) => {
const a = Set.prototype.delete.apply(s.current, l);
return c(),
a
}
,
s.current
}
const q = g.createContext(void 0)
, Z = () => {
const [t,s] = g.useState()
, c = A()
, l = A()
, a = n => {
if (!n) {
s(void 0);
return
}
M.getClient({
clientId: n
}).then(d => {
s(d.client)
}
).catch(d => console.log(d))
}
, u = n => {
a(n == null ? void 0 : n.id)
}
, i = () => {
a(t == null ? void 0 : t.id)
}
, r = n => {
p.deleteResidualPallet({
palletId: n
}).then( ({ok: d, message: C}) => {
if (!d) {
m.error({
message: C
});
return
}
l.delete(n),
i()
}
).catch(d => console.log(d))
}
, h = n => {
if (t) {
if (n.boxes.length === 0 && n.residualProducts.length === 0) {
r(n.id);
return
}
I.openConfirmModal({
title: "Удаление паллета",
children: e.jsx(k, {
size: "sm",
children: "Вы уверены что хотите удалить паллет?"
}),
labels: {
confirm: "Да",
cancel: "Нет"
},
confirmProps: {
color: "red"
},
onConfirm: () => r(n.id)
})
}
}
, f = n => {
p.deleteResidualBox({
boxId: n
}).then( ({ok: d, message: C}) => {
if (!d) {
m.error({
message: C
});
return
}
c.delete(n),
i()
}
).catch(d => console.log(d))
}
;
return {
selectedClient: t,
selectClient: u,
refetchClient: i,
onDeletePalletClick: h,
onCreatePalletClick: () => {
t && p.createResidualPallet({
requestBody: {
clientId: t.id
}
}).then( ({ok: n, message: d}) => {
n || m.error({
message: d
}),
i()
}
).catch(n => console.log(n))
}
,
onDeleteBoxClick: n => {
if (t) {
if (n.residualProducts.length === 0) {
f(n.id);
return
}
I.openConfirmModal({
title: "Удаление короба",
children: e.jsx(k, {
size: "sm",
children: "Вы уверены что хотите удалить короб?"
}),
labels: {
confirm: "Да",
cancel: "Нет"
},
confirmProps: {
color: "red"
},
onConfirm: () => f(n.id)
})
}
}
,
onCreateBoxClick: n => {
t && p.createResidualBox({
requestBody: {
palletId: n ?? null,
clientId: n ? null : t.id
}
}).then( ({ok: d, message: C}) => {
d || m.error({
message: C
}),
i()
}
).catch(d => console.log(d))
}
,
boxIdsToPrint: c,
palletIdsToPrint: l
}
}
, ee = ({children: t}) => {
const s = Z();
return e.jsx(q.Provider, {
value: s,
children: t
})
}
, P = () => {
const t = g.useContext(q);
if (!t)
throw new Error("useResiduesContext must be used within a ResiduesContextProvider");
return t
}
, te = () => {
const {palletIdsToPrint: t, boxIdsToPrint: s} = P()
, c = "/api/v1/residues/pdf"
, l = u => {
const i = window.open(u);
i && i.print()
}
;
return {
onGetPalletsPdfClick: () => {
if (t.size === 0 && s.size === 0) {
m.show({
message: "Не выбран ни один элемент для печати "
});
return
}
const u = t.values().toArray().join(",")
, i = s.values().toArray().join(",");
l(`${c}/?pallet_ids=${u}&box_ids=${i}`)
}
}
}
, se = () => {
const {onCreatePalletClick: t, onCreateBoxClick: s} = P()
, {onGetPalletsPdfClick: c} = te();
return e.jsxs(R, {
children: [e.jsx(S, {
onClick: () => t(),
children: "Добавить паллет"
}), e.jsx(S, {
onClick: () => s(),
children: "Добавить короб"
}), e.jsxs(S, {
onClick: () => c(),
children: [e.jsx(K, {}), "Печать"]
})]
})
}
, ne = () => g.useMemo( () => [{
header: "Название",
accessorKey: "product.name",
Cell: ({row: t}) => {
var s;
return ((s = t.original.product) == null ? void 0 : s.name) ?? "-"
}
}, {
header: "Артикул",
accessorKey: "product.article",
Cell: ({row: t}) => {
var s;
return ((s = t.original.product) == null ? void 0 : s.article) ?? "-"
}
}, {
header: "Размер",
accessorKey: "product.size",
Cell: ({row: t}) => {
var s;
return ((s = t.original.product) == null ? void 0 : s.size) ?? "-"
}
}, {
header: "Количество",
accessorKey: "quantity"
}], [])
, E = ({items: t}) => {
const s = ne()
, {selectedClient: c, refetchClient: l} = P()
, a = i => {
p.deleteResidualProduct({
residualProductId: i.id
}).then( ({ok: r, message: h}) => {
m.guess(r, {
message: h
}),
l()
}
).catch(r => console.log(r))
}
, u = i => {
c && I.openContextModal({
modal: "residualProductModal",
title: "Редактирование товара на паллете",
withCloseButton: !1,
innerProps: {
client: c,
updateOnSubmit: l,
residuesData: {
residualProductId: i.id,
product: i.product,
quantity: i.quantity
}
}
})
}
;
return e.jsx(U, {
data: t,
columns: s,
restProps: {
enableSorting: !1,
enableColumnActions: !1,
enableRowActions: !0,
enableRowNumbers: !0,
positionActionsColumn: "last",
renderRowActions: ({row: i}) => e.jsxs($, {
gap: "md",
children: [e.jsx(B, {
label: "Удалить",
children: e.jsx(y, {
onClick: () => a(i.original),
variant: "default",
children: e.jsx(T, {})
})
}), e.jsx(B, {
label: "Редактировать",
children: e.jsx(y, {
onClick: () => u(i.original),
variant: "default",
children: e.jsx(F, {})
})
})]
})
}
})
}
, v = ({boxes: t}) => {
const {onDeleteBoxClick: s, boxIdsToPrint: c} = P();
if (!t || t.length == 0)
return;
const l = t.map(r => r.id.toString())
, a = r => e.jsx(B, {
label: "Удалить короб",
children: e.jsx(y, {
variant: "default",
onClick: () => s(r),
mx: "md",
children: e.jsx(T, {})
})
})
, u = r => e.jsx(z, {
ml: "sm",
checked: c.has(r.id),
onChange: () => {
c.has(r.id) ? c.delete(r.id) : c.add(r.id)
}
})
, i = r => e.jsxs(j.Item, {
value: r.id.toString(),
children: [e.jsxs(D, {
children: [e.jsxs(j.Control, {
icon: e.jsx(N, {}),
children: ["Короб ", r.id]
}), u(r), a(r)]
}), e.jsx(j.Panel, {
children: r.residualProducts.length > 0 ? e.jsx(E, {
items: r.residualProducts.sort( (h, f) => h.id - f.id)
}) : e.jsx(k, {
children: "Пустой"
})
})]
}, r.id);
return e.jsx(j, {
multiple: !0,
defaultValue: l,
bd: "solid 1px gray",
children: t.sort( (r, h) => r.id - h.id).map(r => i(r))
})
}
, re = () => {
const {selectedClient: t, onDeletePalletClick: s, onCreateBoxClick: c, palletIdsToPrint: l} = P()
, a = []
, u = o => o == null ? void 0 : o.sort( (x, n) => x.id - n.id)
, i = o => e.jsx(z, {
ml: "sm",
checked: l.has(o.id),
onChange: () => {
l.has(o.id) ? l.delete(o.id) : l.add(o.id)
}
})
, r = () => {
const o = u(t == null ? void 0 : t.pallets);
return (o == null ? void 0 : o.map(x => (a.push(x.id.toString()),
e.jsxs(j.Item, {
value: x.id.toString(),
children: [e.jsxs(D, {
children: [e.jsxs(j.Control, {
icon: e.jsx(H, {}),
children: ["Паллет - П", x.id]
}), i(x), h(x)]
}), e.jsx(j.Panel, {
children: w(x)
})]
}, x.id)))) ?? []
}
, h = o => e.jsx(B, {
label: "Удалить паллет",
children: e.jsx(y, {
variant: "default",
onClick: () => s(o),
mx: "md",
children: e.jsx(T, {})
})
})
, f = o => e.jsx(O, {
variant: "default",
onClick: () => c(o),
children: e.jsxs(R, {
gap: "md",
children: [e.jsx(Q, {}), "Добавить короб"]
})
})
, w = o => {
const x = o.boxes.length === 0 && o.residualProducts.length === 0
, n = o.residualProducts.length === 0
, d = x ? "Пустой" : n ? "Короба" : "Товары"
, C = u(o.residualProducts);
return e.jsxs(b, {
gap: L(5),
children: [e.jsxs(R, {
justify: "space-between",
children: [e.jsxs(b, {
gap: "xs",
children: [e.jsxs(k, {
children: ["Дата добавления: ", new Date(o.createdAt).toLocaleString("ru-RU")]
}), e.jsx(_, {
order: 6,
children: d
})]
}), n && f(o.id)]
}), C.length > 0 && e.jsx(E, {
items: C
}), v.length > 0 && e.jsx(v, {
boxes: o.boxes
})]
})
}
;
return e.jsx(V, {
children: e.jsxs(j, {
multiple: !0,
defaultValue: a,
bd: "solid 1px gray",
children: [e.jsx(v, {
boxes: t == null ? void 0 : t.boxes
}), r()]
})
})
}
, oe = () => {
const {selectedClient: t, selectClient: s} = P();
return e.jsxs(b, {
h: "92vh",
children: [e.jsxs(R, {
children: [e.jsx(W, {
onChange: s
}), t && e.jsx(se, {})]
}), t && e.jsx(re, {})]
})
}
, ie = () => e.jsx("div", {
className: Y.container,
children: e.jsx(X, {
fullHeight: !0,
children: e.jsx(ee, {
children: e.jsx(oe, {})
})
})
})
, de = J("/residues")({
component: () => e.jsx(ie, {})
});
export {de as Route};