@feedmepos/mf-inventory-portal 0.0.17-dev.7 → 0.0.17-dev.9
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/{ApprovalView-BBGw0pZF.js → ApprovalView-BJ_SGOrx.js} +6 -6
- package/dist/{BindingsDialog-CgS5gV3F.js → BindingsDialog-Dw_DCOTY.js} +2 -2
- package/dist/{BindingsPicker-DqGny71H.js → BindingsPicker-BRLTF4Qs.js} +2 -2
- package/dist/{BindingsTable-Caok_8rf.js → BindingsTable-BMIkL0Bk.js} +3 -3
- package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DwQzkRMp.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-D9Qp3jke.js} +1 -1
- package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-rxgxAR9e.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-YzVhmNJc.js} +2 -2
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CyFNdiVs.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Dv01gy7k.js} +4 -4
- package/dist/IngredientsView-DYFkUsHx.js +1802 -0
- package/dist/{IntegrationView-DoXiSwI_.js → IntegrationView-Xnl758CS.js} +3 -3
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CUMJT0dh.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CUj9Mnt6.js} +6 -6
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BsgEblKL.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CW0h41FP.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-DcAc50Cz.js → PurchaseOrderPrintPreview-DzimxkGt.js} +1 -1
- package/dist/{ReceiveRequestView-CobKo-v2.js → ReceiveRequestView-C_0jK6GY.js} +12 -12
- package/dist/{RecipeView-mb_QQoNQ.js → RecipeView-B9NcEw7x.js} +6 -6
- package/dist/{StockView-D_o5dpKT.js → StockView-JPw1K8aU.js} +12 -12
- package/dist/{SupplierView-7u3iGe9q.js → SupplierView-CiQLFWmQ.js} +7 -7
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Dre68lfW.js → TransferDetails.vue_vue_type_script_setup_true_lang-BSwsz8Xt.js} +5 -5
- package/dist/{UnitView-BQNLpsJT.js → UnitView-BvbaRHxG.js} +6 -6
- package/dist/{WarehouseView-DiweuuvJ.js → WarehouseView-Cf5Bmfhn.js} +3 -3
- package/dist/api/inventory.d.ts +3 -0
- package/dist/{app-DNyYLGmv.js → app-BbXzmbBO.js} +8 -5
- package/dist/app.js +1 -1
- package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -0
- package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -0
- package/dist/{date2-DEhxnd0C.js → date2-DFqSdEvG.js} +1 -1
- package/dist/{dayjs.min-DVINa0Ro.js → dayjs.min-M4PEyOKN.js} +526 -514
- package/dist/{decimal-D8XBRUfU.js → decimal-S-jYTEL5.js} +1 -1
- package/dist/{fuzzy-CEg_a7wq.js → fuzzy-DW00BX8H.js} +1 -1
- package/dist/{init-date-range-D9NGduWq.js → init-date-range-B_ha80e0.js} +1 -1
- package/dist/{layout-BUnyBR1K.js → layout-DACHKQ9G.js} +1 -1
- package/dist/{rules-DSGV4ljx.js → rules-ldw61cGA.js} +1 -1
- package/dist/{stock-estimate-D1OAYfju.js → stock-estimate-DOP1qO5w.js} +2 -2
- package/dist/stores/inventory.d.ts +4 -0
- package/dist/{supplier-BjPiEva_.js → supplier-DjKC4TaM.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-inventory-binding-dialog-13PwtTn2.js → use-inventory-binding-dialog-D1M09VoX.js} +2 -2
- package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -0
- package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -0
- package/dist/views/ingredients/helper/import-export.helper.d.ts +2 -0
- package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +5 -0
- package/dist/views/receive-request/composables/use-receive-request-form.d.ts +4 -0
- package/dist/views/receive-request/composables/use-receive-request-table.d.ts +12 -0
- package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +4 -2
- package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
- package/dist/{xlsx-BjIddIWP.js → xlsx-BcM9fWkc.js} +1 -1
- package/dist/{xlsx.util-VUE_6qtu.js → xlsx.util-BNXjhkYU.js} +2 -2
- package/package.json +6 -5
- package/dist/IngredientsView-DVdxUu-0.js +0 -1633
|
@@ -0,0 +1,1802 @@
|
|
|
1
|
+
import { ref as B, defineComponent as le, computed as k, resolveComponent as $, openBlock as b, createBlock as D, withCtx as w, createVNode as v, createElementBlock as R, Fragment as Q, createElementVNode as r, createCommentVNode as L, onMounted as st, watch as Ge, unref as V, normalizeClass as X, createTextVNode as qe, toDisplayString as G, renderList as oe, isRef as Pe, renderSlot as fe, createSlots as rt, normalizeStyle as it, Teleport as Be, normalizeProps as ut, guardReactiveProps as dt } from "vue";
|
|
2
|
+
import { u as ne, c as Ke, S as ct, g as xe, F as Z, d as ye, a as Je, C as Se, b as ze, e as mt, _ as pt, f as vt } from "./app-BbXzmbBO.js";
|
|
3
|
+
import { useDialog as Qe, useSnackbar as Ve, useProxiedModel as Le, useDialogChild as ft, useBreakpoints as yt } from "@feedmepos/ui-library";
|
|
4
|
+
import { i as bt, _ as gt } from "./is-linked-ingredient-error-C6AghEwR.js";
|
|
5
|
+
import { F as W, D as Ne, R as be } from "./row-action.enum-BwQbURNh.js";
|
|
6
|
+
import { c as ht, _ as _t, F as Oe, u as xt } from "./layout-DACHKQ9G.js";
|
|
7
|
+
import { _ as Vt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-Dov3Uq2z.js";
|
|
8
|
+
import { R as ge, U as kt, A as he, M as je, I as Ft } from "./rules-ldw61cGA.js";
|
|
9
|
+
import { g as Ct, _ as we, S as Me } from "./StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js";
|
|
10
|
+
import { _ as St } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-CUj9Mnt6.js";
|
|
11
|
+
import { _ as Ie, t as Xe, d as Ze, s as wt, r as Mt } from "./xlsx.util-BNXjhkYU.js";
|
|
12
|
+
import { a as et, t as tt, f as It } from "./date2-DFqSdEvG.js";
|
|
13
|
+
import { useCoreStore as ve } from "@feedmepos/mf-common";
|
|
14
|
+
import { _ as _e } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
|
|
15
|
+
function $t() {
|
|
16
|
+
const s = Qe(), i = Ve(), f = ne(), o = B(!1), l = B();
|
|
17
|
+
function n() {
|
|
18
|
+
const u = {
|
|
19
|
+
unit: {},
|
|
20
|
+
mode: W.CREATE,
|
|
21
|
+
show: !0,
|
|
22
|
+
"onUpdate:show"(x) {
|
|
23
|
+
l.value.show = x;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
l.value = u;
|
|
27
|
+
}
|
|
28
|
+
async function d(u) {
|
|
29
|
+
const x = {
|
|
30
|
+
unit: Ke(u),
|
|
31
|
+
mode: W.UPDATE,
|
|
32
|
+
show: !0,
|
|
33
|
+
"onUpdate:show"(c) {
|
|
34
|
+
l.value.show = c;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
l.value = x;
|
|
38
|
+
}
|
|
39
|
+
async function y(u) {
|
|
40
|
+
o.value = !0;
|
|
41
|
+
try {
|
|
42
|
+
await f.deleteSku(u), i.open({
|
|
43
|
+
title: "Success",
|
|
44
|
+
message: `Deleted ${u.name}`,
|
|
45
|
+
type: "success"
|
|
46
|
+
});
|
|
47
|
+
} catch (x) {
|
|
48
|
+
x instanceof ct && bt(x) ? s.open({
|
|
49
|
+
title: "Cannot delete ingredient",
|
|
50
|
+
contentComponent: gt,
|
|
51
|
+
contentComponentProps: {
|
|
52
|
+
subject: (u == null ? void 0 : u.name) ?? "",
|
|
53
|
+
items: x.errorResponse.message
|
|
54
|
+
},
|
|
55
|
+
secondaryActions: {
|
|
56
|
+
text: "Close",
|
|
57
|
+
close: !0
|
|
58
|
+
}
|
|
59
|
+
}) : console.log("unable to delete ingredient", x), i.open({
|
|
60
|
+
title: `Cannot delete ${u.name}`,
|
|
61
|
+
message: "Please try again.",
|
|
62
|
+
type: "error"
|
|
63
|
+
}), console.error("failed to delete ingredient", x);
|
|
64
|
+
} finally {
|
|
65
|
+
o.value = !1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function F(u) {
|
|
69
|
+
s.open({
|
|
70
|
+
title: `Delete ${(u == null ? void 0 : u.name) ?? "ingredient"}?`,
|
|
71
|
+
closeButton: !1,
|
|
72
|
+
message: "You may not be able to delete this ingredient if it is linked in any of the inventory modules.",
|
|
73
|
+
primaryActions: {
|
|
74
|
+
text: "Delete",
|
|
75
|
+
close: !0,
|
|
76
|
+
variant: "destructive"
|
|
77
|
+
},
|
|
78
|
+
secondaryActions: {
|
|
79
|
+
text: "Cancel",
|
|
80
|
+
close: !0
|
|
81
|
+
}
|
|
82
|
+
}).onPrimary(() => y(u));
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
createIngredient: n,
|
|
86
|
+
updateIngredient: d,
|
|
87
|
+
deleteIngredient: F,
|
|
88
|
+
ingredientDialogProps: l,
|
|
89
|
+
ingredientViewLoading: o
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function Ut({
|
|
93
|
+
updateIngredient: s,
|
|
94
|
+
deleteIngredient: i
|
|
95
|
+
}) {
|
|
96
|
+
async function f(l, n) {
|
|
97
|
+
const d = Ke(n);
|
|
98
|
+
if (l === be.Edit) {
|
|
99
|
+
await s(d);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (l === be.Delete) {
|
|
103
|
+
await i(d);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { columnDefs: [
|
|
108
|
+
{
|
|
109
|
+
accessorKey: "code",
|
|
110
|
+
header: "Code",
|
|
111
|
+
enableSorting: !0,
|
|
112
|
+
size: 300
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
accessorKey: "name",
|
|
116
|
+
header: "Name",
|
|
117
|
+
enableSorting: !0,
|
|
118
|
+
size: 300
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
accessorFn: (l) => {
|
|
122
|
+
var n;
|
|
123
|
+
if (l.trackingMeasurement) {
|
|
124
|
+
const d = (n = l.unit.measurements) == null ? void 0 : n.find(
|
|
125
|
+
(y) => y.id === l.trackingMeasurement
|
|
126
|
+
);
|
|
127
|
+
if (d)
|
|
128
|
+
return `${d.name} (${d.abbrev})`;
|
|
129
|
+
}
|
|
130
|
+
return `${l.unit.name} (${l.unit.abbrev})`;
|
|
131
|
+
},
|
|
132
|
+
header: "Unit",
|
|
133
|
+
enableSorting: !1,
|
|
134
|
+
size: "auto"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "action",
|
|
138
|
+
header: "",
|
|
139
|
+
cell(l) {
|
|
140
|
+
return ht(
|
|
141
|
+
[Ne[be.Edit], Ne[be.Delete]],
|
|
142
|
+
(n) => {
|
|
143
|
+
f(n, l.row.original);
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
enableSorting: !1,
|
|
148
|
+
size: 40,
|
|
149
|
+
meta: {
|
|
150
|
+
cellClass: "",
|
|
151
|
+
headerClass: ""
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
] };
|
|
155
|
+
}
|
|
156
|
+
const He = /* @__PURE__ */ le({
|
|
157
|
+
__name: "ConvertForm",
|
|
158
|
+
props: {
|
|
159
|
+
modelValue: {},
|
|
160
|
+
rootValue: {},
|
|
161
|
+
disabled: { type: Boolean }
|
|
162
|
+
},
|
|
163
|
+
emits: ["update:modelValue"],
|
|
164
|
+
setup(s, { emit: i }) {
|
|
165
|
+
const f = s, o = k(() => {
|
|
166
|
+
var c;
|
|
167
|
+
return (c = f.rootValue) == null ? void 0 : c.unit;
|
|
168
|
+
}), l = k(() => {
|
|
169
|
+
var c;
|
|
170
|
+
return (c = f.rootValue) == null ? void 0 : c._id;
|
|
171
|
+
}), n = i, d = k({
|
|
172
|
+
get() {
|
|
173
|
+
return !!f.modelValue;
|
|
174
|
+
},
|
|
175
|
+
set(c) {
|
|
176
|
+
c ? n("update:modelValue", {
|
|
177
|
+
measurement: null,
|
|
178
|
+
inventoryBindings: []
|
|
179
|
+
}) : n("update:modelValue", null);
|
|
180
|
+
}
|
|
181
|
+
}), y = k(() => Ct(o.value));
|
|
182
|
+
function F(c) {
|
|
183
|
+
const p = f.modelValue ?? {};
|
|
184
|
+
p.measurement = c ? `${c}` : null, n("update:modelValue", p);
|
|
185
|
+
}
|
|
186
|
+
function u(c) {
|
|
187
|
+
const p = f.modelValue ?? {};
|
|
188
|
+
p.inventoryBindings = c, n("update:modelValue", p);
|
|
189
|
+
}
|
|
190
|
+
const x = k(() => {
|
|
191
|
+
if (!f.modelValue) return null;
|
|
192
|
+
const c = f.modelValue;
|
|
193
|
+
return c.measurement ? y.value.find((p) => p.value === c.measurement) ?? null : y.value.find((p) => p.value === null) ?? null;
|
|
194
|
+
});
|
|
195
|
+
return (c, p) => {
|
|
196
|
+
const T = $("FmSwitch"), h = $("FmSelect"), I = $("FmCard");
|
|
197
|
+
return b(), D(I, {
|
|
198
|
+
variant: "outlined",
|
|
199
|
+
class: "p-16 flex flex-col gap-16"
|
|
200
|
+
}, {
|
|
201
|
+
default: w(() => {
|
|
202
|
+
var M, z;
|
|
203
|
+
return [
|
|
204
|
+
v(T, {
|
|
205
|
+
value: "",
|
|
206
|
+
"model-value": d.value,
|
|
207
|
+
"onUpdate:modelValue": p[0] || (p[0] = (C) => d.value = C),
|
|
208
|
+
label: "Convertible",
|
|
209
|
+
sublabel: "Convertible from other recipe or ingredients",
|
|
210
|
+
labelPlacement: "right"
|
|
211
|
+
}, null, 8, ["model-value"]),
|
|
212
|
+
d.value ? (b(), R(Q, { key: 0 }, [
|
|
213
|
+
r("div", null, [
|
|
214
|
+
v(h, {
|
|
215
|
+
label: "Recipes and ingredients convert to",
|
|
216
|
+
modelValue: (M = x.value) == null ? void 0 : M.value,
|
|
217
|
+
"onUpdate:modelValue": F,
|
|
218
|
+
items: y.value
|
|
219
|
+
}, null, 8, ["modelValue", "items"])
|
|
220
|
+
]),
|
|
221
|
+
v(St, {
|
|
222
|
+
id: l.value,
|
|
223
|
+
"model-value": ((z = c.modelValue) == null ? void 0 : z.inventoryBindings) ?? [],
|
|
224
|
+
"onUpdate:modelValue": u,
|
|
225
|
+
"exclude-binding-id": l.value
|
|
226
|
+
}, null, 8, ["id", "model-value", "exclude-binding-id"])
|
|
227
|
+
], 64)) : L("", !0)
|
|
228
|
+
];
|
|
229
|
+
}),
|
|
230
|
+
_: 1
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
function ce() {
|
|
236
|
+
return {
|
|
237
|
+
low: 6,
|
|
238
|
+
mid: 14
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const Rt = { class: "flex flex-col gap-24" }, Et = { class: "flex gap-24 w-full" }, At = { class: "flex-1" }, Dt = { class: "flex-1" }, Tt = { class: "flex gap-24" }, Pt = { class: "flex-1" }, Bt = { class: "h-24" }, zt = { class: "flex-1" }, Lt = { class: "text-fm-color-typo-secondary" }, Nt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Ot = { class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16" }, jt = { class: "w-full" }, Ht = {
|
|
242
|
+
key: 0,
|
|
243
|
+
class: "flex flex-col gap-8"
|
|
244
|
+
}, Yt = {
|
|
245
|
+
type: "button",
|
|
246
|
+
class: "inline-flex h-32 items-center"
|
|
247
|
+
}, Wt = { class: "text-fm-color-typo-secondary" }, Gt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, qt = { class: "col-span-2 mt-16" }, Kt = {
|
|
248
|
+
key: 1,
|
|
249
|
+
class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
|
|
250
|
+
}, Jt = { class: "col-span-2 flex flex-col gap-12" }, Qt = { class: "flex flex-col gap-4" }, Xt = /* @__PURE__ */ r("div", { class: "fm-typo-en-title-sm-800" }, "Alert threshold", -1), Zt = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Configure threshold for days remaining indicator in the stock balance page. ", -1), eo = { class: "col-span-2 flex flex-col gap-4" }, to = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, oo = { class: "flex-1 p-12 flex flex-col gap-8" }, lo = { class: "mx-auto" }, no = { class: "flex flex-col" }, ao = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), so = /* @__PURE__ */ r("div", {
|
|
251
|
+
class: "text-fm-color-typo-secondary",
|
|
252
|
+
style: { "padding-right": "32px" }
|
|
253
|
+
}, "days", -1), ro = /* @__PURE__ */ r("div", {
|
|
254
|
+
class: "h-full bg-fm-color-neutral-gray-200 relative",
|
|
255
|
+
style: { width: "1px" }
|
|
256
|
+
}, [
|
|
257
|
+
/* @__PURE__ */ r("div", {
|
|
258
|
+
class: "absolute bg-white",
|
|
259
|
+
style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
|
|
260
|
+
}, " < ")
|
|
261
|
+
], -1), io = { class: "flex-1 p-12 flex flex-col gap-8" }, uo = { class: "mx-auto" }, co = { class: "flex flex-col" }, mo = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), po = /* @__PURE__ */ r("div", {
|
|
262
|
+
class: "text-fm-color-typo-secondary",
|
|
263
|
+
style: { "padding-right": "32px" }
|
|
264
|
+
}, "days", -1), vo = /* @__PURE__ */ r("div", {
|
|
265
|
+
class: "h-full bg-fm-color-neutral-gray-200 relative",
|
|
266
|
+
style: { width: "1px" }
|
|
267
|
+
}, [
|
|
268
|
+
/* @__PURE__ */ r("div", {
|
|
269
|
+
class: "absolute bg-white",
|
|
270
|
+
style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
|
|
271
|
+
}, " < ")
|
|
272
|
+
], -1), fo = { class: "flex-1 p-12 flex flex-col gap-8" }, yo = { class: "mx-auto" }, bo = /* @__PURE__ */ r("div", { class: "flex flex-col" }, [
|
|
273
|
+
/* @__PURE__ */ r("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "Stock is staple")
|
|
274
|
+
], -1);
|
|
275
|
+
var $e = /* @__PURE__ */ ((s) => (s.Daily = "Daily", s.Consumables = "Consumables", s.ShortTerm = "Short term", s.Kitchen = "Kitchen", s))($e || {});
|
|
276
|
+
const go = /* @__PURE__ */ le({
|
|
277
|
+
__name: "IngredientForm",
|
|
278
|
+
props: {
|
|
279
|
+
mode: {},
|
|
280
|
+
modelValue: {},
|
|
281
|
+
disabled: { type: Boolean }
|
|
282
|
+
},
|
|
283
|
+
emits: ["update:modelValue", "click:submit"],
|
|
284
|
+
setup(s, { expose: i, emit: f }) {
|
|
285
|
+
var te;
|
|
286
|
+
const o = s, l = f, n = ne(), d = ve(), y = Je();
|
|
287
|
+
function F(e) {
|
|
288
|
+
if (e.length === 0) return;
|
|
289
|
+
const t = e[0], m = o.modelValue ?? {
|
|
290
|
+
unit: n.units.find((_) => _)
|
|
291
|
+
};
|
|
292
|
+
m.unit || (m.unit = t, l("update:modelValue", m));
|
|
293
|
+
}
|
|
294
|
+
st(() => {
|
|
295
|
+
F(n.units);
|
|
296
|
+
}), Ge([() => n.units], ([e]) => {
|
|
297
|
+
F(e);
|
|
298
|
+
});
|
|
299
|
+
function u() {
|
|
300
|
+
l("click:submit");
|
|
301
|
+
}
|
|
302
|
+
const x = k({
|
|
303
|
+
get() {
|
|
304
|
+
var e;
|
|
305
|
+
return ((e = o.modelValue) == null ? void 0 : e.code) ?? "";
|
|
306
|
+
},
|
|
307
|
+
set(e) {
|
|
308
|
+
const t = o.modelValue ? {
|
|
309
|
+
...o.modelValue
|
|
310
|
+
} : {};
|
|
311
|
+
t.code = e, l("update:modelValue", t);
|
|
312
|
+
}
|
|
313
|
+
}), c = k({
|
|
314
|
+
get() {
|
|
315
|
+
var e;
|
|
316
|
+
return ((e = o.modelValue) == null ? void 0 : e.name) ?? "";
|
|
317
|
+
},
|
|
318
|
+
set(e) {
|
|
319
|
+
const t = o.modelValue ? {
|
|
320
|
+
...o.modelValue
|
|
321
|
+
} : {};
|
|
322
|
+
t.name = e, l("update:modelValue", t);
|
|
323
|
+
}
|
|
324
|
+
}), p = k({
|
|
325
|
+
get() {
|
|
326
|
+
var t, m;
|
|
327
|
+
const e = (m = (t = o.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : m.costPerUnit;
|
|
328
|
+
return e ? +et(e) : 0;
|
|
329
|
+
},
|
|
330
|
+
set(e) {
|
|
331
|
+
var m, _, A, U;
|
|
332
|
+
const t = o.modelValue ? {
|
|
333
|
+
...o.modelValue
|
|
334
|
+
} : {};
|
|
335
|
+
t.defaultCost ?? (t.defaultCost = {
|
|
336
|
+
costPerUnit: {
|
|
337
|
+
amount: 0,
|
|
338
|
+
precision: 2,
|
|
339
|
+
currency: ((m = xe(d.currentCountry.value)) == null ? void 0 : m.currency) ?? "MYR"
|
|
340
|
+
},
|
|
341
|
+
measurement: (U = (A = (_ = o.modelValue) == null ? void 0 : _.unit) == null ? void 0 : A.measurements) == null ? void 0 : U.find(
|
|
342
|
+
(j) => {
|
|
343
|
+
var Y;
|
|
344
|
+
return j.id === ((Y = o.modelValue) == null ? void 0 : Y.trackingMeasurement);
|
|
345
|
+
}
|
|
346
|
+
)
|
|
347
|
+
}), t.defaultCost.costPerUnit = {
|
|
348
|
+
...t.defaultCost.costPerUnit,
|
|
349
|
+
...tt(+e, 4)
|
|
350
|
+
}, l("update:modelValue", t);
|
|
351
|
+
}
|
|
352
|
+
}), T = k(() => {
|
|
353
|
+
var t, m, _;
|
|
354
|
+
const e = ((t = o.modelValue) == null ? void 0 : t.unit) ?? n.units.find((A) => A);
|
|
355
|
+
return e ? {
|
|
356
|
+
_id: e._id,
|
|
357
|
+
measurement: (m = o.modelValue) == null ? void 0 : m.trackingMeasurement,
|
|
358
|
+
name: ((_ = e.measurements.find((A) => {
|
|
359
|
+
var U;
|
|
360
|
+
return A.id === ((U = o.modelValue) == null ? void 0 : U.trackingMeasurement);
|
|
361
|
+
})) == null ? void 0 : _.name) ?? e.name
|
|
362
|
+
} : null;
|
|
363
|
+
}), h = k({
|
|
364
|
+
get() {
|
|
365
|
+
var e;
|
|
366
|
+
return ((e = o.modelValue) == null ? void 0 : e.operationalGroup) ?? null;
|
|
367
|
+
},
|
|
368
|
+
set(e) {
|
|
369
|
+
const t = o.modelValue ? {
|
|
370
|
+
...o.modelValue
|
|
371
|
+
} : {};
|
|
372
|
+
t.operationalGroup = e, l("update:modelValue", t);
|
|
373
|
+
}
|
|
374
|
+
}), I = k(
|
|
375
|
+
() => [
|
|
376
|
+
...new Set(
|
|
377
|
+
n.skus.map((e) => e.operationalGroup ?? "").filter((e) => e && !Object.values($e).includes(e))
|
|
378
|
+
)
|
|
379
|
+
].sort()
|
|
380
|
+
), M = k({
|
|
381
|
+
get() {
|
|
382
|
+
return h.value !== null;
|
|
383
|
+
},
|
|
384
|
+
set(e) {
|
|
385
|
+
e ? h.value = "" : h.value = null;
|
|
386
|
+
}
|
|
387
|
+
}), z = k(
|
|
388
|
+
() => n.units.flatMap(({ name: e, _id: t, abbrev: m, measurements: _ }) => [
|
|
389
|
+
{
|
|
390
|
+
label: `${e}`,
|
|
391
|
+
value: null,
|
|
392
|
+
displayAsSection: !0
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
label: `${e} (${m})`,
|
|
396
|
+
value: { _id: t },
|
|
397
|
+
displayAsSection: !1
|
|
398
|
+
},
|
|
399
|
+
..._.map(({ id: A, name: U, abbrev: j }) => ({
|
|
400
|
+
label: `${U} (${j})`,
|
|
401
|
+
value: { _id: t, measurement: A },
|
|
402
|
+
displayAsSection: !1
|
|
403
|
+
}))
|
|
404
|
+
])
|
|
405
|
+
);
|
|
406
|
+
function C(e) {
|
|
407
|
+
var t, m, _, A, U;
|
|
408
|
+
return ((m = (t = o.modelValue) == null ? void 0 : t.unit) == null ? void 0 : m._id) === ((_ = e.value) == null ? void 0 : _._id) && ((A = o.modelValue) == null ? void 0 : A.trackingMeasurement) === ((U = e.value) == null ? void 0 : U.measurement);
|
|
409
|
+
}
|
|
410
|
+
function me(e) {
|
|
411
|
+
var j, Y;
|
|
412
|
+
if (!e) return;
|
|
413
|
+
const { _id: t, measurement: m } = e, _ = m || void 0, A = n.units.find((q) => q._id === t);
|
|
414
|
+
if (!A)
|
|
415
|
+
return;
|
|
416
|
+
const U = o.modelValue ?? {};
|
|
417
|
+
U.unit = A, U.trackingMeasurement = _, U.convert && (U.convert.measurement = _ || null), y.enableTotalCost && (U.defaultCost = {
|
|
418
|
+
measurement: A.measurements.find((q) => q.id === _),
|
|
419
|
+
costPerUnit: {
|
|
420
|
+
...((j = U.defaultCost) == null ? void 0 : j.costPerUnit) ?? {
|
|
421
|
+
amount: 0,
|
|
422
|
+
precision: 2,
|
|
423
|
+
currency: ((Y = xe(d.currentCountry.value)) == null ? void 0 : Y.currency) ?? "MYR"
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}), l("update:modelValue", U);
|
|
427
|
+
}
|
|
428
|
+
const H = k({
|
|
429
|
+
get() {
|
|
430
|
+
var e;
|
|
431
|
+
return ((e = o.modelValue) == null ? void 0 : e.convert) ?? null;
|
|
432
|
+
},
|
|
433
|
+
set(e) {
|
|
434
|
+
const t = o.modelValue ? {
|
|
435
|
+
...o.modelValue
|
|
436
|
+
} : {};
|
|
437
|
+
e ? t.convert = e : t.convert = null, l("update:modelValue", t);
|
|
438
|
+
}
|
|
439
|
+
}), ae = k(() => Z.options.filter(
|
|
440
|
+
(e) => e === Z.enum.FIFO || e === Z.enum.WAVG
|
|
441
|
+
).map((e) => {
|
|
442
|
+
function t(m) {
|
|
443
|
+
switch (m) {
|
|
444
|
+
case Z.enum.WAVG:
|
|
445
|
+
return "Weighted Average (WAVG)";
|
|
446
|
+
case Z.enum.FIFO:
|
|
447
|
+
return "First In First Out (FIFO)";
|
|
448
|
+
case Z.enum.LIFO:
|
|
449
|
+
return "Last In First Out (LIFO)";
|
|
450
|
+
case Z.enum.FEFO:
|
|
451
|
+
return "First Expired First Out (FEFO)";
|
|
452
|
+
}
|
|
453
|
+
return "";
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
label: t(e),
|
|
457
|
+
value: e
|
|
458
|
+
};
|
|
459
|
+
})), se = k({
|
|
460
|
+
get() {
|
|
461
|
+
var e;
|
|
462
|
+
return ((e = o.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
|
|
463
|
+
},
|
|
464
|
+
set(e) {
|
|
465
|
+
const t = o.modelValue ? {
|
|
466
|
+
...o.modelValue
|
|
467
|
+
} : {};
|
|
468
|
+
t.valuation = e, l("update:modelValue", t);
|
|
469
|
+
}
|
|
470
|
+
}), J = B();
|
|
471
|
+
i({
|
|
472
|
+
validateInputs: () => {
|
|
473
|
+
var e, t;
|
|
474
|
+
(t = (e = J.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
|
|
475
|
+
},
|
|
476
|
+
resetInputsValidation: () => {
|
|
477
|
+
var e, t;
|
|
478
|
+
(t = (e = J.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
|
|
479
|
+
},
|
|
480
|
+
resetInputs: () => {
|
|
481
|
+
var e, t;
|
|
482
|
+
(t = (e = J.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
const a = B(!1), N = k(
|
|
486
|
+
() => {
|
|
487
|
+
var e, t, m;
|
|
488
|
+
return (e = o.modelValue) != null && e._id ? ((m = n.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
|
|
489
|
+
(_) => _.from === "INGREDIENT"
|
|
490
|
+
)) ?? [] : [];
|
|
491
|
+
}
|
|
492
|
+
), O = k(
|
|
493
|
+
() => {
|
|
494
|
+
var e, t, m;
|
|
495
|
+
return (e = o.modelValue) != null && e._id ? ((m = n.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
|
|
496
|
+
(_) => _.from === "RECIPE"
|
|
497
|
+
)) ?? [] : [];
|
|
498
|
+
}
|
|
499
|
+
), re = k(
|
|
500
|
+
() => {
|
|
501
|
+
var e, t, m;
|
|
502
|
+
return (e = o.modelValue) != null && e._id ? ((m = n.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter((_) => _.from === "MENU")) ?? [] : [];
|
|
503
|
+
}
|
|
504
|
+
), ie = k(
|
|
505
|
+
() => n.skus.map((e) => ({ label: e.name, value: e.code }))
|
|
506
|
+
), E = B((te = o.modelValue) == null ? void 0 : te.code);
|
|
507
|
+
function S(e) {
|
|
508
|
+
var m;
|
|
509
|
+
const t = e.el;
|
|
510
|
+
t && ((m = t.querySelector("[x-should-scroll-into=true]")) == null || m.scrollIntoView());
|
|
511
|
+
}
|
|
512
|
+
function ue(e) {
|
|
513
|
+
switch (e) {
|
|
514
|
+
case Se.MY:
|
|
515
|
+
return "MYR";
|
|
516
|
+
case Se.SG:
|
|
517
|
+
return "SGD";
|
|
518
|
+
case Se.ID:
|
|
519
|
+
return "IDR";
|
|
520
|
+
default:
|
|
521
|
+
return "MYR";
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const ke = k(
|
|
525
|
+
() => {
|
|
526
|
+
var e, t, m, _, A, U;
|
|
527
|
+
return ((_ = (m = (t = (e = o.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : m.find(
|
|
528
|
+
(j) => {
|
|
529
|
+
var Y;
|
|
530
|
+
return j.id === ((Y = o.modelValue) == null ? void 0 : Y.trackingMeasurement);
|
|
531
|
+
}
|
|
532
|
+
)) == null ? void 0 : _.abbrev) ?? ((U = (A = o.modelValue) == null ? void 0 : A.unit) == null ? void 0 : U.abbrev);
|
|
533
|
+
}
|
|
534
|
+
), de = k({
|
|
535
|
+
get() {
|
|
536
|
+
var e, t;
|
|
537
|
+
return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? ce().low;
|
|
538
|
+
},
|
|
539
|
+
set(e) {
|
|
540
|
+
var _;
|
|
541
|
+
const t = ((_ = o.modelValue) == null ? void 0 : _.thresholds) ?? ce();
|
|
542
|
+
t.low = e;
|
|
543
|
+
const m = o.modelValue ? {
|
|
544
|
+
...o.modelValue
|
|
545
|
+
} : {};
|
|
546
|
+
m.thresholds = t, l("update:modelValue", m);
|
|
547
|
+
}
|
|
548
|
+
}), ee = k({
|
|
549
|
+
get() {
|
|
550
|
+
var e, t;
|
|
551
|
+
return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? ce().mid;
|
|
552
|
+
},
|
|
553
|
+
set(e) {
|
|
554
|
+
var _;
|
|
555
|
+
const t = ((_ = o.modelValue) == null ? void 0 : _.thresholds) ?? ce();
|
|
556
|
+
t.mid = e;
|
|
557
|
+
const m = o.modelValue ? {
|
|
558
|
+
...o.modelValue
|
|
559
|
+
} : {};
|
|
560
|
+
m.thresholds = t, l("update:modelValue", m);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
function K() {
|
|
564
|
+
return function(t) {
|
|
565
|
+
return typeof (t == null ? void 0 : t.low) != "number" || typeof (t == null ? void 0 : t.mid) != "number" ? "Required" : t.low >= t.mid ? "Days for red indicator should be less than yellow indicator." : !0;
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
return (e, t) => {
|
|
569
|
+
const m = $("FmTextField"), _ = $("FmLabel"), A = $("FmSelect"), U = $("FmField"), j = $("FmMenuHeader"), Y = $("FmMenuDivider"), q = $("FmMenuItem"), pe = $("FmMenu"), Fe = $("FmFormGroup"), Ue = $("FmSwitch"), lt = $("FmIcon"), Re = $("FmStepperField"), nt = $("FmForm");
|
|
570
|
+
return b(), D(nt, {
|
|
571
|
+
disabled: e.disabled,
|
|
572
|
+
ref_key: "formRef",
|
|
573
|
+
ref: J,
|
|
574
|
+
class: "flex flex-col gap-32",
|
|
575
|
+
onValidationSuccess: u
|
|
576
|
+
}, {
|
|
577
|
+
default: w(() => [
|
|
578
|
+
r("div", Rt, [
|
|
579
|
+
r("div", Et, [
|
|
580
|
+
r("div", At, [
|
|
581
|
+
v(m, {
|
|
582
|
+
label: "Code",
|
|
583
|
+
"model-value": x.value,
|
|
584
|
+
"onUpdate:modelValue": t[0] || (t[0] = (g) => x.value = g),
|
|
585
|
+
rules: [V(ge)(), V(kt)(ie.value, E.value)],
|
|
586
|
+
"label-mark": "required"
|
|
587
|
+
}, null, 8, ["model-value", "rules"])
|
|
588
|
+
]),
|
|
589
|
+
r("div", Dt, [
|
|
590
|
+
v(m, {
|
|
591
|
+
label: "Name",
|
|
592
|
+
"model-value": c.value,
|
|
593
|
+
"onUpdate:modelValue": t[1] || (t[1] = (g) => c.value = g),
|
|
594
|
+
rules: [V(ge)()],
|
|
595
|
+
"label-mark": "required"
|
|
596
|
+
}, null, 8, ["model-value", "rules"])
|
|
597
|
+
])
|
|
598
|
+
]),
|
|
599
|
+
V(y).enableTotalCost ? (b(), D(A, {
|
|
600
|
+
key: 0,
|
|
601
|
+
class: "w-full",
|
|
602
|
+
"model-value": se.value,
|
|
603
|
+
"onUpdate:modelValue": t[2] || (t[2] = (g) => se.value = g),
|
|
604
|
+
items: ae.value
|
|
605
|
+
}, {
|
|
606
|
+
label: w(() => [
|
|
607
|
+
v(_e, { "z-index": 50 }, {
|
|
608
|
+
default: w(() => [
|
|
609
|
+
v(_, { label: "Valuation Method" })
|
|
610
|
+
]),
|
|
611
|
+
_: 1
|
|
612
|
+
})
|
|
613
|
+
]),
|
|
614
|
+
_: 1
|
|
615
|
+
}, 8, ["model-value", "items"])) : L("", !0),
|
|
616
|
+
r("div", Tt, [
|
|
617
|
+
r("div", Pt, [
|
|
618
|
+
v(Fe, {
|
|
619
|
+
"model-value": T.value,
|
|
620
|
+
rules: [V(ge)()],
|
|
621
|
+
"label-mark": "required"
|
|
622
|
+
}, {
|
|
623
|
+
label: w(() => [
|
|
624
|
+
r("div", Bt, [
|
|
625
|
+
v(_, { label: "Unit" })
|
|
626
|
+
])
|
|
627
|
+
]),
|
|
628
|
+
default: w(({ invalid: g }) => [
|
|
629
|
+
v(pe, null, {
|
|
630
|
+
"menu-button": w(() => [
|
|
631
|
+
v(U, {
|
|
632
|
+
class: X([
|
|
633
|
+
"fm-typo-en-body-lg-400",
|
|
634
|
+
{
|
|
635
|
+
"text-fm-color-typo-primary": !e.disabled,
|
|
636
|
+
"text-fm-color-typo-disabled": e.disabled
|
|
637
|
+
}
|
|
638
|
+
]),
|
|
639
|
+
invalid: g,
|
|
640
|
+
"append-icon": "expand_more"
|
|
641
|
+
}, {
|
|
642
|
+
default: w(() => {
|
|
643
|
+
var P;
|
|
644
|
+
return [
|
|
645
|
+
qe(G((P = T.value) == null ? void 0 : P.name), 1)
|
|
646
|
+
];
|
|
647
|
+
}),
|
|
648
|
+
_: 2
|
|
649
|
+
}, 1032, ["class", "invalid"])
|
|
650
|
+
]),
|
|
651
|
+
default: w(() => [
|
|
652
|
+
r("div", {
|
|
653
|
+
class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
|
|
654
|
+
onVnodeMounted: S
|
|
655
|
+
}, [
|
|
656
|
+
(b(!0), R(Q, null, oe(z.value, (P) => (b(), R(Q, {
|
|
657
|
+
key: P.label
|
|
658
|
+
}, [
|
|
659
|
+
P.displayAsSection ? (b(), R(Q, { key: 0 }, [
|
|
660
|
+
v(j, {
|
|
661
|
+
label: P.label
|
|
662
|
+
}, null, 8, ["label"]),
|
|
663
|
+
v(Y)
|
|
664
|
+
], 64)) : (b(), D(q, {
|
|
665
|
+
key: 1,
|
|
666
|
+
label: P.label,
|
|
667
|
+
"model-value": C(P),
|
|
668
|
+
onClick: (Ce) => me(P.value),
|
|
669
|
+
"x-should-scroll-into": `${C(P)}`
|
|
670
|
+
}, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
|
|
671
|
+
], 64))), 128))
|
|
672
|
+
], 512)
|
|
673
|
+
]),
|
|
674
|
+
_: 2
|
|
675
|
+
}, 1024)
|
|
676
|
+
]),
|
|
677
|
+
_: 1
|
|
678
|
+
}, 8, ["model-value", "rules"])
|
|
679
|
+
]),
|
|
680
|
+
r("div", zt, [
|
|
681
|
+
V(y).enableTotalCost ? (b(), D(m, {
|
|
682
|
+
key: 0,
|
|
683
|
+
"model-value": p.value,
|
|
684
|
+
"onUpdate:modelValue": t[3] || (t[3] = (g) => p.value = g),
|
|
685
|
+
rules: [V(he)(0), V(je)(2)]
|
|
686
|
+
}, {
|
|
687
|
+
label: w(() => [
|
|
688
|
+
v(_e, { "z-index": 50 }, {
|
|
689
|
+
default: w(() => [
|
|
690
|
+
v(_, { label: "Price per unit" })
|
|
691
|
+
]),
|
|
692
|
+
_: 1
|
|
693
|
+
})
|
|
694
|
+
]),
|
|
695
|
+
prepend: w(() => {
|
|
696
|
+
var g, P;
|
|
697
|
+
return [
|
|
698
|
+
r("div", Lt, G(ue(((g = V(d).currentCountry) == null ? void 0 : g.value) ?? V(ye)) === "MYR" ? "RM" : ue(((P = V(d).currentCountry) == null ? void 0 : P.value) ?? V(ye))), 1)
|
|
699
|
+
];
|
|
700
|
+
}),
|
|
701
|
+
append: w(() => {
|
|
702
|
+
var g, P, Ce, Ee, Ae, De;
|
|
703
|
+
return [
|
|
704
|
+
r("div", Nt, " / " + G(((Ee = (Ce = (P = (g = e.modelValue) == null ? void 0 : g.unit) == null ? void 0 : P.measurements) == null ? void 0 : Ce.find(
|
|
705
|
+
(at) => {
|
|
706
|
+
var Te;
|
|
707
|
+
return at.id === ((Te = e.modelValue) == null ? void 0 : Te.trackingMeasurement);
|
|
708
|
+
}
|
|
709
|
+
)) == null ? void 0 : Ee.abbrev) ?? ((De = (Ae = e.modelValue) == null ? void 0 : Ae.unit) == null ? void 0 : De.abbrev)), 1)
|
|
710
|
+
];
|
|
711
|
+
}),
|
|
712
|
+
_: 1
|
|
713
|
+
}, 8, ["model-value", "rules"])) : L("", !0)
|
|
714
|
+
])
|
|
715
|
+
])
|
|
716
|
+
]),
|
|
717
|
+
v(He, {
|
|
718
|
+
"model-value": H.value,
|
|
719
|
+
"onUpdate:modelValue": t[4] || (t[4] = (g) => H.value = g),
|
|
720
|
+
"root-value": e.modelValue
|
|
721
|
+
}, null, 8, ["model-value", "root-value"]),
|
|
722
|
+
r("div", Ot, [
|
|
723
|
+
r("div", jt, [
|
|
724
|
+
v(Ue, {
|
|
725
|
+
label: "Assign operational group",
|
|
726
|
+
sublabel: "Assign label for routine disposal",
|
|
727
|
+
modelValue: M.value,
|
|
728
|
+
"onUpdate:modelValue": t[5] || (t[5] = (g) => M.value = g),
|
|
729
|
+
"label-placement": "right"
|
|
730
|
+
}, null, 8, ["modelValue"])
|
|
731
|
+
]),
|
|
732
|
+
M.value ? (b(), R("div", Ht, [
|
|
733
|
+
v(pe, null, {
|
|
734
|
+
"menu-button": w(() => [
|
|
735
|
+
v(m, {
|
|
736
|
+
label: "Operational label",
|
|
737
|
+
modelValue: h.value,
|
|
738
|
+
"onUpdate:modelValue": t[6] || (t[6] = (g) => h.value = g),
|
|
739
|
+
placeholder: "Input text or select preset"
|
|
740
|
+
}, {
|
|
741
|
+
append: w(() => [
|
|
742
|
+
r("button", Yt, [
|
|
743
|
+
v(lt, { name: "expand_more" })
|
|
744
|
+
])
|
|
745
|
+
]),
|
|
746
|
+
_: 1
|
|
747
|
+
}, 8, ["modelValue"])
|
|
748
|
+
]),
|
|
749
|
+
default: w(() => [
|
|
750
|
+
v(j, { label: "Preset" }),
|
|
751
|
+
(b(!0), R(Q, null, oe(Object.values($e), (g) => (b(), D(q, {
|
|
752
|
+
key: g,
|
|
753
|
+
label: g,
|
|
754
|
+
"model-value": h.value === g,
|
|
755
|
+
onClick: (P) => h.value = g
|
|
756
|
+
}, null, 8, ["label", "model-value", "onClick"]))), 128)),
|
|
757
|
+
I.value.length ? (b(), D(j, {
|
|
758
|
+
key: 0,
|
|
759
|
+
label: "Custom"
|
|
760
|
+
})) : L("", !0),
|
|
761
|
+
(b(!0), R(Q, null, oe(I.value, (g) => (b(), D(q, {
|
|
762
|
+
key: g,
|
|
763
|
+
label: g,
|
|
764
|
+
"model-value": h.value === g,
|
|
765
|
+
onClick: (P) => h.value = g
|
|
766
|
+
}, null, 8, ["label", "model-value", "onClick"]))), 128))
|
|
767
|
+
]),
|
|
768
|
+
_: 1
|
|
769
|
+
}),
|
|
770
|
+
v(Fe, {
|
|
771
|
+
"model-value": h.value,
|
|
772
|
+
rules: [V(ge)()]
|
|
773
|
+
}, null, 8, ["model-value", "rules"])
|
|
774
|
+
])) : L("", !0)
|
|
775
|
+
]),
|
|
776
|
+
V(y).enableTotalCost ? (b(), D(m, {
|
|
777
|
+
key: 0,
|
|
778
|
+
"model-value": p.value,
|
|
779
|
+
"onUpdate:modelValue": t[7] || (t[7] = (g) => p.value = g),
|
|
780
|
+
rules: [V(he)(0), V(je)(2)]
|
|
781
|
+
}, {
|
|
782
|
+
label: w(() => [
|
|
783
|
+
v(_e, { "z-index": 50 }, {
|
|
784
|
+
default: w(() => [
|
|
785
|
+
v(_, { label: "Price per unit" })
|
|
786
|
+
]),
|
|
787
|
+
_: 1
|
|
788
|
+
})
|
|
789
|
+
]),
|
|
790
|
+
prepend: w(() => {
|
|
791
|
+
var g, P;
|
|
792
|
+
return [
|
|
793
|
+
r("div", Wt, G(ue(((g = V(d).currentCountry) == null ? void 0 : g.value) ?? V(ye)) === "MYR" ? "RM" : ue(((P = V(d).currentCountry) == null ? void 0 : P.value) ?? V(ye))), 1)
|
|
794
|
+
];
|
|
795
|
+
}),
|
|
796
|
+
append: w(() => [
|
|
797
|
+
r("div", Gt, " / " + G(ke.value), 1)
|
|
798
|
+
]),
|
|
799
|
+
_: 1
|
|
800
|
+
}, 8, ["model-value", "rules"])) : L("", !0),
|
|
801
|
+
r("div", qt, [
|
|
802
|
+
v(He, {
|
|
803
|
+
"model-value": H.value,
|
|
804
|
+
"onUpdate:modelValue": t[8] || (t[8] = (g) => H.value = g),
|
|
805
|
+
"root-value": e.modelValue
|
|
806
|
+
}, null, 8, ["model-value", "root-value"])
|
|
807
|
+
]),
|
|
808
|
+
e.mode !== V(W).CREATE ? (b(), R("div", Kt, [
|
|
809
|
+
r("div", null, [
|
|
810
|
+
v(Ue, {
|
|
811
|
+
label: "Show binded items",
|
|
812
|
+
modelValue: a.value,
|
|
813
|
+
"onUpdate:modelValue": t[9] || (t[9] = (g) => a.value = g),
|
|
814
|
+
"label-placement": "right"
|
|
815
|
+
}, null, 8, ["modelValue"])
|
|
816
|
+
]),
|
|
817
|
+
a.value && N.value.length ? (b(), D(Ie, {
|
|
818
|
+
key: 0,
|
|
819
|
+
name: "Ingredient",
|
|
820
|
+
bindings: N.value
|
|
821
|
+
}, null, 8, ["bindings"])) : L("", !0),
|
|
822
|
+
a.value && O.value.length ? (b(), D(Ie, {
|
|
823
|
+
key: 1,
|
|
824
|
+
name: "Recipe",
|
|
825
|
+
bindings: O.value
|
|
826
|
+
}, null, 8, ["bindings"])) : L("", !0),
|
|
827
|
+
a.value && re.value.length ? (b(), D(Ie, {
|
|
828
|
+
key: 2,
|
|
829
|
+
name: "Menu",
|
|
830
|
+
bindings: re.value
|
|
831
|
+
}, null, 8, ["bindings"])) : L("", !0)
|
|
832
|
+
])) : L("", !0),
|
|
833
|
+
r("div", Jt, [
|
|
834
|
+
r("div", Qt, [
|
|
835
|
+
v(_e, null, {
|
|
836
|
+
default: w(() => [
|
|
837
|
+
Xt
|
|
838
|
+
]),
|
|
839
|
+
_: 1
|
|
840
|
+
}),
|
|
841
|
+
Zt
|
|
842
|
+
]),
|
|
843
|
+
r("div", eo, [
|
|
844
|
+
v(Fe, {
|
|
845
|
+
"model-value": { low: de.value, mid: ee.value },
|
|
846
|
+
rules: [K()]
|
|
847
|
+
}, null, 8, ["model-value", "rules"]),
|
|
848
|
+
r("div", to, [
|
|
849
|
+
r("div", oo, [
|
|
850
|
+
r("div", lo, [
|
|
851
|
+
v(we, {
|
|
852
|
+
days: de.value,
|
|
853
|
+
level: V(Me).low
|
|
854
|
+
}, null, 8, ["days", "level"])
|
|
855
|
+
]),
|
|
856
|
+
r("div", no, [
|
|
857
|
+
ao,
|
|
858
|
+
v(Re, {
|
|
859
|
+
modelValue: de.value,
|
|
860
|
+
"onUpdate:modelValue": t[10] || (t[10] = (g) => de.value = g),
|
|
861
|
+
rules: [V(he)(0)]
|
|
862
|
+
}, {
|
|
863
|
+
append: w(() => [
|
|
864
|
+
so
|
|
865
|
+
]),
|
|
866
|
+
_: 1
|
|
867
|
+
}, 8, ["modelValue", "rules"])
|
|
868
|
+
])
|
|
869
|
+
]),
|
|
870
|
+
ro,
|
|
871
|
+
r("div", io, [
|
|
872
|
+
r("div", uo, [
|
|
873
|
+
v(we, {
|
|
874
|
+
days: ee.value,
|
|
875
|
+
level: V(Me).mid
|
|
876
|
+
}, null, 8, ["days", "level"])
|
|
877
|
+
]),
|
|
878
|
+
r("div", co, [
|
|
879
|
+
mo,
|
|
880
|
+
v(Re, {
|
|
881
|
+
modelValue: ee.value,
|
|
882
|
+
"onUpdate:modelValue": t[11] || (t[11] = (g) => ee.value = g),
|
|
883
|
+
rules: [V(he)(0)]
|
|
884
|
+
}, {
|
|
885
|
+
append: w(() => [
|
|
886
|
+
po
|
|
887
|
+
]),
|
|
888
|
+
_: 1
|
|
889
|
+
}, 8, ["modelValue", "rules"])
|
|
890
|
+
])
|
|
891
|
+
]),
|
|
892
|
+
vo,
|
|
893
|
+
r("div", fo, [
|
|
894
|
+
r("div", yo, [
|
|
895
|
+
v(we, {
|
|
896
|
+
days: ee.value + 1,
|
|
897
|
+
level: V(Me).high
|
|
898
|
+
}, null, 8, ["days", "level"])
|
|
899
|
+
]),
|
|
900
|
+
bo
|
|
901
|
+
])
|
|
902
|
+
])
|
|
903
|
+
])
|
|
904
|
+
])
|
|
905
|
+
]),
|
|
906
|
+
_: 1
|
|
907
|
+
}, 8, ["disabled"]);
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
}), ho = { class: "flex gap-4" }, _o = /* @__PURE__ */ le({
|
|
911
|
+
__name: "IngredientDialog",
|
|
912
|
+
props: {
|
|
913
|
+
show: { type: Boolean },
|
|
914
|
+
unit: {},
|
|
915
|
+
mode: { default: W.READ }
|
|
916
|
+
},
|
|
917
|
+
emits: ["update:show"],
|
|
918
|
+
setup(s) {
|
|
919
|
+
const i = s, f = ne(), o = Ve(), l = Le(i, "show"), n = Le(i, "unit"), d = k(() => {
|
|
920
|
+
switch (i.mode) {
|
|
921
|
+
case W.READ:
|
|
922
|
+
return "View ingredient";
|
|
923
|
+
case W.UPDATE:
|
|
924
|
+
return "Edit ingredient";
|
|
925
|
+
case W.CREATE:
|
|
926
|
+
return "Add ingredient";
|
|
927
|
+
}
|
|
928
|
+
return "";
|
|
929
|
+
}), y = k(() => {
|
|
930
|
+
switch (i.mode) {
|
|
931
|
+
case W.READ:
|
|
932
|
+
return "";
|
|
933
|
+
case W.UPDATE:
|
|
934
|
+
return "Save";
|
|
935
|
+
case W.CREATE:
|
|
936
|
+
return "Add";
|
|
937
|
+
}
|
|
938
|
+
return "";
|
|
939
|
+
}), F = B(), u = B(!1);
|
|
940
|
+
async function x() {
|
|
941
|
+
u.value = !0;
|
|
942
|
+
try {
|
|
943
|
+
await f.createSku(n.value), l.value = !1, o.open({
|
|
944
|
+
title: "Success",
|
|
945
|
+
message: "Created " + n.value.name,
|
|
946
|
+
type: "success"
|
|
947
|
+
});
|
|
948
|
+
} catch (h) {
|
|
949
|
+
h instanceof ze || o.open({
|
|
950
|
+
title: "Failed to create ingredient",
|
|
951
|
+
message: "Please try again",
|
|
952
|
+
type: "error"
|
|
953
|
+
});
|
|
954
|
+
} finally {
|
|
955
|
+
u.value = !1;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
async function c() {
|
|
959
|
+
u.value = !0;
|
|
960
|
+
try {
|
|
961
|
+
await f.updateSku(n.value), u.value = !1, l.value = !1, o.open({
|
|
962
|
+
title: "Success",
|
|
963
|
+
message: "Updated " + n.value.name,
|
|
964
|
+
type: "success"
|
|
965
|
+
});
|
|
966
|
+
} catch (h) {
|
|
967
|
+
h instanceof ze || o.open({
|
|
968
|
+
title: "Failed to update ingredient",
|
|
969
|
+
message: "Please try again",
|
|
970
|
+
type: "error"
|
|
971
|
+
});
|
|
972
|
+
} finally {
|
|
973
|
+
u.value = !1;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function p() {
|
|
977
|
+
var h, I;
|
|
978
|
+
(I = (h = F.value) == null ? void 0 : h.validateInputs) == null || I.call(h);
|
|
979
|
+
}
|
|
980
|
+
function T() {
|
|
981
|
+
switch (i.mode) {
|
|
982
|
+
case W.READ:
|
|
983
|
+
return;
|
|
984
|
+
case W.UPDATE:
|
|
985
|
+
return c();
|
|
986
|
+
case W.CREATE:
|
|
987
|
+
return x();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
return (h, I) => {
|
|
991
|
+
const M = $("FmButton"), z = $("FmSideSheet");
|
|
992
|
+
return b(), D(z, {
|
|
993
|
+
"model-value": V(l),
|
|
994
|
+
"onUpdate:modelValue": I[3] || (I[3] = (C) => Pe(l) ? l.value = C : null),
|
|
995
|
+
header: d.value,
|
|
996
|
+
"close-button": "",
|
|
997
|
+
"dismiss-away": "",
|
|
998
|
+
"max-width": 500
|
|
999
|
+
}, {
|
|
1000
|
+
"side-sheet-footer": w(() => [
|
|
1001
|
+
r("div", ho, [
|
|
1002
|
+
v(M, {
|
|
1003
|
+
loading: u.value,
|
|
1004
|
+
label: y.value,
|
|
1005
|
+
onClick: p
|
|
1006
|
+
}, null, 8, ["loading", "label"]),
|
|
1007
|
+
v(M, {
|
|
1008
|
+
disabled: u.value,
|
|
1009
|
+
label: "Close",
|
|
1010
|
+
variant: "tertiary",
|
|
1011
|
+
onClick: I[2] || (I[2] = (C) => l.value = !1)
|
|
1012
|
+
}, null, 8, ["disabled"])
|
|
1013
|
+
])
|
|
1014
|
+
]),
|
|
1015
|
+
default: w(() => [
|
|
1016
|
+
v(go, {
|
|
1017
|
+
class: "w-full",
|
|
1018
|
+
ref_key: "hasValidationExpose",
|
|
1019
|
+
ref: F,
|
|
1020
|
+
modelValue: V(n),
|
|
1021
|
+
"onUpdate:modelValue": I[0] || (I[0] = (C) => Pe(n) ? n.value = C : null),
|
|
1022
|
+
mode: h.mode,
|
|
1023
|
+
disabled: u.value,
|
|
1024
|
+
"onClick:submit": I[1] || (I[1] = (C) => T())
|
|
1025
|
+
}, null, 8, ["modelValue", "mode", "disabled"])
|
|
1026
|
+
]),
|
|
1027
|
+
_: 1
|
|
1028
|
+
}, 8, ["model-value", "header"]);
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
function* xo(s) {
|
|
1033
|
+
for (; ; )
|
|
1034
|
+
yield s[Math.floor(Math.random() * s.length)];
|
|
1035
|
+
}
|
|
1036
|
+
function Vo(s = 4, i = xo("qwertyuiopasdfghjklzxcvbnm".split(""))) {
|
|
1037
|
+
return Array.from({ length: s }).map(() => i.next().value).join("");
|
|
1038
|
+
}
|
|
1039
|
+
function ko() {
|
|
1040
|
+
return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Vo()}`;
|
|
1041
|
+
}
|
|
1042
|
+
const Fo = {
|
|
1043
|
+
_id: "",
|
|
1044
|
+
name: "",
|
|
1045
|
+
abbrev: "",
|
|
1046
|
+
precision: 0,
|
|
1047
|
+
measurements: []
|
|
1048
|
+
};
|
|
1049
|
+
function Co(s) {
|
|
1050
|
+
var f, o, l, n, d;
|
|
1051
|
+
return {
|
|
1052
|
+
code: s.code,
|
|
1053
|
+
name: s.name,
|
|
1054
|
+
unit: ((f = s.unit.measurements.find((y) => y.id === s.trackingMeasurement)) == null ? void 0 : f.abbrev) ?? s.unit.abbrev,
|
|
1055
|
+
baseUnit: s.unit.abbrev,
|
|
1056
|
+
valuationMethod: s.valuation ?? "WAVG",
|
|
1057
|
+
pricePerUnit: (o = s.defaultCost) != null && o.costPerUnit ? +et((l = s.defaultCost) == null ? void 0 : l.costPerUnit) : 0,
|
|
1058
|
+
thresholdLow: ((n = s.thresholds) == null ? void 0 : n.low) ?? ce().low,
|
|
1059
|
+
thresholdMid: ((d = s.thresholds) == null ? void 0 : d.mid) ?? ce().mid
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
function ot() {
|
|
1063
|
+
var l;
|
|
1064
|
+
const s = [
|
|
1065
|
+
{
|
|
1066
|
+
id: "code",
|
|
1067
|
+
name: "Code"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
id: "name",
|
|
1071
|
+
name: "Name"
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
id: "unit",
|
|
1075
|
+
name: "Unit"
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
id: "baseUnit",
|
|
1079
|
+
name: "Base unit"
|
|
1080
|
+
}
|
|
1081
|
+
], i = Je(), f = ve(), o = xe(f.currentCountry.value);
|
|
1082
|
+
return i.enableTotalCost && s.push(
|
|
1083
|
+
{
|
|
1084
|
+
id: "valuationMethod",
|
|
1085
|
+
name: "Valuation method"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
id: "pricePerUnit",
|
|
1089
|
+
name: `Price per unit (${o == null ? void 0 : o.currency})`
|
|
1090
|
+
}
|
|
1091
|
+
), ((l = f.currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && s.push(
|
|
1092
|
+
{
|
|
1093
|
+
id: "thresholdLow",
|
|
1094
|
+
name: "Show RED when remaining"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
id: "thresholdMid",
|
|
1098
|
+
name: "Show YELLOW when remaining"
|
|
1099
|
+
}
|
|
1100
|
+
), s;
|
|
1101
|
+
}
|
|
1102
|
+
function So() {
|
|
1103
|
+
const i = ne().skus.map(Co), o = ve().currentBusiness.value, l = ot(), n = [
|
|
1104
|
+
["Business name:", o == null ? void 0 : o.name],
|
|
1105
|
+
["Business ID:", o == null ? void 0 : o._id],
|
|
1106
|
+
["Menu version", o == null ? void 0 : o.menuVersion],
|
|
1107
|
+
[],
|
|
1108
|
+
l.map((u) => u.name),
|
|
1109
|
+
...i.map((u) => l.map((x) => u[x.id]))
|
|
1110
|
+
], d = l.map((u) => `system:${u.id}`), y = Xe(n, d), F = `${o == null ? void 0 : o.name} ingredients (${It(/* @__PURE__ */ new Date())}).xlsx`;
|
|
1111
|
+
return Ze(y, F), F;
|
|
1112
|
+
}
|
|
1113
|
+
function wo() {
|
|
1114
|
+
const i = ve().currentBusiness.value, f = ot(), o = [
|
|
1115
|
+
["Business name:", i == null ? void 0 : i.name],
|
|
1116
|
+
["Business ID:", i == null ? void 0 : i._id],
|
|
1117
|
+
["Menu version", i == null ? void 0 : i.menuVersion],
|
|
1118
|
+
[],
|
|
1119
|
+
f.map((y) => y.name)
|
|
1120
|
+
], l = f.map((y) => `system:${y.id}`), n = Xe(o, l), d = "FeedMe ingredients template.xlsx";
|
|
1121
|
+
return Ze(n, d), d;
|
|
1122
|
+
}
|
|
1123
|
+
function Mo(s) {
|
|
1124
|
+
const [
|
|
1125
|
+
i,
|
|
1126
|
+
f,
|
|
1127
|
+
o,
|
|
1128
|
+
l,
|
|
1129
|
+
n,
|
|
1130
|
+
d,
|
|
1131
|
+
...y
|
|
1132
|
+
] = wt(s);
|
|
1133
|
+
if (!i || !i.length || i.some((p) => p.length && !p.startsWith("system:")))
|
|
1134
|
+
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
1135
|
+
const F = i.map((p) => p.split(":")[1]), x = ["code", "name", "unit", "baseUnit"].filter((p) => !F.includes(p));
|
|
1136
|
+
if (x.length)
|
|
1137
|
+
throw new Error(
|
|
1138
|
+
`Missing meta headers (${x.join()}). Excel file does not come from the template.`
|
|
1139
|
+
);
|
|
1140
|
+
return y.map((p, T) => {
|
|
1141
|
+
const h = {};
|
|
1142
|
+
for (const I in F) {
|
|
1143
|
+
const M = F[I];
|
|
1144
|
+
Object.assign(h, { [M]: p[I] });
|
|
1145
|
+
}
|
|
1146
|
+
return {
|
|
1147
|
+
index: T,
|
|
1148
|
+
data: h
|
|
1149
|
+
};
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
function Ye(s, i, f) {
|
|
1153
|
+
var z;
|
|
1154
|
+
const l = ne().units, n = new Array(), d = f.filter((C) => C.data.code === s.code);
|
|
1155
|
+
d.length > 1 && n.push(
|
|
1156
|
+
`Code ${s.code} is already used in row ${d.map((C) => C.index + 6).join()}.`
|
|
1157
|
+
);
|
|
1158
|
+
const y = l.find((C) => C.abbrev === s.baseUnit), F = y == null ? void 0 : y.measurements.find((C) => C.abbrev === s.unit);
|
|
1159
|
+
if (!y)
|
|
1160
|
+
n.push(`Cannot find base unit of symbol ${s.baseUnit}.`);
|
|
1161
|
+
else if (s.baseUnit !== s.unit && !F) {
|
|
1162
|
+
const C = `Cannot find unit conversion for ${s.baseUnit} with symbol ${s.unit || "[empty]"}.`;
|
|
1163
|
+
n.push(C);
|
|
1164
|
+
}
|
|
1165
|
+
const u = Z.options.find(
|
|
1166
|
+
(C) => C === s.valuationMethod
|
|
1167
|
+
);
|
|
1168
|
+
s.valuationMethod && !u && n.push(
|
|
1169
|
+
`Expected valuation method to be one of ${Z.options.join()} but got ${s.valuationMethod} instead.`
|
|
1170
|
+
);
|
|
1171
|
+
const c = ve().currentCountry.value, p = (C) => `${C}`.length && Ft()(C) === !0, T = p(`${s.pricePerUnit}`) === !0 ? {
|
|
1172
|
+
costPerUnit: {
|
|
1173
|
+
...tt(Number(s.pricePerUnit) || 0),
|
|
1174
|
+
currency: ((z = xe(c)) == null ? void 0 : z.currency) ?? "MYR"
|
|
1175
|
+
},
|
|
1176
|
+
measurement: F
|
|
1177
|
+
} : void 0, h = p(`${s.thresholdLow}`) && p(`${s.thresholdMid}`) ? {
|
|
1178
|
+
low: Number(s.thresholdLow) || 0,
|
|
1179
|
+
mid: Number(s.thresholdMid) || 0
|
|
1180
|
+
} : void 0;
|
|
1181
|
+
return {
|
|
1182
|
+
type: "create",
|
|
1183
|
+
sku: {
|
|
1184
|
+
_id: ko(),
|
|
1185
|
+
code: s.code,
|
|
1186
|
+
name: s.name,
|
|
1187
|
+
unit: y ?? l.find((C) => C) ?? Fo,
|
|
1188
|
+
trackingMeasurement: F == null ? void 0 : F.id,
|
|
1189
|
+
valuation: u,
|
|
1190
|
+
defaultCost: T,
|
|
1191
|
+
thresholds: h
|
|
1192
|
+
},
|
|
1193
|
+
errors: n,
|
|
1194
|
+
excelRowNumber: i + 6
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
function Io(s) {
|
|
1198
|
+
try {
|
|
1199
|
+
const i = Mo(s).filter((u) => u.data.code), o = ne().skus, l = mt(o, "code"), n = i.filter((u) => !l[u.data.code]), d = i.filter((u) => l[u.data.code]), y = n.map(
|
|
1200
|
+
(u) => Ye(u.data, u.index, i)
|
|
1201
|
+
), F = d.map((u) => {
|
|
1202
|
+
const x = Ye(u.data, u.index, i), c = l[u.data.code];
|
|
1203
|
+
return {
|
|
1204
|
+
...x,
|
|
1205
|
+
type: "update",
|
|
1206
|
+
original: c,
|
|
1207
|
+
sku: {
|
|
1208
|
+
// to maintain original props not in the import excel, e.g. inventory binding, etc...
|
|
1209
|
+
...c,
|
|
1210
|
+
code: x.sku.code || c.code,
|
|
1211
|
+
name: x.sku.name || c.name,
|
|
1212
|
+
unit: x.sku.unit || c.unit,
|
|
1213
|
+
trackingMeasurement: x.sku.trackingMeasurement || c.trackingMeasurement,
|
|
1214
|
+
valuation: x.sku.valuation || c.valuation,
|
|
1215
|
+
defaultCost: x.sku.defaultCost || c.defaultCost,
|
|
1216
|
+
thresholds: x.sku.thresholds || c.thresholds
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
});
|
|
1220
|
+
return {
|
|
1221
|
+
invalidExcel: !1,
|
|
1222
|
+
importCreateResult: y,
|
|
1223
|
+
importUpdateResult: F
|
|
1224
|
+
};
|
|
1225
|
+
} catch (i) {
|
|
1226
|
+
return {
|
|
1227
|
+
invalidExcel: !0,
|
|
1228
|
+
invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
|
|
1229
|
+
importCreateResult: [],
|
|
1230
|
+
importUpdateResult: []
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
const $o = {
|
|
1235
|
+
key: 0,
|
|
1236
|
+
class: "relative"
|
|
1237
|
+
}, Uo = ["accept", "disabled"], Ro = { class: "flex flex-col gap-8" }, Eo = ["accept", "disabled"], Ao = /* @__PURE__ */ le({
|
|
1238
|
+
__name: "FmDroppableField",
|
|
1239
|
+
props: {
|
|
1240
|
+
buttonLabel: {},
|
|
1241
|
+
label: { default: "" },
|
|
1242
|
+
disabled: { type: Boolean, default: !1 },
|
|
1243
|
+
accept: { default: "" },
|
|
1244
|
+
maxFileSize: { default: 8e6 },
|
|
1245
|
+
contentClass: {}
|
|
1246
|
+
},
|
|
1247
|
+
emits: ["file-upload", "file-rejected"],
|
|
1248
|
+
setup(s, { emit: i }) {
|
|
1249
|
+
const f = s, o = i, l = B(!1), n = B(null), d = B(null), y = B(), F = (a) => {
|
|
1250
|
+
f.disabled || (a.stopPropagation(), a.preventDefault());
|
|
1251
|
+
}, u = (a) => {
|
|
1252
|
+
f.disabled || (a.stopPropagation(), a.preventDefault(), l.value = !0);
|
|
1253
|
+
}, x = (a) => {
|
|
1254
|
+
f.disabled || (a.stopPropagation(), a.preventDefault(), l.value = !1);
|
|
1255
|
+
}, c = (a) => {
|
|
1256
|
+
var N;
|
|
1257
|
+
f.disabled || (a.stopPropagation(), a.preventDefault(), l.value = !1, p((N = a.dataTransfer) == null ? void 0 : N.files));
|
|
1258
|
+
};
|
|
1259
|
+
function p(a) {
|
|
1260
|
+
if (a)
|
|
1261
|
+
if (y.value = a, n.value = h(a[0]), d.value = I(a[0]), n.value && d.value)
|
|
1262
|
+
o("file-upload", a[0]);
|
|
1263
|
+
else {
|
|
1264
|
+
const N = T();
|
|
1265
|
+
o("file-rejected", [
|
|
1266
|
+
{
|
|
1267
|
+
file: a[0],
|
|
1268
|
+
reason: N
|
|
1269
|
+
}
|
|
1270
|
+
]);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
const T = () => {
|
|
1274
|
+
const a = new Array();
|
|
1275
|
+
return n.value || a.push("invalid-type"), d.value || a.push("invalid-size"), a;
|
|
1276
|
+
}, h = (a) => {
|
|
1277
|
+
if (!f.accept) return !0;
|
|
1278
|
+
const N = f.accept.split(",").map((O) => O.trim());
|
|
1279
|
+
for (const O of N)
|
|
1280
|
+
if (M(O)) {
|
|
1281
|
+
if (C(O) === C(a.type)) return !0;
|
|
1282
|
+
} else if (z(a) === O || a.type === O) return !0;
|
|
1283
|
+
return !1;
|
|
1284
|
+
}, I = (a) => a.size <= f.maxFileSize, M = (a) => a.indexOf("*") !== -1, z = (a) => "." + a.name.split(".").pop(), C = (a) => a.substring(0, a.indexOf("/")), me = k(() => {
|
|
1285
|
+
if (l.value) return "Drop file to upload";
|
|
1286
|
+
if (n.value) {
|
|
1287
|
+
if (!d.value) return `File size exceeds ${f.maxFileSize * 1e-6}mb`;
|
|
1288
|
+
} else return "File type is not valid";
|
|
1289
|
+
return "";
|
|
1290
|
+
}), H = k(() => y.value ? !n.value || !d.value : !1), ae = (a) => {
|
|
1291
|
+
const N = a.target;
|
|
1292
|
+
p(N.files);
|
|
1293
|
+
}, se = k(() => {
|
|
1294
|
+
var a;
|
|
1295
|
+
return (a = y.value) == null ? void 0 : a.item(0);
|
|
1296
|
+
}), J = B();
|
|
1297
|
+
return (a, N) => {
|
|
1298
|
+
const O = $("FmLabel"), re = $("FmButton");
|
|
1299
|
+
return b(), R("label", {
|
|
1300
|
+
class: "fm-droppable-field",
|
|
1301
|
+
ref_key: "fmButtonRef",
|
|
1302
|
+
ref: J
|
|
1303
|
+
}, [
|
|
1304
|
+
a.$slots.default ? (b(), R("div", $o, [
|
|
1305
|
+
r("input", {
|
|
1306
|
+
accept: a.accept,
|
|
1307
|
+
disabled: a.disabled,
|
|
1308
|
+
class: "fm-droppable-field__input",
|
|
1309
|
+
type: "file",
|
|
1310
|
+
onChange: ae
|
|
1311
|
+
}, null, 40, Uo)
|
|
1312
|
+
])) : L("", !0),
|
|
1313
|
+
fe(a.$slots, "default", {
|
|
1314
|
+
isDragging: l.value,
|
|
1315
|
+
isValidFileType: n.value,
|
|
1316
|
+
isValidFileSize: d.value,
|
|
1317
|
+
singleValidFile: se.value,
|
|
1318
|
+
openFileDialog: () => {
|
|
1319
|
+
var ie;
|
|
1320
|
+
return console.log("click", J.value), (ie = J.value) == null ? void 0 : ie.click();
|
|
1321
|
+
}
|
|
1322
|
+
}, () => [
|
|
1323
|
+
r("div", Ro, [
|
|
1324
|
+
a.$slots.label ? fe(a.$slots, "label", { key: 0 }, void 0, !0) : (b(), D(O, {
|
|
1325
|
+
key: 1,
|
|
1326
|
+
label: a.label
|
|
1327
|
+
}, null, 8, ["label"]))
|
|
1328
|
+
]),
|
|
1329
|
+
r("div", {
|
|
1330
|
+
class: X([[
|
|
1331
|
+
a.contentClass ? a.contentClass : "w-full h-full",
|
|
1332
|
+
{
|
|
1333
|
+
"fm-droppable-field__container--dragging": l.value,
|
|
1334
|
+
"fm-droppable-field__container--invalid": H.value && !a.disabled,
|
|
1335
|
+
"fm-droppable-field__container--disabled": a.disabled
|
|
1336
|
+
}
|
|
1337
|
+
], "fm-droppable-field__container"]),
|
|
1338
|
+
onDragenter: F,
|
|
1339
|
+
onDragleave: x,
|
|
1340
|
+
onDragover: u,
|
|
1341
|
+
onDrop: c
|
|
1342
|
+
}, [
|
|
1343
|
+
(l.value || H.value) && !a.disabled ? (b(), R("div", {
|
|
1344
|
+
key: 0,
|
|
1345
|
+
class: X({
|
|
1346
|
+
"fm-typo-en-body-lg-600": !0,
|
|
1347
|
+
"text-fm-color-primary": l.value,
|
|
1348
|
+
"text-fm-color-typo-error": H.value
|
|
1349
|
+
})
|
|
1350
|
+
}, G(me.value), 3)) : (b(), D(re, {
|
|
1351
|
+
key: 1,
|
|
1352
|
+
disabled: a.disabled,
|
|
1353
|
+
label: a.buttonLabel ?? "Add files",
|
|
1354
|
+
size: "md",
|
|
1355
|
+
variant: "secondary"
|
|
1356
|
+
}, null, 8, ["disabled", "label"])),
|
|
1357
|
+
fe(a.$slots, "accept-text", {}, () => [
|
|
1358
|
+
f.accept ? (b(), R("div", {
|
|
1359
|
+
key: 0,
|
|
1360
|
+
class: X([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
|
|
1361
|
+
}, G(`Accepts ${f.accept}`), 3)) : L("", !0)
|
|
1362
|
+
], !0),
|
|
1363
|
+
r("input", {
|
|
1364
|
+
accept: a.accept,
|
|
1365
|
+
disabled: a.disabled,
|
|
1366
|
+
class: "fm-droppable-field__input",
|
|
1367
|
+
type: "file",
|
|
1368
|
+
onChange: ae
|
|
1369
|
+
}, null, 40, Eo)
|
|
1370
|
+
], 34),
|
|
1371
|
+
fe(a.$slots, "helper-text", {}, () => [
|
|
1372
|
+
r("div", {
|
|
1373
|
+
class: X([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
|
|
1374
|
+
}, G(`Max size ${f.maxFileSize * 1e-6}mb`), 3)
|
|
1375
|
+
], !0)
|
|
1376
|
+
], !0)
|
|
1377
|
+
], 512);
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
}), Do = /* @__PURE__ */ pt(Ao, [["__scopeId", "data-v-311b22a0"]]), To = { class: "flex items-center gap-12 pl-8" }, Po = /* @__PURE__ */ r("div", null, "•", -1), Bo = { class: "flex flex-col" }, zo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Lo = {
|
|
1381
|
+
key: 0,
|
|
1382
|
+
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
1383
|
+
}, No = { key: 0 }, We = /* @__PURE__ */ le({
|
|
1384
|
+
__name: "ImportIngredientItem",
|
|
1385
|
+
props: {
|
|
1386
|
+
type: {},
|
|
1387
|
+
code: {},
|
|
1388
|
+
name: {},
|
|
1389
|
+
errors: {}
|
|
1390
|
+
},
|
|
1391
|
+
setup(s) {
|
|
1392
|
+
return (i, f) => {
|
|
1393
|
+
const o = $("FmIcon"), l = $("FmTooltip");
|
|
1394
|
+
return b(), R("div", To, [
|
|
1395
|
+
Po,
|
|
1396
|
+
r("div", Bo, [
|
|
1397
|
+
r("div", zo, [
|
|
1398
|
+
r("div", {
|
|
1399
|
+
class: X({
|
|
1400
|
+
"text-fm-color-system-error-300": i.errors.length
|
|
1401
|
+
})
|
|
1402
|
+
}, [
|
|
1403
|
+
qe(G(i.name) + " ", 1),
|
|
1404
|
+
i.type === "create" ? (b(), R("span", Lo, "(new)")) : L("", !0)
|
|
1405
|
+
], 2),
|
|
1406
|
+
i.errors.length ? (b(), R("div", No, [
|
|
1407
|
+
v(l, { "z-index": 50 }, {
|
|
1408
|
+
content: w(() => [
|
|
1409
|
+
r("ol", null, [
|
|
1410
|
+
(b(!0), R(Q, null, oe(i.errors, (n, d) => (b(), R("li", { key: d }, G(n), 1))), 128))
|
|
1411
|
+
])
|
|
1412
|
+
]),
|
|
1413
|
+
default: w(() => [
|
|
1414
|
+
v(o, {
|
|
1415
|
+
name: "error",
|
|
1416
|
+
size: "sm",
|
|
1417
|
+
color: "system-error-300"
|
|
1418
|
+
})
|
|
1419
|
+
]),
|
|
1420
|
+
_: 1
|
|
1421
|
+
})
|
|
1422
|
+
])) : L("", !0)
|
|
1423
|
+
]),
|
|
1424
|
+
r("div", {
|
|
1425
|
+
class: X([
|
|
1426
|
+
"fm-typo-en-body-sm-400",
|
|
1427
|
+
{
|
|
1428
|
+
"text-fm-color-system-error-200": i.errors.length,
|
|
1429
|
+
"text-fm-color-typo-secondary": !i.errors.length
|
|
1430
|
+
}
|
|
1431
|
+
])
|
|
1432
|
+
}, G(i.code), 3)
|
|
1433
|
+
])
|
|
1434
|
+
]);
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
}), Oo = { class: "flex flex-col gap-24" }, jo = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-md-400" }, " Import ingredients from your Excel file and apply changes to your business. ", -1), Ho = { class: "flex flex-col gap-8" }, Yo = { class: "line-clamp-2 text-ellipsis break-all" }, Wo = {
|
|
1438
|
+
key: 2,
|
|
1439
|
+
class: "shrink-0"
|
|
1440
|
+
}, Go = {
|
|
1441
|
+
key: 0,
|
|
1442
|
+
class: "flex flex-col"
|
|
1443
|
+
}, qo = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Ko = {
|
|
1444
|
+
key: 0,
|
|
1445
|
+
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
1446
|
+
}, Jo = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-lg-600" }, "Summary", -1), Qo = /* @__PURE__ */ le({
|
|
1447
|
+
__name: "ImportIngredients",
|
|
1448
|
+
setup(s) {
|
|
1449
|
+
const i = B(null), f = ft(), o = Ve(), l = B(!1), n = B(new Array()), d = B([]), y = B([]), F = k(
|
|
1450
|
+
() => !!n.value.length || d.value.some((c) => c.errors.length) || y.value.some((c) => c.errors.length)
|
|
1451
|
+
), u = k(
|
|
1452
|
+
() => !!d.value.length || !!y.value.length
|
|
1453
|
+
);
|
|
1454
|
+
async function x(c) {
|
|
1455
|
+
n.value = [], d.value = [], y.value = [];
|
|
1456
|
+
try {
|
|
1457
|
+
l.value = !0;
|
|
1458
|
+
const [p] = await Promise.all([
|
|
1459
|
+
Mt(c),
|
|
1460
|
+
// fake buffer
|
|
1461
|
+
new Promise((I) => setTimeout(I, 1e3))
|
|
1462
|
+
]), T = p.SheetNames.find((I) => I);
|
|
1463
|
+
if (!T) {
|
|
1464
|
+
n.value.push("No sheet is found in the excel file.");
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
const h = Io(p.Sheets[T]);
|
|
1468
|
+
if (h.invalidExcel) {
|
|
1469
|
+
n.value.push(h.invalidExcelMessage ?? "Invalid excel");
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
if (d.value = h.importCreateResult, y.value = h.importUpdateResult, !d.value.length && !y.value.length) {
|
|
1473
|
+
n.value.push("No import data is available in the excel file.");
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
f.emitData(h);
|
|
1477
|
+
} catch (p) {
|
|
1478
|
+
o.open({
|
|
1479
|
+
title: "Unable to read file",
|
|
1480
|
+
message: p == null ? void 0 : p.message,
|
|
1481
|
+
type: "error"
|
|
1482
|
+
}), console.error("Error in reading file", p);
|
|
1483
|
+
} finally {
|
|
1484
|
+
n.value.length && o.open({
|
|
1485
|
+
title: "Invalid excel",
|
|
1486
|
+
type: "error"
|
|
1487
|
+
}), l.value = !1;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return Ge(i, (c) => {
|
|
1491
|
+
c && x(c);
|
|
1492
|
+
}), (c, p) => {
|
|
1493
|
+
const T = $("FmCircularProgress"), h = $("FmIcon"), I = $("FmButton");
|
|
1494
|
+
return b(), R("div", Oo, [
|
|
1495
|
+
jo,
|
|
1496
|
+
v(Do, {
|
|
1497
|
+
class: X({
|
|
1498
|
+
"w-full": !0,
|
|
1499
|
+
"h-[200px]": !i.value
|
|
1500
|
+
}),
|
|
1501
|
+
accept: ".xlsx",
|
|
1502
|
+
onFileUpload: p[0] || (p[0] = (M) => i.value = M),
|
|
1503
|
+
label: "Upload template",
|
|
1504
|
+
"button-label": "Select file"
|
|
1505
|
+
}, rt({ _: 2 }, [
|
|
1506
|
+
i.value ? {
|
|
1507
|
+
name: "default",
|
|
1508
|
+
fn: w(({ openFileDialog: M }) => [
|
|
1509
|
+
r("div", Ho, [
|
|
1510
|
+
r("div", {
|
|
1511
|
+
class: X([
|
|
1512
|
+
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
1513
|
+
{
|
|
1514
|
+
"border border-fm-color-neutral-gray-100": l.value,
|
|
1515
|
+
"border border-fm-color-neutral-gray-200": !l.value && !F.value,
|
|
1516
|
+
"border border-fm-color-system-error-200": F.value
|
|
1517
|
+
}
|
|
1518
|
+
])
|
|
1519
|
+
}, [
|
|
1520
|
+
l.value ? (b(), D(T, {
|
|
1521
|
+
key: 0,
|
|
1522
|
+
size: "md",
|
|
1523
|
+
color: "neutral-gray-200"
|
|
1524
|
+
})) : (b(), D(h, {
|
|
1525
|
+
key: 1,
|
|
1526
|
+
name: F.value ? "error" : "attach_file",
|
|
1527
|
+
outline: "",
|
|
1528
|
+
color: F.value ? "system-error-300" : void 0
|
|
1529
|
+
}, null, 8, ["name", "color"])),
|
|
1530
|
+
r("div", {
|
|
1531
|
+
class: X([
|
|
1532
|
+
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
1533
|
+
{
|
|
1534
|
+
"text-fm-color-typo-disabled": l.value,
|
|
1535
|
+
"text-fm-color-typo-primary": !l.value
|
|
1536
|
+
}
|
|
1537
|
+
])
|
|
1538
|
+
}, [
|
|
1539
|
+
r("div", Yo, G(i.value.name), 1)
|
|
1540
|
+
], 2),
|
|
1541
|
+
l.value ? L("", !0) : (b(), R("div", Wo, [
|
|
1542
|
+
v(I, {
|
|
1543
|
+
label: "Replace file",
|
|
1544
|
+
variant: F.value ? "destructive" : "secondary",
|
|
1545
|
+
"prepend-icon": F.value ? void 0 : "autorenew",
|
|
1546
|
+
onClick: M
|
|
1547
|
+
}, null, 8, ["variant", "prepend-icon", "onClick"])
|
|
1548
|
+
]))
|
|
1549
|
+
], 2),
|
|
1550
|
+
n.value.length ? (b(), R("div", Go, [
|
|
1551
|
+
(b(!0), R(Q, null, oe(n.value, (z, C) => (b(), R("div", {
|
|
1552
|
+
key: C,
|
|
1553
|
+
class: "flex gap-8 items-center"
|
|
1554
|
+
}, [
|
|
1555
|
+
v(h, {
|
|
1556
|
+
name: "error",
|
|
1557
|
+
size: "sm",
|
|
1558
|
+
color: "system-error-300"
|
|
1559
|
+
}),
|
|
1560
|
+
r("div", qo, G(z), 1)
|
|
1561
|
+
]))), 128))
|
|
1562
|
+
])) : L("", !0)
|
|
1563
|
+
])
|
|
1564
|
+
]),
|
|
1565
|
+
key: "0"
|
|
1566
|
+
} : void 0
|
|
1567
|
+
]), 1032, ["class"]),
|
|
1568
|
+
u.value ? (b(), R("div", Ko, [
|
|
1569
|
+
Jo,
|
|
1570
|
+
(b(!0), R(Q, null, oe(d.value, (M) => (b(), D(We, {
|
|
1571
|
+
key: M.sku._id,
|
|
1572
|
+
code: M.sku.code,
|
|
1573
|
+
name: M.sku.name,
|
|
1574
|
+
errors: M.errors,
|
|
1575
|
+
type: "create"
|
|
1576
|
+
}, null, 8, ["code", "name", "errors"]))), 128)),
|
|
1577
|
+
(b(!0), R(Q, null, oe(y.value, (M) => (b(), D(We, {
|
|
1578
|
+
key: M.sku._id,
|
|
1579
|
+
code: M.sku.code,
|
|
1580
|
+
name: M.sku.name,
|
|
1581
|
+
errors: M.errors,
|
|
1582
|
+
type: "update"
|
|
1583
|
+
}, null, 8, ["code", "name", "errors"]))), 128))
|
|
1584
|
+
])) : L("", !0)
|
|
1585
|
+
]);
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
}), Xo = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Zo = { class: "px-8 flex items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, el = { class: "flex-1 w-full" }, tl = { class: "flex flex-col py-8" }, ol = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ll = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, gl = /* @__PURE__ */ le({
|
|
1589
|
+
__name: "IngredientsView",
|
|
1590
|
+
setup(s) {
|
|
1591
|
+
const i = ne(), f = k(() => i.skus), o = vt(), l = Qe(), n = Ve(), {
|
|
1592
|
+
createIngredient: d,
|
|
1593
|
+
updateIngredient: y,
|
|
1594
|
+
deleteIngredient: F,
|
|
1595
|
+
ingredientDialogProps: u,
|
|
1596
|
+
ingredientViewLoading: x
|
|
1597
|
+
} = $t(), { columnDefs: c } = Ut({ updateIngredient: y, deleteIngredient: F });
|
|
1598
|
+
function p(E) {
|
|
1599
|
+
switch (E) {
|
|
1600
|
+
case "add":
|
|
1601
|
+
return d();
|
|
1602
|
+
case "import":
|
|
1603
|
+
return O();
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
const T = B(""), h = B(!1), I = k(() => h.value || x.value), { breakpoints: M } = yt(), z = k(() => M.value.xs || M.value.sm), C = k(() => z.value ? 10 : 20), me = xt(), H = B(!1), ae = [
|
|
1607
|
+
{
|
|
1608
|
+
value: "import",
|
|
1609
|
+
label: "Import"
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
value: "export",
|
|
1613
|
+
label: "Export"
|
|
1614
|
+
}
|
|
1615
|
+
];
|
|
1616
|
+
function se(E) {
|
|
1617
|
+
switch (H.value = !1, E) {
|
|
1618
|
+
case "import":
|
|
1619
|
+
return O();
|
|
1620
|
+
case "export":
|
|
1621
|
+
return N();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
const J = k(() => z.value ? [
|
|
1625
|
+
{ label: "More", icon: "more_vert", key: "more" }
|
|
1626
|
+
] : [
|
|
1627
|
+
{ label: "Export", icon: "ios_share", key: "export" }
|
|
1628
|
+
]), a = k(() => {
|
|
1629
|
+
const E = [
|
|
1630
|
+
{ label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }
|
|
1631
|
+
];
|
|
1632
|
+
return z.value ? E : [...E, { label: "Import", value: "import" }];
|
|
1633
|
+
});
|
|
1634
|
+
function N() {
|
|
1635
|
+
const E = So();
|
|
1636
|
+
n.open({
|
|
1637
|
+
title: "Ingredients exported",
|
|
1638
|
+
message: `Filename: ${E}`,
|
|
1639
|
+
type: "success"
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
function O() {
|
|
1643
|
+
l.open({
|
|
1644
|
+
title: "Import ingredients",
|
|
1645
|
+
contentComponent: Qo,
|
|
1646
|
+
overlay: !0,
|
|
1647
|
+
closeButton: !0,
|
|
1648
|
+
primaryActions: {
|
|
1649
|
+
text: "Import",
|
|
1650
|
+
close: !1
|
|
1651
|
+
},
|
|
1652
|
+
secondaryActions: {
|
|
1653
|
+
text: "Close",
|
|
1654
|
+
close: !0
|
|
1655
|
+
},
|
|
1656
|
+
tertiaryActions: {
|
|
1657
|
+
text: "Download template",
|
|
1658
|
+
close: !1,
|
|
1659
|
+
variant: "plain"
|
|
1660
|
+
}
|
|
1661
|
+
}).onPrimary((E) => {
|
|
1662
|
+
if (!E) {
|
|
1663
|
+
n.open({
|
|
1664
|
+
title: "No import data received",
|
|
1665
|
+
type: "error"
|
|
1666
|
+
});
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
if (!E.importCreateResult.length && !E.importUpdateResult.length) {
|
|
1670
|
+
n.open({
|
|
1671
|
+
title: "Invalid content",
|
|
1672
|
+
message: "No import data in the excel file",
|
|
1673
|
+
type: "error"
|
|
1674
|
+
});
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
if (E.importCreateResult.some((S) => S.errors.length) || E.importUpdateResult.some((S) => S.errors.length)) {
|
|
1678
|
+
n.open({
|
|
1679
|
+
title: "Invalid content",
|
|
1680
|
+
message: "There is error in the import data.",
|
|
1681
|
+
type: "error"
|
|
1682
|
+
});
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
l.close(), re(E);
|
|
1686
|
+
}).onTertiary(wo);
|
|
1687
|
+
}
|
|
1688
|
+
async function re(E) {
|
|
1689
|
+
h.value = !0;
|
|
1690
|
+
try {
|
|
1691
|
+
await Promise.all([
|
|
1692
|
+
i.importSkus({
|
|
1693
|
+
create: E.importCreateResult.map((S) => S.sku),
|
|
1694
|
+
update: E.importUpdateResult.map((S) => S.sku)
|
|
1695
|
+
}),
|
|
1696
|
+
new Promise((S) => setTimeout(S, 2e3))
|
|
1697
|
+
]), n.open({
|
|
1698
|
+
title: "Ingredients successfully imported",
|
|
1699
|
+
type: "success"
|
|
1700
|
+
});
|
|
1701
|
+
} catch (S) {
|
|
1702
|
+
n.open({
|
|
1703
|
+
title: "Failed to import ingredients",
|
|
1704
|
+
message: `System message: ${S == null ? void 0 : S.message}`,
|
|
1705
|
+
type: "error"
|
|
1706
|
+
}), console.error("Error in importing skus", E, S);
|
|
1707
|
+
} finally {
|
|
1708
|
+
h.value = !1;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function ie() {
|
|
1712
|
+
H.value = !0;
|
|
1713
|
+
}
|
|
1714
|
+
return (E, S) => {
|
|
1715
|
+
const ue = $("FmTableToolbar"), ke = $("FmTable"), de = $("FmCollapsibleTabs"), ee = $("FmBottomSheet");
|
|
1716
|
+
return b(), D(Vt, {
|
|
1717
|
+
title: "Ingredient",
|
|
1718
|
+
actions: a.value,
|
|
1719
|
+
"onClick:action": p
|
|
1720
|
+
}, {
|
|
1721
|
+
default: w(() => [
|
|
1722
|
+
r("div", Xo, [
|
|
1723
|
+
r("div", Zo, [
|
|
1724
|
+
r("div", el, [
|
|
1725
|
+
v(ue, {
|
|
1726
|
+
searchable: "",
|
|
1727
|
+
"search-model": T.value,
|
|
1728
|
+
"onUpdate:searchModel": S[0] || (S[0] = (K) => T.value = K),
|
|
1729
|
+
actions: J.value,
|
|
1730
|
+
"onClick:actionExport": S[1] || (S[1] = () => N()),
|
|
1731
|
+
"onClick:actionImport": S[2] || (S[2] = () => O()),
|
|
1732
|
+
"onClick:actionMore": S[3] || (S[3] = () => ie())
|
|
1733
|
+
}, null, 8, ["search-model", "actions"])
|
|
1734
|
+
])
|
|
1735
|
+
]),
|
|
1736
|
+
v(ke, {
|
|
1737
|
+
style: it(V(me).tableHeight),
|
|
1738
|
+
"column-defs": V(c),
|
|
1739
|
+
"row-data": f.value,
|
|
1740
|
+
"search-value": T.value,
|
|
1741
|
+
loading: !V(o)._currentLocation || I.value,
|
|
1742
|
+
onRowClick: S[4] || (S[4] = (K) => V(y)(K.original)),
|
|
1743
|
+
"page-size": C.value
|
|
1744
|
+
}, {
|
|
1745
|
+
"list-row": w((K) => [
|
|
1746
|
+
v(_t, {
|
|
1747
|
+
row: K,
|
|
1748
|
+
onRowClick: V(y)
|
|
1749
|
+
}, {
|
|
1750
|
+
default: w((te) => {
|
|
1751
|
+
var e, t, m, _, A, U, j, Y, q, pe;
|
|
1752
|
+
return [
|
|
1753
|
+
r("div", tl, [
|
|
1754
|
+
r("div", ol, [
|
|
1755
|
+
v(V(Oe), {
|
|
1756
|
+
render: (m = (t = (e = te.code) == null ? void 0 : e.column) == null ? void 0 : t.columnDef) == null ? void 0 : m.cell,
|
|
1757
|
+
props: (A = (_ = te.code) == null ? void 0 : _.getContext) == null ? void 0 : A.call(_)
|
|
1758
|
+
}, null, 8, ["render", "props"])
|
|
1759
|
+
]),
|
|
1760
|
+
r("div", ll, [
|
|
1761
|
+
v(V(Oe), {
|
|
1762
|
+
render: (Y = (j = (U = te.name) == null ? void 0 : U.column) == null ? void 0 : j.columnDef) == null ? void 0 : Y.cell,
|
|
1763
|
+
props: (pe = (q = te.name) == null ? void 0 : q.getContext) == null ? void 0 : pe.call(q)
|
|
1764
|
+
}, null, 8, ["render", "props"])
|
|
1765
|
+
])
|
|
1766
|
+
])
|
|
1767
|
+
];
|
|
1768
|
+
}),
|
|
1769
|
+
_: 2
|
|
1770
|
+
}, 1032, ["row", "onRowClick"])
|
|
1771
|
+
]),
|
|
1772
|
+
_: 1
|
|
1773
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
1774
|
+
]),
|
|
1775
|
+
(b(), D(Be, { to: "body" }, [
|
|
1776
|
+
v(_o, ut(dt(V(u))), null, 16)
|
|
1777
|
+
])),
|
|
1778
|
+
(b(), D(Be, { to: "body" }, [
|
|
1779
|
+
v(ee, {
|
|
1780
|
+
"dismiss-away": "",
|
|
1781
|
+
modelValue: H.value,
|
|
1782
|
+
"onUpdate:modelValue": S[6] || (S[6] = (K) => H.value = K)
|
|
1783
|
+
}, {
|
|
1784
|
+
default: w(() => [
|
|
1785
|
+
v(de, {
|
|
1786
|
+
class: "pb-8",
|
|
1787
|
+
items: ae,
|
|
1788
|
+
"onUpdate:modelValue": S[5] || (S[5] = (K) => se(K))
|
|
1789
|
+
})
|
|
1790
|
+
]),
|
|
1791
|
+
_: 1
|
|
1792
|
+
}, 8, ["modelValue"])
|
|
1793
|
+
]))
|
|
1794
|
+
]),
|
|
1795
|
+
_: 1
|
|
1796
|
+
}, 8, ["actions"]);
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
export {
|
|
1801
|
+
gl as default
|
|
1802
|
+
};
|