@feedmepos/mf-inventory-portal 1.2.7 → 1.2.8-dev.1
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/dist/{App-BtLCesbn.js → App-BL2MW6zc.js} +1 -1
- package/dist/{ApprovalView-Ba4XBhGf.js → ApprovalView-C18JNyKG.js} +69 -68
- package/dist/{BindingsDialog-BbBUniCu.js → BindingsDialog-DxXGq2TK.js} +2 -2
- package/dist/{BindingsPicker-C3q3ROku.js → BindingsPicker-BsuXkTQv.js} +1 -1
- package/dist/{BindingsTable-BTxWMif_.js → BindingsTable-BeGm5MK6.js} +1 -1
- package/dist/{ClosingDraftView-DGITBnaY.js → ClosingDraftView-yzzV-yhQ.js} +203 -203
- package/dist/ClosingTemplateView-DgI8ANjn.js +1862 -0
- package/dist/{DeliveryOrderPrintPreview-CUaHpblV.js → DeliveryOrderPrintPreview-B3xmuRAQ.js} +8 -8
- package/dist/{FmAdminBadge-BdwGZY-f.js → FmAdminBadge-9bTzCMaP.js} +6 -6
- package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B1pioWnC.js +230 -0
- package/dist/{FmMultiselectDialog-BETfHs3j.js → FmMultiselectDialog-D4QIUWaf.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BNdbeRQp.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CwuM-hJU.js} +23 -23
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-VYMMcwLl.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BFeK6K0l.js} +1 -1
- package/dist/{IngredientGroupView-C4d9b3Td.js → IngredientGroupView-Ku7t3MgL.js} +12 -12
- package/dist/IngredientsView-CAn1-40w.js +2306 -0
- package/dist/{IntegrationView-CWFzRDWO.js → IntegrationView-DEtbdogx.js} +4 -4
- package/dist/{InventoryBindingForm-Cx0Prlq8.js → InventoryBindingForm-BqBGbblS.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-cpR3Sf2Y.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CpVc2nGE.js} +41 -41
- package/dist/{InventoryBindingSummary-l8XvpxVU.js → InventoryBindingSummary-dEM8P354.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BjRvIX-v.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-0AaD13Wg.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-gjuZveKy.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BqVwcG4Z.js} +11 -11
- package/dist/{PublishView-D2iUnDan.js → PublishView-CE2Ul9NM.js} +14 -14
- package/dist/{PurchaseOrderPrintPreview-DdLvM-wt.js → PurchaseOrderPrintPreview-C6Lg4V4I.js} +11 -11
- package/dist/{ReceiveRequestView-DpF5ZzvH.js → ReceiveRequestView-CDTT3m48.js} +148 -145
- package/dist/{RecipeView-Dvtm8o1Y.js → RecipeView-CROKnpq9.js} +49 -49
- package/dist/StockView-Wv700Rt6.js +2104 -0
- package/dist/SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BdtRkUS6.js +158 -0
- package/dist/{SupplierView-7GtIJ3Fz.js → SupplierView-BNWtlH7a.js} +1133 -1015
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BvzSua6d.js +3058 -0
- package/dist/{TransferTemplateView-Cmvg-yvW.js → TransferTemplateView-DlxBMSPW.js} +131 -130
- package/dist/{UnitView-DjVm1iVX.js → UnitView-B56YIwiR.js} +59 -59
- package/dist/WarehouseView-C0d-uE4n.js +1066 -0
- package/dist/api/inventory.d.ts +8 -0
- package/dist/api/netsuite.d.ts +3 -0
- package/dist/api/purchase-order-template.d.ts +1 -0
- package/dist/api/purchase-order.d.ts +2 -0
- package/dist/api/shipment.d.ts +11 -0
- package/dist/api/warehouse.d.ts +3 -1
- package/dist/{app-Z-ylwRmy.js → app-Bo3plhvb.js} +17877 -17113
- package/dist/app.d.ts +96 -9
- package/dist/app.js +3 -3
- package/dist/closing-template-ByR3kWir.js +53 -0
- package/dist/components/FmInventoryTableToolbar.vue.d.ts +9 -2
- package/dist/components/netsuite/SubsidiaryTreeDialog.vue.d.ts +2 -0
- package/dist/{decimal-D1pJ2776.js → decimal-YpqAHWnk.js} +1 -1
- package/dist/{format-unit-display-9BMm-8A4.js → format-unit-display-CpusApo9.js} +372 -404
- package/dist/{index-rEIM0AVC.js → index-BHD7bEuA.js} +1 -1
- package/dist/{index-BOl10vcm.js → index-CJTjmcUN.js} +1 -1
- package/dist/purchase-order-template-CNhjKd6p.js +41 -0
- package/dist/{stock-B8ewk80v.js → stock-BhgeS5mL.js} +1 -1
- package/dist/stores/feature.d.ts +10 -0
- package/dist/stores/integration/netsuite.d.ts +19 -0
- package/dist/stores/inventory.d.ts +1 -0
- package/dist/stores/location.d.ts +57 -1
- package/dist/stores/supplier.d.ts +96 -0
- package/dist/stores/warehouse.d.ts +4 -0
- package/dist/{supplier-DLSXYY1o.js → supplier-DG8JyhMj.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-ingredient-select-dialog-CTjwdY3T.js → use-ingredient-select-dialog-LIEBAng-.js} +5 -5
- package/dist/{use-inventory-binding-dialog-zXJB7MQY.js → use-inventory-binding-dialog-Df7DfQ1b.js} +8 -8
- package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +24 -0
- package/dist/views/ingredients/components/ingredient-form/IngredientFormProps.d.ts +6 -0
- package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +2 -0
- package/dist/views/receive-request/components/delivery-order-form/CreateForm.vue.d.ts +16 -0
- package/dist/views/receive-request/components/delivery-order-form/CreateFormProps.d.ts +4 -0
- package/dist/views/receive-request/components/delivery-order-form/EditForm.vue.d.ts +16 -0
- package/dist/views/receive-request/components/delivery-order-form/EditFormProps.d.ts +4 -0
- package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
- package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +60 -0
- package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +10 -0
- package/dist/views/receive-request/composables/use-receive-request-form.d.ts +94 -0
- package/dist/views/receive-request/composables/use-receive-request-table.d.ts +72 -1
- package/dist/views/supplier/components/SupplierForm.vue.d.ts +8 -0
- package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +3 -0
- package/dist/views/supplier/composables/use-supplier-table.d.ts +4 -0
- package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -0
- package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +16 -0
- package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -0
- package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -0
- package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -0
- package/package.json +3 -3
- package/dist/ClosingTemplateView-eRvwxXBq.js +0 -1908
- package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-lDkElrkF.js +0 -227
- package/dist/IngredientsView-BvqWuIVT.js +0 -1876
- package/dist/StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js +0 -59
- package/dist/StockView-CRDu_GQ_.js +0 -2086
- package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DbmLtbZt.js +0 -2494
- package/dist/WarehouseView-CBso3SXT.js +0 -1034
|
@@ -0,0 +1,1862 @@
|
|
|
1
|
+
import { ref as P, h as F, defineComponent as B, resolveComponent as R, openBlock as k, createElementBlock as I, createElementVNode as _, normalizeClass as Y, createTextVNode as Me, toDisplayString as C, unref as y, createCommentVNode as G, createVNode as $, withCtx as A, Fragment as j, renderList as W, computed as E, watch as Pe, createSlots as Fe, createBlock as L, isRef as Oe, normalizeStyle as Ye, Teleport as Ke, normalizeProps as Ge, guardReactiveProps as We, mergeProps as qe } from "vue";
|
|
2
|
+
import { u as ie, al as Je, D as Z, i as V, h as Qe, f as Re, am as Xe, an as ae, z as Ze, ao as Ae, B as Ee, a as ce, b as et, C as tt, E as Ve, G as nt, H as ot, ap as st, e as H, P as O, T as lt, aq as at, o as rt, O as Ue, A as it, ar as ct, a7 as le, K as mt, _ as ut, L as dt } from "./app-Bo3plhvb.js";
|
|
3
|
+
import { useI18n as z, useCoreStore as Le } from "@feedmepos/mf-common";
|
|
4
|
+
import { useDialog as te, useDialogChild as pt, useSnackbar as ne, FmButtonVariant as ee, components as N, useProxiedModel as ft, useBreakpoints as vt } from "@feedmepos/ui-library";
|
|
5
|
+
import { defineStore as Ne, storeToRefs as Be } from "pinia";
|
|
6
|
+
import { u as oe } from "./closing-template-ByR3kWir.js";
|
|
7
|
+
import { u as gt } from "./use-ingredient-select-dialog-LIEBAng-.js";
|
|
8
|
+
const se = Ne(
|
|
9
|
+
"closingTemplateTable",
|
|
10
|
+
function() {
|
|
11
|
+
const { t: l } = z(), r = te(), c = P({}), o = re(), n = P({}), g = P(new Array()), m = P(!1), f = ie(), a = oe();
|
|
12
|
+
function v(t) {
|
|
13
|
+
const s = {
|
|
14
|
+
title: t.name,
|
|
15
|
+
doc: t,
|
|
16
|
+
controller: {
|
|
17
|
+
publishAll: async () => {
|
|
18
|
+
var e;
|
|
19
|
+
const i = await a.publishSingleDoc(
|
|
20
|
+
t._id,
|
|
21
|
+
(e = t.locations) == null ? void 0 : e.map((w) => w.dbName)
|
|
22
|
+
);
|
|
23
|
+
return c.value = i.publishedRevByLocation || {}, c.value;
|
|
24
|
+
},
|
|
25
|
+
publishAtLocation: async (i) => {
|
|
26
|
+
const e = await a.publishSingleDoc(t._id, [i.dbName]);
|
|
27
|
+
return c.value = e.publishedRevByLocation || {}, c.value;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
initialPublishedRev: c.value,
|
|
31
|
+
locations: f.locations,
|
|
32
|
+
enabledLocations: t.locations
|
|
33
|
+
};
|
|
34
|
+
r.open({
|
|
35
|
+
title: "Publish template",
|
|
36
|
+
contentComponent: Xe,
|
|
37
|
+
contentComponentProps: s,
|
|
38
|
+
closeButton: !0,
|
|
39
|
+
primaryActions: {
|
|
40
|
+
text: l("common.close"),
|
|
41
|
+
close: !0,
|
|
42
|
+
variant: "tertiary"
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function d() {
|
|
47
|
+
if (g.value = [], !!f._currentLocation) {
|
|
48
|
+
m.value = !0;
|
|
49
|
+
try {
|
|
50
|
+
const [t, s, i] = await Promise.all([
|
|
51
|
+
a.readTemplates(),
|
|
52
|
+
a.getRecentPublishingJob(),
|
|
53
|
+
a.getRecentPublishInfo()
|
|
54
|
+
]).delayed(1e3);
|
|
55
|
+
g.value = t, n.value = s, c.value = i.publishedRevByLocation || {};
|
|
56
|
+
} catch (t) {
|
|
57
|
+
console.log("Something went wrong when fetching templates:", t);
|
|
58
|
+
} finally {
|
|
59
|
+
m.value = !1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function x(t) {
|
|
64
|
+
if (!g.value.find((s) => s._id) && f._currentLocation) {
|
|
65
|
+
m.value = !0;
|
|
66
|
+
try {
|
|
67
|
+
const [s] = await Promise.all([
|
|
68
|
+
a.getTemplate(t),
|
|
69
|
+
new Promise((i) => setTimeout(i, 1e3))
|
|
70
|
+
]);
|
|
71
|
+
g.value = [s];
|
|
72
|
+
} catch (s) {
|
|
73
|
+
console.log("Something went wrong when fetching templates:", s);
|
|
74
|
+
} finally {
|
|
75
|
+
m.value = !1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function T(t, s) {
|
|
80
|
+
switch (s = Re(s), t) {
|
|
81
|
+
case V.Details:
|
|
82
|
+
return o.viewTemplate(s);
|
|
83
|
+
case V.Edit:
|
|
84
|
+
return o.updateTemplate(s);
|
|
85
|
+
case V.Delete:
|
|
86
|
+
return o.deleteTemplate(s, m, d);
|
|
87
|
+
case V.Publish:
|
|
88
|
+
return v(s);
|
|
89
|
+
case V.Duplicate:
|
|
90
|
+
return o.duplicateTemplate(s, m, d);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
columnDefs: [
|
|
95
|
+
{
|
|
96
|
+
id: "_id",
|
|
97
|
+
accessorKey: "_id",
|
|
98
|
+
header: () => l("inventory.closing.table.createdAt"),
|
|
99
|
+
cell(t) {
|
|
100
|
+
return Je(`${t.getValue()}`);
|
|
101
|
+
},
|
|
102
|
+
enableSorting: !0
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "name",
|
|
106
|
+
accessorKey: "name",
|
|
107
|
+
header: () => l("inventory.closing.table.name"),
|
|
108
|
+
enableSorting: !0,
|
|
109
|
+
size: 200
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "noOfItems",
|
|
113
|
+
accessorKey: "items.length",
|
|
114
|
+
header: () => l("inventory.closing.table.noOfItems"),
|
|
115
|
+
enableSorting: !1,
|
|
116
|
+
meta: {
|
|
117
|
+
width: "10rem",
|
|
118
|
+
textAlign: "right"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "enabledLocations",
|
|
123
|
+
accessorKey: "locations.length",
|
|
124
|
+
header: () => l("inventory.closing.table.enabledOutlets"),
|
|
125
|
+
cell(t) {
|
|
126
|
+
var i;
|
|
127
|
+
const s = (i = t.row.original.locations) == null ? void 0 : i.length;
|
|
128
|
+
return s ? `${s}` : "All";
|
|
129
|
+
},
|
|
130
|
+
enableSorting: !1,
|
|
131
|
+
meta: {
|
|
132
|
+
width: "10rem",
|
|
133
|
+
textAlign: "right"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "ref",
|
|
138
|
+
accessorKey: "ref",
|
|
139
|
+
header: () => l("inventory.closing.table.reference"),
|
|
140
|
+
enableSorting: !1,
|
|
141
|
+
size: "auto"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "status",
|
|
145
|
+
header: () => l("inventory.adjustment.template.table.status"),
|
|
146
|
+
enableSorting: !1,
|
|
147
|
+
cell(t) {
|
|
148
|
+
const s = t.row.original, i = s._rev, e = t.row.original.locations || f.locations, p = e.filter((b) => !!(c.value[b.dbName] || []).find((D) => D._id === s._id && D._rev === i)).length === e.length;
|
|
149
|
+
return F(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
class: "flex items-center gap-8"
|
|
153
|
+
},
|
|
154
|
+
F(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
class: [
|
|
158
|
+
"fm-status-badge",
|
|
159
|
+
p ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
p ? "Published" : "Unpublished"
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "action",
|
|
169
|
+
cell(t) {
|
|
170
|
+
const s = t.row.original, i = [
|
|
171
|
+
Z[V.Edit],
|
|
172
|
+
Z[V.Duplicate],
|
|
173
|
+
Z[V.Delete],
|
|
174
|
+
Z[V.Publish]
|
|
175
|
+
];
|
|
176
|
+
return Qe(i, (e) => T(e, s));
|
|
177
|
+
},
|
|
178
|
+
enableSorting: !1,
|
|
179
|
+
size: 40,
|
|
180
|
+
meta: {
|
|
181
|
+
cellClass: "",
|
|
182
|
+
headerClass: ""
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
recentPublish: n,
|
|
187
|
+
templates: g,
|
|
188
|
+
loading: m,
|
|
189
|
+
fetchTemplates: d,
|
|
190
|
+
loadTemplate: x
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
var me = /* @__PURE__ */ ((u) => (u.Ingredients = "Ingredients", u))(me || {});
|
|
195
|
+
function ze(u) {
|
|
196
|
+
const l = u.sku, r = new Set(u.disabledMeasurements);
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
code: l.code,
|
|
200
|
+
name: l.name,
|
|
201
|
+
unit: l.unit.abbrev,
|
|
202
|
+
enabled: !r.has(l.unit._id)
|
|
203
|
+
},
|
|
204
|
+
...l.unit.measurements.map((n) => ({
|
|
205
|
+
unit: n.abbrev,
|
|
206
|
+
enabled: !r.has(n.id)
|
|
207
|
+
}))
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
function He() {
|
|
211
|
+
return [
|
|
212
|
+
{
|
|
213
|
+
id: "code",
|
|
214
|
+
name: "Code"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "name",
|
|
218
|
+
name: "Name"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: "unit",
|
|
222
|
+
name: "Unit"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "enabled",
|
|
226
|
+
name: "Enabled"
|
|
227
|
+
}
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
function yt(u) {
|
|
231
|
+
var m;
|
|
232
|
+
const r = Le().currentBusiness.value, o = (m = u.map((f) => {
|
|
233
|
+
var h;
|
|
234
|
+
const a = f.items.flatMap(ze), v = He(), d = [
|
|
235
|
+
["Template ID", f._id],
|
|
236
|
+
["Template name", f.name],
|
|
237
|
+
["Business name", r == null ? void 0 : r.name],
|
|
238
|
+
["Business ID", r == null ? void 0 : r._id],
|
|
239
|
+
["Menu version", r == null ? void 0 : r.menuVersion],
|
|
240
|
+
[
|
|
241
|
+
"Locations",
|
|
242
|
+
...(h = f.locations) != null && h.length ? f.locations.map((t) => `${t.name} (${t.dbName})`) : ["All"]
|
|
243
|
+
],
|
|
244
|
+
["Reference", f.ref ?? ""],
|
|
245
|
+
[],
|
|
246
|
+
v.map((t) => t.name),
|
|
247
|
+
...a.map((t) => v.map((s) => t[s.id]))
|
|
248
|
+
], x = v.map((t) => `system:${t.id}`), T = ae(d, x);
|
|
249
|
+
return { name: f.name, sheet: T };
|
|
250
|
+
}).reduce(
|
|
251
|
+
(f, a) => {
|
|
252
|
+
var d;
|
|
253
|
+
const v = a.name.slice(0, 12);
|
|
254
|
+
return (d = f.sheetOccurence)[v] ?? (d[v] = 0), f.sheetOccurence[v] += 1, f.sheets[`${v} (${f.sheetOccurence[v]})`] = a.sheet, f;
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
sheets: {},
|
|
258
|
+
sheetOccurence: {}
|
|
259
|
+
}
|
|
260
|
+
)) == null ? void 0 : m.sheets, n = `${r == null ? void 0 : r.name} closing templates (${Ze(/* @__PURE__ */ new Date())}).xlsx`, g = Ae(o);
|
|
261
|
+
return Ee(g, n), n;
|
|
262
|
+
}
|
|
263
|
+
function ht() {
|
|
264
|
+
const u = Le(), l = ce(), r = et(), c = ze({
|
|
265
|
+
sku: {
|
|
266
|
+
unit: {
|
|
267
|
+
_id: "",
|
|
268
|
+
name: "Unit",
|
|
269
|
+
abbrev: "Unit",
|
|
270
|
+
precision: 0,
|
|
271
|
+
measurements: []
|
|
272
|
+
},
|
|
273
|
+
code: "ING001",
|
|
274
|
+
_id: "",
|
|
275
|
+
name: "Sugar"
|
|
276
|
+
}
|
|
277
|
+
})[0], o = u.currentBusiness.value, n = He(), g = [
|
|
278
|
+
["Template ID (leave empty to create new)", ""],
|
|
279
|
+
["Template Name", "New template"],
|
|
280
|
+
["Business name", o == null ? void 0 : o.name],
|
|
281
|
+
["Business ID", o == null ? void 0 : o._id],
|
|
282
|
+
["Menu version", o == null ? void 0 : o.menuVersion],
|
|
283
|
+
[
|
|
284
|
+
"Location codes (leave empty to enable all)",
|
|
285
|
+
"Example outlet (restaurant_xxx)",
|
|
286
|
+
"Example outlet 2 (restaurant_xxx)"
|
|
287
|
+
],
|
|
288
|
+
["Reference:"],
|
|
289
|
+
[],
|
|
290
|
+
n.map((h) => h.name),
|
|
291
|
+
n.map((h) => c[h.id])
|
|
292
|
+
], m = n.map((h) => `system:${h.id}`), f = ae(g, m), a = r.isEnabled ? r.state.setting.childItems ?? [] : [], v = a.reduce(
|
|
293
|
+
(h, t) => {
|
|
294
|
+
var p, b;
|
|
295
|
+
const s = (p = r.netSuiteItemIdToSkuId.get(t.parentNetSuiteId)) == null ? void 0 : p[0], i = (b = r.netSuiteMeasurementIdToMeasurementId.get(
|
|
296
|
+
t.unitOfMeasureId
|
|
297
|
+
)) == null ? void 0 : b[0];
|
|
298
|
+
if (!t.externalId)
|
|
299
|
+
return h;
|
|
300
|
+
if (!s)
|
|
301
|
+
return console.error(`Item ${t.externalId} cannot be mapped to parent FdoInventorySku.`, t), h;
|
|
302
|
+
const e = l.skuById[s], w = e.unit.measurements.find((S) => S.id === i);
|
|
303
|
+
return w ? (h[t.externalId] = {
|
|
304
|
+
sku: e,
|
|
305
|
+
measurement: w
|
|
306
|
+
}, h) : (console.error(
|
|
307
|
+
`Item ${t.externalId} found parent FdoInventorySku of ${e.code} ${e.name} but the measurement of netsuite id ${t.unitOfMeasureId} cannot be found.`,
|
|
308
|
+
t
|
|
309
|
+
), h);
|
|
310
|
+
},
|
|
311
|
+
{}
|
|
312
|
+
), d = ae(
|
|
313
|
+
[
|
|
314
|
+
...l.skus.flatMap((h) => [
|
|
315
|
+
[h.code, h.name, h.unit.abbrev, !0],
|
|
316
|
+
...h.unit.measurements.map((s) => [
|
|
317
|
+
"",
|
|
318
|
+
"",
|
|
319
|
+
s.abbrev,
|
|
320
|
+
!s.abbrev.toLocaleLowerCase("en-us").includes("inactive")
|
|
321
|
+
])
|
|
322
|
+
]),
|
|
323
|
+
...Object.entries(v).map(([h, { sku: t, measurement: s }]) => [
|
|
324
|
+
t.code,
|
|
325
|
+
t.name,
|
|
326
|
+
s.abbrev,
|
|
327
|
+
!s.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
|
|
328
|
+
h
|
|
329
|
+
])
|
|
330
|
+
],
|
|
331
|
+
[
|
|
332
|
+
"Code",
|
|
333
|
+
"Name",
|
|
334
|
+
"Units",
|
|
335
|
+
"Enabled (true/false)",
|
|
336
|
+
...a.length ? ["Netsuite Parent"] : []
|
|
337
|
+
]
|
|
338
|
+
), x = Ae({
|
|
339
|
+
Template: f,
|
|
340
|
+
Ingredients: d
|
|
341
|
+
}), T = `${o == null ? void 0 : o.name} transfer templates import.xlsx`;
|
|
342
|
+
return Ee(x, T), T;
|
|
343
|
+
}
|
|
344
|
+
function bt(u) {
|
|
345
|
+
if (!u.length || `${u[0]}`.toLocaleLowerCase() === "all")
|
|
346
|
+
return [];
|
|
347
|
+
const l = /(.*) \(((warehouse_|restaurant_).{24,})\)/, c = ie().locationByDbName;
|
|
348
|
+
return u.map((o) => {
|
|
349
|
+
const n = new Array(), g = o.trim(), m = l.exec(g);
|
|
350
|
+
if (!m)
|
|
351
|
+
return n.push(`Enabled location value of ${g} cannot be read.`), {
|
|
352
|
+
errors: n
|
|
353
|
+
};
|
|
354
|
+
const f = m[1], a = m[2], v = c[a];
|
|
355
|
+
return v ? (f !== v.name && n.push(
|
|
356
|
+
`Location id ${a} has non-matching name. Found ${f} but expected ${v.name}`
|
|
357
|
+
), {
|
|
358
|
+
errors: n,
|
|
359
|
+
location: v
|
|
360
|
+
}) : (n.push(`Location (${f}) of id ${a} is not found.`), {
|
|
361
|
+
errors: n
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function _t(u) {
|
|
366
|
+
const [
|
|
367
|
+
l,
|
|
368
|
+
r,
|
|
369
|
+
c,
|
|
370
|
+
o,
|
|
371
|
+
n,
|
|
372
|
+
g,
|
|
373
|
+
m,
|
|
374
|
+
f
|
|
375
|
+
] = Ve(u);
|
|
376
|
+
return {
|
|
377
|
+
id: `${r[1] ?? ""}`.trim(),
|
|
378
|
+
name: `${c[1] ?? ""}`.trim(),
|
|
379
|
+
locations: m.slice(1).map((a) => `${a}`.trim()).filter((a) => a),
|
|
380
|
+
reference: `${f[1] ?? ""}`.trim()
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function xt(u) {
|
|
384
|
+
const [
|
|
385
|
+
l,
|
|
386
|
+
r,
|
|
387
|
+
c,
|
|
388
|
+
o,
|
|
389
|
+
n,
|
|
390
|
+
g,
|
|
391
|
+
m,
|
|
392
|
+
f,
|
|
393
|
+
a,
|
|
394
|
+
v,
|
|
395
|
+
...d
|
|
396
|
+
] = Ve(u);
|
|
397
|
+
if (!l || !l.length || l.some((s) => s.length && !s.startsWith("system:")))
|
|
398
|
+
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
399
|
+
const x = l.map((s) => s.split(":")[1]), h = ["code", "name", "unit", "enabled"].filter((s) => !x.includes(s));
|
|
400
|
+
if (h.length)
|
|
401
|
+
throw new Error(
|
|
402
|
+
`Missing meta headers (${h.join()}). Excel file does not come from the template.`
|
|
403
|
+
);
|
|
404
|
+
return d.map((s, i) => {
|
|
405
|
+
const e = {};
|
|
406
|
+
for (const w in x) {
|
|
407
|
+
const p = x[w];
|
|
408
|
+
Object.assign(e, { [p]: s[w] });
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
index: i,
|
|
412
|
+
data: e
|
|
413
|
+
};
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function wt(u) {
|
|
417
|
+
return u.reduce(
|
|
418
|
+
(l, r) => {
|
|
419
|
+
var n;
|
|
420
|
+
const c = r.data, o = r.index;
|
|
421
|
+
return c.unit && (c.code ? l.result.push({ parent: r, children: [] }) : l.result.length ? (n = l.result.at(-1)) == null || n.children.push(r) : l.errors.push(`Cannot find parent for row ${o + 9}`)), l;
|
|
422
|
+
},
|
|
423
|
+
{ result: new Array(), errors: new Array() }
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
function kt(u) {
|
|
427
|
+
const l = u.parent.data, r = new Array(), o = ce().skuByCode[l.code ?? ""];
|
|
428
|
+
if (!o)
|
|
429
|
+
return r.push(`Cannot find ingredient of code ${l.code} ${l.name}`), { errors: r };
|
|
430
|
+
const n = {
|
|
431
|
+
sku: o
|
|
432
|
+
}, g = /* @__PURE__ */ new Set([o.unit._id, ...o.unit.measurements.map((f) => f.id)]), m = o.unit.measurements.find((f) => f.abbrev === l.unit);
|
|
433
|
+
l.unit !== o.unit.abbrev && !m ? r.push(
|
|
434
|
+
`Cannot find measurement unit of ${l.unit} for (${l.code}) ${l.name}.`
|
|
435
|
+
) : (l.enabled === !0 || `${l.enabled}`.toLocaleLowerCase() === "true") && g.delete(o.unit._id);
|
|
436
|
+
for (const f of u.children) {
|
|
437
|
+
const a = f.data, v = a.unit === o.unit.abbrev ? o.unit : void 0, d = o.unit.measurements.find((x) => x.abbrev === a.unit);
|
|
438
|
+
if (!d && !v) {
|
|
439
|
+
r.push(
|
|
440
|
+
`Cannot find measurement unit of ${a.unit} for (${l.code}) ${l.name}.`
|
|
441
|
+
);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
(a.enabled === !0 || `${a.enabled}`.toLocaleLowerCase() === "true") && g.delete((d == null ? void 0 : d.id) ?? (v == null ? void 0 : v._id) ?? "");
|
|
445
|
+
}
|
|
446
|
+
return g.has(o.unit._id) && n.sku.unit.measurements.every((f) => g.has(f.id)) && r.push(`Ingredient ${o.code} - ${o.name} must have at least one unit enabled.`), n.disabledMeasurements = [...g], { errors: r, templateItem: n };
|
|
447
|
+
}
|
|
448
|
+
function Tt(u) {
|
|
449
|
+
const l = u.SheetNames.filter(
|
|
450
|
+
(n) => !Object.values(me).map(String).includes(n)
|
|
451
|
+
), c = se().templates, o = tt(c, "_id");
|
|
452
|
+
try {
|
|
453
|
+
return l.reduce(
|
|
454
|
+
(n, g) => {
|
|
455
|
+
const m = new Array(), f = u.Sheets[g], a = _t(f), v = bt(a.locations), d = v.filter((e) => e.location).map((e) => e.location);
|
|
456
|
+
m.push(...v.flatMap((e) => e.errors));
|
|
457
|
+
const x = xt(f).filter(
|
|
458
|
+
(e) => e.data.code || e.data.unit
|
|
459
|
+
), T = wt(x);
|
|
460
|
+
m.push(...T.errors);
|
|
461
|
+
const h = T.result.map(
|
|
462
|
+
(e) => kt(e)
|
|
463
|
+
);
|
|
464
|
+
m.push(...h.flatMap((e) => e.errors));
|
|
465
|
+
const t = h.filter((e) => e.templateItem).map((e) => e.templateItem);
|
|
466
|
+
if (a.id) {
|
|
467
|
+
const e = o[a.id];
|
|
468
|
+
if (!e) {
|
|
469
|
+
const p = {
|
|
470
|
+
_id: a.id,
|
|
471
|
+
_rev: "",
|
|
472
|
+
name: a.name || `(unnamed from sheet ${g || "<unnamed sheet>"})`,
|
|
473
|
+
items: []
|
|
474
|
+
};
|
|
475
|
+
return m.push(`Template ID ${a.id} is not found.`), n.importUpdateResult.push({
|
|
476
|
+
type: "update",
|
|
477
|
+
original: p,
|
|
478
|
+
template: p,
|
|
479
|
+
excelSheetName: g,
|
|
480
|
+
errors: m
|
|
481
|
+
}), n;
|
|
482
|
+
}
|
|
483
|
+
const w = {
|
|
484
|
+
type: "update",
|
|
485
|
+
original: e,
|
|
486
|
+
template: {
|
|
487
|
+
...e,
|
|
488
|
+
name: a.name,
|
|
489
|
+
locations: d.length ? d : null,
|
|
490
|
+
ref: a.reference,
|
|
491
|
+
items: t
|
|
492
|
+
},
|
|
493
|
+
excelSheetName: g,
|
|
494
|
+
errors: m
|
|
495
|
+
};
|
|
496
|
+
return n.importUpdateResult.push(w), n;
|
|
497
|
+
}
|
|
498
|
+
const i = {
|
|
499
|
+
type: "create",
|
|
500
|
+
template: {
|
|
501
|
+
name: a.name,
|
|
502
|
+
locations: d.length ? d : null,
|
|
503
|
+
ref: a.reference,
|
|
504
|
+
items: t
|
|
505
|
+
},
|
|
506
|
+
excelSheetName: g,
|
|
507
|
+
errors: m
|
|
508
|
+
};
|
|
509
|
+
return n.importCreateResult.push(i), n;
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
invalidExcel: !1,
|
|
513
|
+
importCreateResult: new Array(),
|
|
514
|
+
importUpdateResult: new Array()
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
} catch (n) {
|
|
518
|
+
return {
|
|
519
|
+
invalidExcel: !0,
|
|
520
|
+
invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
|
|
521
|
+
importCreateResult: [],
|
|
522
|
+
importUpdateResult: []
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const $t = { class: "flex items-center gap-12 pl-8" }, Ct = { class: "flex flex-col" }, It = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, St = {
|
|
527
|
+
key: 0,
|
|
528
|
+
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
529
|
+
}, Dt = { key: 0 }, De = /* @__PURE__ */ B({
|
|
530
|
+
__name: "ClosingTemplateImportItem",
|
|
531
|
+
props: {
|
|
532
|
+
type: {},
|
|
533
|
+
name: {},
|
|
534
|
+
locations: {},
|
|
535
|
+
items: {},
|
|
536
|
+
errors: {}
|
|
537
|
+
},
|
|
538
|
+
setup(u) {
|
|
539
|
+
const { t: l } = z();
|
|
540
|
+
return (r, c) => {
|
|
541
|
+
var g, m, f;
|
|
542
|
+
const o = R("FmIcon"), n = R("FmTooltip");
|
|
543
|
+
return k(), I("div", $t, [
|
|
544
|
+
c[0] || (c[0] = _("div", null, "•", -1)),
|
|
545
|
+
_("div", Ct, [
|
|
546
|
+
_("div", It, [
|
|
547
|
+
_("div", {
|
|
548
|
+
class: Y({
|
|
549
|
+
"text-fm-color-system-error-300": r.errors.length
|
|
550
|
+
})
|
|
551
|
+
}, [
|
|
552
|
+
Me(C(r.name) + " ", 1),
|
|
553
|
+
r.type === "create" ? (k(), I("span", St, "(" + C(y(l)("inventory.closing.template.import.new")) + ")", 1)) : G("", !0)
|
|
554
|
+
], 2),
|
|
555
|
+
r.errors.length ? (k(), I("div", Dt, [
|
|
556
|
+
$(n, { "z-index": 50 }, {
|
|
557
|
+
content: A(() => [
|
|
558
|
+
_("ol", null, [
|
|
559
|
+
(k(!0), I(j, null, W(r.errors, (a, v) => (k(), I("li", { key: v }, C(a), 1))), 128))
|
|
560
|
+
])
|
|
561
|
+
]),
|
|
562
|
+
default: A(() => [
|
|
563
|
+
$(o, {
|
|
564
|
+
name: "error",
|
|
565
|
+
size: "sm",
|
|
566
|
+
color: "system-error-300"
|
|
567
|
+
})
|
|
568
|
+
]),
|
|
569
|
+
_: 1
|
|
570
|
+
})
|
|
571
|
+
])) : G("", !0)
|
|
572
|
+
]),
|
|
573
|
+
_("div", {
|
|
574
|
+
class: Y([
|
|
575
|
+
"fm-typo-en-body-sm-400",
|
|
576
|
+
{
|
|
577
|
+
"text-fm-color-system-error-200": r.errors.length,
|
|
578
|
+
"text-fm-color-typo-secondary": !r.errors.length
|
|
579
|
+
}
|
|
580
|
+
])
|
|
581
|
+
}, C((g = r.locations) != null && g.length ? y(l)("inventory.closing.template.import.nLocations", { count: (m = r.locations) == null ? void 0 : m.length }) : y(l)("inventory.closing.template.import.allLocations")) + ", " + C(y(l)("inventory.closing.template.import.nItems", { count: (f = r.items) == null ? void 0 : f.length })), 3)
|
|
582
|
+
])
|
|
583
|
+
]);
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
}), Mt = { class: "flex flex-col gap-24" }, Pt = { class: "fm-typo-en-body-md-400" }, Ft = {
|
|
587
|
+
key: 0,
|
|
588
|
+
class: "flex items-center gap-8"
|
|
589
|
+
}, Rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, At = { class: "flex flex-col gap-8" }, Et = { class: "line-clamp-2 text-ellipsis break-all" }, Vt = {
|
|
590
|
+
key: 2,
|
|
591
|
+
class: "shrink-0"
|
|
592
|
+
}, Ut = {
|
|
593
|
+
key: 0,
|
|
594
|
+
class: "flex flex-col"
|
|
595
|
+
}, Lt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Nt = {
|
|
596
|
+
key: 0,
|
|
597
|
+
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
598
|
+
}, Bt = { class: "fm-typo-en-body-lg-600" }, zt = /* @__PURE__ */ B({
|
|
599
|
+
__name: "ClosingTemplateImport",
|
|
600
|
+
setup(u) {
|
|
601
|
+
const l = P(null), r = pt(), c = ne(), o = P(!1), n = P(!1), g = P(new Array()), m = P([]), f = P([]), a = E(
|
|
602
|
+
() => !!g.value.length || m.value.some((T) => T.errors.length) || f.value.some((T) => T.errors.length)
|
|
603
|
+
), v = E(
|
|
604
|
+
() => !!m.value.length || !!f.value.length
|
|
605
|
+
), { t: d } = z();
|
|
606
|
+
async function x(T) {
|
|
607
|
+
g.value = [], m.value = [], f.value = [];
|
|
608
|
+
try {
|
|
609
|
+
o.value = !0;
|
|
610
|
+
const [h] = await Promise.all([
|
|
611
|
+
ot(T),
|
|
612
|
+
// fake buffer
|
|
613
|
+
new Promise((e) => setTimeout(e, 1e3))
|
|
614
|
+
]);
|
|
615
|
+
if (!h.SheetNames.filter(
|
|
616
|
+
(e) => !Object.values(me).map(String).includes(e)
|
|
617
|
+
).find((e) => e)) {
|
|
618
|
+
g.value.push(d("inventory.ingredient.import.fileError.noSheet"));
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const i = Tt(h);
|
|
622
|
+
if (i.invalidExcel) {
|
|
623
|
+
g.value.push(
|
|
624
|
+
i.invalidExcelMessage ?? d("inventory.ingredient.import.fileError.invalidExcel")
|
|
625
|
+
);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (m.value = i.importCreateResult, f.value = i.importUpdateResult, !m.value.length && !f.value.length) {
|
|
629
|
+
g.value.push(d("inventory.ingredient.import.fileError.noData"));
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
r.emitData(i);
|
|
633
|
+
} catch (h) {
|
|
634
|
+
c.open({
|
|
635
|
+
title: d("inventory.ingredient.import.fileError.unableToRead"),
|
|
636
|
+
message: h == null ? void 0 : h.message,
|
|
637
|
+
type: "error"
|
|
638
|
+
}), console.error("Error in reading file", h);
|
|
639
|
+
} finally {
|
|
640
|
+
g.value.length && c.open({
|
|
641
|
+
title: d("inventory.ingredient.import.fileError.invalidExcel"),
|
|
642
|
+
type: "error"
|
|
643
|
+
}), o.value = !1;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return Pe(l, (T) => {
|
|
647
|
+
T && x(T);
|
|
648
|
+
}), (T, h) => {
|
|
649
|
+
const t = R("FmCircularProgress"), s = R("FmIcon"), i = R("FmButton");
|
|
650
|
+
return k(), I("div", Mt, [
|
|
651
|
+
_("div", Pt, C(y(d)("inventory.closing.template.import.message")), 1),
|
|
652
|
+
n.value ? (k(), I("div", Ft, [
|
|
653
|
+
_("div", null, [
|
|
654
|
+
$(t, {
|
|
655
|
+
size: "md",
|
|
656
|
+
color: "neutral-gray-200"
|
|
657
|
+
})
|
|
658
|
+
]),
|
|
659
|
+
_("div", Rt, C(y(d)("inventory.formField.loading")), 1)
|
|
660
|
+
])) : (k(), I(j, { key: 1 }, [
|
|
661
|
+
$(nt, {
|
|
662
|
+
class: Y({
|
|
663
|
+
"w-full": !0,
|
|
664
|
+
"h-[200px]": !l.value
|
|
665
|
+
}),
|
|
666
|
+
accept: ".xlsx",
|
|
667
|
+
onFileUpload: h[0] || (h[0] = (e) => l.value = e),
|
|
668
|
+
label: y(d)("inventory.ingredient.import.uploadTemplate"),
|
|
669
|
+
"button-label": y(d)("inventory.ingredient.import.selectFile")
|
|
670
|
+
}, Fe({ _: 2 }, [
|
|
671
|
+
l.value ? {
|
|
672
|
+
name: "default",
|
|
673
|
+
fn: A(({ openFileDialog: e }) => [
|
|
674
|
+
_("div", At, [
|
|
675
|
+
_("div", {
|
|
676
|
+
class: Y([
|
|
677
|
+
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
678
|
+
{
|
|
679
|
+
"border border-fm-color-neutral-gray-100": o.value,
|
|
680
|
+
"border border-fm-color-neutral-gray-200": !o.value && !a.value,
|
|
681
|
+
"border border-fm-color-system-error-200": a.value
|
|
682
|
+
}
|
|
683
|
+
])
|
|
684
|
+
}, [
|
|
685
|
+
o.value ? (k(), L(t, {
|
|
686
|
+
key: 0,
|
|
687
|
+
size: "md",
|
|
688
|
+
color: "neutral-gray-200"
|
|
689
|
+
})) : (k(), L(s, {
|
|
690
|
+
key: 1,
|
|
691
|
+
name: a.value ? "error" : "attach_file",
|
|
692
|
+
outline: "",
|
|
693
|
+
color: a.value ? "system-error-300" : void 0
|
|
694
|
+
}, null, 8, ["name", "color"])),
|
|
695
|
+
_("div", {
|
|
696
|
+
class: Y([
|
|
697
|
+
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
698
|
+
{
|
|
699
|
+
"text-fm-color-typo-disabled": o.value,
|
|
700
|
+
"text-fm-color-typo-primary": !o.value
|
|
701
|
+
}
|
|
702
|
+
])
|
|
703
|
+
}, [
|
|
704
|
+
_("div", Et, C(l.value.name), 1)
|
|
705
|
+
], 2),
|
|
706
|
+
o.value ? G("", !0) : (k(), I("div", Vt, [
|
|
707
|
+
$(i, {
|
|
708
|
+
label: y(d)("inventory.ingredient.import.replaceFile"),
|
|
709
|
+
variant: a.value ? "destructive" : "secondary",
|
|
710
|
+
"prepend-icon": a.value ? void 0 : "autorenew",
|
|
711
|
+
onClick: e
|
|
712
|
+
}, null, 8, ["label", "variant", "prepend-icon", "onClick"])
|
|
713
|
+
]))
|
|
714
|
+
], 2),
|
|
715
|
+
g.value.length ? (k(), I("div", Ut, [
|
|
716
|
+
(k(!0), I(j, null, W(g.value, (w, p) => (k(), I("div", {
|
|
717
|
+
key: p,
|
|
718
|
+
class: "flex gap-8 items-center"
|
|
719
|
+
}, [
|
|
720
|
+
$(s, {
|
|
721
|
+
name: "error",
|
|
722
|
+
size: "sm",
|
|
723
|
+
color: "system-error-300"
|
|
724
|
+
}),
|
|
725
|
+
_("div", Lt, C(w), 1)
|
|
726
|
+
]))), 128))
|
|
727
|
+
])) : G("", !0)
|
|
728
|
+
])
|
|
729
|
+
]),
|
|
730
|
+
key: "0"
|
|
731
|
+
} : void 0
|
|
732
|
+
]), 1032, ["class", "label", "button-label"]),
|
|
733
|
+
v.value ? (k(), I("div", Nt, [
|
|
734
|
+
_("div", Bt, C(y(d)("inventory.ingredient.import.summary")), 1),
|
|
735
|
+
(k(!0), I(j, null, W(m.value, (e, w) => (k(), L(De, {
|
|
736
|
+
key: w,
|
|
737
|
+
name: e.template.name,
|
|
738
|
+
locations: e.template.locations,
|
|
739
|
+
items: e.template.items,
|
|
740
|
+
errors: e.errors,
|
|
741
|
+
type: "create"
|
|
742
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128)),
|
|
743
|
+
(k(!0), I(j, null, W(f.value, (e) => (k(), L(De, {
|
|
744
|
+
key: e.template._id,
|
|
745
|
+
name: e.template.name,
|
|
746
|
+
locations: e.template.locations,
|
|
747
|
+
items: e.template.items,
|
|
748
|
+
errors: e.errors,
|
|
749
|
+
type: "update"
|
|
750
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128))
|
|
751
|
+
])) : G("", !0)
|
|
752
|
+
], 64))
|
|
753
|
+
]);
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
}), re = Ne("closingTemplateActions", () => {
|
|
757
|
+
const { t: u } = z(), l = te(), r = ne(), c = oe(), o = st(), n = se(), { loading: g } = Be(n), m = P({});
|
|
758
|
+
function f() {
|
|
759
|
+
m.value = {
|
|
760
|
+
mode: H.CREATE,
|
|
761
|
+
show: !0,
|
|
762
|
+
"onUpdate:show"(i) {
|
|
763
|
+
m.value.show = i;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function a(i) {
|
|
768
|
+
m.value = {
|
|
769
|
+
mode: H.UPDATE,
|
|
770
|
+
modelValue: i,
|
|
771
|
+
show: !0,
|
|
772
|
+
"onUpdate:show"(e) {
|
|
773
|
+
m.value.show = e;
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function v(i, e, w) {
|
|
778
|
+
l.open({
|
|
779
|
+
title: `Confirm deleting template ${i.name}?`,
|
|
780
|
+
message: "Deleted template can no longer be retrieved",
|
|
781
|
+
primaryActions: {
|
|
782
|
+
text: "Delete",
|
|
783
|
+
variant: ee.Destructive,
|
|
784
|
+
close: !0
|
|
785
|
+
},
|
|
786
|
+
secondaryActions: {
|
|
787
|
+
text: "Cancel",
|
|
788
|
+
variant: ee.Plain,
|
|
789
|
+
close: !0
|
|
790
|
+
}
|
|
791
|
+
}).onPrimary(async () => {
|
|
792
|
+
r.open({
|
|
793
|
+
title: `Deleting ${i.name}`,
|
|
794
|
+
type: "info"
|
|
795
|
+
});
|
|
796
|
+
try {
|
|
797
|
+
e.value = !0;
|
|
798
|
+
const [p] = await Promise.allSettled([
|
|
799
|
+
c.deleteTemplate(i),
|
|
800
|
+
new Promise((b) => setTimeout(b, 1e3))
|
|
801
|
+
]);
|
|
802
|
+
if (p.status === "rejected") throw p.reason;
|
|
803
|
+
r.open({
|
|
804
|
+
title: `Deleted ${i.name}`,
|
|
805
|
+
type: "success"
|
|
806
|
+
});
|
|
807
|
+
} catch (p) {
|
|
808
|
+
r.open({
|
|
809
|
+
title: `Unable to delete ${i.name}`,
|
|
810
|
+
message: `See error from server: ${p}`,
|
|
811
|
+
type: "error"
|
|
812
|
+
}), console.error("error on deleting closing template", p);
|
|
813
|
+
} finally {
|
|
814
|
+
e.value = !1, w();
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
function d(i, e, w) {
|
|
819
|
+
let p;
|
|
820
|
+
l.open({
|
|
821
|
+
title: `Confirm duplicating template "${i.name}"?`,
|
|
822
|
+
message: "Duplicated template can be edited after creation",
|
|
823
|
+
primaryActions: {
|
|
824
|
+
text: "Duplicate",
|
|
825
|
+
variant: ee.Destructive,
|
|
826
|
+
close: !0
|
|
827
|
+
},
|
|
828
|
+
secondaryActions: {
|
|
829
|
+
text: "Cancel",
|
|
830
|
+
variant: ee.Plain,
|
|
831
|
+
close: !0
|
|
832
|
+
},
|
|
833
|
+
contentComponent: B({
|
|
834
|
+
props: ["modelValue"],
|
|
835
|
+
emits: ["update:modelValue"],
|
|
836
|
+
setup(b) {
|
|
837
|
+
return () => F(N.FmTextField, {
|
|
838
|
+
modelValue: b.modelValue,
|
|
839
|
+
"onUpdate:modelValue": (S) => p = S,
|
|
840
|
+
label: "New Template Name",
|
|
841
|
+
size: "md",
|
|
842
|
+
variant: "primary"
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
})
|
|
846
|
+
}).onPrimary(async () => {
|
|
847
|
+
r.open({
|
|
848
|
+
title: `Duplicating "${i.name}"`,
|
|
849
|
+
type: "info"
|
|
850
|
+
});
|
|
851
|
+
try {
|
|
852
|
+
e.value = !0;
|
|
853
|
+
const [b] = await Promise.allSettled([
|
|
854
|
+
o.duplicateClosingTemplate(i._id, p),
|
|
855
|
+
new Promise((S) => setTimeout(S, 1e3))
|
|
856
|
+
]);
|
|
857
|
+
if (b.status === "rejected") throw b.reason;
|
|
858
|
+
r.open({
|
|
859
|
+
title: `Duplicated "${i.name}"`,
|
|
860
|
+
type: "success"
|
|
861
|
+
});
|
|
862
|
+
} catch (b) {
|
|
863
|
+
r.open({
|
|
864
|
+
title: `Unable to duplicate "${i.name}"`,
|
|
865
|
+
message: `See error from server: ${b}`,
|
|
866
|
+
type: "error"
|
|
867
|
+
}), console.error("error on duplicating closing template", b);
|
|
868
|
+
} finally {
|
|
869
|
+
e.value = !1, w();
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
const x = P({});
|
|
874
|
+
function T(i) {
|
|
875
|
+
x.value = {
|
|
876
|
+
template: i,
|
|
877
|
+
show: !0,
|
|
878
|
+
"onUpdate:show"(e) {
|
|
879
|
+
x.value.show = e;
|
|
880
|
+
},
|
|
881
|
+
"onAction:edit"() {
|
|
882
|
+
x.value.show = !1, a(Re(i));
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function h() {
|
|
887
|
+
if (!n.templates.length) {
|
|
888
|
+
r.open({
|
|
889
|
+
title: "No data to export",
|
|
890
|
+
type: "error"
|
|
891
|
+
});
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
const i = yt(n.templates);
|
|
895
|
+
r.open({
|
|
896
|
+
title: u("inventory.ingredient.export.success"),
|
|
897
|
+
message: u("inventory.ingredient.export.filename", [i]),
|
|
898
|
+
type: "success"
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function t() {
|
|
902
|
+
n.loading || l.open({
|
|
903
|
+
title: u("inventory.ingredient.import.title"),
|
|
904
|
+
contentComponent: zt,
|
|
905
|
+
overlay: !0,
|
|
906
|
+
closeButton: !0,
|
|
907
|
+
primaryActions: {
|
|
908
|
+
text: u("common.import"),
|
|
909
|
+
close: !1
|
|
910
|
+
},
|
|
911
|
+
secondaryActions: {
|
|
912
|
+
text: u("common.close"),
|
|
913
|
+
close: !0
|
|
914
|
+
},
|
|
915
|
+
tertiaryActions: {
|
|
916
|
+
text: u("inventory.ingredient.import.actions.downloadTemplate"),
|
|
917
|
+
close: !1,
|
|
918
|
+
variant: "plain"
|
|
919
|
+
}
|
|
920
|
+
}).onPrimary((i) => {
|
|
921
|
+
if (!i) {
|
|
922
|
+
r.open({
|
|
923
|
+
title: u("inventory.ingredient.import.error.noData"),
|
|
924
|
+
type: "error"
|
|
925
|
+
});
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (!i.importCreateResult.length && !i.importUpdateResult.length) {
|
|
929
|
+
r.open({
|
|
930
|
+
title: u("inventory.ingredient.import.error.invalidContent"),
|
|
931
|
+
message: u("inventory.ingredient.import.error.noImportData"),
|
|
932
|
+
type: "error"
|
|
933
|
+
});
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
if (i.importCreateResult.some((e) => e.errors.length) || i.importUpdateResult.some((e) => e.errors.length)) {
|
|
937
|
+
r.open({
|
|
938
|
+
title: u("inventory.ingredient.import.error.invalidContent"),
|
|
939
|
+
message: u("inventory.ingredient.import.error.hasErrors"),
|
|
940
|
+
type: "error"
|
|
941
|
+
});
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
l.close(), s(i);
|
|
945
|
+
}).onTertiary(ht);
|
|
946
|
+
}
|
|
947
|
+
async function s(i) {
|
|
948
|
+
g.value = !0;
|
|
949
|
+
try {
|
|
950
|
+
const e = [
|
|
951
|
+
...i.importCreateResult.map(
|
|
952
|
+
(S) => S.template
|
|
953
|
+
),
|
|
954
|
+
...i.importUpdateResult.map(
|
|
955
|
+
(S) => S.template
|
|
956
|
+
)
|
|
957
|
+
], w = 100;
|
|
958
|
+
let p = 0;
|
|
959
|
+
const b = () => {
|
|
960
|
+
p += w, r.open({
|
|
961
|
+
title: u("inventory.ingredient.import.progress", [
|
|
962
|
+
Math.min(p, e.length),
|
|
963
|
+
e.length
|
|
964
|
+
])
|
|
965
|
+
});
|
|
966
|
+
};
|
|
967
|
+
for (const S of e.chunk(100))
|
|
968
|
+
b(), await c.importTemplates(S);
|
|
969
|
+
r.open({
|
|
970
|
+
title: u("inventory.ingredient.import.success"),
|
|
971
|
+
type: "success"
|
|
972
|
+
});
|
|
973
|
+
} catch (e) {
|
|
974
|
+
r.open({
|
|
975
|
+
title: u("inventory.ingredient.import.error.failed"),
|
|
976
|
+
message: u("inventory.ingredient.import.error.systemMessage", [e == null ? void 0 : e.message]),
|
|
977
|
+
type: "error"
|
|
978
|
+
}), console.error("Error in importing skus", i, e);
|
|
979
|
+
} finally {
|
|
980
|
+
g.value = !1, n.fetchTemplates();
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return {
|
|
984
|
+
createTemplate: f,
|
|
985
|
+
viewTemplate: T,
|
|
986
|
+
updateTemplate: a,
|
|
987
|
+
deleteTemplate: v,
|
|
988
|
+
duplicateTemplate: d,
|
|
989
|
+
exportTemplates: h,
|
|
990
|
+
importTemplates: t,
|
|
991
|
+
templateDialogProps: m,
|
|
992
|
+
templateDetailsProps: x
|
|
993
|
+
};
|
|
994
|
+
});
|
|
995
|
+
var K = /* @__PURE__ */ ((u) => (u.Name = "Name", u.Unit = "Unit", u.Delete = "Delete", u))(K || {});
|
|
996
|
+
function Ht(u) {
|
|
997
|
+
return {
|
|
998
|
+
columnDefs: E(() => {
|
|
999
|
+
const r = u.items.map((o) => o.sku.unit.measurements.length).reduce((o, n) => Math.max(o, n), 0);
|
|
1000
|
+
return [
|
|
1001
|
+
{
|
|
1002
|
+
id: "Name",
|
|
1003
|
+
header: () => "Name",
|
|
1004
|
+
enableSorting: !1,
|
|
1005
|
+
size: 400,
|
|
1006
|
+
minSize: 400,
|
|
1007
|
+
accessorFn: (o) => `${o.sku.name} ${o.sku.code}`,
|
|
1008
|
+
cell(o) {
|
|
1009
|
+
const n = o.row.original;
|
|
1010
|
+
return F(
|
|
1011
|
+
"div",
|
|
1012
|
+
{
|
|
1013
|
+
class: "flex flex-col",
|
|
1014
|
+
style: { minWidth: "400px" }
|
|
1015
|
+
},
|
|
1016
|
+
[
|
|
1017
|
+
F(
|
|
1018
|
+
"span",
|
|
1019
|
+
{ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
|
|
1020
|
+
n.sku.name
|
|
1021
|
+
),
|
|
1022
|
+
F(
|
|
1023
|
+
"span",
|
|
1024
|
+
{ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
|
|
1025
|
+
n.sku.code
|
|
1026
|
+
)
|
|
1027
|
+
]
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
id: "Unit",
|
|
1033
|
+
header: () => "Enable unit",
|
|
1034
|
+
enableSorting: !1,
|
|
1035
|
+
minSize: 200,
|
|
1036
|
+
maxSize: 400,
|
|
1037
|
+
cell(o) {
|
|
1038
|
+
var g, m, f;
|
|
1039
|
+
const n = o.row.original;
|
|
1040
|
+
return F("div", { class: "flex items-center gap-32" }, [
|
|
1041
|
+
F(
|
|
1042
|
+
N.FmFormGroup,
|
|
1043
|
+
{
|
|
1044
|
+
value: n.sku.unit._id,
|
|
1045
|
+
modelValue: !((g = n.disabledMeasurements) != null && g.includes(n.sku.unit._id))
|
|
1046
|
+
},
|
|
1047
|
+
F(
|
|
1048
|
+
"div",
|
|
1049
|
+
{
|
|
1050
|
+
class: "flex items-center gap-4",
|
|
1051
|
+
style: { width: "120px" }
|
|
1052
|
+
},
|
|
1053
|
+
[
|
|
1054
|
+
F(N.FmCheckbox, {
|
|
1055
|
+
value: n.sku.unit._id,
|
|
1056
|
+
modelValue: !((m = n.disabledMeasurements) != null && m.includes(n.sku.unit._id)),
|
|
1057
|
+
disabled: u.disabled || !((f = n.disabledMeasurements) != null && f.includes(n.sku.unit._id)) && n.sku.unit.measurements.every(
|
|
1058
|
+
(a) => {
|
|
1059
|
+
var v;
|
|
1060
|
+
return (v = n.disabledMeasurements) == null ? void 0 : v.includes(a.id);
|
|
1061
|
+
}
|
|
1062
|
+
),
|
|
1063
|
+
"onUpdate:modelValue"(a) {
|
|
1064
|
+
var v;
|
|
1065
|
+
if (a)
|
|
1066
|
+
u.updateItem({
|
|
1067
|
+
...n,
|
|
1068
|
+
disabledMeasurements: (v = n.disabledMeasurements) == null ? void 0 : v.filter(
|
|
1069
|
+
(d) => d !== n.sku.unit._id
|
|
1070
|
+
)
|
|
1071
|
+
});
|
|
1072
|
+
else {
|
|
1073
|
+
const d = n.disabledMeasurements ?? [];
|
|
1074
|
+
u.updateItem({
|
|
1075
|
+
...n,
|
|
1076
|
+
disabledMeasurements: [...d, n.sku.unit._id]
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}),
|
|
1081
|
+
F(
|
|
1082
|
+
N.FmTooltip,
|
|
1083
|
+
{ zIndex: 51 },
|
|
1084
|
+
{
|
|
1085
|
+
content() {
|
|
1086
|
+
return n.sku.unit.abbrev;
|
|
1087
|
+
},
|
|
1088
|
+
default() {
|
|
1089
|
+
return F(
|
|
1090
|
+
"div",
|
|
1091
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
1092
|
+
n.sku.unit.abbrev
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
]
|
|
1098
|
+
)
|
|
1099
|
+
),
|
|
1100
|
+
...Array.from({ length: Math.max(r, 0) }).map((a, v) => {
|
|
1101
|
+
var T, h, t, s;
|
|
1102
|
+
const d = o.row.original, x = d.sku.unit.measurements[v];
|
|
1103
|
+
return x ? F(
|
|
1104
|
+
N.FmFormGroup,
|
|
1105
|
+
{
|
|
1106
|
+
modelValue: !((T = d.disabledMeasurements) != null && T.includes(x.id)),
|
|
1107
|
+
value: x.id
|
|
1108
|
+
},
|
|
1109
|
+
F(
|
|
1110
|
+
"div",
|
|
1111
|
+
{
|
|
1112
|
+
class: "flex items-center gap-4",
|
|
1113
|
+
style: { width: "120px" }
|
|
1114
|
+
},
|
|
1115
|
+
[
|
|
1116
|
+
F(N.FmCheckbox, {
|
|
1117
|
+
value: x.id,
|
|
1118
|
+
modelValue: !((h = d.disabledMeasurements) != null && h.includes(x.id)),
|
|
1119
|
+
disabled: u.disabled || !((t = d.disabledMeasurements) != null && t.includes(x.id)) && ((s = d.disabledMeasurements) == null ? void 0 : s.includes(d.sku.unit._id)) && d.sku.unit.measurements.filter((i) => i.id != x.id).every((i) => {
|
|
1120
|
+
var e;
|
|
1121
|
+
return (e = d.disabledMeasurements) == null ? void 0 : e.includes(i.id);
|
|
1122
|
+
}),
|
|
1123
|
+
"onUpdate:modelValue"(i) {
|
|
1124
|
+
var e;
|
|
1125
|
+
if (i)
|
|
1126
|
+
u.updateItem({
|
|
1127
|
+
...d,
|
|
1128
|
+
disabledMeasurements: (e = d.disabledMeasurements) == null ? void 0 : e.filter(
|
|
1129
|
+
(w) => w !== x.id
|
|
1130
|
+
)
|
|
1131
|
+
});
|
|
1132
|
+
else {
|
|
1133
|
+
const w = d.disabledMeasurements ?? [];
|
|
1134
|
+
u.updateItem({
|
|
1135
|
+
...d,
|
|
1136
|
+
disabledMeasurements: [...w, x.id]
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}),
|
|
1141
|
+
F(
|
|
1142
|
+
N.FmTooltip,
|
|
1143
|
+
{ zIndex: 51 },
|
|
1144
|
+
{
|
|
1145
|
+
content() {
|
|
1146
|
+
return x.abbrev;
|
|
1147
|
+
},
|
|
1148
|
+
default() {
|
|
1149
|
+
return F(
|
|
1150
|
+
"div",
|
|
1151
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
1152
|
+
x.abbrev
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
)
|
|
1157
|
+
]
|
|
1158
|
+
)
|
|
1159
|
+
) : null;
|
|
1160
|
+
})
|
|
1161
|
+
]);
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
id: "Delete",
|
|
1166
|
+
header: "",
|
|
1167
|
+
cell(o) {
|
|
1168
|
+
const n = o.row.original;
|
|
1169
|
+
return F(
|
|
1170
|
+
"div",
|
|
1171
|
+
{ class: "w-full flex justify-end" },
|
|
1172
|
+
F(N.FmButton, {
|
|
1173
|
+
class: "delete-button",
|
|
1174
|
+
key: n.sku._id,
|
|
1175
|
+
type: "button",
|
|
1176
|
+
icon: "delete",
|
|
1177
|
+
variant: "tertiary",
|
|
1178
|
+
size: "md",
|
|
1179
|
+
disabled: u.disabled,
|
|
1180
|
+
onClick: () => {
|
|
1181
|
+
u.deleteItem(n);
|
|
1182
|
+
}
|
|
1183
|
+
})
|
|
1184
|
+
);
|
|
1185
|
+
},
|
|
1186
|
+
enableSorting: !1,
|
|
1187
|
+
size: 40,
|
|
1188
|
+
meta: {
|
|
1189
|
+
cellClass: "",
|
|
1190
|
+
headerClass: ""
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
];
|
|
1194
|
+
})
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
const jt = { class: "flex flex-col gap-16 py-12" }, Ot = { class: "flex" }, Yt = { class: "flex-1 flex flex-col" }, Kt = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, Gt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Wt = { class: "flex flex-col gap-4" }, qt = /* @__PURE__ */ B({
|
|
1198
|
+
__name: "ClosingTemplateItem",
|
|
1199
|
+
props: {
|
|
1200
|
+
cellByColId: {},
|
|
1201
|
+
row: {}
|
|
1202
|
+
},
|
|
1203
|
+
setup(u) {
|
|
1204
|
+
const l = u, r = E(() => l.row), c = E(
|
|
1205
|
+
() => r.value.getVisibleCells().filter((o) => o.column.id !== K.Name && o.column.id !== K.Delete)
|
|
1206
|
+
);
|
|
1207
|
+
return (o, n) => {
|
|
1208
|
+
var g, m, f, a, v;
|
|
1209
|
+
return k(), I("div", jt, [
|
|
1210
|
+
_("div", Ot, [
|
|
1211
|
+
_("div", Yt, [
|
|
1212
|
+
_("div", Kt, C(r.value.original.sku.name), 1),
|
|
1213
|
+
_("div", Gt, C(r.value.original.sku.code), 1)
|
|
1214
|
+
]),
|
|
1215
|
+
_("div", null, [
|
|
1216
|
+
$(y(O), {
|
|
1217
|
+
render: (f = (m = (g = o.cellByColId[y(K).Delete]) == null ? void 0 : g.column) == null ? void 0 : m.columnDef) == null ? void 0 : f.cell,
|
|
1218
|
+
props: (v = (a = o.cellByColId[y(K).Delete]) == null ? void 0 : a.getContext) == null ? void 0 : v.call(a)
|
|
1219
|
+
}, null, 8, ["render", "props"])
|
|
1220
|
+
])
|
|
1221
|
+
]),
|
|
1222
|
+
_("div", Wt, [
|
|
1223
|
+
n[0] || (n[0] = _("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, null, -1)),
|
|
1224
|
+
(k(!0), I(j, null, W(c.value, (d) => {
|
|
1225
|
+
var x, T, h;
|
|
1226
|
+
return k(), I("div", {
|
|
1227
|
+
key: d.id
|
|
1228
|
+
}, [
|
|
1229
|
+
$(y(O), {
|
|
1230
|
+
render: (T = (x = d.column) == null ? void 0 : x.columnDef) == null ? void 0 : T.cell,
|
|
1231
|
+
props: (h = d.getContext) == null ? void 0 : h.call(d)
|
|
1232
|
+
}, null, 8, ["render", "props"])
|
|
1233
|
+
]);
|
|
1234
|
+
}), 128))
|
|
1235
|
+
])
|
|
1236
|
+
]);
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
}), Jt = { class: "flex flex-col gap-16" }, Qt = { class: "flex flex-col gap-24" }, Xt = { class: "flex flex-col gap-16" }, Zt = { class: "flex items-center" }, en = { class: "flex-1 fm-typo-en-title-sm-600" }, tn = { class: "flex flex-col gap-16" }, nn = { class: "flex items-center" }, on = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, sn = /* @__PURE__ */ B({
|
|
1240
|
+
__name: "ClosingTemplateForm",
|
|
1241
|
+
props: {
|
|
1242
|
+
modelValue: {},
|
|
1243
|
+
disabled: { type: Boolean }
|
|
1244
|
+
},
|
|
1245
|
+
setup(u, { expose: l }) {
|
|
1246
|
+
const r = u, c = lt(), { t: o } = z(), n = ce();
|
|
1247
|
+
te();
|
|
1248
|
+
const {
|
|
1249
|
+
promptSelectLocations: g,
|
|
1250
|
+
columnDefs: m,
|
|
1251
|
+
rowData: f
|
|
1252
|
+
} = at({
|
|
1253
|
+
getLocations() {
|
|
1254
|
+
return c.locations;
|
|
1255
|
+
},
|
|
1256
|
+
setLocations(t) {
|
|
1257
|
+
c.locations = t;
|
|
1258
|
+
}
|
|
1259
|
+
}), a = P(), v = P("");
|
|
1260
|
+
l({
|
|
1261
|
+
validateInputs: () => {
|
|
1262
|
+
var t, s;
|
|
1263
|
+
(s = (t = a.value) == null ? void 0 : t.validateInputs) == null || s.call(t);
|
|
1264
|
+
},
|
|
1265
|
+
resetInputsValidation: () => {
|
|
1266
|
+
var t, s;
|
|
1267
|
+
(s = (t = a.value) == null ? void 0 : t.resetInputsValidation) == null || s.call(t);
|
|
1268
|
+
},
|
|
1269
|
+
resetInputs: () => {
|
|
1270
|
+
var t, s;
|
|
1271
|
+
(s = (t = a.value) == null ? void 0 : t.resetInputs) == null || s.call(t);
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
const d = Ht({
|
|
1275
|
+
updateItem: (t) => {
|
|
1276
|
+
c.items = c.items.map((s) => s.sku._id !== t.sku._id ? s : t);
|
|
1277
|
+
},
|
|
1278
|
+
deleteItem: (t) => {
|
|
1279
|
+
c.items = c.items.filter((s) => s.sku._id !== t.sku._id);
|
|
1280
|
+
},
|
|
1281
|
+
get items() {
|
|
1282
|
+
return c.items;
|
|
1283
|
+
},
|
|
1284
|
+
get disabled() {
|
|
1285
|
+
return r.disabled;
|
|
1286
|
+
}
|
|
1287
|
+
}), x = E(() => d.columnDefs.value), { promptSelectIngredients: T } = gt();
|
|
1288
|
+
async function h() {
|
|
1289
|
+
const s = n.skus.map((w) => ({
|
|
1290
|
+
label: w.name,
|
|
1291
|
+
sublabel: w.code,
|
|
1292
|
+
value: w
|
|
1293
|
+
})).filter((w) => {
|
|
1294
|
+
var p;
|
|
1295
|
+
return (p = c.items) == null ? void 0 : p.find((b) => b.sku._id === w.value._id);
|
|
1296
|
+
}).map((w) => w.value), i = c.items ?? [], e = await T(
|
|
1297
|
+
s.map((w) => w._id),
|
|
1298
|
+
(w) => {
|
|
1299
|
+
const p = n.skuById[w], b = i.find((D) => D.sku._id === p._id);
|
|
1300
|
+
return b || {
|
|
1301
|
+
sku: p
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
e && (e.sort((w, p) => w.sku.code.localeCompare(p.sku.code)), c.items = e);
|
|
1306
|
+
}
|
|
1307
|
+
return (t, s) => {
|
|
1308
|
+
const i = R("FmTextField"), e = R("FmButton"), w = R("FmTable"), p = R("FmIcon"), b = R("FmFormGroup"), S = R("FmForm");
|
|
1309
|
+
return k(), L(S, {
|
|
1310
|
+
ref_key: "formRef",
|
|
1311
|
+
ref: a,
|
|
1312
|
+
class: "flex flex-col gap-32",
|
|
1313
|
+
disabled: t.disabled
|
|
1314
|
+
}, {
|
|
1315
|
+
default: A(() => [
|
|
1316
|
+
_("div", Jt, [
|
|
1317
|
+
_("div", Qt, [
|
|
1318
|
+
$(i, {
|
|
1319
|
+
label: y(o)("inventory.closing.form.name"),
|
|
1320
|
+
"label-mark": "required",
|
|
1321
|
+
modelValue: y(c).name,
|
|
1322
|
+
"onUpdate:modelValue": s[0] || (s[0] = (D) => y(c).name = D),
|
|
1323
|
+
rules: [y(rt)()]
|
|
1324
|
+
}, null, 8, ["label", "modelValue", "rules"]),
|
|
1325
|
+
$(i, {
|
|
1326
|
+
label: y(o)("inventory.closing.form.reference"),
|
|
1327
|
+
"label-mark": "optional",
|
|
1328
|
+
modelValue: y(c).ref,
|
|
1329
|
+
"onUpdate:modelValue": s[1] || (s[1] = (D) => y(c).ref = D)
|
|
1330
|
+
}, null, 8, ["label", "modelValue"])
|
|
1331
|
+
])
|
|
1332
|
+
]),
|
|
1333
|
+
_("div", Xt, [
|
|
1334
|
+
_("div", Zt, [
|
|
1335
|
+
_("div", en, C(y(o)("inventory.closing.form.locations")), 1),
|
|
1336
|
+
$(e, {
|
|
1337
|
+
disabled: t.disabled,
|
|
1338
|
+
label: y(o)("inventory.closing.form.selectLocation"),
|
|
1339
|
+
"prepend-icon": "add",
|
|
1340
|
+
variant: "plain",
|
|
1341
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1342
|
+
onClick: y(g)
|
|
1343
|
+
}, null, 8, ["disabled", "label", "onClick"])
|
|
1344
|
+
]),
|
|
1345
|
+
$(w, {
|
|
1346
|
+
"column-defs": y(m),
|
|
1347
|
+
"row-data": y(f),
|
|
1348
|
+
"shrink-at": 9999,
|
|
1349
|
+
onRowClick: y(g),
|
|
1350
|
+
"hide-footer": ""
|
|
1351
|
+
}, null, 8, ["column-defs", "row-data", "onRowClick"])
|
|
1352
|
+
]),
|
|
1353
|
+
_("div", tn, [
|
|
1354
|
+
_("div", nn, [
|
|
1355
|
+
_("div", on, C(y(o)("inventory.closing.form.items.title")), 1),
|
|
1356
|
+
$(e, {
|
|
1357
|
+
disabled: t.disabled,
|
|
1358
|
+
label: y(o)("inventory.closing.form.items.addItem"),
|
|
1359
|
+
"prepend-icon": "add",
|
|
1360
|
+
variant: "plain",
|
|
1361
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1362
|
+
onClick: s[2] || (s[2] = (D) => h()),
|
|
1363
|
+
size: "md"
|
|
1364
|
+
}, null, 8, ["disabled", "label"])
|
|
1365
|
+
]),
|
|
1366
|
+
$(i, {
|
|
1367
|
+
placeholder: "Filter items",
|
|
1368
|
+
modelValue: v.value,
|
|
1369
|
+
"onUpdate:modelValue": s[4] || (s[4] = (D) => v.value = D)
|
|
1370
|
+
}, Fe({ _: 2 }, [
|
|
1371
|
+
v.value ? {
|
|
1372
|
+
name: "append",
|
|
1373
|
+
fn: A(() => [
|
|
1374
|
+
$(p, {
|
|
1375
|
+
name: "close",
|
|
1376
|
+
onClick: s[3] || (s[3] = (D) => v.value = ""),
|
|
1377
|
+
class: "cursor-pointer"
|
|
1378
|
+
})
|
|
1379
|
+
]),
|
|
1380
|
+
key: "0"
|
|
1381
|
+
} : void 0
|
|
1382
|
+
]), 1032, ["modelValue"]),
|
|
1383
|
+
(k(), L(w, {
|
|
1384
|
+
"search-value": v.value,
|
|
1385
|
+
"column-defs": x.value,
|
|
1386
|
+
"row-data": y(c).items,
|
|
1387
|
+
key: y(c).items.map((D) => D.sku._id).join("."),
|
|
1388
|
+
"hide-footer": y(c).items.length <= 10,
|
|
1389
|
+
"page-size": Math.min(10, y(c).items.length)
|
|
1390
|
+
}, {
|
|
1391
|
+
"list-row": A((D) => [
|
|
1392
|
+
(k(), L(Ue, {
|
|
1393
|
+
row: D,
|
|
1394
|
+
key: y(c).items.map((M) => M.sku._id).join(".")
|
|
1395
|
+
}, {
|
|
1396
|
+
default: A((M) => [
|
|
1397
|
+
$(qt, {
|
|
1398
|
+
row: D,
|
|
1399
|
+
"cell-by-col-id": M
|
|
1400
|
+
}, null, 8, ["row", "cell-by-col-id"])
|
|
1401
|
+
]),
|
|
1402
|
+
_: 2
|
|
1403
|
+
}, 1032, ["row"]))
|
|
1404
|
+
]),
|
|
1405
|
+
_: 1
|
|
1406
|
+
}, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
|
|
1407
|
+
$(b, {
|
|
1408
|
+
"model-value": y(c).items.length,
|
|
1409
|
+
rules: [y(it)(1)]
|
|
1410
|
+
}, null, 8, ["model-value", "rules"])
|
|
1411
|
+
])
|
|
1412
|
+
]),
|
|
1413
|
+
_: 1
|
|
1414
|
+
}, 8, ["disabled"]);
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
}), ln = { class: "flex items-center" }, an = { class: "fm-typo-en-title-md-600" }, rn = { class: "flex gap-4" }, cn = /* @__PURE__ */ B({
|
|
1418
|
+
__name: "ClosingTemplateDialog",
|
|
1419
|
+
props: {
|
|
1420
|
+
mode: {},
|
|
1421
|
+
modelValue: {},
|
|
1422
|
+
show: { type: Boolean }
|
|
1423
|
+
},
|
|
1424
|
+
emits: ["update:show", "submitted"],
|
|
1425
|
+
setup(u, { expose: l, emit: r }) {
|
|
1426
|
+
var w;
|
|
1427
|
+
const c = u, o = r, n = oe(), g = ne(), { t: m } = z(), f = ft(c, "show");
|
|
1428
|
+
function a() {
|
|
1429
|
+
return {
|
|
1430
|
+
_id: "",
|
|
1431
|
+
name: "",
|
|
1432
|
+
items: []
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
const v = P(c.modelValue ?? a()), d = P(((w = c.modelValue) == null ? void 0 : w._id) ?? `${Math.random()}`);
|
|
1436
|
+
Pe(
|
|
1437
|
+
() => c.show,
|
|
1438
|
+
(p) => {
|
|
1439
|
+
var b;
|
|
1440
|
+
p && (v.value = c.modelValue ?? a(), d.value = ((b = c.modelValue) == null ? void 0 : b._id) ?? `${Math.random()}`);
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
const x = P(!1), T = E(() => {
|
|
1444
|
+
switch (c.mode) {
|
|
1445
|
+
case H.READ:
|
|
1446
|
+
return "";
|
|
1447
|
+
case H.CREATE:
|
|
1448
|
+
return m("inventory.closing.template.create.title");
|
|
1449
|
+
case H.UPDATE:
|
|
1450
|
+
return m("inventory.closing.template.update.title");
|
|
1451
|
+
}
|
|
1452
|
+
return "";
|
|
1453
|
+
}), h = P();
|
|
1454
|
+
l({
|
|
1455
|
+
validateInputs: () => {
|
|
1456
|
+
var p, b;
|
|
1457
|
+
(b = (p = h.value) == null ? void 0 : p.validateInputs) == null || b.call(p);
|
|
1458
|
+
},
|
|
1459
|
+
resetInputsValidation: () => {
|
|
1460
|
+
var p, b;
|
|
1461
|
+
(b = (p = h.value) == null ? void 0 : p.resetInputsValidation) == null || b.call(p);
|
|
1462
|
+
},
|
|
1463
|
+
resetInputs: () => {
|
|
1464
|
+
var p, b;
|
|
1465
|
+
(b = (p = h.value) == null ? void 0 : p.resetInputs) == null || b.call(p);
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
async function t() {
|
|
1469
|
+
const p = v.value;
|
|
1470
|
+
if (p) {
|
|
1471
|
+
x.value = !0;
|
|
1472
|
+
try {
|
|
1473
|
+
await n.createTemplate(p), await new Promise((b) => setTimeout(b, 1e3)), g.open({
|
|
1474
|
+
title: m("inventory.closing.template.create.success"),
|
|
1475
|
+
message: m("inventory.closing.template.create.successMessage"),
|
|
1476
|
+
type: "success"
|
|
1477
|
+
}), o("update:show", !1), o("submitted");
|
|
1478
|
+
} catch (b) {
|
|
1479
|
+
g.open({
|
|
1480
|
+
title: m("inventory.closing.template.create.error"),
|
|
1481
|
+
message: m("inventory.closing.template.create.errorMessage"),
|
|
1482
|
+
type: "error"
|
|
1483
|
+
}), console.error("Error in creating closing template", b);
|
|
1484
|
+
} finally {
|
|
1485
|
+
x.value = !1;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
async function s() {
|
|
1490
|
+
const p = v.value;
|
|
1491
|
+
if (p) {
|
|
1492
|
+
x.value = !0;
|
|
1493
|
+
try {
|
|
1494
|
+
await n.updateTemplate({
|
|
1495
|
+
...p,
|
|
1496
|
+
_rev: p._rev ?? ""
|
|
1497
|
+
}), await new Promise((b) => setTimeout(b, 1e3)), g.open({
|
|
1498
|
+
title: m("inventory.closing.template.update.success"),
|
|
1499
|
+
message: m("inventory.closing.template.update.successMessage"),
|
|
1500
|
+
type: "success"
|
|
1501
|
+
}), o("update:show", !1), o("submitted");
|
|
1502
|
+
} catch (b) {
|
|
1503
|
+
g.open({
|
|
1504
|
+
title: m("inventory.closing.template.update.error"),
|
|
1505
|
+
message: m("inventory.closing.template.update.errorMessage"),
|
|
1506
|
+
type: "error"
|
|
1507
|
+
}), console.error("Error in updating closing template", b);
|
|
1508
|
+
} finally {
|
|
1509
|
+
x.value = !1;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function i() {
|
|
1514
|
+
switch (c.mode) {
|
|
1515
|
+
case H.CREATE:
|
|
1516
|
+
return t();
|
|
1517
|
+
case H.UPDATE:
|
|
1518
|
+
return s();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
function e() {
|
|
1522
|
+
var p, b;
|
|
1523
|
+
(b = (p = h.value) == null ? void 0 : p.validateInputs) == null || b.call(p);
|
|
1524
|
+
}
|
|
1525
|
+
return (p, b) => {
|
|
1526
|
+
const S = R("FmButton"), D = R("FmSideSheet");
|
|
1527
|
+
return k(), L(D, {
|
|
1528
|
+
modelValue: y(f),
|
|
1529
|
+
"onUpdate:modelValue": b[2] || (b[2] = (M) => Oe(f) ? f.value = M : null),
|
|
1530
|
+
"dismiss-away": "",
|
|
1531
|
+
"close-button": "",
|
|
1532
|
+
"max-width": 800
|
|
1533
|
+
}, {
|
|
1534
|
+
"side-sheet-header": A(() => [
|
|
1535
|
+
_("div", ln, [
|
|
1536
|
+
_("div", an, C(T.value), 1)
|
|
1537
|
+
])
|
|
1538
|
+
]),
|
|
1539
|
+
default: A(() => [
|
|
1540
|
+
(k(), L(sn, {
|
|
1541
|
+
class: "w-full",
|
|
1542
|
+
ref_key: "formRef",
|
|
1543
|
+
ref: h,
|
|
1544
|
+
onValidationSuccess: i,
|
|
1545
|
+
"model-value": v.value,
|
|
1546
|
+
"onUpdate:modelValue": b[0] || (b[0] = (M) => v.value = M),
|
|
1547
|
+
disabled: x.value,
|
|
1548
|
+
key: d.value
|
|
1549
|
+
}, null, 8, ["model-value", "disabled"]))
|
|
1550
|
+
]),
|
|
1551
|
+
"side-sheet-footer": A(() => [
|
|
1552
|
+
_("div", rn, [
|
|
1553
|
+
$(S, {
|
|
1554
|
+
loading: x.value,
|
|
1555
|
+
label: y(m)("common.save"),
|
|
1556
|
+
onClick: e
|
|
1557
|
+
}, null, 8, ["loading", "label"]),
|
|
1558
|
+
$(S, {
|
|
1559
|
+
disabled: x.value,
|
|
1560
|
+
variant: "tertiary",
|
|
1561
|
+
label: y(m)("common.close"),
|
|
1562
|
+
onClick: b[1] || (b[1] = (M) => o("update:show", !1))
|
|
1563
|
+
}, null, 8, ["disabled", "label"])
|
|
1564
|
+
])
|
|
1565
|
+
]),
|
|
1566
|
+
_: 1
|
|
1567
|
+
}, 8, ["modelValue"]);
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
}), mn = {};
|
|
1571
|
+
function un(u, l) {
|
|
1572
|
+
return k(), I("div");
|
|
1573
|
+
}
|
|
1574
|
+
const dn = /* @__PURE__ */ ct(mn, [["render", un]]), pn = { class: "flex flex-col gap-40" }, fn = { key: 0 }, vn = {
|
|
1575
|
+
key: 1,
|
|
1576
|
+
class: "flex gap-8 items-center"
|
|
1577
|
+
}, gn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, yn = {
|
|
1578
|
+
key: 2,
|
|
1579
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
|
|
1580
|
+
}, hn = {
|
|
1581
|
+
key: 3,
|
|
1582
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
|
|
1583
|
+
}, bn = { class: "fm-typo-en-body-md-600" }, _n = { class: "fm-typo-en-body-md-600" }, xn = { key: 4 }, wn = { class: "fm-typo-en-body-md-600" }, kn = { class: "fm-typo-en-body-md-600" }, Tn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, $n = /* @__PURE__ */ B({
|
|
1584
|
+
__name: "ClosingTemplatePublish",
|
|
1585
|
+
emits: ["close"],
|
|
1586
|
+
setup(u, { emit: l }) {
|
|
1587
|
+
const r = P(!1), c = ne(), o = oe(), n = se(), { t: g } = z(), m = l;
|
|
1588
|
+
async function f() {
|
|
1589
|
+
r.value = !0;
|
|
1590
|
+
try {
|
|
1591
|
+
await o.startNewPublish().delayed(1e3), c.open({
|
|
1592
|
+
title: "Success",
|
|
1593
|
+
message: "You may refresh after a while to review publish status",
|
|
1594
|
+
type: "success"
|
|
1595
|
+
}), d();
|
|
1596
|
+
} catch (x) {
|
|
1597
|
+
c.open({
|
|
1598
|
+
title: "Something went wrong",
|
|
1599
|
+
message: "Please try again",
|
|
1600
|
+
type: "error"
|
|
1601
|
+
}), console.error("error on creating publish task", x);
|
|
1602
|
+
} finally {
|
|
1603
|
+
r.value = !1;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
const a = E(() => n.recentPublish.recentJob), v = E(
|
|
1607
|
+
() => n.templates.length && (!a.value || a.value.outlets.length === a.value.completed.length)
|
|
1608
|
+
);
|
|
1609
|
+
function d() {
|
|
1610
|
+
m("close");
|
|
1611
|
+
}
|
|
1612
|
+
return (x, T) => {
|
|
1613
|
+
const h = R("FmCircularProgress"), t = R("i18n-t"), s = R("FmButton");
|
|
1614
|
+
return k(), I("div", pn, [
|
|
1615
|
+
y(n).templates.length ? r.value ? (k(), I("div", vn, [
|
|
1616
|
+
_("div", null, [
|
|
1617
|
+
$(h, {
|
|
1618
|
+
size: "md",
|
|
1619
|
+
color: "neutral-gray-300"
|
|
1620
|
+
})
|
|
1621
|
+
]),
|
|
1622
|
+
_("div", gn, [
|
|
1623
|
+
_("span", null, C(y(g)("inventory.closing.template.publish.publishing")), 1)
|
|
1624
|
+
])
|
|
1625
|
+
])) : a.value ? a.value.outlets.length === a.value.completed.length ? (k(), I("div", hn, [
|
|
1626
|
+
$(t, {
|
|
1627
|
+
keypath: "inventory.closing.template.publish.recentlyPublishedAt",
|
|
1628
|
+
tag: "p"
|
|
1629
|
+
}, {
|
|
1630
|
+
started: A(() => [
|
|
1631
|
+
_("span", bn, C(y(le)(new Date(a.value.createdAt))), 1)
|
|
1632
|
+
]),
|
|
1633
|
+
finished: A(() => [
|
|
1634
|
+
_("span", _n, C(y(le)(new Date(a.value.updatedAt))), 1)
|
|
1635
|
+
]),
|
|
1636
|
+
_: 1
|
|
1637
|
+
}),
|
|
1638
|
+
_("p", null, C(y(g)("inventory.closing.template.publish.message")), 1)
|
|
1639
|
+
])) : (k(), I("div", xn, [
|
|
1640
|
+
$(t, {
|
|
1641
|
+
keypath: "inventory.closing.template.publish.stillPublishing",
|
|
1642
|
+
tag: "p"
|
|
1643
|
+
}, {
|
|
1644
|
+
started: A(() => [
|
|
1645
|
+
_("span", wn, C(y(le)(new Date(a.value.createdAt))), 1)
|
|
1646
|
+
]),
|
|
1647
|
+
progress: A(() => [
|
|
1648
|
+
_("span", kn, " (" + C(a.value.completed.length) + "/" + C(a.value.outlets.length) + " completed) ", 1)
|
|
1649
|
+
]),
|
|
1650
|
+
_: 1
|
|
1651
|
+
}),
|
|
1652
|
+
Me(" Your recent publishing task is still pending (" + C(a.value.completed.length) + " / " + C(a.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
|
|
1653
|
+
])) : (k(), I("div", yn, [
|
|
1654
|
+
_("p", null, C(y(g)("inventory.closing.template.publish.noRecentActivity")), 1),
|
|
1655
|
+
_("p", null, C(y(g)("inventory.closing.template.publish.message")), 1)
|
|
1656
|
+
])) : (k(), I("div", fn, [
|
|
1657
|
+
_("p", null, C(y(g)("inventory.closing.template.publish.nothingToPublish")), 1)
|
|
1658
|
+
])),
|
|
1659
|
+
_("div", Tn, [
|
|
1660
|
+
$(s, {
|
|
1661
|
+
disabled: !v.value,
|
|
1662
|
+
loading: r.value,
|
|
1663
|
+
label: "Publish to all outlets",
|
|
1664
|
+
onClick: f
|
|
1665
|
+
}, null, 8, ["disabled", "loading"]),
|
|
1666
|
+
$(s, {
|
|
1667
|
+
variant: "tertiary",
|
|
1668
|
+
label: "Close",
|
|
1669
|
+
onClick: d
|
|
1670
|
+
})
|
|
1671
|
+
])
|
|
1672
|
+
]);
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
}), Cn = { class: "flex-1 flex flex-col gap-8" }, In = { class: "flex flex-col" }, Sn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Mn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Pn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Nn = /* @__PURE__ */ B({
|
|
1676
|
+
__name: "ClosingTemplateView",
|
|
1677
|
+
setup(u) {
|
|
1678
|
+
const { t: l } = z(), { createTemplate: r, updateTemplate: c, exportTemplates: o, importTemplates: n } = re(), { templateDialogProps: g, templateDetailsProps: m } = Be(re()), f = ie(), a = te(), v = se(), d = mt(), { breakpoints: x } = vt();
|
|
1679
|
+
f.watchLocation(v.fetchTemplates);
|
|
1680
|
+
const T = E(() => v.loading), h = P(""), t = E(() => x.value.xs || x.value.sm), s = E(() => t.value ? 10 : 20);
|
|
1681
|
+
function i(b) {
|
|
1682
|
+
switch (b) {
|
|
1683
|
+
case V.Add:
|
|
1684
|
+
return r();
|
|
1685
|
+
case "publish":
|
|
1686
|
+
return e();
|
|
1687
|
+
case "import":
|
|
1688
|
+
return n();
|
|
1689
|
+
case "export":
|
|
1690
|
+
return o();
|
|
1691
|
+
case "refresh":
|
|
1692
|
+
return v.fetchTemplates();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
function e() {
|
|
1696
|
+
a.open({
|
|
1697
|
+
title: "Publish closing templates",
|
|
1698
|
+
contentComponent: $n,
|
|
1699
|
+
contentComponentProps: {
|
|
1700
|
+
onClose() {
|
|
1701
|
+
a.close();
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
function w(b) {
|
|
1707
|
+
return b;
|
|
1708
|
+
}
|
|
1709
|
+
const p = E(() => t.value ? [
|
|
1710
|
+
{
|
|
1711
|
+
label: l("inventory.closing.template.create.title"),
|
|
1712
|
+
value: V.Add,
|
|
1713
|
+
isPrimary: !0,
|
|
1714
|
+
prependIcon: "add"
|
|
1715
|
+
},
|
|
1716
|
+
{
|
|
1717
|
+
label: l("inventory.common.refresh"),
|
|
1718
|
+
value: "refresh",
|
|
1719
|
+
isPrimary: !1
|
|
1720
|
+
},
|
|
1721
|
+
{
|
|
1722
|
+
label: l("inventory.common.publish"),
|
|
1723
|
+
value: "publish",
|
|
1724
|
+
isPrimary: !1
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
label: l("inventory.common.import"),
|
|
1728
|
+
value: "import",
|
|
1729
|
+
isPrimary: !1
|
|
1730
|
+
},
|
|
1731
|
+
{
|
|
1732
|
+
label: l("inventory.common.export"),
|
|
1733
|
+
value: "export",
|
|
1734
|
+
isPrimary: !1
|
|
1735
|
+
}
|
|
1736
|
+
] : [
|
|
1737
|
+
{
|
|
1738
|
+
label: l("inventory.closing.template.create.title"),
|
|
1739
|
+
value: V.Add,
|
|
1740
|
+
isPrimary: !0,
|
|
1741
|
+
prependIcon: "add"
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
label: l("inventory.common.publish"),
|
|
1745
|
+
value: "publish",
|
|
1746
|
+
isPrimary: !1
|
|
1747
|
+
},
|
|
1748
|
+
{
|
|
1749
|
+
label: l("inventory.common.import"),
|
|
1750
|
+
value: "import",
|
|
1751
|
+
isPrimary: !1
|
|
1752
|
+
},
|
|
1753
|
+
{
|
|
1754
|
+
label: l("inventory.common.refresh"),
|
|
1755
|
+
value: "refresh",
|
|
1756
|
+
isPrimary: !1
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
label: l("inventory.common.export"),
|
|
1760
|
+
value: "export",
|
|
1761
|
+
isPrimary: !1
|
|
1762
|
+
}
|
|
1763
|
+
]);
|
|
1764
|
+
return (b, S) => {
|
|
1765
|
+
const D = R("FmTable");
|
|
1766
|
+
return k(), I(j, null, [
|
|
1767
|
+
$(ut, {
|
|
1768
|
+
title: y(l)("inventory.closing.template.title"),
|
|
1769
|
+
actions: p.value,
|
|
1770
|
+
"onClick:action": i
|
|
1771
|
+
}, {
|
|
1772
|
+
default: A(() => [
|
|
1773
|
+
_("div", {
|
|
1774
|
+
class: Y([
|
|
1775
|
+
"flex flex-col gap-8 max-h-full",
|
|
1776
|
+
{
|
|
1777
|
+
"p-0": t.value,
|
|
1778
|
+
"px-24 ": !t.value
|
|
1779
|
+
}
|
|
1780
|
+
])
|
|
1781
|
+
}, [
|
|
1782
|
+
$(dt, {
|
|
1783
|
+
searchable: "",
|
|
1784
|
+
search: h.value,
|
|
1785
|
+
"onUpdate:search": S[0] || (S[0] = (M) => h.value = M)
|
|
1786
|
+
}, null, 8, ["search"]),
|
|
1787
|
+
$(D, {
|
|
1788
|
+
style: Ye(y(d).tableHeight),
|
|
1789
|
+
"column-defs": y(v).columnDefs,
|
|
1790
|
+
"row-data": y(v).templates,
|
|
1791
|
+
"search-value": h.value,
|
|
1792
|
+
loading: T.value,
|
|
1793
|
+
onRowClick: S[1] || (S[1] = (M) => y(c)(M.original)),
|
|
1794
|
+
"page-size": s.value
|
|
1795
|
+
}, {
|
|
1796
|
+
"list-row": A((M) => [
|
|
1797
|
+
$(Ue, {
|
|
1798
|
+
row: M,
|
|
1799
|
+
onRowClick: (U) => y(c)(U)
|
|
1800
|
+
}, {
|
|
1801
|
+
default: A((U) => {
|
|
1802
|
+
var ue, de, pe, q, fe, ve, ge, ye, J, he, be, _e, xe, we, ke, Q, Te, $e, Ce, Ie, X, Se;
|
|
1803
|
+
return [
|
|
1804
|
+
_("div", Cn, [
|
|
1805
|
+
_("div", In, [
|
|
1806
|
+
_("div", Sn, [
|
|
1807
|
+
$(y(O), {
|
|
1808
|
+
render: (pe = (de = (ue = U._id) == null ? void 0 : ue.column) == null ? void 0 : de.columnDef) == null ? void 0 : pe.cell,
|
|
1809
|
+
props: (fe = (q = U._id) == null ? void 0 : q.getContext) == null ? void 0 : fe.call(q)
|
|
1810
|
+
}, null, 8, ["render", "props"])
|
|
1811
|
+
]),
|
|
1812
|
+
_("div", Dn, [
|
|
1813
|
+
$(y(O), {
|
|
1814
|
+
render: (ye = (ge = (ve = U.name) == null ? void 0 : ve.column) == null ? void 0 : ge.columnDef) == null ? void 0 : ye.cell,
|
|
1815
|
+
props: (he = (J = U.name) == null ? void 0 : J.getContext) == null ? void 0 : he.call(J)
|
|
1816
|
+
}, null, 8, ["render", "props"])
|
|
1817
|
+
]),
|
|
1818
|
+
_("div", null, C((be = M.original.locations) != null && be.length ? y(l)("inventory.closing.table.enabledForN", {
|
|
1819
|
+
count: ((_e = M.original.locations) == null ? void 0 : _e.length) ?? 0
|
|
1820
|
+
}) : y(l)("inventory.closing.table.enabledForAll")), 1),
|
|
1821
|
+
_("div", Mn, C([
|
|
1822
|
+
...M.original.items.slice(0, 3).map((je) => je.sku.name),
|
|
1823
|
+
...M.original.items.length >= 3 ? [`and ${M.original.items.length - 3} more items`] : []
|
|
1824
|
+
].join(", ")), 1),
|
|
1825
|
+
_("div", Pn, [
|
|
1826
|
+
$(y(O), {
|
|
1827
|
+
render: (ke = (we = (xe = U.ref) == null ? void 0 : xe.column) == null ? void 0 : we.columnDef) == null ? void 0 : ke.cell,
|
|
1828
|
+
props: (Te = (Q = U.ref) == null ? void 0 : Q.getContext) == null ? void 0 : Te.call(Q)
|
|
1829
|
+
}, null, 8, ["render", "props"])
|
|
1830
|
+
])
|
|
1831
|
+
]),
|
|
1832
|
+
_("div", null, [
|
|
1833
|
+
$(y(O), {
|
|
1834
|
+
render: (Ie = (Ce = ($e = U.status) == null ? void 0 : $e.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : Ie.cell,
|
|
1835
|
+
props: (Se = (X = U.status) == null ? void 0 : X.getContext) == null ? void 0 : Se.call(X)
|
|
1836
|
+
}, null, 8, ["render", "props"])
|
|
1837
|
+
])
|
|
1838
|
+
])
|
|
1839
|
+
];
|
|
1840
|
+
}),
|
|
1841
|
+
_: 2
|
|
1842
|
+
}, 1032, ["row", "onRowClick"])
|
|
1843
|
+
]),
|
|
1844
|
+
_: 1
|
|
1845
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
1846
|
+
], 2)
|
|
1847
|
+
]),
|
|
1848
|
+
_: 1
|
|
1849
|
+
}, 8, ["title", "actions"]),
|
|
1850
|
+
(k(), L(Ke, { to: "body" }, [
|
|
1851
|
+
$(dn, Ge(We(y(m))), null, 16),
|
|
1852
|
+
$(cn, qe(y(g), {
|
|
1853
|
+
onSubmitted: S[2] || (S[2] = (M) => y(v).fetchTemplates())
|
|
1854
|
+
}), null, 16)
|
|
1855
|
+
]))
|
|
1856
|
+
], 64);
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1860
|
+
export {
|
|
1861
|
+
Nn as default
|
|
1862
|
+
};
|