ProductBarcode: add barcode processing in frontend

This commit is contained in:
Crumb Owl
2025-07-06 20:53:47 +02:00
parent fc88df0ff0
commit c3af4ac4ac
2 changed files with 49 additions and 1 deletions

View File

@@ -56,7 +56,7 @@
const { t } = useI18n();
const { activeDialog, closeDialog } = useDialog();
const { activeDialog, openDialog, closeDialog } = useDialog();
const open = computed(() => activeDialog.value && activeDialog.value.id === "scanner");
const sources = ref<MediaDeviceInfo[]>([]);
@@ -66,6 +66,7 @@
const codeReader = new BrowserMultiFormatReader();
const errorMessage = ref<string | null>(null);
const detectedBarcode = ref<string>("");
const api = useUserApi();
const handleError = (error: unknown) => {
console.error("Scanner error:", error);
@@ -85,6 +86,46 @@
const handleButtonClick = () => {
console.log("Button clicked!");
getQRCodeUrl();
// console.log("Value::: ", productEAN);
/* const route2 = useRoute();
const currentURL = window.location.href;
// Adjust route import as needed
console.log(route2(`/getproductfromean`)); */
};
/*
function openCreateModal(ItemCreate ic) {
this.$emit('open-modal', ic)
}
*/
async function getQRCodeUrl() {
/* const { isCanceled } = await confirm.open(
"Are you sure you want to ensure all assets have an ID? This can take a while and cannot be undone."
);
if (isCanceled) {
return;
} */
const result = await api.actions.getEAN(detectedBarcode.value);
// this.$store.commit('setScannedData', result);
if(result.error)
return
openDialog("create-item", result.data);
/* if (result.error) {
toast.error("Failed to ensure asset IDs.");
} */
// toast.success(`${result.data.completed} assets have been updated.`);
};
const startScanner = async () => {

View File

@@ -310,6 +310,13 @@
form.location = found;
}
}
if(active.params)
{
form.name = active.params.name;
form.description = active.params.description;
}
if (labelId.value) {
form.labels = labels.value.filter(l => l.id === labelId.value).map(l => l.id);
}