+
-
-
+
+
@@ -77,7 +73,8 @@
if (videoInputDevices.length > 0) {
isScan = true
document.getElementById("divImage").style.display = 'none'
- document.getElementById("divScan").style.display = 'block'
+ document.getElementById("divBtnScan").style.display = 'block'
+ document.getElementById("divRsltBarcode").style.display = 'block'
// temp code -----------------------------
//document.getElementById("divScan").style.display = 'none'
//isScan = false
@@ -102,11 +99,29 @@
sourceSelectPanel.style.display = 'block'
//--------------------------------------------
+ // barcode scan - barcode reader기가 인식된 경우에만 활성
document.getElementById('startButton').addEventListener('click', () => {
codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
if (result) {
console.log(result)
document.getElementById('result').textContent = result.text
+
+ // FIXME: API 호출 - GET /api/biz/nims/v1/getPrdMnfSeqInfoOfBarcode
+ ajax.get({
+ url: '
',
+ data:{barcodeStr: result.text},
+ success: res => {
+ if (res.success) {
+ //console.log(data[0].qrcode)
+ document.getElementById('result2').value = JSON.stringify(res.data, null, 4)
+ return true;
+ }else{
+ alert(`${res.code}: ${res.message}`)
+ }
+ }
+ });
+
+
}
if (err && !(err instanceof ZXing.NotFoundException)) {
console.error(err)
@@ -115,11 +130,32 @@
})
console.log(`Started continous decode from camera with id ${selectedDeviceId}`)
})
+
+ // document.getElementById('decodeButton').addEventListener('click', () => {
+ // const img = document.getElementById('img')
+ // codeReader.decodeFromImage(img).then((result) => {
+ // console.log(result)
+ // document.getElementById('result').textContent = result.text
+ // }).catch((err) => {
+ // console.error(err)
+ // document.getElementById('result').textContent = err
+ // })
+ // console.log(`Started decode for image from ${img.src}`)
+ // })
+
+ document.getElementById('resetButton').addEventListener('click', () => {
+ codeReader.reset()
+ document.getElementById('result').textContent = '';
+ document.getElementById('result2').value = ''
+ console.log('Reset.')
+ })
}
+ // barcode image - barcode reader기가 인식되지 않은 경우
if (!isScan) {
- document.getElementById("divScan").style.display = 'none'
document.getElementById("divImage").style.display = 'block'
+ document.getElementById("divBtnScan").style.display = 'none'
+ document.getElementById("divRsltBarcode").style.display = 'none'
const sec9 = document.querySelector('#divImage');
const uploadBox = sec9.querySelector('#img');
@@ -171,11 +207,9 @@
for (let i = 0; i < data.length; i++) {
formData.append('uploadFiles', data[i]);
}
-
- document.getElementById('result').textContent = ''
document.getElementById('result2').value = ''
+
requestSubmit({
- //url: '/api/biz/nims/v1/getProductInfoByQrcodeImg',
url: '
',
method: 'POST',
data: formData,
@@ -183,13 +217,14 @@
},
loadend: (res) => {
- const data = JSON.parse(res)
- if (data.success) {
+ const rslt = JSON.parse(res)
+ if (rslt.success) {
//console.log(data[0].qrcode)
- document.getElementById('result2').value = JSON.stringify(data)
+ document.getElementById('result2').value = JSON.stringify(rslt.data, null, 4)
return true;
+ }else{
+ alert(`${rslt.code}: ${rslt.message}`)
}
- alert(JSON.stringify(data));
},
error: (e) => {
@@ -197,26 +232,7 @@
}
});
});
-
- // document.getElementById('decodeButton').addEventListener('click', () => {
- // const img = document.getElementById('img')
- // codeReader.decodeFromImage(img).then((result) => {
- // console.log(result)
- // document.getElementById('result').textContent = result.text
- // }).catch((err) => {
- // console.error(err)
- // document.getElementById('result').textContent = err
- // })
- // console.log(`Started decode for image from ${img.src}`)
- // })
}
-
- document.getElementById('resetButton').addEventListener('click', () => {
- codeReader.reset()
- document.getElementById('result').textContent = '';
- console.log('Reset.')
- })
-
})
.catch((err) => {
console.error(err)
@@ -263,7 +279,7 @@
fileInfos = null;
return isStop;
}
- alert(JSON.stringify(fileInfos));
+ alert(JSON.stringify(fileInfos, null, 4));
return true;
}