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