{"version":3,"file":"fillContainers-fac1b3eb.js","sources":["../../src/components/pages/containers/dialogs/FillContainersDialog.vue","../../src/components/pages/containers/composables/fillContainers.ts"],"sourcesContent":["\n \n \n \n \n \n \n {{\n $t($m.keys.racking_non_assembly_warning.value)\n }}\n \n \n [item.details.name, item.details.code]\"\n :item-value=\"(item) => item.details.id\"\n :placeholder=\"$m.assembly_output_not_specified\"\n :read-only=\"readOnly\"\n :rules=\"[$ruleSet.required()]\"\n :disabled=\"isAssembly\"\n />\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{ scannedContainersText }}\n {{ scannedContainersSummary }}\n \n \n {{ errorMessage }}\n \n \n \n \n getClassForRow(row.item)\"\n />\n \n \n getClassForRow(row.item)\"\n />\n \n \n \n \n\n \n \n \n \n \n \n {{ scannedContainersText }}\n getClassForRow(row.item)\"\n />\n \n \n\n\n\n\n\n","import api from \"@/app/api\";\nimport type Guid from \"@/app/types/common/guid\";\nimport { containerService } from \"@/app/services/extensions/containerServiceExtended\";\nimport { productBatchService } from \"@/app/services/generated/productbatchService\";\nimport appStore from \"@/store/modules/appStore\";\nimport type { StockItem } from \"@/app/services/generated/stockitemService\";\nimport type { PackageType } from \"@/app/services/generated/packagetypeService\";\nimport { translate, keys } from \"@/plugins/i18n\";\nimport { showModalDialog } from \"@/components/platform/common/showModalDialog\";\nimport type { ContainerWithStatus } from \"@/app/services/generated/containerService\";\nimport FillContainersDialog from \"@/components/pages/containers/dialogs/FillContainersDialog.vue\";\nimport { EnumItemMainPurpose } from \"@/app/services/generated/enums/enumItemMainPurpose.generated\";\nimport type { Item } from \"@/app/services/generated/itemService\";\n\nexport interface FillContainersEvent {\n permLabelsToAdd: string[];\n permLabelsToRemove: string[];\n stockItemId: Guid;\n urn: string;\n}\n\nexport interface FillContainersDialogProps {\n filledContainers?: ContainerWithStatus[];\n readOnly?: boolean;\n stockItemId?: Guid;\n batchUrn?: string;\n isAssembly?: boolean;\n}\n\nexport const showFillContainersDialog = async (\n fillContainersProps: FillContainersDialogProps\n) => {\n return await showModalDialog<\n FillContainersEvent,\n typeof FillContainersDialog\n >(FillContainersDialog, {\n props: {\n ...fillContainersProps,\n },\n });\n};\n\nexport const isStockItemRackable = (\n item: StockItem,\n packageType?: PackageType\n) => {\n if (item.isMaterial) {\n return false;\n }\n return !!packageType?.isReturnable;\n};\n\nexport const isItemRackable = (\n item: Item,\n packageType?: Readonly\n) => {\n if (item.details.mainPurpose === EnumItemMainPurpose.material) {\n return false;\n }\n return !!packageType?.isReturnable;\n};\n\nexport const updateContainers = async (\n fillContainersEvent: FillContainersEvent,\n productBatchId?: Guid,\n assemblyId?: Guid\n) => {\n await emptyContainers(fillContainersEvent.permLabelsToRemove);\n await fillContainers(\n fillContainersEvent.permLabelsToAdd,\n fillContainersEvent.stockItemId,\n fillContainersEvent.urn,\n productBatchId,\n assemblyId\n );\n};\n\n/**\n *\n * @param permLabels List of perm labels to fill\n * @param stockItemId Product to fill the containers with\n * @param batchUrn Batch of the product to fill the containers with\n * @param productBatchId Optional product batch id (overrides batchUrn)\n * @param assemblyId Optional assembly id\n */\nexport const fillContainers = async (\n permLabels: string[],\n stockItemId: Guid,\n batchUrn: string,\n productBatchId?: Guid,\n assemblyId?: Guid\n) => {\n if (!permLabels.length) {\n // Nothing to update\n return;\n }\n\n if (!productBatchId) {\n const productBatch = await productBatchService.getOrCreateProductBatch(\n api.tenantId,\n stockItemId,\n batchUrn\n );\n productBatchId = productBatch.id;\n }\n\n await containerService.fillContainers(\n api.tenantId,\n permLabels,\n productBatchId,\n assemblyId ?? null,\n null\n );\n\n showContainerUpdateSnackbar(permLabels, \"fill\");\n};\n\nexport const emptyContainers = async (permLabels: readonly string[]) => {\n await containerService.emptyContainers(api.tenantId, permLabels);\n showContainerUpdateSnackbar(permLabels, \"empty\");\n};\n\nconst showContainerUpdateSnackbar = (\n permLabels: readonly string[],\n updateAction: \"fill\" | \"empty\"\n) => {\n if (!permLabels.length) {\n return;\n }\n const permLabelText =\n permLabels[0] +\n (permLabels.length > 1\n ? ` + ${permLabels.length - 1} ${translate(keys.more)}`\n : \"\");\n const actionKey =\n updateAction === \"fill\"\n ? keys.production_packaging_assembly_filled_container\n : keys.production_packaging_assembly_emptied_container;\n\n appStore.pushSnackbarConfig({\n text: translate(actionKey, {\n permLabel: permLabelText,\n }).toString(),\n timeout: 4000,\n });\n};\n"],"names":["ref"],"mappings":"w2BA6KA,MAAA,UAAA,gBAAA,CACA,KAAA,uBACA,WAAA,CACA,qBACA,SACA,QACA,eACA,MACA,EACA,MAAA,CACA,MAAA,CACA,KAAA,QACA,SAAA,EACA,EACA,iBAAA,CACA,KAAA,MACA,SAAA,GACA,QAAA,IAAA,CAAA,CACA,EACA,SAAA,CACA,KAAA,QACA,SAAA,GACA,QAAA,EACA,EACA,YAAA,CACA,KAAA,OACA,SAAA,EACA,EACA,SAAA,CACA,KAAA,OACA,SAAA,EACA,EACA,WAAA,CACA,KAAA,QACA,SAAA,GACA,QAAA,EACA,CACA,EACA,KAAA,KACA,CACA,uBACA,iBAAA,GAGA,MAAA,MAAA,QAAA,CACA,KAAA,CAAA,UAAA,aACA,CAAA,GAAA,EAAA,EAAA,QAAA,EACA,CAAA,OAAA,MAAA,EAAA,uBACA,MAAA,MAAA,OAAA,EACA,OAAA,EAEA,CACA,yBACA,sBACA,yBACA,aACA,gBACA,iBACA,kBAAA,iBACA,kBAAA,EAEA,CAAA,mBAAA,eACA,SACA,IACA,CAAA,EACA,gBAAA,MAAA,OAAA,GAAA,EAAA,kBAAA,EAAA,QACA,iBAAA,MAAA,OAAA,GACA,gBAAA,MAAA,MACA,GAAA,EAAA,YAAA,EAAA,UAAA,SACA,CACA,EAAA,OAEA,CAAA,EAGA,MAAA,SAAA,cAAA,CACA,aAAA,iBAAA,CACA,EAEA,iBAAAA,MAAA,EAAA,EACA,kBAAAA,MAAA,EAAA,EACA,WAAAA,MAAA,EAAA,EACA,iBAAA,MAAA,MAAA,kBAAA,EAEA,IAAA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