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