add.html 13.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header" />
    <th:block th:include="include :: select2-css" />
	<style type="text/css">
		/* 缩略图 */
		#my_thumbnail{
			height: 85px;
			overflow-x: auto;
			border: 1px solid blue;
		}
		#my_thumbnail img{
			margin: 0 5px;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-receiptHeader-add">
<!--			<div class="form-group">-->
<!--				<label class="col-sm-3 control-label">入库类型:</label>-->
<!--				<div class="col-sm-8">-->
<!--					<select id="receiptType" name="receiptType" class="form-control">-->
<!--						<option th:text="CLXXRK" th:value="CLXXRK"></option>-->
<!--					</select>-->
<!--				</div>-->
<!--			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">入库类型:</label>
				<div class="col-sm-8">
					<input id="receiptType" name="receiptType" class="form-control" type="text" th:value="CLXXRK" readonly>
				</div>
			</div>
<!--			<div class="form-group">-->
<!--				<label class="col-sm-3 control-label">原料批号:</label>-->
<!--				<div class="col-sm-8">-->
<!--					<input id="materialBatch" name="materialBatch" class="form-control" type="text">-->
<!--				</div>-->
<!--			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">供应商:</label>
				<div class="col-sm-8">
					<select id="supplier" name="supplier" class="form-control" type="text"></select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">司机姓名:</label>
				<div class="col-sm-8">
					<input id="vehicleName" name="vehicleName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">身份证号:</label>
				<div class="col-sm-8">
					<input id="cardNumber" name="cardNumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group" style="margin-left: 190px">
				<button onclick="ReadIDCard()" class="btn btn-danger" type="button">识别身份证</button>
				<button type="button" class="btn btn-primary"  onclick="getWeight()" >获取重量</button>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆毛重:</label>
				<div class="col-sm-8">
					<input id="grossWeight" name="grossWeight" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆皮重:</label>
				<div class="col-sm-8">
					<input id="tareWeight" name="tareWeight" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆净重:</label>
				<div class="col-sm-8">
					<input id="netWeight" name="netWeight" class="form-control" type="text">
				</div>
			</div>

<!--			<div class="form-group">-->
<!--				<label class="col-sm-3 control-label">物料编码:</label>-->
<!--				<div class="col-sm-8">-->
<!--					<select id="materialCode" name="materialCode" class="form-control" type="text"></select>-->
<!--				</div>-->
<!--			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">物料:</label>
				<div class="col-sm-8">
					<select id="userDef2" name="userDef2" class="form-control" th:with="probablyMaterial=${@dict.getType('probablyMaterial')}">
						<option th:each="dict : ${probablyMaterial}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
					</select>
				</div>
			</div>
<!--			<div class="form-group">-->
<!--				<label class="col-sm-3 control-label">物料单位:</label>-->
<!--				<div class="col-sm-8">-->
<!--					<select id="materialUnit" name="materialUnit" class="form-control" type="text"></select>-->
<!--				</div>-->
<!--			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">车牌号:</label>
				<div class="col-sm-8">
					<input id="carNumber" name="carNumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">驾驶证:</label>
				<div class="col-sm-8">
					<input id="driverNumber" name="driverNumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">同行人数:</label>
				<div class="col-sm-8">
					<input id="userDef1" name="userDef1" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">入库单备注:</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">预计到达时间:</label>
				<div class="col-sm-8">
					<input id="incomingTime" name="incomingTime" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group" style="width:600px;margin: 0 auto;white-space: nowrap">
				<img id="cameraPlc" name="cameraPlc" src="" width="300px" height="200px"/>
				<img id="view1" src="" width="300px" height="200px" alt="主摄像头画面">
			</div>
			<div class="form-group" style="width:600px;margin: 0 auto;white-space: nowrap">
<!--				<img id="view1" src="" width="300px" height="200px" alt="主摄像头画面">-->

			</div>
			<div class="form-group" style="width:310px;margin: 0 auto;">
<!--				<video id="video" hidden="hidden"></video>-->
<!--				<canvas id="canvas"></canvas>-->
				<button class="btn btn-info" type="button" onclick="scan()">驾驶证拍照</button>
