From aade2d437ef8dbc49aedef4a1cc572d92e99bf7a Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 22 May 2024 17:36:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20barcode=20read=20=EC=83=98=ED=94=8C=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 26 ++++- .../WEB-INF/jsp/adds/nims/barcode-read.jsp | 100 ++++++++++-------- 2 files changed, 82 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 45675a1..d7a8326 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,34 @@ target/ - +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ ### STS ### +.apt_generated .classpath .factorypath .project .settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ +### VS Code ### +.vscode/ logs/ -files/ \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/barcode-read.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/barcode-read.jsp index 64fda85..a2e58ca 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/barcode-read.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/barcode-read.jsp @@ -1,13 +1,7 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%> <%@ include file="/WEB-INF/jsp/include/taglib.jsp"%> -사고마약류폐기관리 - - - - - - + QR code reading @@ -17,17 +11,16 @@ href="https://unpkg.com/normalize.css@8.0.0/normalize.css"> - - - + +

QR code Scan or image upload

-
+
Start Reset @@ -50,8 +43,11 @@
- -
+
+ +
+
+

@@ -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; }