@feedmepos/mf-inventory-portal 0.0.17-dev.1 → 0.0.17-dev.2
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-NJ4FogNu.js → ApprovalView-DuDqkTeC.js} +9 -9
- package/dist/{BindingsDialog-B-j1k1SE.js → BindingsDialog-0Q6o47Up.js} +5 -5
- package/dist/{BindingsPicker-CEi3jyh0.js → BindingsPicker-k4drpC9m.js} +6 -6
- package/dist/{BindingsTable-DHYJ2Eqm.js → BindingsTable-B5hZHvuD.js} +26 -26
- package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-1XPAzm5R.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CoiUbqV-.js} +1 -1
- package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-DL98UqsQ.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-C1TGiM-x.js} +9 -9
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DqD-jNxc.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DsjnPaTj.js} +3 -3
- package/dist/IngredientsView-D3uTxXqO.js +1637 -0
- package/dist/{IntegrationView-DxqyRxVR.js → IntegrationView-B1iYpADR.js} +4 -4
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang--KLpvU2e.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-GinKxaoG.js} +6 -6
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-HpuL5QhV.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BDznyTkG.js} +1 -1
- package/dist/{PurchaseOrderPrintPreview-BGbCA7Al.js → PurchaseOrderPrintPreview-BJ4uktza.js} +4 -4
- package/dist/{ReceiveRequestView-C1ae5dRi.js → ReceiveRequestView-BOvNswDa.js} +13 -13
- package/dist/RecipeView-4I-OWCb6.js +581 -0
- package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-Dov3Uq2z.js +64 -0
- package/dist/{StockView-Pyk4MBIQ.js → StockView-D2cS56Qi.js} +13 -13
- package/dist/{SupplierView-CVZ7bOgA.js → SupplierView-CZPwQkMt.js} +8 -8
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Ctqjw3f1.js → TransferDetails.vue_vue_type_script_setup_true_lang-CqKi2NMD.js} +5 -5
- package/dist/{UnitView-DVauPXKw.js → UnitView-CV7Od1Jw.js} +7 -7
- package/dist/{WarehouseView-BYivsQgQ.js → WarehouseView-BtQJYBl0.js} +4 -4
- package/dist/api/inventory.d.ts +102 -0
- package/dist/{app-DXqS7qYg.js → app-B4nF7QvC.js} +1037 -1019
- package/dist/app.js +1 -1
- package/dist/components/FmDroppableField.vue.d.ts +75 -0
- package/dist/{date2-B96h4mWb.js → date2-BwR5G9qy.js} +1 -1
- package/dist/{dayjs.min-CQkpEWlm.js → dayjs.min-DGsqRPL2.js} +2 -2
- package/dist/{decimal-DQOX97fs.js → decimal-DGwTROX2.js} +1 -1
- package/dist/{fuzzy-Dr-kBYFA.js → fuzzy-D903uHSq.js} +1 -1
- package/dist/helper/random.d.ts +2 -0
- package/dist/helper/xlsx.util.d.ts +1 -0
- package/dist/{init-date-range-6CJBD0GL.js → init-date-range-CWbgpQ8e.js} +1 -1
- package/dist/{layout-CVjYEZxq.js → layout-8DgajRcn.js} +12 -12
- package/dist/{rules-B_-yQn9M.js → rules-Dq4Ee_PT.js} +1 -1
- package/dist/{stock-estimate-DoU-A7bG.js → stock-estimate-4jgl53Nk.js} +2 -2
- package/dist/stores/inventory.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/{supplier-D2Wuv0oV.js → supplier-Bv4RiUno.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-inventory-binding-dialog-Bc0Yx1fK.js → use-inventory-binding-dialog-h8HlGzcz.js} +2 -2
- package/dist/views/ingredients/components/import-ingredients/ImportIngredientItem.vue.d.ts +12 -0
- package/dist/views/ingredients/components/import-ingredients/ImportIngredientItemProps.d.ts +6 -0
- package/dist/views/ingredients/components/import-ingredients/ImportIngredients.vue.d.ts +2 -0
- package/dist/views/ingredients/components/import-ingredients/ImportIngredientsProps.d.ts +5 -0
- package/dist/views/ingredients/helper/import-export.helper.d.ts +45 -0
- package/dist/views/ingredients/helper/sku-id.helper.d.ts +1 -0
- package/dist/xlsx-wBLs03H5.js +24004 -0
- package/dist/xlsx.util-DxDZloWT.js +107 -0
- package/package.json +2 -2
- package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-BYi6BUwT.js +0 -49
- package/dist/IngredientsView-DNbppADe.js +0 -973
- package/dist/RecipeView-BwP8jlG0.js +0 -596
- package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js +0 -53
- package/dist/xlsx-Vw9D2Jo4.js +0 -15510
|
@@ -0,0 +1,1637 @@
|
|
|
1
|
+
import { ref as P, defineComponent as oe, computed as V, resolveComponent as C, openBlock as g, createBlock as L, withCtx as I, createVNode as y, createElementBlock as D, Fragment as ee, createElementVNode as u, createCommentVNode as G, onMounted as qe, watch as Te, unref as F, normalizeClass as q, createTextVNode as Pe, toDisplayString as K, renderList as ce, isRef as we, renderSlot as ve, createSlots as Ke, normalizeStyle as Je, Teleport as Me, normalizeProps as Qe, guardReactiveProps as Xe } from "vue";
|
|
2
|
+
import { u as ne, c as Be, S as Ze, g as ge, F as Q, d as $e, a as Le, C as he, b as Ie, e as ze, _ as et, f as tt } from "./app-B4nF7QvC.js";
|
|
3
|
+
import { useDialog as Ne, 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 W, 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-8DgajRcn.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-Dq4Ee_PT.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-GinKxaoG.js";
|
|
11
|
+
import { _ as Ce, t as Oe, d as je, s as vt, r as yt } from "./xlsx.util-DxDZloWT.js";
|
|
12
|
+
import { a as He, t as Ye, f as gt } from "./date2-BwR5G9qy.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 = Ne(), r = be(), p = ne(), o = P(!1), n = P();
|
|
17
|
+
function l() {
|
|
18
|
+
const i = {
|
|
19
|
+
unit: {},
|
|
20
|
+
mode: W.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: W.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 Ze && 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 h(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: h,
|
|
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 = V(() => {
|
|
166
|
+
var d;
|
|
167
|
+
return (d = p.rootValue) == null ? void 0 : d.unit;
|
|
168
|
+
}), n = V(() => {
|
|
169
|
+
var d;
|
|
170
|
+
return (d = p.rootValue) == null ? void 0 : d._id;
|
|
171
|
+
}), l = r, c = V({
|
|
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 = V(() => pt(o.value));
|
|
182
|
+
function h(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 = V(() => {
|
|
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 = C("FmSwitch"), k = C("FmSelect"), S = C("FmCard");
|
|
197
|
+
return g(), L(S, {
|
|
198
|
+
variant: "outlined",
|
|
199
|
+
class: "p-16 flex flex-col gap-16"
|
|
200
|
+
}, {
|
|
201
|
+
default: I(() => {
|
|
202
|
+
var w, B;
|
|
203
|
+
return [
|
|
204
|
+
y(A, {
|
|
205
|
+
value: "",
|
|
206
|
+
"model-value": c.value,
|
|
207
|
+
"onUpdate:modelValue": v[0] || (v[0] = (x) => c.value = x),
|
|
208
|
+
label: "Convertible",
|
|
209
|
+
sublabel: "Convertible from other recipe or ingredients",
|
|
210
|
+
labelPlacement: "right"
|
|
211
|
+
}, null, 8, ["model-value"]),
|
|
212
|
+
c.value ? (g(), D(ee, { key: 0 }, [
|
|
213
|
+
u("div", null, [
|
|
214
|
+
y(k, {
|
|
215
|
+
label: "Recipes and ingredients convert to",
|
|
216
|
+
modelValue: (w = b.value) == null ? void 0 : w.value,
|
|
217
|
+
"onUpdate:modelValue": h,
|
|
218
|
+
items: f.value
|
|
219
|
+
}, null, 8, ["modelValue", "items"])
|
|
220
|
+
]),
|
|
221
|
+
y(ft, {
|
|
222
|
+
id: n.value,
|
|
223
|
+
"model-value": ((B = d.modelValue) == null ? void 0 : B.inventoryBindings) ?? [],
|
|
224
|
+
"onUpdate:modelValue": i,
|
|
225
|
+
"exclude-binding-id": n.value
|
|
226
|
+
}, null, 8, ["id", "model-value", "exclude-binding-id"])
|
|
227
|
+
], 64)) : G("", !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 h(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
|
+
qe(() => {
|
|
287
|
+
h(l.units);
|
|
288
|
+
}), Te([() => l.units], ([t]) => {
|
|
289
|
+
h(t);
|
|
290
|
+
});
|
|
291
|
+
function i() {
|
|
292
|
+
n("click:submit");
|
|
293
|
+
}
|
|
294
|
+
const b = V({
|
|
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 = V({
|
|
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 = V({
|
|
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 ? +He(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
|
+
(z) => {
|
|
335
|
+
var H;
|
|
336
|
+
return z.id === ((H = o.modelValue) == null ? void 0 : H.trackingMeasurement);
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
}), e.defaultCost.costPerUnit = {
|
|
340
|
+
...e.defaultCost.costPerUnit,
|
|
341
|
+
...Ye(+t, 4)
|
|
342
|
+
}, n("update:modelValue", e);
|
|
343
|
+
}
|
|
344
|
+
}), A = V(() => {
|
|
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
|
+
}), k = V(
|
|
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: z }) => ({
|
|
368
|
+
label: `${$} (${z})`,
|
|
369
|
+
value: { _id: e, measurement: U },
|
|
370
|
+
displayAsSection: !1
|
|
371
|
+
}))
|
|
372
|
+
])
|
|
373
|
+
);
|
|
374
|
+
function S(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 w(t) {
|
|
379
|
+
var z, H;
|
|
380
|
+
if (!t) return;
|
|
381
|
+
const { _id: e, measurement: m } = t, _ = m || void 0, U = l.units.find((Z) => Z._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((Z) => Z.id === _),
|
|
387
|
+
costPerUnit: {
|
|
388
|
+
...((z = $.defaultCost) == null ? void 0 : z.costPerUnit) ?? {
|
|
389
|
+
amount: 0,
|
|
390
|
+
precision: 2,
|
|
391
|
+
currency: ((H = ge(c.currentCountry.value)) == null ? void 0 : H.currency) ?? "MYR"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}), n("update:modelValue", $);
|
|
395
|
+
}
|
|
396
|
+
const B = V({
|
|
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
|
+
}), x = V(() => Q.options.filter(
|
|
408
|
+
(t) => t === Q.enum.FIFO || t === Q.enum.WAVG
|
|
409
|
+
).map((t) => {
|
|
410
|
+
function e(m) {
|
|
411
|
+
switch (m) {
|
|
412
|
+
case Q.enum.WAVG:
|
|
413
|
+
return "Weighted Average (WAVG)";
|
|
414
|
+
case Q.enum.FIFO:
|
|
415
|
+
return "First In First Out (FIFO)";
|
|
416
|
+
case Q.enum.LIFO:
|
|
417
|
+
return "Last In First Out (LIFO)";
|
|
418
|
+
case Q.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 = V({
|
|
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
|
+
}), j = P();
|
|
439
|
+
r({
|
|
440
|
+
validateInputs: () => {
|
|
441
|
+
var t, e;
|
|
442
|
+
(e = (t = j.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
|
|
443
|
+
},
|
|
444
|
+
resetInputsValidation: () => {
|
|
445
|
+
var t, e;
|
|
446
|
+
(e = (t = j.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
|
|
447
|
+
},
|
|
448
|
+
resetInputs: () => {
|
|
449
|
+
var t, e;
|
|
450
|
+
(e = (t = j.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
const J = P(!1), ae = V(
|
|
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
|
+
), X = V(
|
|
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 = V(
|
|
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
|
+
), N = V(
|
|
473
|
+
() => l.skus.map((t) => ({ label: t.name, value: t.code }))
|
|
474
|
+
), O = P((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 te(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 = V(
|
|
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
|
+
(z) => {
|
|
497
|
+
var H;
|
|
498
|
+
return z.id === ((H = o.modelValue) == null ? void 0 : H.trackingMeasurement);
|
|
499
|
+
}
|
|
500
|
+
)) == null ? void 0 : _.abbrev) ?? (($ = (U = o.modelValue) == null ? void 0 : U.unit) == null ? void 0 : $.abbrev);
|
|
501
|
+
}
|
|
502
|
+
), M = V({
|
|
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
|
+
}), E = V({
|
|
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 = C("FmTextField"), _ = C("FmLabel"), U = C("FmSelect"), $ = C("FmField"), z = C("FmMenuHeader"), H = C("FmMenuDivider"), Z = C("FmMenuItem"), fe = C("FmMenu"), ue = C("FmFormGroup"), se = C("FmSwitch"), de = C("FmStepperField"), Ge = C("FmForm");
|
|
538
|
+
return g(), L(Ge, {
|
|
539
|
+
disabled: t.disabled,
|
|
540
|
+
ref_key: "formRef",
|
|
541
|
+
ref: j,
|
|
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] = (T) => b.value = T),
|
|
550
|
+
rules: [F(xe)(), F(dt)(N.value, O.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] = (T) => d.value = T),
|
|
557
|
+
rules: [F(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] = (T) => le.value = T),
|
|
564
|
+
items: x.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: q([F(f).enableTotalCost ? "col-span-1" : "col-span-2"]),
|
|
578
|
+
"model-value": A.value,
|
|
579
|
+
rules: [F(xe)()],
|
|
580
|
+
"label-mark": "required"
|
|
581
|
+
}, {
|
|
582
|
+
label: I(() => [
|
|
583
|
+
y(_, { label: "Unit" })
|
|
584
|
+
]),
|
|
585
|
+
default: I(({ invalid: T }) => [
|
|
586
|
+
y(fe, null, {
|
|
587
|
+
"menu-button": I(() => [
|
|
588
|
+
y($, {
|
|
589
|
+
class: q([
|
|
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: T,
|
|
597
|
+
"append-icon": "expand_more"
|
|
598
|
+
}, {
|
|
599
|
+
default: I(() => {
|
|
600
|
+
var Y;
|
|
601
|
+
return [
|
|
602
|
+
Pe(K((Y = A.value) == null ? void 0 : Y.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(ee, null, ce(k.value, (Y) => (g(), D(ee, {
|
|
614
|
+
key: Y.label
|
|
615
|
+
}, [
|
|
616
|
+
Y.displayAsSection ? (g(), D(ee, { key: 0 }, [
|
|
617
|
+
y(z, {
|
|
618
|
+
label: Y.label
|
|
619
|
+
}, null, 8, ["label"]),
|
|
620
|
+
y(H)
|
|
621
|
+
], 64)) : (g(), L(Z, {
|
|
622
|
+
key: 1,
|
|
623
|
+
label: Y.label,
|
|
624
|
+
"model-value": S(Y),
|
|
625
|
+
onClick: (Ao) => w(Y.value),
|
|
626
|
+
"x-should-scroll-into": `${S(Y)}`
|
|
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
|
+
F(f).enableTotalCost ? (g(), L(m, {
|
|
637
|
+
key: 0,
|
|
638
|
+
"model-value": v.value,
|
|
639
|
+
"onUpdate:modelValue": e[3] || (e[3] = (T) => v.value = T),
|
|
640
|
+
rules: [F(Ve)(0), F(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 T, Y;
|
|
652
|
+
return [
|
|
653
|
+
u("div", xt, K(te(((T = F(c).currentCountry) == null ? void 0 : T.value) ?? F($e)) === "MYR" ? "RM" : te(((Y = F(c).currentCountry) == null ? void 0 : Y.value) ?? F($e))), 1)
|
|
654
|
+
];
|
|
655
|
+
}),
|
|
656
|
+
append: I(() => [
|
|
657
|
+
u("div", Vt, " / " + K(R.value), 1)
|
|
658
|
+
]),
|
|
659
|
+
_: 1
|
|
660
|
+
}, 8, ["model-value", "rules"])) : G("", !0),
|
|
661
|
+
u("div", kt, [
|
|
662
|
+
y(ht, {
|
|
663
|
+
"model-value": B.value,
|
|
664
|
+
"onUpdate:modelValue": e[4] || (e[4] = (T) => B.value = T),
|
|
665
|
+
"root-value": t.modelValue
|
|
666
|
+
}, null, 8, ["model-value", "root-value"])
|
|
667
|
+
]),
|
|
668
|
+
t.mode !== F(W).CREATE ? (g(), D("div", Ft, [
|
|
669
|
+
u("div", null, [
|
|
670
|
+
y(se, {
|
|
671
|
+
label: "Show binded items",
|
|
672
|
+
modelValue: J.value,
|
|
673
|
+
"onUpdate:modelValue": e[5] || (e[5] = (T) => J.value = T),
|
|
674
|
+
"label-placement": "right"
|
|
675
|
+
}, null, 8, ["modelValue"])
|
|
676
|
+
]),
|
|
677
|
+
J.value && ae.value.length ? (g(), L(Ce, {
|
|
678
|
+
key: 0,
|
|
679
|
+
name: "Ingredient",
|
|
680
|
+
bindings: ae.value
|
|
681
|
+
}, null, 8, ["bindings"])) : G("", !0),
|
|
682
|
+
J.value && X.value.length ? (g(), L(Ce, {
|
|
683
|
+
key: 1,
|
|
684
|
+
name: "Recipe",
|
|
685
|
+
bindings: X.value
|
|
686
|
+
}, null, 8, ["bindings"])) : G("", !0),
|
|
687
|
+
J.value && a.value.length ? (g(), L(Ce, {
|
|
688
|
+
key: 2,
|
|
689
|
+
name: "Menu",
|
|
690
|
+
bindings: a.value
|
|
691
|
+
}, null, 8, ["bindings"])) : G("", !0)
|
|
692
|
+
])) : G("", !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: M.value, mid: E.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: M.value,
|
|
713
|
+
level: F(Fe).low
|
|
714
|
+
}, null, 8, ["days", "level"])
|
|
715
|
+
]),
|
|
716
|
+
u("div", At, [
|
|
717
|
+
Dt,
|
|
718
|
+
y(de, {
|
|
719
|
+
modelValue: M.value,
|
|
720
|
+
"onUpdate:modelValue": e[6] || (e[6] = (T) => M.value = T),
|
|
721
|
+
rules: [F(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: E.value,
|
|
735
|
+
level: F(Fe).mid
|
|
736
|
+
}, null, 8, ["days", "level"])
|
|
737
|
+
]),
|
|
738
|
+
u("div", Lt, [
|
|
739
|
+
zt,
|
|
740
|
+
y(de, {
|
|
741
|
+
modelValue: E.value,
|
|
742
|
+
"onUpdate:modelValue": e[7] || (e[7] = (T) => E.value = T),
|
|
743
|
+
rules: [F(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: E.value + 1,
|
|
757
|
+
level: F(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: W.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 = V(() => {
|
|
780
|
+
switch (r.mode) {
|
|
781
|
+
case W.READ:
|
|
782
|
+
return "View ingredient";
|
|
783
|
+
case W.UPDATE:
|
|
784
|
+
return "Edit ingredient";
|
|
785
|
+
case W.CREATE:
|
|
786
|
+
return "Add ingredient";
|
|
787
|
+
}
|
|
788
|
+
return "";
|
|
789
|
+
}), f = V(() => {
|
|
790
|
+
switch (r.mode) {
|
|
791
|
+
case W.READ:
|
|
792
|
+
return "";
|
|
793
|
+
case W.UPDATE:
|
|
794
|
+
return "Save";
|
|
795
|
+
case W.CREATE:
|
|
796
|
+
return "Add";
|
|
797
|
+
}
|
|
798
|
+
return "";
|
|
799
|
+
}), h = P(), i = P(!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 (k) {
|
|
809
|
+
k 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 (k) {
|
|
827
|
+
k 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 k, S;
|
|
838
|
+
(S = (k = h.value) == null ? void 0 : k.validateInputs) == null || S.call(k);
|
|
839
|
+
}
|
|
840
|
+
function A() {
|
|
841
|
+
switch (r.mode) {
|
|
842
|
+
case W.READ:
|
|
843
|
+
return;
|
|
844
|
+
case W.UPDATE:
|
|
845
|
+
return d();
|
|
846
|
+
case W.CREATE:
|
|
847
|
+
return b();
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return (k, S) => {
|
|
851
|
+
const w = C("FmButton"), B = C("FmSideSheet");
|
|
852
|
+
return g(), L(B, {
|
|
853
|
+
"model-value": F(n),
|
|
854
|
+
"onUpdate:modelValue": S[3] || (S[3] = (x) => we(n) ? n.value = x : 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(w, {
|
|
863
|
+
loading: i.value,
|
|
864
|
+
label: f.value,
|
|
865
|
+
onClick: v
|
|
866
|
+
}, null, 8, ["loading", "label"]),
|
|
867
|
+
y(w, {
|
|
868
|
+
disabled: i.value,
|
|
869
|
+
label: "Close",
|
|
870
|
+
variant: "tertiary",
|
|
871
|
+
onClick: S[2] || (S[2] = (x) => 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: h,
|
|
880
|
+
modelValue: F(l),
|
|
881
|
+
"onUpdate:modelValue": S[0] || (S[0] = (x) => we(l) ? l.value = x : null),
|
|
882
|
+
mode: k.mode,
|
|
883
|
+
disabled: i.value,
|
|
884
|
+
"onClick:submit": S[1] || (S[1] = (x) => 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 ? +He((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 We() {
|
|
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 = We(), 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 = Oe(l, c), h = `${o == null ? void 0 : o.name} ingredients (${gt(/* @__PURE__ */ new Date())}).xlsx`;
|
|
971
|
+
return je(f, h), h;
|
|
972
|
+
}
|
|
973
|
+
function to() {
|
|
974
|
+
const r = me().currentBusiness.value, p = We(), 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 = Oe(o, n), c = "FeedMe ingredients template.xlsx";
|
|
981
|
+
return je(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), h = r.map((b) => b.split(":")[1]);
|
|
993
|
+
return f.map((b, d) => {
|
|
994
|
+
const v = {};
|
|
995
|
+
for (const A in h) {
|
|
996
|
+
const k = h[A];
|
|
997
|
+
Object.assign(v, { [k]: b[A] });
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
index: d,
|
|
1001
|
+
data: v
|
|
1002
|
+
};
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
function De(s, r, p) {
|
|
1006
|
+
var B;
|
|
1007
|
+
const n = ne().units, l = new Array(), c = p.filter((x) => x.data.code === s.code);
|
|
1008
|
+
c.length > 1 && l.push(
|
|
1009
|
+
`Code ${s.code} is already used in row ${c.map((x) => x.index + 6).join()}.`
|
|
1010
|
+
);
|
|
1011
|
+
const f = n.find((x) => x.abbrev === s.baseUnit), h = f == null ? void 0 : f.measurements.find((x) => x.abbrev === s.unit);
|
|
1012
|
+
if (!f)
|
|
1013
|
+
l.push(`Cannot find base unit of symbol ${s.baseUnit}.`);
|
|
1014
|
+
else if (s.baseUnit !== s.unit && !h) {
|
|
1015
|
+
const x = `Cannot find unit conversion for ${s.baseUnit} with symbol ${s.unit || "[empty]"}.`;
|
|
1016
|
+
l.push(x);
|
|
1017
|
+
}
|
|
1018
|
+
const i = Q.options.find(
|
|
1019
|
+
(x) => x === s.valuationMethod
|
|
1020
|
+
);
|
|
1021
|
+
s.valuationMethod && !i && l.push(
|
|
1022
|
+
`Expected valuation method to be one of ${Q.options.join()} but got ${s.valuationMethod} instead.`
|
|
1023
|
+
);
|
|
1024
|
+
const d = me().currentCountry.value, v = (x) => `${x}`.length && mt()(x) === !0, A = v(`${s.pricePerUnit}`) === !0 ? {
|
|
1025
|
+
costPerUnit: {
|
|
1026
|
+
...Ye(Number(s.pricePerUnit) || 0),
|
|
1027
|
+
currency: ((B = ge(d)) == null ? void 0 : B.currency) ?? "MYR"
|
|
1028
|
+
},
|
|
1029
|
+
measurement: h
|
|
1030
|
+
} : void 0, k = 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((x) => x) ?? Xt,
|
|
1041
|
+
trackingMeasurement: h == null ? void 0 : h.id,
|
|
1042
|
+
valuation: i,
|
|
1043
|
+
defaultCost: A,
|
|
1044
|
+
thresholds: k
|
|
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
|
+
), h = 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: h
|
|
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 = P(!1), l = P(null), c = P(null), f = P(), h = (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 N;
|
|
1100
|
+
p.disabled || (a.stopPropagation(), a.preventDefault(), n.value = !1, v((N = a.dataTransfer) == null ? void 0 : N.files));
|
|
1101
|
+
};
|
|
1102
|
+
function v(a) {
|
|
1103
|
+
if (a)
|
|
1104
|
+
if (f.value = a, l.value = k(a[0]), c.value = S(a[0]), l.value && c.value)
|
|
1105
|
+
o("file-upload", a[0]);
|
|
1106
|
+
else {
|
|
1107
|
+
const N = A();
|
|
1108
|
+
o("file-rejected", [
|
|
1109
|
+
{
|
|
1110
|
+
file: a[0],
|
|
1111
|
+
reason: N
|
|
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
|
+
}, k = (a) => {
|
|
1120
|
+
if (!p.accept) return !0;
|
|
1121
|
+
const N = p.accept.split(",").map((O) => O.trim());
|
|
1122
|
+
for (const O of N)
|
|
1123
|
+
if (w(O)) {
|
|
1124
|
+
if (x(O) === x(a.type)) return !0;
|
|
1125
|
+
} else if (B(a) === O || a.type === O) return !0;
|
|
1126
|
+
return !1;
|
|
1127
|
+
}, S = (a) => a.size <= p.maxFileSize, w = (a) => a.indexOf("*") !== -1, B = (a) => "." + a.name.split(".").pop(), x = (a) => a.substring(0, a.indexOf("/")), le = V(() => {
|
|
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
|
+
}), j = V(() => f.value ? !l.value || !c.value : !1), J = (a) => {
|
|
1134
|
+
const N = a.target;
|
|
1135
|
+
v(N.files);
|
|
1136
|
+
}, ae = V(() => {
|
|
1137
|
+
var a;
|
|
1138
|
+
return (a = f.value) == null ? void 0 : a.item(0);
|
|
1139
|
+
}), X = P();
|
|
1140
|
+
return (a, N) => {
|
|
1141
|
+
const O = C("FmLabel"), ie = C("FmButton");
|
|
1142
|
+
return g(), D("label", {
|
|
1143
|
+
class: "fm-droppable-field",
|
|
1144
|
+
ref_key: "fmButtonRef",
|
|
1145
|
+
ref: X
|
|
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: J
|
|
1154
|
+
}, null, 40, ao)
|
|
1155
|
+
])) : G("", !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 te;
|
|
1163
|
+
return console.log("click", X.value), (te = X.value) == null ? void 0 : te.click();
|
|
1164
|
+
}
|
|
1165
|
+
}, () => [
|
|
1166
|
+
u("div", so, [
|
|
1167
|
+
a.$slots.label ? ve(a.$slots, "label", { key: 0 }, void 0, !0) : (g(), L(O, {
|
|
1168
|
+
key: 1,
|
|
1169
|
+
label: a.label
|
|
1170
|
+
}, null, 8, ["label"]))
|
|
1171
|
+
]),
|
|
1172
|
+
u("div", {
|
|
1173
|
+
class: q([[
|
|
1174
|
+
a.contentClass ? a.contentClass : "w-full h-full",
|
|
1175
|
+
{
|
|
1176
|
+
"fm-droppable-field__container--dragging": n.value,
|
|
1177
|
+
"fm-droppable-field__container--invalid": j.value && !a.disabled,
|
|
1178
|
+
"fm-droppable-field__container--disabled": a.disabled
|
|
1179
|
+
}
|
|
1180
|
+
], "fm-droppable-field__container"]),
|
|
1181
|
+
onDragenter: h,
|
|
1182
|
+
onDragleave: b,
|
|
1183
|
+
onDragover: i,
|
|
1184
|
+
onDrop: d
|
|
1185
|
+
}, [
|
|
1186
|
+
(n.value || j.value) && !a.disabled ? (g(), D("div", {
|
|
1187
|
+
key: 0,
|
|
1188
|
+
class: q({
|
|
1189
|
+
"fm-typo-en-body-lg-600": !0,
|
|
1190
|
+
"text-fm-color-primary": n.value,
|
|
1191
|
+
"text-fm-color-typo-error": j.value
|
|
1192
|
+
})
|
|
1193
|
+
}, K(le.value), 3)) : (g(), L(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: q([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
|
|
1204
|
+
}, K(`Accepts ${p.accept}`), 3)) : G("", !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: J
|
|
1212
|
+
}, null, 40, ro)
|
|
1213
|
+
], 34),
|
|
1214
|
+
ve(a.$slots, "helper-text", {}, () => [
|
|
1215
|
+
u("div", {
|
|
1216
|
+
class: q([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
|
|
1217
|
+
}, K(`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 = C("FmIcon"), n = C("FmTooltip");
|
|
1237
|
+
return g(), D("div", co, [
|
|
1238
|
+
mo,
|
|
1239
|
+
u("div", po, [
|
|
1240
|
+
u("div", fo, [
|
|
1241
|
+
u("div", {
|
|
1242
|
+
class: q({
|
|
1243
|
+
"text-fm-color-system-error-300": r.errors.length
|
|
1244
|
+
})
|
|
1245
|
+
}, [
|
|
1246
|
+
Pe(K(r.name) + " ", 1),
|
|
1247
|
+
r.type === "create" ? (g(), D("span", vo, "(new)")) : G("", !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(ee, null, ce(r.errors, (l, c) => (g(), D("li", { key: c }, K(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
|
+
])) : G("", !0)
|
|
1266
|
+
]),
|
|
1267
|
+
u("div", {
|
|
1268
|
+
class: q([
|
|
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
|
+
}, K(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 = P(null), p = ot(), o = be(), n = P(!1), l = P(new Array()), c = P([]), f = P([]), h = V(
|
|
1290
|
+
() => !!l.value.length || c.value.some((d) => d.errors.length) || f.value.some((d) => d.errors.length)
|
|
1291
|
+
), i = V(
|
|
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((S) => setTimeout(S, 2e3))
|
|
1302
|
+
]), A = v.SheetNames.find((S) => S);
|
|
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 k = no(v.Sheets[A]);
|
|
1310
|
+
c.value = k.importCreateResult, f.value = k.importUpdateResult, !c.value.length && !f.value.length && l.value.push("No import data is available in the excel file."), p.emitData(k);
|
|
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 = C("FmCircularProgress"), k = C("FmIcon"), S = C("FmButton");
|
|
1325
|
+
return g(), D("div", go, [
|
|
1326
|
+
bo,
|
|
1327
|
+
y(uo, {
|
|
1328
|
+
class: q({
|
|
1329
|
+
"w-full": !0,
|
|
1330
|
+
"h-[200px]": !r.value
|
|
1331
|
+
}),
|
|
1332
|
+
accept: ".xlsx",
|
|
1333
|
+
onFileUpload: v[0] || (v[0] = (w) => r.value = w),
|
|
1334
|
+
label: "Upload template",
|
|
1335
|
+
"button-label": "Select file"
|
|
1336
|
+
}, Ke({ _: 2 }, [
|
|
1337
|
+
r.value ? {
|
|
1338
|
+
name: "default",
|
|
1339
|
+
fn: I(({ openFileDialog: w }) => [
|
|
1340
|
+
u("div", _o, [
|
|
1341
|
+
u("div", {
|
|
1342
|
+
class: q([
|
|
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 && !h.value,
|
|
1347
|
+
"border border-fm-color-system-error-200": h.value
|
|
1348
|
+
}
|
|
1349
|
+
])
|
|
1350
|
+
}, [
|
|
1351
|
+
n.value ? (g(), L(A, {
|
|
1352
|
+
key: 0,
|
|
1353
|
+
size: "md",
|
|
1354
|
+
color: "neutral-gray-200"
|
|
1355
|
+
})) : (g(), L(k, {
|
|
1356
|
+
key: 1,
|
|
1357
|
+
name: h.value ? "error" : "attach_file",
|
|
1358
|
+
outline: "",
|
|
1359
|
+
color: h.value ? "system-error-300" : void 0
|
|
1360
|
+
}, null, 8, ["name", "color"])),
|
|
1361
|
+
u("div", {
|
|
1362
|
+
class: q([
|
|
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, K(r.value.name), 1)
|
|
1371
|
+
], 2),
|
|
1372
|
+
n.value ? G("", !0) : (g(), D("div", xo, [
|
|
1373
|
+
y(S, {
|
|
1374
|
+
label: "Replace file",
|
|
1375
|
+
variant: h.value ? "destructive" : "secondary",
|
|
1376
|
+
"prepend-icon": h.value ? void 0 : "autorenew",
|
|
1377
|
+
onClick: w
|
|
1378
|
+
}, null, 8, ["variant", "prepend-icon", "onClick"])
|
|
1379
|
+
]))
|
|
1380
|
+
], 2),
|
|
1381
|
+
l.value.length ? (g(), D("div", Vo, [
|
|
1382
|
+
(g(!0), D(ee, null, ce(l.value, (B, x) => (g(), D("div", {
|
|
1383
|
+
key: x,
|
|
1384
|
+
class: "flex gap-8 items-center"
|
|
1385
|
+
}, [
|
|
1386
|
+
y(k, {
|
|
1387
|
+
name: "error",
|
|
1388
|
+
size: "sm",
|
|
1389
|
+
color: "system-error-300"
|
|
1390
|
+
}),
|
|
1391
|
+
u("div", ko, K(B), 1)
|
|
1392
|
+
]))), 128))
|
|
1393
|
+
])) : G("", !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(ee, null, ce(c.value, (w) => (g(), L(Ee, {
|
|
1402
|
+
key: w.sku._id,
|
|
1403
|
+
code: w.sku.code,
|
|
1404
|
+
name: w.sku.name,
|
|
1405
|
+
errors: w.errors,
|
|
1406
|
+
type: "create"
|
|
1407
|
+
}, null, 8, ["code", "name", "errors"]))), 128)),
|
|
1408
|
+
(g(!0), D(ee, null, ce(f.value, (w) => (g(), L(Ee, {
|
|
1409
|
+
key: w.sku._id,
|
|
1410
|
+
code: w.sku.code,
|
|
1411
|
+
name: w.sku.name,
|
|
1412
|
+
errors: w.errors,
|
|
1413
|
+
type: "update"
|
|
1414
|
+
}, null, 8, ["code", "name", "errors"]))), 128))
|
|
1415
|
+
])) : G("", !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 = V(() => r.skus), o = tt(), n = Ne(), l = be(), {
|
|
1423
|
+
createIngredient: c,
|
|
1424
|
+
updateIngredient: f,
|
|
1425
|
+
deleteIngredient: h,
|
|
1426
|
+
ingredientDialogProps: i,
|
|
1427
|
+
ingredientViewLoading: b
|
|
1428
|
+
} = bt(), { columnDefs: d } = _t({ updateIngredient: f, deleteIngredient: h });
|
|
1429
|
+
function v(R) {
|
|
1430
|
+
switch (R) {
|
|
1431
|
+
case "add":
|
|
1432
|
+
return c();
|
|
1433
|
+
case "import":
|
|
1434
|
+
return O();
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
const A = P(""), k = P(!1), S = V(() => k.value || b.value), { breakpoints: w } = nt(), B = V(() => w.value.xs || w.value.sm), x = V(() => B.value ? 10 : 20), le = it(), j = P(!1), J = [
|
|
1438
|
+
{
|
|
1439
|
+
value: "import",
|
|
1440
|
+
label: "Import"
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
value: "export",
|
|
1444
|
+
label: "Export"
|
|
1445
|
+
}
|
|
1446
|
+
];
|
|
1447
|
+
function ae(R) {
|
|
1448
|
+
switch (j.value = !1, R) {
|
|
1449
|
+
case "import":
|
|
1450
|
+
return O();
|
|
1451
|
+
case "export":
|
|
1452
|
+
return N();
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
const X = V(() => B.value ? [
|
|
1456
|
+
{ label: "More", icon: "more_vert", key: "more" }
|
|
1457
|
+
] : [
|
|
1458
|
+
{ label: "Export", icon: "ios_share", key: "export" }
|
|
1459
|
+
]), a = V(() => {
|
|
1460
|
+
const R = [
|
|
1461
|
+
{ label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }
|
|
1462
|
+
];
|
|
1463
|
+
return B.value ? R : [...R, { label: "Import", value: "import" }];
|
|
1464
|
+
});
|
|
1465
|
+
function N() {
|
|
1466
|
+
const R = eo();
|
|
1467
|
+
l.open({
|
|
1468
|
+
title: "Ingredients exported",
|
|
1469
|
+
message: `Filename: ${R}`,
|
|
1470
|
+
type: "success"
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
function O() {
|
|
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((M) => M.errors.length) || R.importUpdateResult.some((M) => M.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
|
+
const M = ze(
|
|
1521
|
+
R.importUpdateResult.map((E) => E.sku),
|
|
1522
|
+
"code"
|
|
1523
|
+
);
|
|
1524
|
+
k.value = !0;
|
|
1525
|
+
try {
|
|
1526
|
+
await Promise.all([
|
|
1527
|
+
r.importSkus({
|
|
1528
|
+
create: R.importCreateResult.map((E) => E.sku),
|
|
1529
|
+
update: p.value.map((E) => M[E.code] ?? E)
|
|
1530
|
+
}),
|
|
1531
|
+
new Promise((E) => setTimeout(E, 2e3))
|
|
1532
|
+
]), l.open({
|
|
1533
|
+
title: "Ingredients successfully imported",
|
|
1534
|
+
type: "success"
|
|
1535
|
+
});
|
|
1536
|
+
} catch (E) {
|
|
1537
|
+
l.open({
|
|
1538
|
+
title: "Failed to import ingredients",
|
|
1539
|
+
message: `System message: ${E == null ? void 0 : E.message}`,
|
|
1540
|
+
type: "error"
|
|
1541
|
+
}), console.error("Error in importing skus", R, E);
|
|
1542
|
+
} finally {
|
|
1543
|
+
k.value = !1;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
function te() {
|
|
1547
|
+
j.value = !0;
|
|
1548
|
+
}
|
|
1549
|
+
return (R, M) => {
|
|
1550
|
+
const E = C("FmTableToolbar"), _e = C("FmTable"), pe = C("FmCollapsibleTabs"), t = C("FmBottomSheet");
|
|
1551
|
+
return g(), L(ut, {
|
|
1552
|
+
title: "Ingredient",
|
|
1553
|
+
actions: a.value,
|
|
1554
|
+
"onClick:action": v
|
|
1555
|
+
}, {
|
|
1556
|
+
default: I(() => [
|
|
1557
|
+
u("div", wo, [
|
|
1558
|
+
u("div", Mo, [
|
|
1559
|
+
u("div", $o, [
|
|
1560
|
+
y(E, {
|
|
1561
|
+
searchable: "",
|
|
1562
|
+
"search-model": A.value,
|
|
1563
|
+
"onUpdate:searchModel": M[0] || (M[0] = (e) => A.value = e),
|
|
1564
|
+
actions: X.value,
|
|
1565
|
+
"onClick:actionExport": M[1] || (M[1] = () => N()),
|
|
1566
|
+
"onClick:actionImport": M[2] || (M[2] = () => O()),
|
|
1567
|
+
"onClick:actionMore": M[3] || (M[3] = () => te())
|
|
1568
|
+
}, null, 8, ["search-model", "actions"])
|
|
1569
|
+
])
|
|
1570
|
+
]),
|
|
1571
|
+
y(_e, {
|
|
1572
|
+
style: Je(F(le).tableHeight),
|
|
1573
|
+
"column-defs": F(d),
|
|
1574
|
+
"row-data": p.value,
|
|
1575
|
+
"search-value": A.value,
|
|
1576
|
+
loading: !F(o)._currentLocation || S.value,
|
|
1577
|
+
onRowClick: M[4] || (M[4] = (e) => F(f)(e.original)),
|
|
1578
|
+
"page-size": x.value
|
|
1579
|
+
}, {
|
|
1580
|
+
"list-row": I((e) => [
|
|
1581
|
+
y(rt, {
|
|
1582
|
+
row: e,
|
|
1583
|
+
onRowClick: F(f)
|
|
1584
|
+
}, {
|
|
1585
|
+
default: I((m) => {
|
|
1586
|
+
var _, U, $, z, H, Z, fe, ue, se, de;
|
|
1587
|
+
return [
|
|
1588
|
+
u("div", Io, [
|
|
1589
|
+
u("div", Ro, [
|
|
1590
|
+
y(F(Ae), {
|
|
1591
|
+
render: ($ = (U = (_ = m.code) == null ? void 0 : _.column) == null ? void 0 : U.columnDef) == null ? void 0 : $.cell,
|
|
1592
|
+
props: (H = (z = m.code) == null ? void 0 : z.getContext) == null ? void 0 : H.call(z)
|
|
1593
|
+
}, null, 8, ["render", "props"])
|
|
1594
|
+
]),
|
|
1595
|
+
u("div", Uo, [
|
|
1596
|
+
y(F(Ae), {
|
|
1597
|
+
render: (ue = (fe = (Z = m.name) == null ? void 0 : Z.column) == null ? void 0 : fe.columnDef) == null ? void 0 : ue.cell,
|
|
1598
|
+
props: (de = (se = m.name) == null ? void 0 : se.getContext) == null ? void 0 : de.call(se)
|
|
1599
|
+
}, null, 8, ["render", "props"])
|
|
1600
|
+
])
|
|
1601
|
+
])
|
|
1602
|
+
];
|
|
1603
|
+
}),
|
|
1604
|
+
_: 2
|
|
1605
|
+
}, 1032, ["row", "onRowClick"])
|
|
1606
|
+
]),
|
|
1607
|
+
_: 1
|
|
1608
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
1609
|
+
]),
|
|
1610
|
+
(g(), L(Me, { to: "body" }, [
|
|
1611
|
+
y(qt, Qe(Xe(F(i))), null, 16)
|
|
1612
|
+
])),
|
|
1613
|
+
(g(), L(Me, { to: "body" }, [
|
|
1614
|
+
y(t, {
|
|
1615
|
+
"dismiss-away": "",
|
|
1616
|
+
modelValue: j.value,
|
|
1617
|
+
"onUpdate:modelValue": M[6] || (M[6] = (e) => j.value = e)
|
|
1618
|
+
}, {
|
|
1619
|
+
default: I(() => [
|
|
1620
|
+
y(pe, {
|
|
1621
|
+
class: "pb-8",
|
|
1622
|
+
items: J,
|
|
1623
|
+
"onUpdate:modelValue": M[5] || (M[5] = (e) => ae(e))
|
|
1624
|
+
})
|
|
1625
|
+
]),
|
|
1626
|
+
_: 1
|
|
1627
|
+
}, 8, ["modelValue"])
|
|
1628
|
+
]))
|
|
1629
|
+
]),
|
|
1630
|
+
_: 1
|
|
1631
|
+
}, 8, ["actions"]);
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
export {
|
|
1636
|
+
qo as default
|
|
1637
|
+
};
|