Index: ssts-web/src/main/webapp/disinfectsystem/packing/splitForeignTousseView.js =================================================================== diff -u -r23091 -r24812 --- ssts-web/src/main/webapp/disinfectsystem/packing/splitForeignTousseView.js (.../splitForeignTousseView.js) (revision 23091) +++ ssts-web/src/main/webapp/disinfectsystem/packing/splitForeignTousseView.js (.../splitForeignTousseView.js) (revision 24812) @@ -258,8 +258,9 @@ barcodeField.setValue(""); } +var cameraPhotos = []; function splitForeignTousse(packTaskId,foreignTousseName,showName,invoicePlanId,thizAmount,supplierName,basketBarcode,packageType,sterilingType){ - + cameraPhotos = []; top.Ext4.define('cellEditingGrid',{ extend: 'top.Ext4.grid.Panel', xtype: 'cell-editing', @@ -782,6 +783,12 @@ handler : function() { splitForeignTousse_packingTousseBtnClick0(this); } + },{ + text : '拍照', + hidden : !sstsConfig.showCameraPhoto, + handler : function() { + openCameraWindow(); + } }] }); @@ -909,6 +916,103 @@ splitForeignTousse_packingTousseBtnClick(btn); } } + // 拍照 + function openCameraWindow() { + if (Ext4.chromeVersion < 62) { + showResult("请使用62以上版本的chrome浏览器!", null, + sstsConfig.messagePauseTimeOnPackingPage); + return false; + } + if (!isSplitComplete()) { + return false; + } + var splitedTousseStore = top.Ext4.getCmp("splitedTousseGrid") + .getStore(); + var records = splitedTousseGrid.getSelectionModel().getSelection(); + if (records.length == 0) { + showResult("请选择要上传照片的包!" , null , sstsConfig.messagePauseTimeOnPackingPage); + return false; + } + if (records.length != 1) { + showResult("只能选择一个包!" , null , sstsConfig.messagePauseTimeOnPackingPage); + return false; + } + var data = records[0].data; + cameraPhotos = data.cameraPhotos; + if(!cameraPhotos){ + data.cameraPhotos = []; + cameraPhotos = data.cameraPhotos; + } + // 弹出窗口 + var pageUrl = WWWROOT + '/disinfectsystem/test/video_split.jsp'; + var style = "menubar=no,location=no,directories=no,toolbar=no,statusbar=no,resizable=no," + + getCenterWindowPos(1920, 1080) + ",scrollbars=no"; + var popwin = window.open(pageUrl, '图片采集', style); + if (popwin != null) { + popwin.focus(); + } + } + function isSplitComplete(){ + var waitSplitMaterialStore = top.Ext4.getCmp("waitSplitMaterialGrid").getStore(); + var splitedMaterialStore = top.Ext4.getCmp("splitedMaterialGrid").getStore(); + + var v = waitSplitMaterialStore.getCount(); + if(v > 0){ + showResult("待拆分的材料部分未拆分!" , null , sstsConfig.messagePauseTimeOnPackingPage); + return false; + } + v = splitedMaterialStore.getCount(); + if(v > 0){ + showResult("已拆分的材料部分未拆分!" , null , sstsConfig.messagePauseTimeOnPackingPage); + return false; + } + return true; + } + function uploadTousseCameraPhotos(tousses){ + if(!sstsConfig.showCameraPhoto){ + return; + } + var splitedTousseStore = top.Ext4.getCmp("splitedTousseGrid").getStore(); + + top.Ext4.MessageBox.progress('正在上传图片', '请稍候...'); + //外来器械拆分小包名称带总拆包数量 + var count = splitedTousseStore.getCount(); + for ( var i = 0; i < count; i++) { + var record = splitedTousseStore.getAt(i); + var cameraPhotos = record.data.cameraPhotos; + if(cameraPhotos && cameraPhotos.length>0){ + for(var cpi = 0; cpi < cameraPhotos.length; cpi++){ + uploadTousseCameraPhoto(tousses[i].id,cameraPhotos[cpi]); + } + } + } + hideMessageBox4(true); + } + + function uploadTousseCameraPhoto(objectId,base64Data){ + var imageType = '装配采集图片'; + var url = WWWROOT + '/disinfectSystem/baseData/uploadImageFileAction!uploadBase64Image.do?imageType='+imageType; //这里我用struts2做后台处理 + if(objectId){ + url += '&objectId='+objectId; + } + $.ajax({ + type: "POST", + url: url, + async:false, + dataType: "json", + data: { + base64Data: base64Data + } + }).done(function(o) { + if(o.success){ + message = o.message; + showResult(message, null , sstsConfig.messagePauseTimeOnPackingPage); + }else{ + message = o.message; + showResult(message, null , sstsConfig.messagePauseTimeOnPackingPage); + } + }); + } // 装配按钮处理 function splitForeignTousse_packingTousseBtnClick(btn){ if (!foreignToussePanel.form.isValid()) { @@ -922,16 +1026,9 @@ var waitSplitMaterialStore = top.Ext4.getCmp("waitSplitMaterialGrid").getStore(); var splitedMaterialStore = top.Ext4.getCmp("splitedMaterialGrid").getStore(); - var v = waitSplitMaterialStore.getCount(); - if(v > 0){ - showResult("待拆分的材料部分未拆分!" , null , sstsConfig.messagePauseTimeOnPackingPage); - return false; + if(!isSplitComplete()){ + return false; } - v = splitedMaterialStore.getCount(); - if(v > 0){ - showResult("已拆分的材料部分未拆分!" , null , sstsConfig.messagePauseTimeOnPackingPage); - return false; - } top.Ext4.getCmp('taskGroup2').setValue(taskGroup); var ids = packTaskId; @@ -1027,6 +1124,8 @@ var tousses = result.tousses; + // 上传照片 + uploadTousseCameraPhotos(tousses); packingToussesArray = packingToussesArray.concat(tousses); // 审核时打印标签 Index: ssts-web/src/main/webapp/disinfectsystem/test/video_split.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/test/video_split.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/test/video_split.js (revision 24812) @@ -0,0 +1,179 @@ + +var imgWidth = 640; +var imgHeight = 480; +var g_status = 'NotStarted'; +var message = ''; +var captured = false; +var cameraPhotos = window.opener.cameraPhotos; +var cameraPhotosIndex = 0; + +function clearCanvas(canvasId){ + var canvas = $("#"+canvasId)[0]; + var context = canvas.getContext("2d"); + context.clearRect(0,0,canvas.width,canvas.height); +} +function showImgInCanvas(canvasId,imgData){ + clearCanvas(canvasId); + var canvas = $("#"+canvasId)[0]; + var context = canvas.getContext("2d"); + var img = new Image; + img.onload = function(){ + context.drawImage(img,0,0); // Or at whatever offset you like + }; + img.src = imgData; +} +function displayCurPhoto(){ + var count = cameraPhotos.length; + if(count == 0){ + // 清除显示 + clearCanvas("added_photo_canvas"); + return; + } + showImgInCanvas("added_photo_canvas",cameraPhotos[cameraPhotosIndex]); +} +function fun_prevPhoto(){ + var count = cameraPhotos.length; + if(count == 0){ + alert('没有图片可以显示!'); + return; + } + if(cameraPhotosIndex == 0){ + alert('已经是第一张!'); + return; + } + --cameraPhotosIndex; + displayCurPhoto(); +} +function fun_nextPhoto(){ + var count = cameraPhotos.length; + if(count == 0){ + alert('没有图片可以显示!'); + return + } + if(cameraPhotosIndex == count-1){ + alert('已经是最后一张!'); + return; + } + ++cameraPhotosIndex; + displayCurPhoto(); +} +function fun_delete(){ + var count = cameraPhotos.length; + if(count == 0){ + alert('没有图片可以删除!'); + } + cameraPhotos.splice(cameraPhotosIndex,1); + if(cameraPhotosIndex == count-1 && cameraPhotosIndex > 0){ + --cameraPhotosIndex; + } + displayCurPhoto(); +} + +function fun_addPhoto(){ + if(!captured){ + alert('请先抓拍'); + return; + } + var count = cameraPhotos.length; + if(count >= 10){ + alert('最多只能添加10张!'); + return; + } + // 实际运用可不写,测试代 , 为单击拍照按钮就获取了当前图像,有其他用途 + var canvans = document.getElementById("cur_photo_canvas"); + // 以下开始编 数据 + var base64Data = canvans.toDataURL('image/jpeg', 1.0); + + cameraPhotos.push(base64Data); + cameraPhotosIndex = cameraPhotos.length-1; + displayCurPhoto(); + + clearCanvas("cur_photo_canvas"); + captured = false; + return ; + +} + +// 这段代 主要是获取摄像头的视频流并显示在Video 签中 +$(function() { + var canvas = document.getElementById("cur_photo_canvas") + var context = canvas + .getContext("2d") + var video = document + .getElementById("video") + var videoObj = { + "video" : true + } + var errBack = function(error) { + console.log("Video capture error: ", error.code); + }; + + +if (navigator.mediaDevices.getUserMedia) { +navigator.mediaDevices.getUserMedia(videoObj).then(function(stream) { + video.srcObject = stream; + var playPromise = video.play(); + if (playPromise !== undefined) { + playPromise.then(function() { + // Automatic playback started! + console.log("Automatic playback started!"); + }).catch(function(error) { + // Automatic playback failed. + // Show a UI element to let the user manually start playback. + console.log("Automatic playback failed.", error); + }); + } +}).catch(errBack); +} else { + +} +// 这个是拍照按钮的事件, +$("#snap").click(function() { +context.drawImage(video, 0, 0, imgWidth, imgHeight); +captured = true; +// CatchCode(); +}); + +$("#btn_add").click(fun_addPhoto); +$("#btn_prevPhoto").click(fun_prevPhoto); +$("#btn_nextPhoto").click(fun_nextPhoto); +$("#btn_delete").click(fun_delete); +$("#btn_close").click(function() { + if(g_status == 'Uploading'){ + alert('正在上传,请稍后关闭'); + return; + } + self.close(); +}); + +displayCurPhoto(); +}); + + +function setStatus(status,message){ + g_status = status; + refreshStatus(message); +} +function refreshStatus(message){ + var s = ''; + switch(g_status){ + case 'NotStarted': + break; + case 'Uploading': + s = '正在上传...'; + break; + case 'UploadSuccess': + s = message; + break; + case 'UploadFailed': + s = message; + break; + } + $("#input_status").html(s); +} +// 定时器 +// var interval = setInterval(CatchCode, "1000"); +// 这个是 刷新上 图像的 +function uploadImg() { + +} Index: ssts-web/src/main/webapp/disinfectsystem/test/video_split.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/test/video_split.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/test/video_split.jsp (revision 24812) @@ -0,0 +1,38 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> + + + + +拍照 + + + + + + + + + + + + +
+ + + + + + +
+
+
+ + + \ No newline at end of file