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