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