<!--				<button onclick="ReadIDCard()" class="btn btn-warning" type="button">识别身份证</button>-->
				<button id="plc" name="plc" class="btn btn-danger" type="button">车辆入库拍照</button>
			</div>
			<div id="my_thumbnail">
			</div>
			<div class="form-group" style="margin-left: 350px">
<!--				<button onclick="ReadIDCard()" class="btn btn-danger" type="button">识别身份证</button>-->
			</div>
			<div style="border: 2px solid red;margin-top: 30px;" hidden="hidden">
				<img id="res_img" src="" width="400px" height="300px" alt="">
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary" >提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button" >关闭</button>
				</div>
			</div>
		</form>
	</div>
    <th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<th:block th:include="include :: thumbnail_customized-js" />
<!--	<script type="text/javascript" src="../js/api/equipment.js"></script>-->
<!--	<script type="text/javascript" src="../js/api/gaopaiyi.js"></script>-->
<!--	<script type="text/javascript" src="../js/api/pdf.js"></script>-->
<!--	<script type="text/javascript" src="../js/api/person.js"></script>-->
<!--	<script type="text/javascript" src="../js/api/serialport.js"></script>-->
<!--	<script type="text/javascript" src="../js/customized/thumbnail_customized.js"></script>-->
    <script type="text/javascript">

		$("#view1").attr("src", "http://127.0.0.1:38088/video=stream&camidx=0");
		$("#view2").attr("src", "http://127.0.0.1:38088/video=stream&camidx=1");

		// 加载主头视频模式
		view1_mode_data1 = { "camidx": "0", "mode": "0" };
		view1_mode_data2 = { "camidx": "0", "mode": "1" };
		$.post("http://127.0.0.1:38088/device=getresolution", JSON.stringify(view1_mode_data2), function(res){

		})

		// 加载副头视频模式
		view2_mode_data1 = { "camidx": "1", "mode": "0" };
		view2_mode_data2 = { "camidx": "1", "mode": "1" };
		$.post("http://127.0.0.1:38088/device=getresolution", JSON.stringify(view2_mode_data2), function(res){

		})

		function scan(){
			data = {
				"filepath": "D:\\driverIn.jpg",
				"rotate": "0",
				"deskew": "0",
				"camidx": "0",
				"ColorMode": "0",
				"quality": "0"
			}
			$.post("http://127.0.0.1:38088/video=grabimage", JSON.stringify(data), function(res){
				add_img(res.photoBase64);
			})
		}

		function add_img(img_base64){
			img = document.createElement('img');
			img.id = 'hu' + String(Math.random());
			img.src = "data:image/jpg;base64," + img_base64;
			img.oncontextmenu = showOperation;
			img.style.width = '80px';
			img.style.height = '80px';
			document.getElementById('my_thumbnail').appendChild(img)
		}
			//
			document.getElementById("plc")
				.addEventListener("click", function() {
					$.ajax({
						cache : false,
						type : "POST",
						url : ctx + "API/WMS/v2/cameraLogin",
						dataType: 'json',
						data : {
							"cameraId": "1"
						},
						async : false,
						error : function(request) {
							$.modal.alertError("请求失败!");
						},
						success : function(result) {
							if (result.code == web_status.SUCCESS) {
								getData()
								$.modal.msgSuccess(result.msg);
							}else{
								$.modal.msgError(result.msg);
							}
						}
					});
				});
		function getData(){
			let url = "/wms/img/Capture/carIn.jpg?" + Date.parse(new Date());
			$("#cameraPlc").attr('src',url);
			// setTimeout(getData,5000)
		}

		function drawCanvasImage() {
			const canvas = document.getElementById('canvas');
			canvas.width = width;
			canvas.height = height;
			const context = canvas.getContext('2d');
			context.drawImage(video, 0, 0, width, height, 0, 0, width, height);
			// //获取图片,数据格式为base64
			// const imageData = canvas.toDataURL("image/png");
		}

		var prefix = ctx + "vehicle/vehicleReceipt";

		$("#form-receiptHeader-add").validate({
            rules:{
				receiptType:{
					required:true,
				},
                companyCode:{
                    required:true,
                },
            },
			submitHandler: function(form) {
                $.ajax({
                    cache : true,
                    type : "POST",
                    url : prefix + "/add",
					data : $("#form-receiptHeader-add").serializeArray(),
                    async : false,
                    error : function(request) {
                        $.modal.alertError("请求失败!");
                    },
                    success : function(data) {
                        $.operate.saveSuccess(data);
                    }
                });
			}
		});

		$(function () {
            layui.use('laydate', function() {
                var laydate = layui.laydate;
                laydate.render({ elem: '#incomingTime',min: 0, theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss'});
            });
            $('#supplier').select2({
                ajax: {
                    url: ctx+'config/supplier/getData',
                    dataType: 'json',
                    type: 'post',
                    data: function (params) {
                        let query = {
                            supplierName: params.term,
                        }
                        return query;
                    }
                }
            });
			$('#materialCode').select2({
				ajax: {
					url: ctx+'config/material/getData',
					dataType: 'json',
					type: 'post',
					data: function (params) {
						let query = {
							materialName: params.term,
						}
						return query;
					}
				}
			});
			$('#materialUnit').select2({
				ajax: {
					url: ctx+'config/materialUnit/getData',
					dataType: 'json',
					type: 'post',
					data: function (params) {
						let query = {
							unit: params.term,
						}
						return query;
					}
				}
			});
        })
		function getWeight(){
			let url='http://10.34.101.77:8888/wms/API/WMS/v2/getWeightForSerial';
			let type = "POST";
			let dataType = "json";
			let data = {};
			let config = {
				url: url,
				type: type,
				dataType: dataType,
				data: data,
				beforeSend: function () {
					$.modal.loading("正在处理中,请稍后...");
				},
				success: function (result) {
					console.log(result.data)
					$("#grossWeight").val(result.data)
					$.operate.ajaxSuccess(result);
				}
			};
			$.ajax(config)
		}


		function ReadIDCard(){
			$.post("http://127.0.0.1:38088/card=idcard", function(res){
				if(res.code == '0'){
					$("#cardNumber").val(res.IDCardInfo.cardID)
					$("#vehicleName").val(res.IDCardInfo.name)
					add_img(res.IDCardInfo.photoBase64_Z);
					add_img(res.IDCardInfo.photoBase64_F);
				}else{
					alert("请将证件放对位置!!!")
				}
			})
		}



		// 主头纠偏拍照
		function scan1cutpage(){
			debugger;
			var data = {
				"filepath": "base64",
				"rotate": "0",
				"cutpage": "1",
				"camidx": "0"
			};
			$.post("http://127.0.0.1:38088/video=grabimage", JSON.stringify(data),
					function(res){
						$('#res_img').attr('src', "data:image/jpg;base64," + res.photoBase64);
						// 调用方式
						// 参数一: 选择器,代表img标签
						// 参数二: 图片名称,可选
						downloadIamge('#res_img', res.photoBase64)
					}
			)
		}



		function downloadIamge(selector, name) {
			var image = new Image()
			// 解决跨域 Canvas 污染问题
			image.setAttribute('crossOrigin', 'anonymous')
			image.onload = function () {
				var canvas = document.createElement('canvas')
				canvas.width = image.width
				canvas.height = image.height

				var context = canvas.getContext('2d')
				context.drawImage(image, 0, 0, image.width, image.height)
				var url = canvas.toDataURL('image/png')

				// 生成一个a元素
				var a = document.createElement('a')
				// 创建一个单击事件
				var event = new MouseEvent('click')

				// 将a的download属性设置为我们想要下载的图片名称,若name不存在则使用‘下载图片名称’作为默认名称
				a.download = name || '下载图片名称'
				// 将生成的URL设置为a.href属性
				a.href = url

				// 触发a的单击事件
				a.dispatchEvent(event)
			}

			image.src = document.querySelector(selector).src
		}

	</script>
</body>
</html>