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