mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
ProductBarcode: display barcode type in frontend/Scanner.vue
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
role="alert"
|
||||
>
|
||||
<MdiAlertCircleOutline class="text-default" />
|
||||
<span class="text-sm font-medium">Product barcode detected: {{ detectedBarcode }}</span>
|
||||
<span class="text-sm font-medium">{{ detectedBarcodeType }} product barcode detected: {{ detectedBarcode }} </span>
|
||||
|
||||
<ButtonGroup>
|
||||
<Button :disabled="loading" type="submit" @click="handleButtonClick">Fetchdata and create</Button>
|
||||
@@ -66,6 +66,7 @@
|
||||
const codeReader = new BrowserMultiFormatReader();
|
||||
const errorMessage = ref<string | null>(null);
|
||||
const detectedBarcode = ref<string>("");
|
||||
const detectedBarcodeType = ref<string>("");
|
||||
const api = useUserApi();
|
||||
|
||||
const handleError = (error: unknown) => {
|
||||
@@ -193,13 +194,16 @@
|
||||
navigateTo(sanitizedPath);
|
||||
} catch (err) {
|
||||
// Check if it's a barcode for a new element
|
||||
switch (result.getBarcodeFormat()) {
|
||||
const bcfmt = result.getBarcodeFormat();
|
||||
|
||||
switch (bcfmt) {
|
||||
case BarcodeFormat.EAN_13:
|
||||
case BarcodeFormat.UPC_A:
|
||||
case BarcodeFormat.UPC_E:
|
||||
case BarcodeFormat.UPC_EAN_EXTENSION:
|
||||
console.info("Barcode detected");
|
||||
detectedBarcode.value = result.getText();
|
||||
detectedBarcodeType.value = BarcodeFormat[bcfmt].replaceAll("_","-");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user