@feedmepos/mf-inventory-portal 1.5.12 → 1.6.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-DBEmTaMX.js → App-BWiKiRD2.js} +4 -4
- package/dist/{ApprovalView-BvzIwH1r.js → ApprovalView-TFet-Rht.js} +7 -7
- package/dist/{BindingsDialog-DnqHoU0Y.js → BindingsDialog-ByO16R7B.js} +2 -2
- package/dist/{BindingsPicker-Bjpj0zdJ.js → BindingsPicker-BzeipJDM.js} +2 -2
- package/dist/{BindingsTable-S5Nqq4Qv.js → BindingsTable-CATRwDGx.js} +3 -3
- package/dist/ClosingDraftView-Bilo3C7N.js +4318 -0
- package/dist/{ClosingHistoryView-B2ccrB2K.js → ClosingHistoryView-DJEhuzBh.js} +5 -5
- package/dist/ClosingTemplateView-DTS__1eO.js +2221 -0
- package/dist/{DefaultView-DQhLe6LE.js → DefaultView-Dpwvllot.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-Cup9mzpO.js → DeliveryOrderPrintPreview-BZ-BDWlS.js} +2 -2
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DuZFuSbw.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BMJVOiL_.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DoPyc0aE.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-QvgQwP6t.js} +2 -2
- package/dist/{FmMultiselectDialog-Cwazmlw3.js → FmMultiselectDialog-B1rAOXTC.js} +2 -2
- package/dist/{FmMultiselectDialog-DnuUrW7h.js → FmMultiselectDialog-W0_FfMmH.js} +1 -1
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BMzzUsa4.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DNpKzzVC.js} +5 -5
- package/dist/{ImportView-CXtrdABV.js → ImportView-B_3OeL5b.js} +6 -6
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Cfp95IvX.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CdNdnCp-.js} +1 -1
- package/dist/{IngredientGroupView-Bm-2yK8J.js → IngredientGroupView-B_v-UNeR.js} +5 -5
- package/dist/{IngredientsView-Bo8w9LSr.js → IngredientsView-DTXevc-8.js} +15 -15
- package/dist/{IntegrationExplorerView-DUqQ64CE.js → IntegrationExplorerView-C6JUipFs.js} +352 -352
- package/dist/IntegrationView-DX4hhKYv.js +5100 -0
- package/dist/{InventoryBindingForm-DWJRCTf8.js → InventoryBindingForm-BpNKhiGF.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DH-xUQ5m.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BWy-YpCv.js} +5 -5
- package/dist/{InventoryBindingSummary-DSwCvTnu.js → InventoryBindingSummary-BL4AkZY3.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-KDWRZCxm.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DURnZteR.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Wuv2teWn.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BR0Hc9cL.js} +1 -1
- package/dist/{PublishView-BSahQbqy.js → PublishView-CELngZXP.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-C8umjCEU.js → PurchaseOrderPrintPreview-HCGMQWdo.js} +2 -2
- package/dist/{ReceiveRequestView-Bf5dAcun.js → ReceiveRequestView-DfrpsGeI.js} +26 -26
- package/dist/{RecipeView-wU9u23Zp.js → RecipeView-DCrrdrhp.js} +1104 -1117
- package/dist/{SettingsView-C5Uc6h0A.js → SettingsView-CHoDkUIF.js} +4 -4
- package/dist/{StockView-QF68mXtU.js → StockView-DlP1-pbq.js} +19 -19
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cgw8EDXb.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-NZcNoQ6u.js} +1 -1
- package/dist/{SupplierView-xBONJSsg.js → SupplierView-DqQbgLqh.js} +12 -12
- package/dist/{SurchargeView-BK8aNKZl.js → SurchargeView-CtlXOPJ3.js} +6 -6
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-tsuedeNl.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BRrHPAJj.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BXVa7pt5.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bw3UN_Zn.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CVRD5iri.js → TransferDetails.vue_vue_type_script_setup_true_lang-atZZPJBf.js} +20 -20
- package/dist/TransferTemplateView-Dl0k38tD.js +2327 -0
- package/dist/{UnitCostHistoryView-BS0nrbkD.js → UnitCostHistoryView-Dh-yAgvG.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CeD0qWRC.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-FqnqY9bU.js} +5 -5
- package/dist/{UnitView-DsKX7DM0.js → UnitView-D5Zvz2xm.js} +7 -7
- package/dist/{WarehouseView-DRZaGu80.js → WarehouseView-s5g9AQq5.js} +5 -5
- package/dist/{WastageTemplateView-CtMSWKFj.js → WastageTemplateView-XzJSsB29.js} +14 -14
- package/dist/api/closing-draft.d.ts +6 -0
- package/dist/api/codemax.d.ts +11 -0
- package/dist/api/inventory.d.ts +1 -0
- package/dist/api/netsuite.d.ts +5 -4
- package/dist/api/surcharge.d.ts +1 -0
- package/dist/{app-DYMYQwvV.js → app-D-l9FM2n.js} +15762 -13683
- package/dist/app.d.ts +288 -0
- package/dist/app.js +1 -1
- package/dist/{closing-template-Cxsa4j_W.js → closing-template-C56_2aLc.js} +1 -1
- package/dist/{date2-BdXL0GG5.js → date2-CRMgo5NH.js} +1 -1
- package/dist/{dayjs.min-LoBFKjU2.js → dayjs.min-9bo3vPqj.js} +1 -1
- package/dist/{decimal-BFFta-yv.js → decimal-CsE7mms2.js} +2 -2
- package/dist/{defineDeepModel-CCZ3fqXQ.js → defineDeepModel-DDX70CM6.js} +1 -1
- package/dist/{duplicate-template-C2Qho2Ig.js → duplicate-template-BrEOP-1V.js} +1 -1
- package/dist/{feature-Dt5ZFkZR.js → feature-Bl6yUhw_.js} +2 -2
- package/dist/{format-time-from-id-LqoWbcB4.js → format-time-from-id-BuMdYlM9.js} +1 -1
- package/dist/format-unit-display-CMfuvGP6.js +1432 -0
- package/dist/{import-export.helper-DogBd6aS.js → import-export.helper-C9F9d-rh.js} +6 -6
- package/dist/{index-IMHyRNdu.js → index-BcOtIfdU.js} +1 -1
- package/dist/index-BdSVteJV.js +257 -0
- package/dist/{index-D0xsiYLO.js → index-cbmIhZ6F.js} +1 -1
- package/dist/{inventory-core-dart.default-BkcD7c_a.js → inventory-core-dart.default-DewosGoK.js} +1 -1
- package/dist/{lz-string-CgecKowu.js → lz-string-Ye-dLAix.js} +1 -1
- package/dist/modules/print-template/api/print-template.d.ts +1 -0
- package/dist/{netsuite-9qEVrdMv.js → netsuite-Dyw1JtQL.js} +2 -2
- package/dist/{number-DSMFbPf0.js → number-YiCgPFTE.js} +3 -3
- package/dist/{predefined-templates-OZoiOUoA.js → predefined-templates-B0Eto9Jx.js} +1 -1
- package/dist/{purchase-order-template-CUee1L_x.js → purchase-order-template-zHPLRQDQ.js} +1 -1
- package/dist/{recalculationUtils-CPcCUHIm.js → recalculationUtils-DZLZlctO.js} +1 -1
- package/dist/{rules-CMNaUkUU.js → rules-BsVkaxL5.js} +2 -2
- package/dist/{stock-BOaUT0Y3.js → stock-DlQopDTl.js} +1 -1
- package/dist/stores/api.d.ts +1 -0
- package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
- package/dist/stores/integration/codemax.d.ts +432 -0
- package/dist/stores/integration/index.d.ts +4 -1
- package/dist/{supplier-BAbQZL7x.js → supplier-UPX_1aFs.js} +2 -2
- package/dist/{surcharge-C5tQ0vs0.js → surcharge-DO3-kAit.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{uom-rules-CSmRb5Ds.js → uom-rules-DbhFLCUC.js} +1 -1
- package/dist/{use-ingredient-select-dialog-B9XYlxjA.js → use-ingredient-select-dialog-BASkk3-u.js} +16 -16
- package/dist/{use-inventory-binding-dialog-BzIb4yxm.js → use-inventory-binding-dialog-DTc48xUU.js} +2 -2
- package/dist/use-template-enabled-locations-gwYjb6_p.js +132 -0
- package/dist/{use-transfer-locations-Di5ozOgU.js → use-transfer-locations-BJ0xIECi.js} +2 -2
- package/dist/{useHrmPermission-N8GPw9P_.js → useHrmPermission-G4mfvYF8.js} +1 -1
- package/dist/{useNavigationMenu-BLnGMLsm.js → useNavigationMenu-Be-99JmQ.js} +2 -2
- package/dist/{useSseClient-BQtJfryY.js → useSseClient-D1h38l_K.js} +3 -3
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +800 -0
- package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +40 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupAction.vue.d.ts +21 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupCard.vue.d.ts +20 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +823 -0
- package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupGrid.vue.d.ts +20 -0
- package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +10 -0
- package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1400 -133
- package/dist/views/closing-draft/helpers/closing-draft-summary.helper.d.ts +11 -0
- package/dist/views/closing-draft/helpers/closing-group-detail.helper.d.ts +68 -0
- package/dist/views/closing-draft/helpers/closing-group-status.helper.d.ts +6 -0
- package/dist/views/closing-draft/helpers/closing-groups.helper.d.ts +28 -0
- package/dist/views/closing-draft/helpers/merge-closing-draft-items.helper.d.ts +9 -0
- package/dist/views/closing-template/components/closing-template-form/components/ClosingTemplateGroupsEditor.vue.d.ts +31 -0
- package/dist/views/closing-template/components/closing-template-form/components/ClosingTemplateItem.vue.d.ts +164 -7
- package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +24 -88
- package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +108 -0
- package/dist/views/closing-template/composables/use-closing-template-table.d.ts +108 -0
- package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +3 -3
- package/dist/views/integration/Codemax.vue.d.ts +2 -0
- package/dist/views/integration/components/ApplyProductCodemax.vue.d.ts +341 -0
- package/dist/views/integration/components/ApplyProductDialogCodemax.vue.d.ts +298 -0
- package/dist/views/integration/components/ApplyProductDialogPropsCodemax.d.ts +17 -0
- package/dist/views/integration/components/CodemaxDialog.vue.d.ts +519 -0
- package/dist/views/recipe/composables/use-recipe-bulk-editor.d.ts +3 -3
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorDialog.vue.d.ts +2 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep1.vue.d.ts +2 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep2.vue.d.ts +8 -0
- package/dist/views/transfer-template/components/template-item-bulk-editor/TemplateItemBulkEditorStep3.vue.d.ts +2 -0
- package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +3225 -0
- package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +4 -1
- package/dist/views/transfer-template/helpers/template-item-bulk-editor-export.d.ts +9 -0
- package/dist/{vue-i18n-DR8I1LQH.js → vue-i18n-fX3C6wjd.js} +306 -306
- package/dist/{xlsx-D5-Cqx-l.js → xlsx-BsL1DoEA.js} +1 -1
- package/dist/{xlsx.util-DEdsfN6W.js → xlsx.util-D_XTOHMv.js} +3 -3
- package/package.json +4 -4
- package/dist/ClosingDraftView-Y074sSoz.js +0 -3343
- package/dist/ClosingTemplateView-BcvKBWVJ.js +0 -2077
- package/dist/IntegrationView-CtkbKPzC.js +0 -4586
- package/dist/TransferTemplateView-Cm4evaK3.js +0 -1564
- package/dist/format-unit-display-CWqmpVa_.js +0 -1268
- package/dist/index-2DNXazDV.js +0 -164
- package/dist/use-template-enabled-locations-V5iE0ywc.js +0 -146
|
@@ -0,0 +1,2221 @@
|
|
|
1
|
+
import { ref as N, h as $e, defineComponent as J, resolveComponent as B, openBlock as k, createElementBlock as D, createElementVNode as i, normalizeClass as te, createTextVNode as ee, toDisplayString as A, unref as x, createCommentVNode as W, createVNode as R, withCtx as z, Fragment as H, renderList as q, computed as U, watch as Fe, createSlots as je, createBlock as K, normalizeStyle as Te, withModifiers as pe, isRef as Ye, Teleport as Ke, 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-DGlWE5I8.js";
|
|
3
|
+
import { useI18n as oe, useCoreStore as Ce } from "@feedmepos/mf-common";
|
|
4
|
+
import { useDialog as _e, useDialogChild as Ze, useSnackbar as xe, FmButtonVariant as fe, components as et, useProxiedModel as tt, useBreakpoints as ot } from "@feedmepos/ui-library";
|
|
5
|
+
import { defineStore as Be, storeToRefs as Ne } from "pinia";
|
|
6
|
+
import { F as Z } from "./form-mode.enum-BKiNVH6A.js";
|
|
7
|
+
import { a as we } from "./closing-template-C56_2aLc.js";
|
|
8
|
+
import { u as Ie, c as Ue, a as De, l as nt } from "./app-D-l9FM2n.js";
|
|
9
|
+
import { t as be, a as Se, d as Ae, s as Le, r as st } from "./xlsx.util-D_XTOHMv.js";
|
|
10
|
+
import { F as at } from "./FmDroppableField-J0xUsOTV.js";
|
|
11
|
+
import { f as Ve, a as ge } from "./date2-CRMgo5NH.js";
|
|
12
|
+
import { D as ye, R as Y } from "./row-action.enum-DQ9bJ_uv.js";
|
|
13
|
+
import { c as lt } from "./component-kqxARxvM.js";
|
|
14
|
+
import { f as rt } from "./format-time-from-id-BuMdYlM9.js";
|
|
15
|
+
import { _ as it } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bw3UN_Zn.js";
|
|
16
|
+
import { u as ct } from "./netsuite-Dyw1JtQL.js";
|
|
17
|
+
import { u as ut } from "./duplicate-template-BrEOP-1V.js";
|
|
18
|
+
import { _ as mt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-QvgQwP6t.js";
|
|
19
|
+
import { R as dt, A as pt } from "./rules-BsVkaxL5.js";
|
|
20
|
+
import { u as ze } from "./use-ingredient-select-dialog-BASkk3-u.js";
|
|
21
|
+
import { d as ft } from "./defineDeepModel-DDX70CM6.js";
|
|
22
|
+
import { u as yt } from "./use-template-enabled-locations-gwYjb6_p.js";
|
|
23
|
+
import { _ as vt } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BRrHPAJj.js";
|
|
24
|
+
import { _ as gt, F as ve } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
|
|
25
|
+
import { _ as bt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
26
|
+
const ke = Be(
|
|
27
|
+
"closingTemplateTable",
|
|
28
|
+
function() {
|
|
29
|
+
const { t: o } = oe(), t = _e(), v = N({}), r = he(), f = N({}), g = N(new Array()), d = N(!1), a = Ie(), s = we();
|
|
30
|
+
function w(l) {
|
|
31
|
+
const n = {
|
|
32
|
+
title: l.name,
|
|
33
|
+
doc: l,
|
|
34
|
+
controller: {
|
|
35
|
+
publishAll: async (y) => {
|
|
36
|
+
const e = y || l.locations, _ = await s.publishSingleDoc(
|
|
37
|
+
l._id,
|
|
38
|
+
e == null ? void 0 : e.map((C) => C.dbName)
|
|
39
|
+
);
|
|
40
|
+
return v.value = _.publishedRevByLocation || {}, v.value;
|
|
41
|
+
},
|
|
42
|
+
publishAtLocation: async (y) => {
|
|
43
|
+
const e = await s.publishSingleDoc(l._id, [y.dbName]);
|
|
44
|
+
return v.value = e.publishedRevByLocation || {}, v.value;
|
|
45
|
+
},
|
|
46
|
+
unpublishAll: async (y) => {
|
|
47
|
+
const e = y || l.locations, _ = await s.unpublishSingleDoc(
|
|
48
|
+
l._id,
|
|
49
|
+
e == null ? void 0 : e.map((C) => C.dbName)
|
|
50
|
+
);
|
|
51
|
+
return v.value = _.publishedRevByLocation || {}, v.value;
|
|
52
|
+
},
|
|
53
|
+
unpublishAtLocation: async (y) => {
|
|
54
|
+
const e = await s.unpublishSingleDoc(l._id, [
|
|
55
|
+
y.dbName
|
|
56
|
+
]);
|
|
57
|
+
return v.value = e.publishedRevByLocation || {}, v.value;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
initialPublishedRev: v.value,
|
|
61
|
+
locations: a.locations,
|
|
62
|
+
enabledLocations: l.locations
|
|
63
|
+
};
|
|
64
|
+
t.open({
|
|
65
|
+
title: "Publish template",
|
|
66
|
+
contentComponent: it,
|
|
67
|
+
contentComponentProps: n,
|
|
68
|
+
closeButton: !0,
|
|
69
|
+
minWidth: 700,
|
|
70
|
+
maxHeight: "80vh",
|
|
71
|
+
contentScrollable: !1,
|
|
72
|
+
primaryActions: {
|
|
73
|
+
text: o("common.close"),
|
|
74
|
+
close: !0,
|
|
75
|
+
variant: "tertiary"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function p() {
|
|
80
|
+
if (g.value = [], !!a._currentLocation) {
|
|
81
|
+
d.value = !0;
|
|
82
|
+
try {
|
|
83
|
+
const [l, n, y] = await Promise.all([
|
|
84
|
+
s.readTemplates(),
|
|
85
|
+
s.getRecentPublishingJob(),
|
|
86
|
+
s.getRecentPublishInfo()
|
|
87
|
+
]).delayed(1e3);
|
|
88
|
+
g.value = l, f.value = n, v.value = y.publishedRevByLocation || {};
|
|
89
|
+
} catch (l) {
|
|
90
|
+
console.log("Something went wrong when fetching templates:", l);
|
|
91
|
+
} finally {
|
|
92
|
+
d.value = !1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function I(l) {
|
|
97
|
+
if (!g.value.find((n) => n._id) && a._currentLocation) {
|
|
98
|
+
d.value = !0;
|
|
99
|
+
try {
|
|
100
|
+
const [n] = await Promise.all([
|
|
101
|
+
s.getTemplate(l),
|
|
102
|
+
new Promise((y) => setTimeout(y, 1e3))
|
|
103
|
+
]);
|
|
104
|
+
g.value = [n];
|
|
105
|
+
} catch (n) {
|
|
106
|
+
console.log("Something went wrong when fetching templates:", n);
|
|
107
|
+
} finally {
|
|
108
|
+
d.value = !1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function F(l, n) {
|
|
113
|
+
switch (n = Ue(n), l) {
|
|
114
|
+
case Y.Details:
|
|
115
|
+
return r.viewTemplate(n);
|
|
116
|
+
case Y.Edit:
|
|
117
|
+
return r.updateTemplate(n);
|
|
118
|
+
case Y.Delete:
|
|
119
|
+
return r.deleteTemplate(n, d, p);
|
|
120
|
+
case Y.Publish:
|
|
121
|
+
return w(n);
|
|
122
|
+
case Y.Duplicate:
|
|
123
|
+
return r.duplicateTemplate(n, d, p);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
columnDefs: [
|
|
128
|
+
{
|
|
129
|
+
id: "_id",
|
|
130
|
+
accessorKey: "_id",
|
|
131
|
+
header: () => o("inventory.closing.table.createdAt"),
|
|
132
|
+
cell(l) {
|
|
133
|
+
return rt(`${l.getValue()}`);
|
|
134
|
+
},
|
|
135
|
+
enableSorting: !0
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "name",
|
|
139
|
+
accessorKey: "name",
|
|
140
|
+
header: () => o("inventory.closing.table.name"),
|
|
141
|
+
enableSorting: !0,
|
|
142
|
+
size: 200
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "noOfItems",
|
|
146
|
+
accessorKey: "items.length",
|
|
147
|
+
header: () => o("inventory.closing.table.noOfItems"),
|
|
148
|
+
enableSorting: !1,
|
|
149
|
+
meta: {
|
|
150
|
+
width: "10rem",
|
|
151
|
+
textAlign: "right"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "enabledLocations",
|
|
156
|
+
accessorKey: "locations.length",
|
|
157
|
+
header: () => o("inventory.closing.table.enabledOutlets"),
|
|
158
|
+
cell(l) {
|
|
159
|
+
var y;
|
|
160
|
+
const n = (y = l.row.original.locations) == null ? void 0 : y.length;
|
|
161
|
+
return n ? `${n}` : "All";
|
|
162
|
+
},
|
|
163
|
+
enableSorting: !1,
|
|
164
|
+
meta: {
|
|
165
|
+
width: "10rem",
|
|
166
|
+
textAlign: "right"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "ref",
|
|
171
|
+
accessorKey: "ref",
|
|
172
|
+
header: () => o("inventory.closing.table.reference"),
|
|
173
|
+
enableSorting: !1,
|
|
174
|
+
size: "auto"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: "status",
|
|
178
|
+
header: () => o("inventory.adjustment.template.table.status"),
|
|
179
|
+
enableSorting: !1,
|
|
180
|
+
cell(l) {
|
|
181
|
+
const n = l.row.original, e = (l.row.original.locations || a.locations).filter((S) => !!a.locationByDbName[S.dbName]), _ = e.filter((S) => !!(v.value[S.dbName] || []).find(
|
|
182
|
+
($) => $._id === n._id && ($.updatedAt ? $.updatedAt === n.updatedAt : $._rev === n._rev)
|
|
183
|
+
)).length, C = e.length > 0 && _ === e.length;
|
|
184
|
+
return $e(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
class: "flex items-center gap-8"
|
|
188
|
+
},
|
|
189
|
+
$e(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
class: [
|
|
193
|
+
"fm-status-badge",
|
|
194
|
+
C ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
C ? "Published" : "Unpublished"
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: "action",
|
|
204
|
+
cell(l) {
|
|
205
|
+
const n = l.row.original, y = [
|
|
206
|
+
ye[Y.Edit],
|
|
207
|
+
ye[Y.Duplicate],
|
|
208
|
+
ye[Y.Delete],
|
|
209
|
+
ye[Y.Publish]
|
|
210
|
+
];
|
|
211
|
+
return lt(y, (e) => F(e, n));
|
|
212
|
+
},
|
|
213
|
+
enableSorting: !1,
|
|
214
|
+
size: 40,
|
|
215
|
+
meta: {
|
|
216
|
+
cellClass: "",
|
|
217
|
+
headerClass: ""
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
recentPublish: f,
|
|
222
|
+
templates: g,
|
|
223
|
+
loading: d,
|
|
224
|
+
fetchTemplates: p,
|
|
225
|
+
loadTemplate: I
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
var Re = /* @__PURE__ */ ((c) => (c.Ingredients = "Ingredients", c))(Re || {});
|
|
230
|
+
function Ge(c) {
|
|
231
|
+
const o = c.sku, t = new Set(c.disabledMeasurements);
|
|
232
|
+
return [
|
|
233
|
+
{
|
|
234
|
+
code: o.code,
|
|
235
|
+
name: o.name,
|
|
236
|
+
unit: o.unit.abbrev,
|
|
237
|
+
enabled: !t.has(o.unit._id)
|
|
238
|
+
},
|
|
239
|
+
...o.unit.measurements.map((f) => ({
|
|
240
|
+
unit: f.abbrev,
|
|
241
|
+
enabled: !t.has(f.id)
|
|
242
|
+
}))
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
function He() {
|
|
246
|
+
return [
|
|
247
|
+
{
|
|
248
|
+
id: "code",
|
|
249
|
+
name: "Code"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
id: "name",
|
|
253
|
+
name: "Name"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "unit",
|
|
257
|
+
name: "Unit"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
id: "enabled",
|
|
261
|
+
name: "Enabled"
|
|
262
|
+
}
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
function ht(c) {
|
|
266
|
+
var d;
|
|
267
|
+
const t = Ce().currentBusiness.value, r = (d = c.map((a) => {
|
|
268
|
+
var m;
|
|
269
|
+
const s = a.items.flatMap(Ge), w = He(), p = [
|
|
270
|
+
["Template ID", a._id],
|
|
271
|
+
["Template name", a.name],
|
|
272
|
+
["Business name", t == null ? void 0 : t.name],
|
|
273
|
+
["Business ID", t == null ? void 0 : t._id],
|
|
274
|
+
["Menu version", t == null ? void 0 : t.menuVersion],
|
|
275
|
+
[
|
|
276
|
+
"Locations",
|
|
277
|
+
...(m = a.locations) != null && m.length ? a.locations.map((l) => `${l.name} (${l.dbName})`) : ["All"]
|
|
278
|
+
],
|
|
279
|
+
["Reference", a.ref ?? ""],
|
|
280
|
+
[],
|
|
281
|
+
w.map((l) => l.name),
|
|
282
|
+
...s.map((l) => w.map((n) => l[n.id]))
|
|
283
|
+
], I = w.map((l) => `system:${l.id}`), F = be(p, I);
|
|
284
|
+
return { name: a.name, sheet: F };
|
|
285
|
+
}).reduce(
|
|
286
|
+
(a, s) => {
|
|
287
|
+
var p;
|
|
288
|
+
const w = s.name.slice(0, 12);
|
|
289
|
+
return (p = a.sheetOccurence)[w] ?? (p[w] = 0), a.sheetOccurence[w] += 1, a.sheets[`${w} (${a.sheetOccurence[w]})`] = s.sheet, a;
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
sheets: {},
|
|
293
|
+
sheetOccurence: {}
|
|
294
|
+
}
|
|
295
|
+
)) == null ? void 0 : d.sheets, f = `${t == null ? void 0 : t.name} closing templates (${Ve(/* @__PURE__ */ new Date())}).xlsx`, g = Se(r);
|
|
296
|
+
return Ae(g, f), f;
|
|
297
|
+
}
|
|
298
|
+
function _t(c) {
|
|
299
|
+
Ce().currentBusiness.value;
|
|
300
|
+
const t = 3, v = (p) => {
|
|
301
|
+
const I = [], F = p.sku, m = new Set(p.disabledMeasurements || []);
|
|
302
|
+
m.has(F.unit._id) || I.push(F.unit.abbrev);
|
|
303
|
+
for (const l of F.unit.measurements) {
|
|
304
|
+
if (I.length >= t) break;
|
|
305
|
+
m.has(l.id) || I.push(l.abbrev);
|
|
306
|
+
}
|
|
307
|
+
return I;
|
|
308
|
+
}, r = ["#", "Code", "Name", "UOM"], f = [
|
|
309
|
+
["Template:", c.name],
|
|
310
|
+
["Reference:", c.ref ?? ""],
|
|
311
|
+
[],
|
|
312
|
+
r,
|
|
313
|
+
...c.items.map((p, I) => {
|
|
314
|
+
const F = v(p);
|
|
315
|
+
return [
|
|
316
|
+
I + 1,
|
|
317
|
+
// Index starting from 1
|
|
318
|
+
p.sku.code,
|
|
319
|
+
p.sku.name,
|
|
320
|
+
// Add UOM columns (up to MAX_UOM_COLUMNS)
|
|
321
|
+
...Array(t).fill("").map(
|
|
322
|
+
(m, l) => F[l] ? `_____ ${F[l]}` : ""
|
|
323
|
+
)
|
|
324
|
+
];
|
|
325
|
+
})
|
|
326
|
+
], g = be(f, r);
|
|
327
|
+
if (g["!ref"]) {
|
|
328
|
+
const p = {
|
|
329
|
+
top: { style: "thin", color: { rgb: "000000" } },
|
|
330
|
+
bottom: { style: "thin", color: { rgb: "000000" } },
|
|
331
|
+
left: { style: "thin", color: { rgb: "000000" } },
|
|
332
|
+
right: { style: "thin", color: { rgb: "000000" } }
|
|
333
|
+
}, I = 4, F = I + c.items.length, m = r.map((l, n) => String.fromCharCode(65 + n));
|
|
334
|
+
for (let l = I; l <= F; l++)
|
|
335
|
+
m.forEach((n) => {
|
|
336
|
+
const y = `${n}${l}`;
|
|
337
|
+
g[y] || (g[y] = { t: "s", v: "" }), g[y].s = {
|
|
338
|
+
border: p
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
g["!cols"] = [
|
|
343
|
+
{ wch: 5 },
|
|
344
|
+
// Index column - narrow
|
|
345
|
+
{ wch: 15 },
|
|
346
|
+
// Code column
|
|
347
|
+
{ wch: 30 },
|
|
348
|
+
// Name column - adjusted for more columns
|
|
349
|
+
...Array.from({ length: t }, () => ({ wch: 15 }))
|
|
350
|
+
// UOM columns
|
|
351
|
+
], g["!margins"] = {
|
|
352
|
+
left: 0.7,
|
|
353
|
+
right: 0.7,
|
|
354
|
+
top: 0.75,
|
|
355
|
+
bottom: 0.75,
|
|
356
|
+
header: 0.3,
|
|
357
|
+
footer: 0.3
|
|
358
|
+
};
|
|
359
|
+
const a = c.name.slice(0, 31), s = Se({ [a]: g }), w = `${c.name} - Closing Template (${Ve(/* @__PURE__ */ new Date())}).xlsx`;
|
|
360
|
+
return Ae(s, w), w;
|
|
361
|
+
}
|
|
362
|
+
function xt() {
|
|
363
|
+
const c = Ce(), o = De(), t = ct(), v = Ge({
|
|
364
|
+
sku: {
|
|
365
|
+
unit: {
|
|
366
|
+
_id: "",
|
|
367
|
+
name: "Unit",
|
|
368
|
+
abbrev: "Unit",
|
|
369
|
+
precision: 0,
|
|
370
|
+
measurements: []
|
|
371
|
+
},
|
|
372
|
+
code: "ING001",
|
|
373
|
+
_id: "",
|
|
374
|
+
name: "Sugar"
|
|
375
|
+
}
|
|
376
|
+
})[0], r = c.currentBusiness.value, f = He(), g = [
|
|
377
|
+
["Template ID (leave empty to create new)", ""],
|
|
378
|
+
["Template Name", "New template"],
|
|
379
|
+
["Business name", r == null ? void 0 : r.name],
|
|
380
|
+
["Business ID", r == null ? void 0 : r._id],
|
|
381
|
+
["Menu version", r == null ? void 0 : r.menuVersion],
|
|
382
|
+
[
|
|
383
|
+
"Location codes (leave empty to enable all)",
|
|
384
|
+
"Example outlet (restaurant_xxx)",
|
|
385
|
+
"Example outlet 2 (restaurant_xxx)"
|
|
386
|
+
],
|
|
387
|
+
["Reference:"],
|
|
388
|
+
[],
|
|
389
|
+
f.map((m) => m.name),
|
|
390
|
+
f.map((m) => v[m.id])
|
|
391
|
+
], d = f.map((m) => `system:${m.id}`), a = be(g, d), s = t.isEnabled ? t.state.setting.childItems ?? [] : [], w = s.reduce(
|
|
392
|
+
(m, l) => {
|
|
393
|
+
var C, S;
|
|
394
|
+
const n = (C = t.netSuiteItemIdToSkuId.get(l.parentNetSuiteId)) == null ? void 0 : C[0], y = (S = t.netSuiteMeasurementIdToMeasurementId.get(
|
|
395
|
+
l.unitOfMeasureId
|
|
396
|
+
)) == null ? void 0 : S[0];
|
|
397
|
+
if (!l.externalId)
|
|
398
|
+
return m;
|
|
399
|
+
if (!n)
|
|
400
|
+
return console.error(`Item ${l.externalId} cannot be mapped to parent FdoInventorySku.`, l), m;
|
|
401
|
+
const e = o.skuById[n], _ = e.unit.measurements.find((h) => h.id === y);
|
|
402
|
+
return _ ? (m[l.externalId] = {
|
|
403
|
+
sku: e,
|
|
404
|
+
measurement: _
|
|
405
|
+
}, m) : (console.error(
|
|
406
|
+
`Item ${l.externalId} found parent FdoInventorySku of ${e.code} ${e.name} but the measurement of netsuite id ${l.unitOfMeasureId} cannot be found.`,
|
|
407
|
+
l
|
|
408
|
+
), m);
|
|
409
|
+
},
|
|
410
|
+
{}
|
|
411
|
+
), p = be(
|
|
412
|
+
[
|
|
413
|
+
...o.skus.flatMap((m) => [
|
|
414
|
+
[m.code, m.name, m.unit.abbrev, !0],
|
|
415
|
+
...m.unit.measurements.map((n) => [
|
|
416
|
+
"",
|
|
417
|
+
"",
|
|
418
|
+
n.abbrev,
|
|
419
|
+
!n.abbrev.toLocaleLowerCase("en-us").includes("inactive")
|
|
420
|
+
])
|
|
421
|
+
]),
|
|
422
|
+
...Object.entries(w).map(([m, { sku: l, measurement: n }]) => [
|
|
423
|
+
l.code,
|
|
424
|
+
l.name,
|
|
425
|
+
n.abbrev,
|
|
426
|
+
!n.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
|
|
427
|
+
m
|
|
428
|
+
])
|
|
429
|
+
],
|
|
430
|
+
[
|
|
431
|
+
"Code",
|
|
432
|
+
"Name",
|
|
433
|
+
"Units",
|
|
434
|
+
"Enabled (true/false)",
|
|
435
|
+
...s.length ? ["Netsuite Parent"] : []
|
|
436
|
+
]
|
|
437
|
+
), I = Se({
|
|
438
|
+
Template: a,
|
|
439
|
+
Ingredients: p
|
|
440
|
+
}), F = `${r == null ? void 0 : r.name} transfer templates import.xlsx`;
|
|
441
|
+
return Ae(I, F), F;
|
|
442
|
+
}
|
|
443
|
+
function wt(c) {
|
|
444
|
+
if (!c.length || `${c[0]}`.toLocaleLowerCase() === "all")
|
|
445
|
+
return [];
|
|
446
|
+
const o = /(.*) \(((warehouse_|restaurant_).{24,})\)/, v = Ie().locationByDbName;
|
|
447
|
+
return c.map((r) => {
|
|
448
|
+
const f = new Array(), g = r.trim(), d = o.exec(g);
|
|
449
|
+
if (!d)
|
|
450
|
+
return f.push(`Enabled location value of ${g} cannot be read.`), {
|
|
451
|
+
errors: f
|
|
452
|
+
};
|
|
453
|
+
const a = d[1], s = d[2], w = v[s];
|
|
454
|
+
return w ? (a !== w.name && f.push(
|
|
455
|
+
`Location id ${s} has non-matching name. Found ${a} but expected ${w.name}`
|
|
456
|
+
), {
|
|
457
|
+
errors: f,
|
|
458
|
+
location: w
|
|
459
|
+
}) : (f.push(`Location (${a}) of id ${s} is not found.`), {
|
|
460
|
+
errors: f
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
function kt(c) {
|
|
465
|
+
const [
|
|
466
|
+
o,
|
|
467
|
+
t,
|
|
468
|
+
v,
|
|
469
|
+
r,
|
|
470
|
+
f,
|
|
471
|
+
g,
|
|
472
|
+
d,
|
|
473
|
+
a
|
|
474
|
+
] = Le(c);
|
|
475
|
+
return {
|
|
476
|
+
id: `${t[1] ?? ""}`.trim(),
|
|
477
|
+
name: `${v[1] ?? ""}`.trim(),
|
|
478
|
+
locations: d.slice(1).map((s) => `${s}`.trim()).filter((s) => s),
|
|
479
|
+
reference: `${a[1] ?? ""}`.trim()
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function $t(c) {
|
|
483
|
+
const [
|
|
484
|
+
o,
|
|
485
|
+
t,
|
|
486
|
+
v,
|
|
487
|
+
r,
|
|
488
|
+
f,
|
|
489
|
+
g,
|
|
490
|
+
d,
|
|
491
|
+
a,
|
|
492
|
+
s,
|
|
493
|
+
w,
|
|
494
|
+
...p
|
|
495
|
+
] = Le(c);
|
|
496
|
+
if (!o || !o.length || o.some((n) => n.length && !n.startsWith("system:")))
|
|
497
|
+
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
498
|
+
const I = o.map((n) => n.split(":")[1]), m = ["code", "name", "unit", "enabled"].filter((n) => !I.includes(n));
|
|
499
|
+
if (m.length)
|
|
500
|
+
throw new Error(
|
|
501
|
+
`Missing meta headers (${m.join()}). Excel file does not come from the template.`
|
|
502
|
+
);
|
|
503
|
+
return p.map((n, y) => {
|
|
504
|
+
const e = {};
|
|
505
|
+
for (const _ in I) {
|
|
506
|
+
const C = I[_];
|
|
507
|
+
Object.assign(e, { [C]: n[_] });
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
index: y,
|
|
511
|
+
data: e
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function Tt(c) {
|
|
516
|
+
return c.reduce(
|
|
517
|
+
(o, t) => {
|
|
518
|
+
var f;
|
|
519
|
+
const v = t.data, r = t.index;
|
|
520
|
+
return v.unit && (v.code ? o.result.push({ parent: t, children: [] }) : o.result.length ? (f = o.result.at(-1)) == null || f.children.push(t) : o.errors.push(`Cannot find parent for row ${r + 9}`)), o;
|
|
521
|
+
},
|
|
522
|
+
{ result: new Array(), errors: new Array() }
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
function Ft(c) {
|
|
526
|
+
const o = c.parent.data, t = new Array(), r = De().skuByCode[o.code ?? ""];
|
|
527
|
+
if (!r)
|
|
528
|
+
return t.push(`Cannot find ingredient of code ${o.code} ${o.name}`), { errors: t };
|
|
529
|
+
const f = {
|
|
530
|
+
sku: r
|
|
531
|
+
}, g = /* @__PURE__ */ new Set([r.unit._id, ...r.unit.measurements.map((a) => a.id)]), d = r.unit.measurements.find((a) => a.abbrev === o.unit);
|
|
532
|
+
o.unit !== r.unit.abbrev && !d ? t.push(
|
|
533
|
+
`Cannot find measurement unit of ${o.unit} for (${o.code}) ${o.name}.`
|
|
534
|
+
) : (o.enabled === !0 || `${o.enabled}`.toLocaleLowerCase() === "true") && g.delete(r.unit._id);
|
|
535
|
+
for (const a of c.children) {
|
|
536
|
+
const s = a.data, w = s.unit === r.unit.abbrev ? r.unit : void 0, p = r.unit.measurements.find((I) => I.abbrev === s.unit);
|
|
537
|
+
if (!p && !w) {
|
|
538
|
+
t.push(
|
|
539
|
+
`Cannot find measurement unit of ${s.unit} for (${o.code}) ${o.name}.`
|
|
540
|
+
);
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
(s.enabled === !0 || `${s.enabled}`.toLocaleLowerCase() === "true") && g.delete((p == null ? void 0 : p.id) ?? (w == null ? void 0 : w._id) ?? "");
|
|
544
|
+
}
|
|
545
|
+
return g.has(r.unit._id) && f.sku.unit.measurements.every((a) => g.has(a.id)) && t.push(`Ingredient ${r.code} - ${r.name} must have at least one unit enabled.`), f.disabledMeasurements = [...g], { errors: t, templateItem: f };
|
|
546
|
+
}
|
|
547
|
+
function Ct(c) {
|
|
548
|
+
const o = c.SheetNames.filter(
|
|
549
|
+
(f) => !Object.values(Re).map(String).includes(f)
|
|
550
|
+
), v = ke().templates, r = nt(v, "_id");
|
|
551
|
+
try {
|
|
552
|
+
return o.reduce(
|
|
553
|
+
(f, g) => {
|
|
554
|
+
const d = new Array(), a = c.Sheets[g], s = kt(a), w = wt(s.locations), p = w.filter((e) => e.location).map((e) => e.location);
|
|
555
|
+
d.push(...w.flatMap((e) => e.errors));
|
|
556
|
+
const I = $t(a).filter(
|
|
557
|
+
(e) => e.data.code || e.data.unit
|
|
558
|
+
), F = Tt(I);
|
|
559
|
+
d.push(...F.errors);
|
|
560
|
+
const m = F.result.map(
|
|
561
|
+
(e) => Ft(e)
|
|
562
|
+
);
|
|
563
|
+
d.push(...m.flatMap((e) => e.errors));
|
|
564
|
+
const l = m.filter((e) => e.templateItem).map((e) => e.templateItem);
|
|
565
|
+
if (s.id) {
|
|
566
|
+
const e = r[s.id];
|
|
567
|
+
if (!e) {
|
|
568
|
+
const C = {
|
|
569
|
+
_id: s.id,
|
|
570
|
+
_rev: "",
|
|
571
|
+
name: s.name || `(unnamed from sheet ${g || "<unnamed sheet>"})`,
|
|
572
|
+
items: []
|
|
573
|
+
};
|
|
574
|
+
return d.push(`Template ID ${s.id} is not found.`), f.importUpdateResult.push({
|
|
575
|
+
type: "update",
|
|
576
|
+
original: C,
|
|
577
|
+
template: C,
|
|
578
|
+
excelSheetName: g,
|
|
579
|
+
errors: d
|
|
580
|
+
}), f;
|
|
581
|
+
}
|
|
582
|
+
const _ = {
|
|
583
|
+
type: "update",
|
|
584
|
+
original: e,
|
|
585
|
+
template: {
|
|
586
|
+
...e,
|
|
587
|
+
name: s.name,
|
|
588
|
+
locations: p.length ? p : null,
|
|
589
|
+
ref: s.reference,
|
|
590
|
+
items: l
|
|
591
|
+
},
|
|
592
|
+
excelSheetName: g,
|
|
593
|
+
errors: d
|
|
594
|
+
};
|
|
595
|
+
return f.importUpdateResult.push(_), f;
|
|
596
|
+
}
|
|
597
|
+
const y = {
|
|
598
|
+
type: "create",
|
|
599
|
+
template: {
|
|
600
|
+
name: s.name,
|
|
601
|
+
locations: p.length ? p : null,
|
|
602
|
+
ref: s.reference,
|
|
603
|
+
items: l
|
|
604
|
+
},
|
|
605
|
+
excelSheetName: g,
|
|
606
|
+
errors: d
|
|
607
|
+
};
|
|
608
|
+
return f.importCreateResult.push(y), f;
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
invalidExcel: !1,
|
|
612
|
+
importCreateResult: new Array(),
|
|
613
|
+
importUpdateResult: new Array()
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
} catch (f) {
|
|
617
|
+
return {
|
|
618
|
+
invalidExcel: !0,
|
|
619
|
+
invalidExcelMessage: (f == null ? void 0 : f.message) ?? "Invalid excel",
|
|
620
|
+
importCreateResult: [],
|
|
621
|
+
importUpdateResult: []
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
const It = { class: "flex items-center gap-12 pl-8" }, Dt = { class: "flex flex-col" }, St = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, At = {
|
|
626
|
+
key: 0,
|
|
627
|
+
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
628
|
+
}, Rt = { key: 0 }, Ee = /* @__PURE__ */ J({
|
|
629
|
+
__name: "ClosingTemplateImportItem",
|
|
630
|
+
props: {
|
|
631
|
+
type: {},
|
|
632
|
+
name: {},
|
|
633
|
+
locations: {},
|
|
634
|
+
items: {},
|
|
635
|
+
errors: {}
|
|
636
|
+
},
|
|
637
|
+
setup(c) {
|
|
638
|
+
const { t: o } = oe();
|
|
639
|
+
return (t, v) => {
|
|
640
|
+
var g, d, a;
|
|
641
|
+
const r = B("FmIcon"), f = B("FmTooltip");
|
|
642
|
+
return k(), D("div", It, [
|
|
643
|
+
v[0] || (v[0] = i("div", null, "•", -1)),
|
|
644
|
+
i("div", Dt, [
|
|
645
|
+
i("div", St, [
|
|
646
|
+
i("div", {
|
|
647
|
+
class: te({
|
|
648
|
+
"text-fm-color-system-error-300": t.errors.length
|
|
649
|
+
})
|
|
650
|
+
}, [
|
|
651
|
+
ee(A(t.name) + " ", 1),
|
|
652
|
+
t.type === "create" ? (k(), D("span", At, "(" + A(x(o)("inventory.closing.template.import.new")) + ")", 1)) : W("", !0)
|
|
653
|
+
], 2),
|
|
654
|
+
t.errors.length ? (k(), D("div", Rt, [
|
|
655
|
+
R(f, { "z-index": 50 }, {
|
|
656
|
+
content: z(() => [
|
|
657
|
+
i("ol", null, [
|
|
658
|
+
(k(!0), D(H, null, q(t.errors, (s, w) => (k(), D("li", { key: w }, A(s), 1))), 128))
|
|
659
|
+
])
|
|
660
|
+
]),
|
|
661
|
+
default: z(() => [
|
|
662
|
+
R(r, {
|
|
663
|
+
name: "error",
|
|
664
|
+
size: "sm",
|
|
665
|
+
color: "system-error-300"
|
|
666
|
+
})
|
|
667
|
+
]),
|
|
668
|
+
_: 1
|
|
669
|
+
})
|
|
670
|
+
])) : W("", !0)
|
|
671
|
+
]),
|
|
672
|
+
i("div", {
|
|
673
|
+
class: te([
|
|
674
|
+
"fm-typo-en-body-sm-400",
|
|
675
|
+
{
|
|
676
|
+
"text-fm-color-system-error-200": t.errors.length,
|
|
677
|
+
"text-fm-color-typo-secondary": !t.errors.length
|
|
678
|
+
}
|
|
679
|
+
])
|
|
680
|
+
}, A((g = t.locations) != null && g.length ? x(o)("inventory.closing.template.import.nLocations", { count: (d = t.locations) == null ? void 0 : d.length }) : x(o)("inventory.closing.template.import.allLocations")) + ", " + A(x(o)("inventory.closing.template.import.nItems", { count: (a = t.items) == null ? void 0 : a.length })), 3)
|
|
681
|
+
])
|
|
682
|
+
]);
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
}), Pt = { class: "flex flex-col gap-24" }, Mt = { class: "fm-typo-en-body-md-400" }, Et = {
|
|
686
|
+
key: 0,
|
|
687
|
+
class: "flex items-center gap-8"
|
|
688
|
+
}, Bt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Nt = { class: "flex flex-col gap-8" }, Ut = { class: "line-clamp-2 text-ellipsis break-all" }, Lt = {
|
|
689
|
+
key: 2,
|
|
690
|
+
class: "shrink-0"
|
|
691
|
+
}, Vt = {
|
|
692
|
+
key: 0,
|
|
693
|
+
class: "flex flex-col"
|
|
694
|
+
}, zt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Gt = {
|
|
695
|
+
key: 0,
|
|
696
|
+
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
697
|
+
}, Ht = { class: "fm-typo-en-body-lg-600" }, Ot = /* @__PURE__ */ J({
|
|
698
|
+
__name: "ClosingTemplateImport",
|
|
699
|
+
setup(c) {
|
|
700
|
+
const o = N(null), t = Ze(), v = xe(), r = N(!1), f = N(!1), g = N(new Array()), d = N([]), a = N([]), s = U(
|
|
701
|
+
() => !!g.value.length || d.value.some((F) => F.errors.length) || a.value.some((F) => F.errors.length)
|
|
702
|
+
), w = U(
|
|
703
|
+
() => !!d.value.length || !!a.value.length
|
|
704
|
+
), { t: p } = oe();
|
|
705
|
+
async function I(F) {
|
|
706
|
+
g.value = [], d.value = [], a.value = [];
|
|
707
|
+
try {
|
|
708
|
+
r.value = !0;
|
|
709
|
+
const [m] = await Promise.all([
|
|
710
|
+
st(F),
|
|
711
|
+
// fake buffer
|
|
712
|
+
new Promise((e) => setTimeout(e, 1e3))
|
|
713
|
+
]);
|
|
714
|
+
if (!m.SheetNames.filter(
|
|
715
|
+
(e) => !Object.values(Re).map(String).includes(e)
|
|
716
|
+
).find((e) => e)) {
|
|
717
|
+
g.value.push(p("inventory.ingredient.import.fileError.noSheet"));
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const y = Ct(m);
|
|
721
|
+
if (y.invalidExcel) {
|
|
722
|
+
g.value.push(
|
|
723
|
+
y.invalidExcelMessage ?? p("inventory.ingredient.import.fileError.invalidExcel")
|
|
724
|
+
);
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (d.value = y.importCreateResult, a.value = y.importUpdateResult, !d.value.length && !a.value.length) {
|
|
728
|
+
g.value.push(p("inventory.ingredient.import.fileError.noData"));
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
t.emitData(y);
|
|
732
|
+
} catch (m) {
|
|
733
|
+
v.open({
|
|
734
|
+
title: p("inventory.ingredient.import.fileError.unableToRead"),
|
|
735
|
+
message: m == null ? void 0 : m.message,
|
|
736
|
+
type: "error"
|
|
737
|
+
}), console.error("Error in reading file", m);
|
|
738
|
+
} finally {
|
|
739
|
+
g.value.length && v.open({
|
|
740
|
+
title: p("inventory.ingredient.import.fileError.invalidExcel"),
|
|
741
|
+
type: "error"
|
|
742
|
+
}), r.value = !1;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return Fe(o, (F) => {
|
|
746
|
+
F && I(F);
|
|
747
|
+
}), (F, m) => {
|
|
748
|
+
const l = B("FmCircularProgress"), n = B("FmIcon"), y = B("FmButton");
|
|
749
|
+
return k(), D("div", Pt, [
|
|
750
|
+
i("div", Mt, A(x(p)("inventory.closing.template.import.message")), 1),
|
|
751
|
+
f.value ? (k(), D("div", Et, [
|
|
752
|
+
i("div", null, [
|
|
753
|
+
R(l, {
|
|
754
|
+
size: "md",
|
|
755
|
+
color: "neutral-gray-200"
|
|
756
|
+
})
|
|
757
|
+
]),
|
|
758
|
+
i("div", Bt, A(x(p)("inventory.formField.loading")), 1)
|
|
759
|
+
])) : (k(), D(H, { key: 1 }, [
|
|
760
|
+
R(at, {
|
|
761
|
+
class: te({
|
|
762
|
+
"w-full": !0,
|
|
763
|
+
"h-[200px]": !o.value
|
|
764
|
+
}),
|
|
765
|
+
accept: ".xlsx",
|
|
766
|
+
onFileUpload: m[0] || (m[0] = (e) => o.value = e),
|
|
767
|
+
label: x(p)("inventory.ingredient.import.uploadTemplate"),
|
|
768
|
+
"button-label": x(p)("inventory.ingredient.import.selectFile")
|
|
769
|
+
}, je({ _: 2 }, [
|
|
770
|
+
o.value ? {
|
|
771
|
+
name: "default",
|
|
772
|
+
fn: z(({ openFileDialog: e }) => [
|
|
773
|
+
i("div", Nt, [
|
|
774
|
+
i("div", {
|
|
775
|
+
class: te([
|
|
776
|
+
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
777
|
+
{
|
|
778
|
+
"border border-fm-color-neutral-gray-100": r.value,
|
|
779
|
+
"border border-fm-color-neutral-gray-200": !r.value && !s.value,
|
|
780
|
+
"border border-fm-color-system-error-200": s.value
|
|
781
|
+
}
|
|
782
|
+
])
|
|
783
|
+
}, [
|
|
784
|
+
r.value ? (k(), K(l, {
|
|
785
|
+
key: 0,
|
|
786
|
+
size: "md",
|
|
787
|
+
color: "neutral-gray-200"
|
|
788
|
+
})) : (k(), K(n, {
|
|
789
|
+
key: 1,
|
|
790
|
+
name: s.value ? "error" : "attach_file",
|
|
791
|
+
outline: "",
|
|
792
|
+
color: s.value ? "system-error-300" : void 0
|
|
793
|
+
}, null, 8, ["name", "color"])),
|
|
794
|
+
i("div", {
|
|
795
|
+
class: te([
|
|
796
|
+
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
797
|
+
{
|
|
798
|
+
"text-fm-color-typo-disabled": r.value,
|
|
799
|
+
"text-fm-color-typo-primary": !r.value
|
|
800
|
+
}
|
|
801
|
+
])
|
|
802
|
+
}, [
|
|
803
|
+
i("div", Ut, A(o.value.name), 1)
|
|
804
|
+
], 2),
|
|
805
|
+
r.value ? W("", !0) : (k(), D("div", Lt, [
|
|
806
|
+
R(y, {
|
|
807
|
+
label: x(p)("inventory.ingredient.import.replaceFile"),
|
|
808
|
+
variant: s.value ? "destructive" : "secondary",
|
|
809
|
+
"prepend-icon": s.value ? void 0 : "autorenew",
|
|
810
|
+
onClick: e
|
|
811
|
+
}, null, 8, ["label", "variant", "prepend-icon", "onClick"])
|
|
812
|
+
]))
|
|
813
|
+
], 2),
|
|
814
|
+
g.value.length ? (k(), D("div", Vt, [
|
|
815
|
+
(k(!0), D(H, null, q(g.value, (_, C) => (k(), D("div", {
|
|
816
|
+
key: C,
|
|
817
|
+
class: "flex gap-8 items-center"
|
|
818
|
+
}, [
|
|
819
|
+
R(n, {
|
|
820
|
+
name: "error",
|
|
821
|
+
size: "sm",
|
|
822
|
+
color: "system-error-300"
|
|
823
|
+
}),
|
|
824
|
+
i("div", zt, A(_), 1)
|
|
825
|
+
]))), 128))
|
|
826
|
+
])) : W("", !0)
|
|
827
|
+
])
|
|
828
|
+
]),
|
|
829
|
+
key: "0"
|
|
830
|
+
} : void 0
|
|
831
|
+
]), 1032, ["class", "label", "button-label"]),
|
|
832
|
+
w.value ? (k(), D("div", Gt, [
|
|
833
|
+
i("div", Ht, A(x(p)("inventory.ingredient.import.summary")), 1),
|
|
834
|
+
(k(!0), D(H, null, q(d.value, (e, _) => (k(), K(Ee, {
|
|
835
|
+
key: _,
|
|
836
|
+
name: e.template.name,
|
|
837
|
+
locations: e.template.locations,
|
|
838
|
+
items: e.template.items,
|
|
839
|
+
errors: e.errors,
|
|
840
|
+
type: "create"
|
|
841
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128)),
|
|
842
|
+
(k(!0), D(H, null, q(a.value, (e) => (k(), K(Ee, {
|
|
843
|
+
key: e.template._id,
|
|
844
|
+
name: e.template.name,
|
|
845
|
+
locations: e.template.locations,
|
|
846
|
+
items: e.template.items,
|
|
847
|
+
errors: e.errors,
|
|
848
|
+
type: "update"
|
|
849
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128))
|
|
850
|
+
])) : W("", !0)
|
|
851
|
+
], 64))
|
|
852
|
+
]);
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
}), he = Be("closingTemplateActions", () => {
|
|
856
|
+
const { t: c } = oe(), o = _e(), t = xe(), v = we(), r = ut(), f = ke(), { loading: g } = Ne(f), d = N({});
|
|
857
|
+
function a() {
|
|
858
|
+
d.value = {
|
|
859
|
+
mode: Z.CREATE,
|
|
860
|
+
show: !0,
|
|
861
|
+
"onUpdate:show"(e) {
|
|
862
|
+
d.value.show = e;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function s(e) {
|
|
867
|
+
d.value = {
|
|
868
|
+
mode: Z.UPDATE,
|
|
869
|
+
modelValue: e,
|
|
870
|
+
show: !0,
|
|
871
|
+
"onUpdate:show"(_) {
|
|
872
|
+
d.value.show = _;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function w(e, _, C) {
|
|
877
|
+
o.open({
|
|
878
|
+
title: `Confirm deleting template ${e.name}?`,
|
|
879
|
+
message: "Deleted template can no longer be retrieved",
|
|
880
|
+
primaryActions: {
|
|
881
|
+
text: "Delete",
|
|
882
|
+
variant: fe.Destructive,
|
|
883
|
+
close: !0
|
|
884
|
+
},
|
|
885
|
+
secondaryActions: {
|
|
886
|
+
text: "Cancel",
|
|
887
|
+
variant: fe.Plain,
|
|
888
|
+
close: !0
|
|
889
|
+
}
|
|
890
|
+
}).onPrimary(async () => {
|
|
891
|
+
t.open({
|
|
892
|
+
title: `Deleting ${e.name}`,
|
|
893
|
+
type: "info"
|
|
894
|
+
});
|
|
895
|
+
try {
|
|
896
|
+
_.value = !0;
|
|
897
|
+
const [S] = await Promise.allSettled([
|
|
898
|
+
v.deleteTemplate(e),
|
|
899
|
+
new Promise((h) => setTimeout(h, 1e3))
|
|
900
|
+
]);
|
|
901
|
+
if (S.status === "rejected") throw S.reason;
|
|
902
|
+
t.open({
|
|
903
|
+
title: `Deleted "${e.name}"`,
|
|
904
|
+
type: "success"
|
|
905
|
+
});
|
|
906
|
+
} catch (S) {
|
|
907
|
+
t.open({
|
|
908
|
+
title: `Unable to delete "${e.name}"`,
|
|
909
|
+
message: S.message,
|
|
910
|
+
type: "error"
|
|
911
|
+
});
|
|
912
|
+
} finally {
|
|
913
|
+
_.value = !1, C();
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
function p(e, _, C) {
|
|
918
|
+
let S;
|
|
919
|
+
o.open({
|
|
920
|
+
title: `Confirm duplicating template "${e.name}"?`,
|
|
921
|
+
message: "Duplicated template can be edited after creation",
|
|
922
|
+
primaryActions: {
|
|
923
|
+
text: "Duplicate",
|
|
924
|
+
variant: fe.Destructive,
|
|
925
|
+
close: !0
|
|
926
|
+
},
|
|
927
|
+
secondaryActions: {
|
|
928
|
+
text: "Cancel",
|
|
929
|
+
variant: fe.Plain,
|
|
930
|
+
close: !0
|
|
931
|
+
},
|
|
932
|
+
contentComponent: J({
|
|
933
|
+
props: ["modelValue"],
|
|
934
|
+
emits: ["update:modelValue"],
|
|
935
|
+
setup(h) {
|
|
936
|
+
return () => $e(et.FmTextField, {
|
|
937
|
+
modelValue: h.modelValue,
|
|
938
|
+
"onUpdate:modelValue": ($) => S = $,
|
|
939
|
+
label: "New Template Name",
|
|
940
|
+
size: "md",
|
|
941
|
+
variant: "primary"
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
})
|
|
945
|
+
}).onPrimary(async () => {
|
|
946
|
+
t.open({
|
|
947
|
+
title: `Duplicating "${e.name}"`,
|
|
948
|
+
type: "info"
|
|
949
|
+
});
|
|
950
|
+
try {
|
|
951
|
+
_.value = !0;
|
|
952
|
+
const [h] = await Promise.allSettled([
|
|
953
|
+
r.duplicateClosingTemplate(e._id, S),
|
|
954
|
+
new Promise(($) => setTimeout($, 1e3))
|
|
955
|
+
]);
|
|
956
|
+
if (h.status === "rejected") throw h.reason;
|
|
957
|
+
t.open({
|
|
958
|
+
title: `Duplicated "${e.name}"`,
|
|
959
|
+
type: "success"
|
|
960
|
+
});
|
|
961
|
+
} catch (h) {
|
|
962
|
+
t.open({
|
|
963
|
+
title: `Unable to duplicate "${e.name}"`,
|
|
964
|
+
message: `See error from server: ${h}`,
|
|
965
|
+
type: "error"
|
|
966
|
+
}), console.error("error on duplicating closing template", h);
|
|
967
|
+
} finally {
|
|
968
|
+
_.value = !1, C();
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
const I = N({});
|
|
973
|
+
function F(e) {
|
|
974
|
+
I.value = {
|
|
975
|
+
template: e,
|
|
976
|
+
show: !0,
|
|
977
|
+
"onUpdate:show"(_) {
|
|
978
|
+
I.value.show = _;
|
|
979
|
+
},
|
|
980
|
+
"onAction:edit"() {
|
|
981
|
+
I.value.show = !1, s(Ue(e));
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function m() {
|
|
986
|
+
if (!f.templates.length) {
|
|
987
|
+
t.open({
|
|
988
|
+
title: "No data to export",
|
|
989
|
+
type: "error"
|
|
990
|
+
});
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
const e = ht(f.templates);
|
|
994
|
+
t.open({
|
|
995
|
+
title: c("inventory.ingredient.export.success"),
|
|
996
|
+
message: c("inventory.ingredient.export.filename", [e]),
|
|
997
|
+
type: "success"
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
function l(e) {
|
|
1001
|
+
if (!e.items.length) {
|
|
1002
|
+
t.open({
|
|
1003
|
+
title: "No items in template to export",
|
|
1004
|
+
type: "error"
|
|
1005
|
+
});
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
const _ = _t(e);
|
|
1009
|
+
t.open({
|
|
1010
|
+
title: c("inventory.ingredient.export.success"),
|
|
1011
|
+
message: c("inventory.ingredient.export.filename", [_]),
|
|
1012
|
+
type: "success"
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
function n() {
|
|
1016
|
+
f.loading || o.open({
|
|
1017
|
+
title: c("inventory.ingredient.import.title"),
|
|
1018
|
+
contentComponent: Ot,
|
|
1019
|
+
overlay: !0,
|
|
1020
|
+
closeButton: !0,
|
|
1021
|
+
primaryActions: {
|
|
1022
|
+
text: c("common.import"),
|
|
1023
|
+
close: !1
|
|
1024
|
+
},
|
|
1025
|
+
secondaryActions: {
|
|
1026
|
+
text: c("common.close"),
|
|
1027
|
+
close: !0
|
|
1028
|
+
},
|
|
1029
|
+
tertiaryActions: {
|
|
1030
|
+
text: c("inventory.ingredient.import.actions.downloadTemplate"),
|
|
1031
|
+
close: !1,
|
|
1032
|
+
variant: "plain"
|
|
1033
|
+
}
|
|
1034
|
+
}).onPrimary((e) => {
|
|
1035
|
+
if (!e) {
|
|
1036
|
+
t.open({
|
|
1037
|
+
title: c("inventory.ingredient.import.error.noData"),
|
|
1038
|
+
type: "error"
|
|
1039
|
+
});
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (!e.importCreateResult.length && !e.importUpdateResult.length) {
|
|
1043
|
+
t.open({
|
|
1044
|
+
title: c("inventory.ingredient.import.error.invalidContent"),
|
|
1045
|
+
message: c("inventory.ingredient.import.error.noImportData"),
|
|
1046
|
+
type: "error"
|
|
1047
|
+
});
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
if (e.importCreateResult.some((_) => _.errors.length) || e.importUpdateResult.some((_) => _.errors.length)) {
|
|
1051
|
+
t.open({
|
|
1052
|
+
title: c("inventory.ingredient.import.error.invalidContent"),
|
|
1053
|
+
message: c("inventory.ingredient.import.error.hasErrors"),
|
|
1054
|
+
type: "error"
|
|
1055
|
+
});
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
o.close(), y(e);
|
|
1059
|
+
}).onTertiary(xt);
|
|
1060
|
+
}
|
|
1061
|
+
async function y(e) {
|
|
1062
|
+
g.value = !0;
|
|
1063
|
+
try {
|
|
1064
|
+
const _ = [
|
|
1065
|
+
...e.importCreateResult.map(
|
|
1066
|
+
($) => $.template
|
|
1067
|
+
),
|
|
1068
|
+
...e.importUpdateResult.map(
|
|
1069
|
+
($) => $.template
|
|
1070
|
+
)
|
|
1071
|
+
], C = 100;
|
|
1072
|
+
let S = 0;
|
|
1073
|
+
const h = () => {
|
|
1074
|
+
S += C, t.open({
|
|
1075
|
+
title: c("inventory.ingredient.import.progress", [
|
|
1076
|
+
Math.min(S, _.length),
|
|
1077
|
+
_.length
|
|
1078
|
+
])
|
|
1079
|
+
});
|
|
1080
|
+
};
|
|
1081
|
+
for (const $ of _.chunk(100))
|
|
1082
|
+
h(), await v.importTemplates($);
|
|
1083
|
+
t.open({
|
|
1084
|
+
title: c("inventory.ingredient.import.success"),
|
|
1085
|
+
type: "success"
|
|
1086
|
+
});
|
|
1087
|
+
} catch (_) {
|
|
1088
|
+
t.open({
|
|
1089
|
+
title: c("inventory.ingredient.import.error.failed"),
|
|
1090
|
+
message: c("inventory.ingredient.import.error.systemMessage", [_ == null ? void 0 : _.message]),
|
|
1091
|
+
type: "error"
|
|
1092
|
+
}), console.error("Error in importing skus", e, _);
|
|
1093
|
+
} finally {
|
|
1094
|
+
g.value = !1, f.fetchTemplates();
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return {
|
|
1098
|
+
createTemplate: a,
|
|
1099
|
+
viewTemplate: F,
|
|
1100
|
+
updateTemplate: s,
|
|
1101
|
+
deleteTemplate: w,
|
|
1102
|
+
duplicateTemplate: p,
|
|
1103
|
+
exportTemplates: m,
|
|
1104
|
+
exportSingleTemplate: l,
|
|
1105
|
+
importTemplates: n,
|
|
1106
|
+
templateDialogProps: d,
|
|
1107
|
+
templateDetailsProps: I
|
|
1108
|
+
};
|
|
1109
|
+
});
|
|
1110
|
+
function jt(c) {
|
|
1111
|
+
return c ? Number(c.amount) / Math.pow(10, Number(c.precision) || 0) : 0;
|
|
1112
|
+
}
|
|
1113
|
+
function Pe(c) {
|
|
1114
|
+
const o = new Set(c.disabledMeasurements ?? []), t = [
|
|
1115
|
+
{
|
|
1116
|
+
id: c.sku.unit._id,
|
|
1117
|
+
label: c.sku.unit.abbrev,
|
|
1118
|
+
isBase: !0,
|
|
1119
|
+
factor: 0,
|
|
1120
|
+
enabled: !o.has(c.sku.unit._id)
|
|
1121
|
+
}
|
|
1122
|
+
];
|
|
1123
|
+
for (const v of c.sku.unit.measurements)
|
|
1124
|
+
t.push({
|
|
1125
|
+
id: v.id,
|
|
1126
|
+
label: v.abbrev,
|
|
1127
|
+
isBase: !1,
|
|
1128
|
+
factor: jt(v.conversion),
|
|
1129
|
+
enabled: !o.has(v.id)
|
|
1130
|
+
});
|
|
1131
|
+
return t;
|
|
1132
|
+
}
|
|
1133
|
+
function Yt(c) {
|
|
1134
|
+
return Pe(c).filter((o) => o.enabled).length;
|
|
1135
|
+
}
|
|
1136
|
+
function Kt(c) {
|
|
1137
|
+
return Pe(c).filter((o) => o.enabled).map((o) => !o.isBase && o.factor ? `${o.label} ×${o.factor}` : o.label);
|
|
1138
|
+
}
|
|
1139
|
+
function Wt(c, o) {
|
|
1140
|
+
const t = new Set(c.disabledMeasurements ?? []);
|
|
1141
|
+
if (o.enabled) {
|
|
1142
|
+
if (Yt(c) <= 1) return null;
|
|
1143
|
+
t.add(o.id);
|
|
1144
|
+
} else
|
|
1145
|
+
t.delete(o.id);
|
|
1146
|
+
return { ...c, disabledMeasurements: [...t] };
|
|
1147
|
+
}
|
|
1148
|
+
const qt = { class: "flex items-center gap-12 py-12" }, Jt = {
|
|
1149
|
+
class: "flex items-center justify-center shrink-0 rounded-md border border-fm-color-neutral-gray-300 fm-typo-en-body-sm-600 text-fm-color-typo-secondary",
|
|
1150
|
+
style: { width: "28px", height: "28px" }
|
|
1151
|
+
}, Xt = {
|
|
1152
|
+
class: "flex flex-col gap-2 shrink-0",
|
|
1153
|
+
style: { width: "280px" }
|
|
1154
|
+
}, Qt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border border-fm-color-neutral-gray-200 rounded px-8 py-1 self-start" }, Zt = {
|
|
1155
|
+
class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary",
|
|
1156
|
+
style: { "word-break": "break-word", "line-height": "1.2" }
|
|
1157
|
+
}, eo = {
|
|
1158
|
+
class: "flex-1 flex flex-wrap items-center",
|
|
1159
|
+
style: { gap: "6px" }
|
|
1160
|
+
}, to = {
|
|
1161
|
+
key: 0,
|
|
1162
|
+
class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-200 rounded",
|
|
1163
|
+
style: { padding: "0 6px" }
|
|
1164
|
+
}, oo = {
|
|
1165
|
+
key: 1,
|
|
1166
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-primary",
|
|
1167
|
+
style: { opacity: "0.7" }
|
|
1168
|
+
}, no = {
|
|
1169
|
+
class: "shrink-0 flex items-center justify-end gap-4",
|
|
1170
|
+
style: { width: "200px" }
|
|
1171
|
+
}, so = /* @__PURE__ */ J({
|
|
1172
|
+
__name: "ClosingTemplateItem",
|
|
1173
|
+
props: {
|
|
1174
|
+
item: {},
|
|
1175
|
+
index: {},
|
|
1176
|
+
disabled: { type: Boolean }
|
|
1177
|
+
},
|
|
1178
|
+
emits: ["update", "delete"],
|
|
1179
|
+
setup(c, { emit: o }) {
|
|
1180
|
+
const t = c, v = o, r = U(() => Pe(t.item)), f = U(() => r.value.filter((s) => s.enabled)), g = U(() => f.value.length);
|
|
1181
|
+
function d(s) {
|
|
1182
|
+
if (t.disabled) return;
|
|
1183
|
+
const w = Wt(t.item, s);
|
|
1184
|
+
w && v("update", w);
|
|
1185
|
+
}
|
|
1186
|
+
function a(s) {
|
|
1187
|
+
return s.isBase ? "Base unit" : s.factor ? `1 ${s.label} = ${s.factor} ${t.item.sku.unit.abbrev}` : "";
|
|
1188
|
+
}
|
|
1189
|
+
return (s, w) => {
|
|
1190
|
+
const p = B("FmButton"), I = B("FmMenuItem"), F = B("FmMenu");
|
|
1191
|
+
return k(), D("div", qt, [
|
|
1192
|
+
i("span", Jt, A(s.index + 1), 1),
|
|
1193
|
+
i("div", Xt, [
|
|
1194
|
+
i("span", Qt, A(s.item.sku.code), 1),
|
|
1195
|
+
i("div", Zt, A(s.item.sku.name), 1)
|
|
1196
|
+
]),
|
|
1197
|
+
i("div", eo, [
|
|
1198
|
+
(k(!0), D(H, null, q(f.value, (m) => (k(), D("span", {
|
|
1199
|
+
key: m.id,
|
|
1200
|
+
class: te([
|
|
1201
|
+
"flex items-center rounded-full border",
|
|
1202
|
+
m.isBase ? "border-fm-color-neutral-gray-300 bg-fm-color-neutral-gray-100" : "border-fm-color-primary bg-fm-color-system-warning-100"
|
|
1203
|
+
]),
|
|
1204
|
+
style: { gap: "6px", padding: "4px 12px" }
|
|
1205
|
+
}, [
|
|
1206
|
+
i("span", {
|
|
1207
|
+
class: te(["fm-typo-en-body-sm-600 whitespace-nowrap", m.isBase ? "text-fm-color-typo-primary" : "text-fm-color-primary"])
|
|
1208
|
+
}, A(m.label), 3),
|
|
1209
|
+
m.isBase ? (k(), D("span", to, " BASE ")) : m.factor ? (k(), D("span", oo, " ×" + A(m.factor), 1)) : W("", !0)
|
|
1210
|
+
], 2))), 128))
|
|
1211
|
+
]),
|
|
1212
|
+
i("div", no, [
|
|
1213
|
+
R(F, { "close-on-click": !1 }, {
|
|
1214
|
+
"menu-button": z(() => [
|
|
1215
|
+
R(p, {
|
|
1216
|
+
variant: "secondary",
|
|
1217
|
+
"prepend-icon": "tune",
|
|
1218
|
+
size: "md",
|
|
1219
|
+
disabled: s.disabled,
|
|
1220
|
+
label: `Units ${g.value}/${r.value.length}`
|
|
1221
|
+
}, null, 8, ["disabled", "label"])
|
|
1222
|
+
]),
|
|
1223
|
+
default: z(() => [
|
|
1224
|
+
(k(!0), D(H, null, q(r.value, (m) => (k(), K(I, {
|
|
1225
|
+
key: m.id,
|
|
1226
|
+
"model-value": m.enabled,
|
|
1227
|
+
"has-checkbox": "",
|
|
1228
|
+
label: m.label,
|
|
1229
|
+
sublabel: a(m),
|
|
1230
|
+
disabled: s.disabled || m.enabled && g.value === 1,
|
|
1231
|
+
onClick: (l) => d(m)
|
|
1232
|
+
}, null, 8, ["model-value", "label", "sublabel", "disabled", "onClick"]))), 128))
|
|
1233
|
+
]),
|
|
1234
|
+
_: 1
|
|
1235
|
+
}),
|
|
1236
|
+
R(p, {
|
|
1237
|
+
disabled: s.disabled,
|
|
1238
|
+
icon: "delete",
|
|
1239
|
+
variant: "tertiary",
|
|
1240
|
+
size: "md",
|
|
1241
|
+
onClick: w[0] || (w[0] = (m) => v("delete"))
|
|
1242
|
+
}, null, 8, ["disabled"])
|
|
1243
|
+
])
|
|
1244
|
+
]);
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
}), ao = { class: "flex flex-col gap-12" }, lo = { class: "flex items-start justify-between gap-8" }, ro = { class: "flex flex-col" }, io = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, co = { class: "flex gap-8 shrink-0" }, uo = { class: "flex flex-wrap items-center gap-8" }, mo = ["onClick"], po = { class: "fm-typo-en-body-md-600 whitespace-nowrap" }, fo = ["disabled"], yo = { class: "rounded-lg border border-fm-color-neutral-gray-200 overflow-hidden" }, vo = { class: "flex items-center gap-12 px-16 py-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-50" }, go = {
|
|
1248
|
+
key: 0,
|
|
1249
|
+
class: "flex-1 flex items-baseline gap-8 min-w-0"
|
|
1250
|
+
}, bo = {
|
|
1251
|
+
key: 1,
|
|
1252
|
+
class: "flex-1 min-w-0"
|
|
1253
|
+
}, ho = {
|
|
1254
|
+
class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 rounded-full shrink-0",
|
|
1255
|
+
style: { padding: "4px 10px" }
|
|
1256
|
+
}, _o = {
|
|
1257
|
+
key: 0,
|
|
1258
|
+
class: "flex flex-col"
|
|
1259
|
+
}, xo = ["onDragstart", "onDrop"], wo = {
|
|
1260
|
+
key: 0,
|
|
1261
|
+
class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
|
|
1262
|
+
style: { padding: "24px" }
|
|
1263
|
+
}, ko = {
|
|
1264
|
+
key: 1,
|
|
1265
|
+
class: "flex flex-col"
|
|
1266
|
+
}, $o = {
|
|
1267
|
+
key: 0,
|
|
1268
|
+
class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
|
|
1269
|
+
style: { padding: "24px" }
|
|
1270
|
+
}, To = ["onDragstart", "onDrop"], Fo = {
|
|
1271
|
+
class: "flex items-center justify-center shrink-0 rounded-md border border-fm-color-neutral-gray-300 fm-typo-en-body-sm-600 text-fm-color-typo-secondary",
|
|
1272
|
+
style: { width: "28px", height: "28px" }
|
|
1273
|
+
}, Co = { class: "flex-1 min-w-0" }, Io = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Do = {
|
|
1274
|
+
class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary",
|
|
1275
|
+
style: { "line-height": "1.2" }
|
|
1276
|
+
}, So = {
|
|
1277
|
+
class: "flex flex-wrap gap-4 justify-end",
|
|
1278
|
+
style: { "max-width": "320px" }
|
|
1279
|
+
}, Ao = /* @__PURE__ */ J({
|
|
1280
|
+
__name: "ClosingTemplateGroupsEditor",
|
|
1281
|
+
props: {
|
|
1282
|
+
items: {},
|
|
1283
|
+
groups: {},
|
|
1284
|
+
updateItem: { type: Function },
|
|
1285
|
+
deleteItem: { type: Function },
|
|
1286
|
+
updateGroups: { type: Function },
|
|
1287
|
+
disabled: { type: Boolean }
|
|
1288
|
+
},
|
|
1289
|
+
emits: ["reorderDefault", "addItems"],
|
|
1290
|
+
setup(c, { emit: o }) {
|
|
1291
|
+
const { promptSelectIngredients: t } = ze(), v = _e(), r = c, f = o, g = ["#EAB308", "#22C55E", "#3B82F6", "#A855F7", "#F97316", "#EC4899", "#14B8A6"], d = N("default"), a = U(() => r.groups ?? []);
|
|
1292
|
+
function s(u) {
|
|
1293
|
+
r.updateGroups(u);
|
|
1294
|
+
}
|
|
1295
|
+
function w() {
|
|
1296
|
+
return `tmplGroup_${Date.now()}_${Math.floor(Math.random() * 1e4)}`;
|
|
1297
|
+
}
|
|
1298
|
+
const p = N(null), I = N(null);
|
|
1299
|
+
function F(u, b, T) {
|
|
1300
|
+
var P;
|
|
1301
|
+
I.value = u, p.value = b, (P = T.dataTransfer) == null || P.setData("text/plain", String(b)), T.dataTransfer && (T.dataTransfer.effectAllowed = "move");
|
|
1302
|
+
}
|
|
1303
|
+
function m(u, b, T) {
|
|
1304
|
+
const P = [...u], [M] = P.splice(b, 1);
|
|
1305
|
+
return P.splice(T, 0, M), P;
|
|
1306
|
+
}
|
|
1307
|
+
function l(u, b) {
|
|
1308
|
+
const T = p.value, P = I.value;
|
|
1309
|
+
if (p.value = null, I.value = null, !(T === null || P !== u || T === b))
|
|
1310
|
+
if (u === "default")
|
|
1311
|
+
f(
|
|
1312
|
+
"reorderDefault",
|
|
1313
|
+
m(
|
|
1314
|
+
r.items.map((M) => M.sku._id),
|
|
1315
|
+
T,
|
|
1316
|
+
b
|
|
1317
|
+
)
|
|
1318
|
+
);
|
|
1319
|
+
else {
|
|
1320
|
+
const M = V(u);
|
|
1321
|
+
M && Q(u, m(M.items.map((E) => E.skuId), T, b));
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
const n = U(
|
|
1325
|
+
() => Object.fromEntries(r.items.map((u) => [u.sku._id, u]))
|
|
1326
|
+
);
|
|
1327
|
+
Fe(
|
|
1328
|
+
() => r.items.map((u) => u.sku._id),
|
|
1329
|
+
(u) => {
|
|
1330
|
+
const b = new Set(u);
|
|
1331
|
+
let T = !1;
|
|
1332
|
+
const P = a.value.map((M) => {
|
|
1333
|
+
const E = M.items.filter((G) => b.has(G.skuId));
|
|
1334
|
+
return E.length !== M.items.length ? (T = !0, { ...M, items: E }) : M;
|
|
1335
|
+
});
|
|
1336
|
+
T && s(P);
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
const y = U(() => {
|
|
1340
|
+
const u = /* @__PURE__ */ new Map();
|
|
1341
|
+
for (const T of a.value)
|
|
1342
|
+
for (const P of T.items) u.set(P.skuId, (u.get(P.skuId) ?? 0) + 1);
|
|
1343
|
+
let b = 0;
|
|
1344
|
+
return u.forEach((T) => {
|
|
1345
|
+
T > 1 && b++;
|
|
1346
|
+
}), b;
|
|
1347
|
+
}), e = U(() => {
|
|
1348
|
+
const u = a.value.length;
|
|
1349
|
+
return `${r.items.length} items in Default · ${y.value} shared across named groups · ${u + 1} total groups (${u} named + Default)`;
|
|
1350
|
+
}), _ = U(() => [
|
|
1351
|
+
{ id: "default", isDefault: !0, name: "Default", color: null, itemCount: r.items.length },
|
|
1352
|
+
...a.value.map((u, b) => ({
|
|
1353
|
+
id: u.id,
|
|
1354
|
+
isDefault: !1,
|
|
1355
|
+
name: u.name,
|
|
1356
|
+
color: g[b % g.length],
|
|
1357
|
+
itemCount: u.items.length
|
|
1358
|
+
}))
|
|
1359
|
+
]), C = U(
|
|
1360
|
+
() => _.value.find((u) => u.id === d.value) ?? _.value[0]
|
|
1361
|
+
), S = U(() => C.value.isDefault), h = U(
|
|
1362
|
+
() => S.value ? [] : ce(d.value)
|
|
1363
|
+
);
|
|
1364
|
+
function $(u) {
|
|
1365
|
+
return d.value === u;
|
|
1366
|
+
}
|
|
1367
|
+
function L() {
|
|
1368
|
+
const u = w();
|
|
1369
|
+
s([...a.value, { id: u, name: `Group ${a.value.length + 1}`, items: [] }]), d.value = u;
|
|
1370
|
+
}
|
|
1371
|
+
function V(u) {
|
|
1372
|
+
return a.value.find((b) => b.id === u) ?? null;
|
|
1373
|
+
}
|
|
1374
|
+
function X(u) {
|
|
1375
|
+
s(a.value.filter((b) => b.id !== u)), d.value === u && (d.value = "default");
|
|
1376
|
+
}
|
|
1377
|
+
function ne(u, b) {
|
|
1378
|
+
v.open({
|
|
1379
|
+
title: `Delete group "${b || "Untitled"}"?`,
|
|
1380
|
+
closeButton: !1,
|
|
1381
|
+
message: "This removes the group and its item selection. The items stay in Default and other groups.",
|
|
1382
|
+
primaryActions: { text: "Delete", close: !0, variant: "destructive" },
|
|
1383
|
+
secondaryActions: { text: "Cancel", close: !0 }
|
|
1384
|
+
}).onPrimary(() => X(u));
|
|
1385
|
+
}
|
|
1386
|
+
function O(u, b) {
|
|
1387
|
+
s(a.value.map((T) => T.id === u ? { ...T, name: b } : T));
|
|
1388
|
+
}
|
|
1389
|
+
function Q(u, b) {
|
|
1390
|
+
s(
|
|
1391
|
+
a.value.map(
|
|
1392
|
+
(T) => T.id === u ? { ...T, items: b.map((P, M) => ({ skuId: P, position: M })) } : T
|
|
1393
|
+
)
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
async function le(u) {
|
|
1397
|
+
if (r.disabled) return;
|
|
1398
|
+
const b = V(u);
|
|
1399
|
+
if (!b) return;
|
|
1400
|
+
const T = await t(
|
|
1401
|
+
b.items.map((P) => P.skuId),
|
|
1402
|
+
(P) => P,
|
|
1403
|
+
r.items.map((P) => P.sku)
|
|
1404
|
+
);
|
|
1405
|
+
T && Q(u, T);
|
|
1406
|
+
}
|
|
1407
|
+
function re() {
|
|
1408
|
+
S.value ? f("addItems") : le(d.value);
|
|
1409
|
+
}
|
|
1410
|
+
function ie(u, b) {
|
|
1411
|
+
const T = V(u);
|
|
1412
|
+
if (!T) return;
|
|
1413
|
+
const P = T.items.some((M) => M.skuId === b) ? T.items.filter((M) => M.skuId !== b).map((M) => M.skuId) : [...T.items.map((M) => M.skuId), b];
|
|
1414
|
+
Q(u, P);
|
|
1415
|
+
}
|
|
1416
|
+
function ce(u) {
|
|
1417
|
+
const b = V(u);
|
|
1418
|
+
return b ? b.items.map((T) => n.value[T.skuId]).filter(Boolean) : [];
|
|
1419
|
+
}
|
|
1420
|
+
function se(u) {
|
|
1421
|
+
const b = $(u.id);
|
|
1422
|
+
if (u.isDefault)
|
|
1423
|
+
return b ? { background: "#1F2937", color: "#FFFFFF", border: "1px solid #1F2937" } : { background: "#FFFFFF", color: "#374151", border: "1px solid #E5E7EB" };
|
|
1424
|
+
const T = u.color || "#999999";
|
|
1425
|
+
return b ? { background: T, color: ae(T), border: `1px solid ${T}` } : { background: `${T}1A`, color: "#374151", border: `1px solid ${T}` };
|
|
1426
|
+
}
|
|
1427
|
+
function ae(u) {
|
|
1428
|
+
const b = u.replace("#", ""), T = parseInt(b.slice(0, 2), 16), P = parseInt(b.slice(2, 4), 16), M = parseInt(b.slice(4, 6), 16);
|
|
1429
|
+
return (0.299 * T + 0.587 * P + 0.114 * M) / 255 > 0.6 ? "#1F2937" : "#FFFFFF";
|
|
1430
|
+
}
|
|
1431
|
+
function ue(u) {
|
|
1432
|
+
return $(u.id) ? (u.isDefault ? "#FFFFFF" : ae(u.color || "#999999")) === "#FFFFFF" ? { background: "rgba(255,255,255,0.25)", color: "#FFFFFF" } : { background: "rgba(0,0,0,0.12)", color: "#1F2937" } : { background: "rgba(0,0,0,0.06)", color: "inherit" };
|
|
1433
|
+
}
|
|
1434
|
+
return (u, b) => {
|
|
1435
|
+
const T = B("FmButton"), P = B("FmIcon"), M = B("FmTextField");
|
|
1436
|
+
return k(), D("div", ao, [
|
|
1437
|
+
i("div", lo, [
|
|
1438
|
+
i("div", ro, [
|
|
1439
|
+
b[4] || (b[4] = i("div", { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, "Groups & items", -1)),
|
|
1440
|
+
i("div", io, A(e.value), 1)
|
|
1441
|
+
]),
|
|
1442
|
+
i("div", co, [
|
|
1443
|
+
R(T, {
|
|
1444
|
+
disabled: u.disabled,
|
|
1445
|
+
label: "New Group",
|
|
1446
|
+
"prepend-icon": "add",
|
|
1447
|
+
variant: "primary",
|
|
1448
|
+
size: "md",
|
|
1449
|
+
class: "rounded-lg",
|
|
1450
|
+
onClick: L
|
|
1451
|
+
}, null, 8, ["disabled"])
|
|
1452
|
+
])
|
|
1453
|
+
]),
|
|
1454
|
+
i("div", uo, [
|
|
1455
|
+
(k(!0), D(H, null, q(_.value, (E) => (k(), D("button", {
|
|
1456
|
+
key: E.id,
|
|
1457
|
+
type: "button",
|
|
1458
|
+
class: "flex items-center rounded-full",
|
|
1459
|
+
style: Te([{ gap: "8px", padding: "6px 14px" }, se(E)]),
|
|
1460
|
+
onClick: (G) => d.value = E.id
|
|
1461
|
+
}, [
|
|
1462
|
+
i("span", po, A(E.name), 1),
|
|
1463
|
+
i("span", {
|
|
1464
|
+
class: "fm-typo-en-body-sm-600 rounded-full",
|
|
1465
|
+
style: Te([{ padding: "0 8px" }, ue(E)])
|
|
1466
|
+
}, A(E.itemCount), 5)
|
|
1467
|
+
], 12, mo))), 128)),
|
|
1468
|
+
i("button", {
|
|
1469
|
+
type: "button",
|
|
1470
|
+
disabled: u.disabled,
|
|
1471
|
+
class: "flex items-center rounded-full border border-dashed border-fm-color-neutral-gray-400 text-fm-color-typo-secondary",
|
|
1472
|
+
style: { gap: "6px", padding: "6px 14px" },
|
|
1473
|
+
onClick: L
|
|
1474
|
+
}, [
|
|
1475
|
+
R(P, {
|
|
1476
|
+
name: "add",
|
|
1477
|
+
size: "sm"
|
|
1478
|
+
}),
|
|
1479
|
+
b[5] || (b[5] = i("span", { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, "New group", -1))
|
|
1480
|
+
], 8, fo)
|
|
1481
|
+
]),
|
|
1482
|
+
i("div", yo, [
|
|
1483
|
+
i("div", vo, [
|
|
1484
|
+
S.value ? (k(), D("div", go, b[6] || (b[6] = [
|
|
1485
|
+
i("span", { class: "fm-typo-en-body-lg-600 italic text-fm-color-typo-primary" }, "Default", -1),
|
|
1486
|
+
i("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary truncate" }, " master list · sets the item pool & units ", -1)
|
|
1487
|
+
]))) : (k(), D("div", bo, [
|
|
1488
|
+
R(M, {
|
|
1489
|
+
"model-value": C.value.name,
|
|
1490
|
+
disabled: u.disabled,
|
|
1491
|
+
placeholder: "Group name",
|
|
1492
|
+
"onUpdate:modelValue": b[0] || (b[0] = (E) => O(d.value, E))
|
|
1493
|
+
}, null, 8, ["model-value", "disabled"])
|
|
1494
|
+
])),
|
|
1495
|
+
i("span", ho, A(C.value.itemCount) + " items ", 1),
|
|
1496
|
+
S.value ? W("", !0) : (k(), K(T, {
|
|
1497
|
+
key: 2,
|
|
1498
|
+
disabled: u.disabled,
|
|
1499
|
+
label: "Delete group",
|
|
1500
|
+
"prepend-icon": "delete",
|
|
1501
|
+
variant: "secondary",
|
|
1502
|
+
size: "md",
|
|
1503
|
+
class: "rounded-lg shrink-0",
|
|
1504
|
+
onClick: b[1] || (b[1] = (E) => ne(d.value, C.value.name))
|
|
1505
|
+
}, null, 8, ["disabled"])),
|
|
1506
|
+
R(T, {
|
|
1507
|
+
disabled: u.disabled,
|
|
1508
|
+
label: "Add items",
|
|
1509
|
+
"prepend-icon": "add",
|
|
1510
|
+
variant: "primary",
|
|
1511
|
+
size: "md",
|
|
1512
|
+
class: "rounded-lg shrink-0",
|
|
1513
|
+
onClick: re
|
|
1514
|
+
}, null, 8, ["disabled"])
|
|
1515
|
+
]),
|
|
1516
|
+
S.value ? (k(), D("div", _o, [
|
|
1517
|
+
(k(!0), D(H, null, q(u.items, (E, G) => (k(), D("div", {
|
|
1518
|
+
key: E.sku._id,
|
|
1519
|
+
draggable: "true",
|
|
1520
|
+
onDragstart: (j) => F("default", G, j),
|
|
1521
|
+
onDragover: b[2] || (b[2] = pe(() => {
|
|
1522
|
+
}, ["prevent"])),
|
|
1523
|
+
onDrop: pe((j) => l("default", G), ["prevent"]),
|
|
1524
|
+
class: "flex items-center gap-4 px-16 border-b border-fm-color-neutral-gray-200 hover:bg-fm-color-neutral-gray-100 cursor-grab"
|
|
1525
|
+
}, [
|
|
1526
|
+
R(P, {
|
|
1527
|
+
name: "drag_indicator",
|
|
1528
|
+
size: "sm",
|
|
1529
|
+
color: "neutral-gray-400",
|
|
1530
|
+
class: "shrink-0"
|
|
1531
|
+
}),
|
|
1532
|
+
R(so, {
|
|
1533
|
+
class: "flex-1 min-w-0",
|
|
1534
|
+
item: E,
|
|
1535
|
+
index: G,
|
|
1536
|
+
disabled: u.disabled,
|
|
1537
|
+
onUpdate: u.updateItem,
|
|
1538
|
+
onDelete: (j) => u.deleteItem(E)
|
|
1539
|
+
}, null, 8, ["item", "index", "disabled", "onUpdate", "onDelete"])
|
|
1540
|
+
], 40, xo))), 128)),
|
|
1541
|
+
u.items.length ? W("", !0) : (k(), D("div", wo, b[7] || (b[7] = [
|
|
1542
|
+
ee(" No items yet — click "),
|
|
1543
|
+
i("span", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, "+ Add items", -1),
|
|
1544
|
+
ee(" to add from your catalog. ")
|
|
1545
|
+
])))
|
|
1546
|
+
])) : (k(), D("div", ko, [
|
|
1547
|
+
h.value.length ? W("", !0) : (k(), D("div", $o, b[8] || (b[8] = [
|
|
1548
|
+
ee(" No items yet — click "),
|
|
1549
|
+
i("span", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, "+ Add items", -1),
|
|
1550
|
+
ee(" on this group to assign items. ")
|
|
1551
|
+
]))),
|
|
1552
|
+
(k(!0), D(H, null, q(h.value, (E, G) => (k(), D("div", {
|
|
1553
|
+
key: E.sku._id,
|
|
1554
|
+
draggable: "true",
|
|
1555
|
+
onDragstart: (j) => F(d.value, G, j),
|
|
1556
|
+
onDragover: b[3] || (b[3] = pe(() => {
|
|
1557
|
+
}, ["prevent"])),
|
|
1558
|
+
onDrop: pe((j) => l(d.value, G), ["prevent"]),
|
|
1559
|
+
class: "flex items-center gap-12 px-16 py-12 border-b border-fm-color-neutral-gray-200 hover:bg-fm-color-neutral-gray-100 cursor-grab"
|
|
1560
|
+
}, [
|
|
1561
|
+
R(P, {
|
|
1562
|
+
name: "drag_indicator",
|
|
1563
|
+
size: "sm",
|
|
1564
|
+
color: "neutral-gray-400",
|
|
1565
|
+
class: "shrink-0"
|
|
1566
|
+
}),
|
|
1567
|
+
i("span", Fo, A(G + 1), 1),
|
|
1568
|
+
i("div", Co, [
|
|
1569
|
+
i("div", Io, A(E.sku.code), 1),
|
|
1570
|
+
i("div", Do, A(E.sku.name), 1)
|
|
1571
|
+
]),
|
|
1572
|
+
i("div", So, [
|
|
1573
|
+
(k(!0), D(H, null, q(x(Kt)(E), (j, me) => (k(), D("span", {
|
|
1574
|
+
key: me,
|
|
1575
|
+
class: "px-8 py-2 rounded-full border border-fm-color-neutral-gray-200 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
|
|
1576
|
+
}, A(j), 1))), 128))
|
|
1577
|
+
]),
|
|
1578
|
+
R(T, {
|
|
1579
|
+
disabled: u.disabled,
|
|
1580
|
+
icon: "delete",
|
|
1581
|
+
variant: "tertiary",
|
|
1582
|
+
size: "md",
|
|
1583
|
+
onClick: (j) => ie(d.value, E.sku._id)
|
|
1584
|
+
}, null, 8, ["disabled", "onClick"])
|
|
1585
|
+
], 40, To))), 128))
|
|
1586
|
+
]))
|
|
1587
|
+
])
|
|
1588
|
+
]);
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
}), Ro = { class: "flex flex-col gap-16" }, Po = { class: "flex flex-col gap-24" }, Mo = { class: "flex flex-col gap-16" }, Eo = { class: "flex items-center" }, Bo = { class: "flex-1 fm-typo-en-title-sm-600" }, No = { class: "flex flex-col gap-16" }, Uo = { class: "flex items-center" }, Lo = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Vo = /* @__PURE__ */ J({
|
|
1592
|
+
__name: "ClosingTemplateForm",
|
|
1593
|
+
props: {
|
|
1594
|
+
modelValue: {},
|
|
1595
|
+
disabled: { type: Boolean }
|
|
1596
|
+
},
|
|
1597
|
+
setup(c, { expose: o }) {
|
|
1598
|
+
const t = ft(), { t: v } = oe(), r = De(), {
|
|
1599
|
+
promptSelectLocations: f,
|
|
1600
|
+
columnDefs: g,
|
|
1601
|
+
rowData: d
|
|
1602
|
+
} = yt({
|
|
1603
|
+
getLocations() {
|
|
1604
|
+
return t.locations;
|
|
1605
|
+
},
|
|
1606
|
+
setLocations(n) {
|
|
1607
|
+
t.locations = n;
|
|
1608
|
+
}
|
|
1609
|
+
}), a = N(), s = U(() => t.items.map((n, y) => ({ item: n, originalIndex: y })).sort((n, y) => {
|
|
1610
|
+
const e = n.item.position ?? n.originalIndex, _ = y.item.position ?? y.originalIndex;
|
|
1611
|
+
return e - _;
|
|
1612
|
+
}).map(({ item: n }) => n));
|
|
1613
|
+
function w(n) {
|
|
1614
|
+
const y = new Map(t.items.map((_) => [_.sku._id, _])), e = [];
|
|
1615
|
+
n.forEach((_, C) => {
|
|
1616
|
+
const S = y.get(_);
|
|
1617
|
+
S && e.push({ ...S, position: C });
|
|
1618
|
+
}), t.items = e;
|
|
1619
|
+
}
|
|
1620
|
+
o({
|
|
1621
|
+
validateInputs: () => {
|
|
1622
|
+
var n, y;
|
|
1623
|
+
(y = (n = a.value) == null ? void 0 : n.validateInputs) == null || y.call(n);
|
|
1624
|
+
},
|
|
1625
|
+
resetInputsValidation: () => {
|
|
1626
|
+
var n, y;
|
|
1627
|
+
(y = (n = a.value) == null ? void 0 : n.resetInputsValidation) == null || y.call(n);
|
|
1628
|
+
},
|
|
1629
|
+
resetInputs: () => {
|
|
1630
|
+
var n, y;
|
|
1631
|
+
(y = (n = a.value) == null ? void 0 : n.resetInputs) == null || y.call(n);
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
function p(n) {
|
|
1635
|
+
t.items = t.items.map((y) => y.sku._id === n.sku._id ? n : y);
|
|
1636
|
+
}
|
|
1637
|
+
function I(n) {
|
|
1638
|
+
t.items = t.items.filter((y) => y.sku._id !== n.sku._id);
|
|
1639
|
+
}
|
|
1640
|
+
function F(n) {
|
|
1641
|
+
t.groups = n;
|
|
1642
|
+
}
|
|
1643
|
+
const { promptSelectIngredients: m } = ze();
|
|
1644
|
+
async function l() {
|
|
1645
|
+
const y = r.skus.map((C) => ({
|
|
1646
|
+
label: C.name,
|
|
1647
|
+
sublabel: C.code,
|
|
1648
|
+
value: C
|
|
1649
|
+
})).filter((C) => {
|
|
1650
|
+
var S;
|
|
1651
|
+
return (S = t.items) == null ? void 0 : S.find((h) => h.sku._id === C.value._id);
|
|
1652
|
+
}).map((C) => C.value), e = t.items ?? [], _ = await m(
|
|
1653
|
+
y.map((C) => C._id),
|
|
1654
|
+
(C) => {
|
|
1655
|
+
const S = r.skuById[C], h = e.find((L) => L.sku._id === S._id);
|
|
1656
|
+
return h || {
|
|
1657
|
+
sku: S
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
);
|
|
1661
|
+
_ && (_.sort((C, S) => C.sku.code.localeCompare(S.sku.code)), t.items = _);
|
|
1662
|
+
}
|
|
1663
|
+
return (n, y) => {
|
|
1664
|
+
const e = B("FmTextField"), _ = B("FmButton"), C = B("FmTable"), S = B("FmFormGroup"), h = B("FmForm");
|
|
1665
|
+
return k(), K(h, {
|
|
1666
|
+
ref_key: "formRef",
|
|
1667
|
+
ref: a,
|
|
1668
|
+
class: "flex flex-col gap-32",
|
|
1669
|
+
disabled: n.disabled
|
|
1670
|
+
}, {
|
|
1671
|
+
default: z(() => [
|
|
1672
|
+
i("div", Ro, [
|
|
1673
|
+
i("div", Po, [
|
|
1674
|
+
R(e, {
|
|
1675
|
+
label: x(v)("inventory.closing.form.name"),
|
|
1676
|
+
"label-mark": "required",
|
|
1677
|
+
modelValue: x(t).name,
|
|
1678
|
+
"onUpdate:modelValue": y[0] || (y[0] = ($) => x(t).name = $),
|
|
1679
|
+
rules: [x(dt)()]
|
|
1680
|
+
}, null, 8, ["label", "modelValue", "rules"]),
|
|
1681
|
+
R(e, {
|
|
1682
|
+
label: x(v)("inventory.closing.form.reference"),
|
|
1683
|
+
"label-mark": "optional",
|
|
1684
|
+
modelValue: x(t).ref,
|
|
1685
|
+
"onUpdate:modelValue": y[1] || (y[1] = ($) => x(t).ref = $)
|
|
1686
|
+
}, null, 8, ["label", "modelValue"])
|
|
1687
|
+
])
|
|
1688
|
+
]),
|
|
1689
|
+
i("div", Mo, [
|
|
1690
|
+
i("div", Eo, [
|
|
1691
|
+
i("div", Bo, A(x(v)("inventory.closing.form.locations")), 1),
|
|
1692
|
+
R(_, {
|
|
1693
|
+
disabled: n.disabled,
|
|
1694
|
+
label: x(v)("inventory.closing.form.selectLocation"),
|
|
1695
|
+
"prepend-icon": "add",
|
|
1696
|
+
variant: "plain",
|
|
1697
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1698
|
+
onClick: x(f)
|
|
1699
|
+
}, null, 8, ["disabled", "label", "onClick"])
|
|
1700
|
+
]),
|
|
1701
|
+
R(C, {
|
|
1702
|
+
"column-defs": x(g),
|
|
1703
|
+
"row-data": x(d),
|
|
1704
|
+
"shrink-at": 9999,
|
|
1705
|
+
onRowClick: x(f),
|
|
1706
|
+
"hide-footer": ""
|
|
1707
|
+
}, null, 8, ["column-defs", "row-data", "onRowClick"])
|
|
1708
|
+
]),
|
|
1709
|
+
i("div", No, [
|
|
1710
|
+
i("div", Uo, [
|
|
1711
|
+
i("div", Lo, A(x(v)("inventory.closing.form.items.title")), 1)
|
|
1712
|
+
]),
|
|
1713
|
+
R(Ao, {
|
|
1714
|
+
items: s.value,
|
|
1715
|
+
groups: x(t).groups,
|
|
1716
|
+
"update-item": p,
|
|
1717
|
+
"delete-item": I,
|
|
1718
|
+
"update-groups": F,
|
|
1719
|
+
disabled: n.disabled,
|
|
1720
|
+
onReorderDefault: w,
|
|
1721
|
+
onAddItems: l
|
|
1722
|
+
}, null, 8, ["items", "groups", "disabled"]),
|
|
1723
|
+
R(S, {
|
|
1724
|
+
"model-value": x(t).items.length,
|
|
1725
|
+
rules: [x(pt)(1)]
|
|
1726
|
+
}, null, 8, ["model-value", "rules"])
|
|
1727
|
+
])
|
|
1728
|
+
]),
|
|
1729
|
+
_: 1
|
|
1730
|
+
}, 8, ["disabled"]);
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
}), zo = { class: "flex items-center" }, Go = { class: "fm-typo-en-title-md-600" }, Ho = { class: "flex justify-between" }, Oo = { class: "fm-typo-en-body-lg-600" }, jo = { class: "flex flex-col gap-8" }, Yo = { class: "flex flex-col gap-4" }, Ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Wo = { class: "flex items-center gap-8" }, qo = { class: "fm-typo-en-body-lg-600" }, Jo = { class: "flex gap-4" }, Xo = /* @__PURE__ */ J({
|
|
1734
|
+
__name: "ClosingTemplateDialog",
|
|
1735
|
+
props: {
|
|
1736
|
+
mode: {},
|
|
1737
|
+
modelValue: {},
|
|
1738
|
+
show: { type: Boolean }
|
|
1739
|
+
},
|
|
1740
|
+
emits: ["update:show", "submitted"],
|
|
1741
|
+
setup(c, { expose: o, emit: t }) {
|
|
1742
|
+
var S;
|
|
1743
|
+
const v = c, r = t, f = we(), g = he(), d = xe(), { t: a } = oe(), s = tt(v, "show");
|
|
1744
|
+
function w() {
|
|
1745
|
+
return {
|
|
1746
|
+
_id: "",
|
|
1747
|
+
name: "",
|
|
1748
|
+
items: []
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
const p = N(v.modelValue ?? w()), I = N(((S = v.modelValue) == null ? void 0 : S._id) ?? `${Math.random()}`);
|
|
1752
|
+
Fe(
|
|
1753
|
+
() => v.show,
|
|
1754
|
+
(h) => {
|
|
1755
|
+
var $;
|
|
1756
|
+
h && (p.value = v.modelValue ?? w(), I.value = (($ = v.modelValue) == null ? void 0 : $._id) ?? `${Math.random()}`);
|
|
1757
|
+
}
|
|
1758
|
+
);
|
|
1759
|
+
const F = N(!1), m = U(() => {
|
|
1760
|
+
switch (v.mode) {
|
|
1761
|
+
case Z.READ:
|
|
1762
|
+
return "";
|
|
1763
|
+
case Z.CREATE:
|
|
1764
|
+
return a("inventory.closing.template.create.title");
|
|
1765
|
+
case Z.UPDATE:
|
|
1766
|
+
return a("inventory.closing.template.update.title");
|
|
1767
|
+
}
|
|
1768
|
+
return "";
|
|
1769
|
+
}), l = N();
|
|
1770
|
+
o({
|
|
1771
|
+
validateInputs: () => {
|
|
1772
|
+
var h, $;
|
|
1773
|
+
($ = (h = l.value) == null ? void 0 : h.validateInputs) == null || $.call(h);
|
|
1774
|
+
},
|
|
1775
|
+
resetInputsValidation: () => {
|
|
1776
|
+
var h, $;
|
|
1777
|
+
($ = (h = l.value) == null ? void 0 : h.resetInputsValidation) == null || $.call(h);
|
|
1778
|
+
},
|
|
1779
|
+
resetInputs: () => {
|
|
1780
|
+
var h, $;
|
|
1781
|
+
($ = (h = l.value) == null ? void 0 : h.resetInputs) == null || $.call(h);
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
async function n() {
|
|
1785
|
+
const h = p.value;
|
|
1786
|
+
if (h) {
|
|
1787
|
+
F.value = !0;
|
|
1788
|
+
try {
|
|
1789
|
+
await f.createTemplate(h), await new Promise(($) => setTimeout($, 1e3)), d.open({
|
|
1790
|
+
title: a("inventory.closing.template.create.success"),
|
|
1791
|
+
message: a("inventory.closing.template.create.successMessage"),
|
|
1792
|
+
type: "success"
|
|
1793
|
+
}), r("update:show", !1), r("submitted");
|
|
1794
|
+
} catch ($) {
|
|
1795
|
+
d.open({
|
|
1796
|
+
title: a("inventory.closing.template.create.error"),
|
|
1797
|
+
message: a("inventory.closing.template.create.errorMessage"),
|
|
1798
|
+
type: "error"
|
|
1799
|
+
}), console.error("Error in creating closing template", $);
|
|
1800
|
+
} finally {
|
|
1801
|
+
F.value = !1;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
async function y() {
|
|
1806
|
+
const h = p.value;
|
|
1807
|
+
if (h) {
|
|
1808
|
+
F.value = !0, delete h.updatedAt;
|
|
1809
|
+
try {
|
|
1810
|
+
await f.updateTemplate({
|
|
1811
|
+
...h,
|
|
1812
|
+
_rev: h._rev ?? ""
|
|
1813
|
+
}), await new Promise(($) => setTimeout($, 1e3)), d.open({
|
|
1814
|
+
title: a("inventory.closing.template.update.success"),
|
|
1815
|
+
message: a("inventory.closing.template.update.successMessage"),
|
|
1816
|
+
type: "success"
|
|
1817
|
+
}), r("update:show", !1), r("submitted");
|
|
1818
|
+
} catch ($) {
|
|
1819
|
+
d.open({
|
|
1820
|
+
title: a("inventory.closing.template.update.error"),
|
|
1821
|
+
message: a("inventory.closing.template.update.errorMessage"),
|
|
1822
|
+
type: "error"
|
|
1823
|
+
}), console.error("Error in updating closing template", $);
|
|
1824
|
+
} finally {
|
|
1825
|
+
F.value = !1;
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function e() {
|
|
1830
|
+
switch (v.mode) {
|
|
1831
|
+
case Z.CREATE:
|
|
1832
|
+
return n();
|
|
1833
|
+
case Z.UPDATE:
|
|
1834
|
+
return y();
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
function _() {
|
|
1838
|
+
var h, $;
|
|
1839
|
+
($ = (h = l.value) == null ? void 0 : h.validateInputs) == null || $.call(h);
|
|
1840
|
+
}
|
|
1841
|
+
function C() {
|
|
1842
|
+
p.value && g.exportSingleTemplate(p.value);
|
|
1843
|
+
}
|
|
1844
|
+
return (h, $) => {
|
|
1845
|
+
const L = B("FmMenuDivider"), V = B("FmCard"), X = B("FmButton"), ne = B("FmSideSheet");
|
|
1846
|
+
return k(), K(ne, {
|
|
1847
|
+
modelValue: x(s),
|
|
1848
|
+
"onUpdate:modelValue": $[2] || ($[2] = (O) => Ye(s) ? s.value = O : null),
|
|
1849
|
+
"dismiss-away": "",
|
|
1850
|
+
"close-button": "",
|
|
1851
|
+
"max-width": 9999
|
|
1852
|
+
}, {
|
|
1853
|
+
"side-sheet-header": z(() => [
|
|
1854
|
+
i("div", zo, [
|
|
1855
|
+
i("div", Go, A(m.value), 1)
|
|
1856
|
+
])
|
|
1857
|
+
]),
|
|
1858
|
+
default: z(() => [
|
|
1859
|
+
p.value.updatedAt ? (k(), K(V, {
|
|
1860
|
+
key: 0,
|
|
1861
|
+
variant: "outlined",
|
|
1862
|
+
class: "flex flex-col gap-8 px-12 py-16 mb-16"
|
|
1863
|
+
}, {
|
|
1864
|
+
default: z(() => {
|
|
1865
|
+
var O;
|
|
1866
|
+
return [
|
|
1867
|
+
i("div", Ho, [
|
|
1868
|
+
i("div", Oo, A(x(a)("inventory.transfer.template.details.templateSummary")), 1)
|
|
1869
|
+
]),
|
|
1870
|
+
R(L),
|
|
1871
|
+
i("div", jo, [
|
|
1872
|
+
i("div", Yo, [
|
|
1873
|
+
i("div", Ko, A(x(a)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
|
|
1874
|
+
i("div", Wo, [
|
|
1875
|
+
i("div", qo, [
|
|
1876
|
+
ee(A(x(ge)(p.value.updatedAt)) + " ", 1),
|
|
1877
|
+
(O = p.value.updatedBy) != null && O.name ? (k(), D(H, { key: 0 }, [
|
|
1878
|
+
ee(" (" + A(p.value.updatedBy.name) + ") ", 1)
|
|
1879
|
+
], 64)) : W("", !0)
|
|
1880
|
+
]),
|
|
1881
|
+
R(vt, {
|
|
1882
|
+
"closing-id": p.value._id
|
|
1883
|
+
}, null, 8, ["closing-id"])
|
|
1884
|
+
])
|
|
1885
|
+
])
|
|
1886
|
+
])
|
|
1887
|
+
];
|
|
1888
|
+
}),
|
|
1889
|
+
_: 1
|
|
1890
|
+
})) : W("", !0),
|
|
1891
|
+
(k(), K(Vo, {
|
|
1892
|
+
class: "w-full",
|
|
1893
|
+
ref_key: "formRef",
|
|
1894
|
+
ref: l,
|
|
1895
|
+
onValidationSuccess: e,
|
|
1896
|
+
"model-value": p.value,
|
|
1897
|
+
"onUpdate:modelValue": $[0] || ($[0] = (O) => p.value = O),
|
|
1898
|
+
disabled: F.value,
|
|
1899
|
+
key: I.value
|
|
1900
|
+
}, null, 8, ["model-value", "disabled"]))
|
|
1901
|
+
]),
|
|
1902
|
+
"side-sheet-footer": z(() => [
|
|
1903
|
+
i("div", Jo, [
|
|
1904
|
+
R(X, {
|
|
1905
|
+
loading: F.value,
|
|
1906
|
+
label: x(a)("common.save"),
|
|
1907
|
+
onClick: _
|
|
1908
|
+
}, null, 8, ["loading", "label"]),
|
|
1909
|
+
h.mode === x(Z).UPDATE ? (k(), K(X, {
|
|
1910
|
+
key: 0,
|
|
1911
|
+
disabled: F.value,
|
|
1912
|
+
variant: "secondary",
|
|
1913
|
+
label: x(a)("inventory.common.export"),
|
|
1914
|
+
"prepend-icon": "download",
|
|
1915
|
+
onClick: C
|
|
1916
|
+
}, null, 8, ["disabled", "label"])) : W("", !0),
|
|
1917
|
+
R(X, {
|
|
1918
|
+
disabled: F.value,
|
|
1919
|
+
variant: "tertiary",
|
|
1920
|
+
label: x(a)("common.close"),
|
|
1921
|
+
onClick: $[1] || ($[1] = (O) => r("update:show", !1))
|
|
1922
|
+
}, null, 8, ["disabled", "label"])
|
|
1923
|
+
])
|
|
1924
|
+
]),
|
|
1925
|
+
_: 1
|
|
1926
|
+
}, 8, ["modelValue"]);
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
}), Qo = {};
|
|
1930
|
+
function Zo(c, o) {
|
|
1931
|
+
return k(), D("div");
|
|
1932
|
+
}
|
|
1933
|
+
const en = /* @__PURE__ */ bt(Qo, [["render", Zo]]), tn = { class: "flex flex-col gap-40" }, on = { key: 0 }, nn = {
|
|
1934
|
+
key: 1,
|
|
1935
|
+
class: "flex gap-8 items-center"
|
|
1936
|
+
}, sn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, an = {
|
|
1937
|
+
key: 2,
|
|
1938
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
|
|
1939
|
+
}, ln = {
|
|
1940
|
+
key: 3,
|
|
1941
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
|
|
1942
|
+
}, rn = { class: "fm-typo-en-body-md-600" }, cn = { class: "fm-typo-en-body-md-600" }, un = { key: 4 }, mn = { class: "fm-typo-en-body-md-600" }, dn = { class: "fm-typo-en-body-md-600" }, pn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, fn = /* @__PURE__ */ J({
|
|
1943
|
+
__name: "ClosingTemplatePublish",
|
|
1944
|
+
emits: ["close"],
|
|
1945
|
+
setup(c, { emit: o }) {
|
|
1946
|
+
const t = N(!1), v = xe(), r = we(), f = ke(), { t: g } = oe(), d = o;
|
|
1947
|
+
async function a() {
|
|
1948
|
+
t.value = !0;
|
|
1949
|
+
try {
|
|
1950
|
+
await r.startNewPublish().delayed(1e3), v.open({
|
|
1951
|
+
title: "Success",
|
|
1952
|
+
message: "You may refresh after a while to review publish status",
|
|
1953
|
+
type: "success"
|
|
1954
|
+
}), p();
|
|
1955
|
+
} catch (I) {
|
|
1956
|
+
v.open({
|
|
1957
|
+
title: "Something went wrong",
|
|
1958
|
+
message: "Please try again",
|
|
1959
|
+
type: "error"
|
|
1960
|
+
}), console.error("error on creating publish task", I);
|
|
1961
|
+
} finally {
|
|
1962
|
+
t.value = !1;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
const s = U(() => f.recentPublish.recentJob), w = U(
|
|
1966
|
+
() => f.templates.length && (!s.value || s.value.outlets.length === s.value.completed.length)
|
|
1967
|
+
);
|
|
1968
|
+
function p() {
|
|
1969
|
+
d("close");
|
|
1970
|
+
}
|
|
1971
|
+
return (I, F) => {
|
|
1972
|
+
const m = B("FmCircularProgress"), l = B("i18n-t"), n = B("FmButton");
|
|
1973
|
+
return k(), D("div", tn, [
|
|
1974
|
+
x(f).templates.length ? t.value ? (k(), D("div", nn, [
|
|
1975
|
+
i("div", null, [
|
|
1976
|
+
R(m, {
|
|
1977
|
+
size: "md",
|
|
1978
|
+
color: "neutral-gray-300"
|
|
1979
|
+
})
|
|
1980
|
+
]),
|
|
1981
|
+
i("div", sn, [
|
|
1982
|
+
i("span", null, A(x(g)("inventory.closing.template.publish.publishing")), 1)
|
|
1983
|
+
])
|
|
1984
|
+
])) : s.value ? s.value.outlets.length === s.value.completed.length ? (k(), D("div", ln, [
|
|
1985
|
+
R(l, {
|
|
1986
|
+
keypath: "inventory.closing.template.publish.recentlyPublishedAt",
|
|
1987
|
+
tag: "p"
|
|
1988
|
+
}, {
|
|
1989
|
+
started: z(() => [
|
|
1990
|
+
i("span", rn, A(x(ge)(new Date(s.value.createdAt))), 1)
|
|
1991
|
+
]),
|
|
1992
|
+
finished: z(() => [
|
|
1993
|
+
i("span", cn, A(x(ge)(new Date(s.value.updatedAt))), 1)
|
|
1994
|
+
]),
|
|
1995
|
+
_: 1
|
|
1996
|
+
}),
|
|
1997
|
+
i("p", null, A(x(g)("inventory.closing.template.publish.message")), 1)
|
|
1998
|
+
])) : (k(), D("div", un, [
|
|
1999
|
+
R(l, {
|
|
2000
|
+
keypath: "inventory.closing.template.publish.stillPublishing",
|
|
2001
|
+
tag: "p"
|
|
2002
|
+
}, {
|
|
2003
|
+
started: z(() => [
|
|
2004
|
+
i("span", mn, A(x(ge)(new Date(s.value.createdAt))), 1)
|
|
2005
|
+
]),
|
|
2006
|
+
progress: z(() => [
|
|
2007
|
+
i("span", dn, " (" + A(s.value.completed.length) + "/" + A(s.value.outlets.length) + " completed) ", 1)
|
|
2008
|
+
]),
|
|
2009
|
+
_: 1
|
|
2010
|
+
}),
|
|
2011
|
+
ee(" Your recent publishing task is still pending (" + A(s.value.completed.length) + " / " + A(s.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
|
|
2012
|
+
])) : (k(), D("div", an, [
|
|
2013
|
+
i("p", null, A(x(g)("inventory.closing.template.publish.noRecentActivity")), 1),
|
|
2014
|
+
i("p", null, A(x(g)("inventory.closing.template.publish.message")), 1)
|
|
2015
|
+
])) : (k(), D("div", on, [
|
|
2016
|
+
i("p", null, A(x(g)("inventory.closing.template.publish.nothingToPublish")), 1)
|
|
2017
|
+
])),
|
|
2018
|
+
i("div", pn, [
|
|
2019
|
+
R(n, {
|
|
2020
|
+
disabled: !w.value,
|
|
2021
|
+
loading: t.value,
|
|
2022
|
+
label: "Publish to all outlets",
|
|
2023
|
+
onClick: a
|
|
2024
|
+
}, null, 8, ["disabled", "loading"]),
|
|
2025
|
+
R(n, {
|
|
2026
|
+
variant: "tertiary",
|
|
2027
|
+
label: "Close",
|
|
2028
|
+
onClick: p
|
|
2029
|
+
})
|
|
2030
|
+
])
|
|
2031
|
+
]);
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
}), yn = { class: "flex-1 flex flex-col gap-8" }, vn = { class: "flex flex-col" }, gn = { 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" }, hn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, _n = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Yn = /* @__PURE__ */ J({
|
|
2035
|
+
__name: "ClosingTemplateView",
|
|
2036
|
+
setup(c) {
|
|
2037
|
+
const { t: o } = oe(), { createTemplate: t, updateTemplate: v, exportTemplates: r, importTemplates: f } = he(), { templateDialogProps: g, templateDetailsProps: d } = Ne(he()), a = Ie(), s = _e(), w = ke(), p = Xe(), { breakpoints: I } = ot();
|
|
2038
|
+
a.watchLocation(w.fetchTemplates);
|
|
2039
|
+
const F = U(() => w.loading), m = N(""), l = U(() => I.value.xs || I.value.sm), n = U(() => l.value ? 10 : 20);
|
|
2040
|
+
function y(S) {
|
|
2041
|
+
switch (S) {
|
|
2042
|
+
case Y.Add:
|
|
2043
|
+
return t();
|
|
2044
|
+
case "publish":
|
|
2045
|
+
return e();
|
|
2046
|
+
case "import":
|
|
2047
|
+
return f();
|
|
2048
|
+
case "export":
|
|
2049
|
+
return r();
|
|
2050
|
+
case "refresh":
|
|
2051
|
+
return w.fetchTemplates();
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
function e() {
|
|
2055
|
+
s.open({
|
|
2056
|
+
title: "Publish closing templates",
|
|
2057
|
+
contentComponent: fn,
|
|
2058
|
+
contentComponentProps: {
|
|
2059
|
+
onClose() {
|
|
2060
|
+
s.close();
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
function _(S) {
|
|
2066
|
+
return S;
|
|
2067
|
+
}
|
|
2068
|
+
const C = U(() => l.value ? [
|
|
2069
|
+
{
|
|
2070
|
+
label: o("inventory.closing.template.create.title"),
|
|
2071
|
+
value: Y.Add,
|
|
2072
|
+
isPrimary: !0,
|
|
2073
|
+
prependIcon: "add"
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
label: o("inventory.common.refresh"),
|
|
2077
|
+
value: "refresh",
|
|
2078
|
+
isPrimary: !1
|
|
2079
|
+
},
|
|
2080
|
+
{
|
|
2081
|
+
label: o("inventory.common.publish"),
|
|
2082
|
+
value: "publish",
|
|
2083
|
+
isPrimary: !1
|
|
2084
|
+
},
|
|
2085
|
+
{
|
|
2086
|
+
label: o("inventory.common.import"),
|
|
2087
|
+
value: "import",
|
|
2088
|
+
isPrimary: !1
|
|
2089
|
+
},
|
|
2090
|
+
{
|
|
2091
|
+
label: o("inventory.common.export"),
|
|
2092
|
+
value: "export",
|
|
2093
|
+
isPrimary: !1
|
|
2094
|
+
}
|
|
2095
|
+
] : [
|
|
2096
|
+
{
|
|
2097
|
+
label: o("inventory.closing.template.create.title"),
|
|
2098
|
+
value: Y.Add,
|
|
2099
|
+
isPrimary: !0,
|
|
2100
|
+
prependIcon: "add"
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
label: o("inventory.common.publish"),
|
|
2104
|
+
value: "publish",
|
|
2105
|
+
isPrimary: !1
|
|
2106
|
+
},
|
|
2107
|
+
{
|
|
2108
|
+
label: o("inventory.common.import"),
|
|
2109
|
+
value: "import",
|
|
2110
|
+
isPrimary: !1
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
label: o("inventory.common.refresh"),
|
|
2114
|
+
value: "refresh",
|
|
2115
|
+
isPrimary: !1
|
|
2116
|
+
},
|
|
2117
|
+
{
|
|
2118
|
+
label: o("inventory.common.export"),
|
|
2119
|
+
value: "export",
|
|
2120
|
+
isPrimary: !1
|
|
2121
|
+
}
|
|
2122
|
+
]);
|
|
2123
|
+
return (S, h) => {
|
|
2124
|
+
const $ = B("FmTable");
|
|
2125
|
+
return k(), D(H, null, [
|
|
2126
|
+
R(Qe, {
|
|
2127
|
+
title: x(o)("inventory.closing.template.title"),
|
|
2128
|
+
actions: C.value,
|
|
2129
|
+
"onClick:action": y
|
|
2130
|
+
}, {
|
|
2131
|
+
default: z(() => [
|
|
2132
|
+
i("div", {
|
|
2133
|
+
class: te([
|
|
2134
|
+
"flex flex-col gap-8 max-h-full",
|
|
2135
|
+
{
|
|
2136
|
+
"p-0": l.value,
|
|
2137
|
+
"px-24 ": !l.value
|
|
2138
|
+
}
|
|
2139
|
+
])
|
|
2140
|
+
}, [
|
|
2141
|
+
R(mt, {
|
|
2142
|
+
searchable: "",
|
|
2143
|
+
search: m.value,
|
|
2144
|
+
"onUpdate:search": h[0] || (h[0] = (L) => m.value = L)
|
|
2145
|
+
}, null, 8, ["search"]),
|
|
2146
|
+
R($, {
|
|
2147
|
+
style: Te(x(p).tableHeight),
|
|
2148
|
+
"column-defs": x(w).columnDefs,
|
|
2149
|
+
"row-data": x(w).templates,
|
|
2150
|
+
"search-value": m.value,
|
|
2151
|
+
loading: F.value,
|
|
2152
|
+
onRowClick: h[1] || (h[1] = (L) => x(v)(L.original)),
|
|
2153
|
+
"page-size": n.value
|
|
2154
|
+
}, {
|
|
2155
|
+
"list-row": z((L) => [
|
|
2156
|
+
R(gt, {
|
|
2157
|
+
row: L,
|
|
2158
|
+
onRowClick: (V) => x(v)(V)
|
|
2159
|
+
}, {
|
|
2160
|
+
default: z((V) => {
|
|
2161
|
+
var X, ne, O, Q, le, re, ie, ce, se, ae, ue, u, b, T, P, M, E, G, j, me, de, Me;
|
|
2162
|
+
return [
|
|
2163
|
+
i("div", yn, [
|
|
2164
|
+
i("div", vn, [
|
|
2165
|
+
i("div", gn, [
|
|
2166
|
+
R(x(ve), {
|
|
2167
|
+
render: (O = (ne = (X = V._id) == null ? void 0 : X.column) == null ? void 0 : ne.columnDef) == null ? void 0 : O.cell,
|
|
2168
|
+
props: (le = (Q = V._id) == null ? void 0 : Q.getContext) == null ? void 0 : le.call(Q)
|
|
2169
|
+
}, null, 8, ["render", "props"])
|
|
2170
|
+
]),
|
|
2171
|
+
i("div", bn, [
|
|
2172
|
+
R(x(ve), {
|
|
2173
|
+
render: (ce = (ie = (re = V.name) == null ? void 0 : re.column) == null ? void 0 : ie.columnDef) == null ? void 0 : ce.cell,
|
|
2174
|
+
props: (ae = (se = V.name) == null ? void 0 : se.getContext) == null ? void 0 : ae.call(se)
|
|
2175
|
+
}, null, 8, ["render", "props"])
|
|
2176
|
+
]),
|
|
2177
|
+
i("div", null, A((ue = L.original.locations) != null && ue.length ? x(o)("inventory.closing.table.enabledForN", {
|
|
2178
|
+
count: ((u = L.original.locations) == null ? void 0 : u.length) ?? 0
|
|
2179
|
+
}) : x(o)("inventory.closing.table.enabledForAll")), 1),
|
|
2180
|
+
i("div", hn, A([
|
|
2181
|
+
...L.original.items.slice(0, 3).map((Oe) => Oe.sku.name),
|
|
2182
|
+
...L.original.items.length >= 3 ? [`and ${L.original.items.length - 3} more items`] : []
|
|
2183
|
+
].join(", ")), 1),
|
|
2184
|
+
i("div", _n, [
|
|
2185
|
+
R(x(ve), {
|
|
2186
|
+
render: (P = (T = (b = V.ref) == null ? void 0 : b.column) == null ? void 0 : T.columnDef) == null ? void 0 : P.cell,
|
|
2187
|
+
props: (E = (M = V.ref) == null ? void 0 : M.getContext) == null ? void 0 : E.call(M)
|
|
2188
|
+
}, null, 8, ["render", "props"])
|
|
2189
|
+
])
|
|
2190
|
+
]),
|
|
2191
|
+
i("div", null, [
|
|
2192
|
+
R(x(ve), {
|
|
2193
|
+
render: (me = (j = (G = V.status) == null ? void 0 : G.column) == null ? void 0 : j.columnDef) == null ? void 0 : me.cell,
|
|
2194
|
+
props: (Me = (de = V.status) == null ? void 0 : de.getContext) == null ? void 0 : Me.call(de)
|
|
2195
|
+
}, null, 8, ["render", "props"])
|
|
2196
|
+
])
|
|
2197
|
+
])
|
|
2198
|
+
];
|
|
2199
|
+
}),
|
|
2200
|
+
_: 2
|
|
2201
|
+
}, 1032, ["row", "onRowClick"])
|
|
2202
|
+
]),
|
|
2203
|
+
_: 1
|
|
2204
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
2205
|
+
], 2)
|
|
2206
|
+
]),
|
|
2207
|
+
_: 1
|
|
2208
|
+
}, 8, ["title", "actions"]),
|
|
2209
|
+
(k(), K(Ke, { to: "body" }, [
|
|
2210
|
+
R(en, We(qe(x(d))), null, 16),
|
|
2211
|
+
R(Xo, Je(x(g), {
|
|
2212
|
+
onSubmitted: h[2] || (h[2] = (L) => x(w).fetchTemplates())
|
|
2213
|
+
}), null, 16)
|
|
2214
|
+
]))
|
|
2215
|
+
], 64);
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
});
|
|
2219
|
+
export {
|
|
2220
|
+
Yn as default
|
|
2221
|
+
};
|