mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
ProductBarcode: add barcode processing in frontend
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user