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