add.html 10.3 KB
<!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" />
</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">
					<input id="supplier" name="supplier" 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="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">
				<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">
					<input id="meterialName" name="meterialName" 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="materialCode" name="materialCode" 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="materialUnit" name="materialUnit" 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="materialSpec" name="materialSpec" 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="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="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="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" />
    <script type="text/javascript">
		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 : {
                        "receiptType": $("#receiptType option:selected").val(),
						"supplier": $("input[name='supplier']").val(),
                        "vehicleName": $("input[name='vehicleName']").val(),
						"cardNumber": $("input[name='cardNumber']").val(),
						"grossWeight": $("input[name='grossWeight']").val(),
						"tareWeight": $("input[name='tareWeight']").val(),
						"carNumber": $("input[name='carNumber']").val(),
						"driverNumber": $("input[name='driverNumber']").val(),
						"remark": $("input[name='remark']").val(),
						// "materialBatch": $("input[name='materialBatch']").val(),
						"meterialName": $("input[name='meterialName']").val(),
						"materialCode": $("input[name='materialCode']").val(),
						"materialUnit": $("input[name='materialUnit']").val(),
						"materialSpec": $("input[name='materialSpec']").val(),
                        "incomingTime": $("input[name='incomingTime']").val(),
						"netWeight": $("input[name='netWeight']").val()
					},
                    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: '#scheduledArriveDate',min: 0, theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss'});
            });
            $('#supplierName2').select2({
                ajax: {
                    url: ctx+'config/supplier/getData',
                    dataType: 'json',
                    type: 'post',
                    data: function (params) {
                        let query = {
                            supplierName: params.term,
                        }
                        return query;
                    }
                }
            });
        })

		function ReadIDCard()
		{
			IdBase64 = "";
			var params = "";
			var url = "http://127.0.0.1:38088/card=idcard";

			$.ajax({
				type: "post",
				url: url,
				dataType: "json",
				data: params,
				success: function(data)
				{
					if(data.code != 0)
					{
						alert("请将证件放对位置!!!")
					}
					else
					{
						$("#cardNumber").val(data.IDCardInfo.cardID)
						$("#vehicleName").val(data.IDCardInfo.name)
						// document.getElementById("cardNumber").innerHTML = data.IDCardInfo.cardID
						// $("input[name='cardNumber']").val() = data.IDCardInfo.cardID
						// document.getElementById("result").innerHTML = "ReadIDCard <br />返回代码:" + data.code +
						// 		"<br />返回信息:" + data.message +
						// 		"<br />姓名:" + data.IDCardInfo.name +
						// 		"<br />性别:" + data.IDCardInfo.sex +
						// 		"<br />民族:" + data.IDCardInfo.nationCode +
						// 		"<br />生日:" + data.IDCardInfo.birthday +
						// 		"<br />地址:" + data.IDCardInfo.address +
						// 		"<br />身份证号:" + data.IDCardInfo.cardID +
						// 		"<br />发卡机构:" + data.IDCardInfo.issueOrgan +
						// 		"<br />有效时间:" + data.IDCardInfo.validStart + "-" + data.IDCardInfo.validEnd;
						// document.getElementById("photo").src= "data:image/gif;base64," + data.IDCardInfo.photoBase64;
						// IdBase64 = data.IDCardInfo.photoBase64;
					}
				}
			});
			scan1cutpage();
		}



		// 主头纠偏拍照
		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>