add.html 13.4 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
<!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">
						<input id="receiptType" name="receiptType" class="form-control" type="text" th:value="CLXXCK" readonly>
				</div>
<!--					<select id="receiptType" name="receiptType" class="form-control">-->
<!--						readonly-->
<!--&lt;!&ndash;						<option th:text="CLXXRK" th:value="CLXXRK"></option>&ndash;&gt;-->
<!--					</select>-->
			</div>
<!--			<div class="form-group">-->
<!--				<label class="col-sm-3 control-label">磅单编号:</label>-->
<!--				<div class="col-sm-8">-->
<!--					<input id="poundNumber" name="poundNumber" 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="vehicleDocumentType" name="vehicleDocumentType" class="form-control" th:with="vehicleDocumentType=${@dict.getType('vehicleDocumentType')}">
						<option th:each="dict : ${vehicleDocumentType}" 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="customerCode" name="customerCode" class="form-control"></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-6">
					<input id="cardNumber" name="cardNumber" class="form-control" type="text">
				</div>
				<button onclick="ReadIDCard()" class="btn btn-primary" type="button">识别</button>
				<button class="btn btn-info" type="button" onclick="paiZhao()">拍照</button>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆毛重:</label>
				<div class="col-sm-6">
					<input id="grossWeight" name="grossWeight" class="form-control" type="text">
				</div>
				<button type="button" class="btn btn-primary"  onclick="getWeight(0)" >取重</button>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆皮重:</label>
				<div class="col-sm-6">
					<input id="tareWeight" name="tareWeight" class="form-control" type="text">
				</div>
				<button type="button" class="btn btn-primary"  onclick="getWeight(1)" >取重</button>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车辆净重:</label>
				<div class="col-sm-6">
					<input id="netWeight" name="netWeight" class="form-control" type="number">
				</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"></select>
				</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="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 class="fileUpload" type="file" id="userDef2" name="userDef2" multiple>
				</div>
			</div>
<!--			<div id="my_thumbnail">-->
<!--			</div>-->
<!--&lt;!&ndash;			<div class="form-group" style="margin-left: 350px">&ndash;&gt;-->
<!--&lt;!&ndash;				<button onclick="ReadIDCard()" class="btn btn-danger" type="button">识别身份证</button>&ndash;&gt;-->
<!--&lt;!&ndash;			</div>&ndash;&gt;-->
<!--			<div style="border: 2px solid red;margin-top: 30px;" hidden="hidden">-->
<!--				<img id="res_img" src="" width="400px" height="300px" alt="">-->
<!--			</div>-->
			<input id="userDef7" name="userDef7" hidden>
			<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" />
	<th:block th:include="include :: bootstrap-fileinput-css"/>
	<th:block th:include="include :: bootstrap-fileinput-js"/>
	<th:block th:include="include :: piexif-js"/>
    <script type="text/javascript">
		//初始化fileinput
		var FileInput = function () {
			var oFile = new Object();
			//初始化fileinput控件(第一次初始化)
			oFile.Init = function(ctrlName, uploadUrl) {
				var control = $('#' + ctrlName);
				//初始化上传控件的样式
				control.fileinput({
					language: 'zh', //设置语言
					uploadUrl: uploadUrl, //上传的地址
					allowedFileExtensions: ['jpg', 'gif', 'png', 'pdf'], //接收的文件后缀
					showUpload: true, //是否显示上传按钮
					showCaption: false, //是否显示标题
					browseClass: "btn btn-primary", //按钮样式
					maxFileCount: 10, //表示允许同时上传的最大文件个数
					enctype: 'multipart/form-data',
					validateInitialCount:true,
					previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
					msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!",
					uploadExtraData:function (previewId, index) { //传参
						var data = {

						};
						return data;
					}
				});
				//导入文件上传完成之后的事件
				control.on("fileuploaded", function (event, data, previewId, index) {
					let plugin = $('#userDef2').data('fileinput');
					console.log(plugin.initialPreview);
				});
			}
			return oFile;
		};
		//初始化fileinput
		var oFileInput = new FileInput();
		//参数1:控件id、参数2:上传地址
		oFileInput.Init("userDef2", ctx + 'vehicle/vehicleReceipt/uploadReport');

		function paiZhao(){
			// vehicleName
			//cardNumber
			//carNumber
			//driverNumber
			if($("#vehicleName").val()==''){
				$.modal.msgWarning("请先录入 司机姓名 在进行拍照!!");
				$("#vehicleName").focus();
				return;
			}
			if($("#cardNumber").val()==''){
				$.modal.msgWarning("请先录入 身份证号 在进行拍照!!");
				$("#cardNumber").focus();
				return;
			}
			if($("#carNumber").val()==''){
				$.modal.msgWarning("请先录入 车牌号 在进行拍照!!");
				$("#carNumber").focus();
				return;
			}
			if($("#driverNumber").val()==''){
				$.modal.msgWarning("请先录入 驾驶证 在进行拍照!!");
				$("#driverNumber").focus();
				return;
			}
			let vehicleName = $("#vehicleName").val();
			let cardNumber = $("#cardNumber").val();
			let carNumber = $("#carNumber").val();
			let driverNumber = $("#driverNumber").val();
			let url = ctx+ "vehicle/vehicleShipment/pictures/"+vehicleName+"/"+cardNumber+"/"+carNumber+"/"+driverNumber;
			$.modal.open("车辆拍照" ,url);
		}

		var prefix = ctx + "vehicle/vehicleShipment";

		$("#form-receiptHeader-add").validate({
            rules:{
				receiptType:{
					required:true,
				},
                companyCode:{
                    required:true,
                },
            },
			submitHandler: function(form) {
				let imglist=$(".file-preview-success .file-preview-image");
				let userDef7='';
				for(let a=0;a<imglist.length;a++){
					userDef7+=imglist[parseInt(a)].title+",";
				}
				if(userDef7!=''){
					userDef7=userDef7.substring(0,userDef7.length-1);
				}
				$("#userDef7").val(userDef7);
                $.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: '#scheduledArriveDate',min: 0, theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss'});
            });
			$('#customerCode').select2({
				ajax: {
					url: ctx+'config/customer/getData',
					dataType: 'json',
					type: 'post',
					data: function (params) {
						let query = {
							customerName: 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;
					}
				}
			});
        });

		$("#grossWeight").blur(function(){
			if($("#tareWeight").val()!=''){
				let total = numAdd($("#grossWeight").val(),$("#tareWeight").val())
				$("#netWeight").val(total)
			}
		})

		$("#tareWeight").blur(function(){
			if($("#grossWeight")!=''){
				let total = numAdd($("#grossWeight").val(),$("#tareWeight").val())
				$("#netWeight").val(total)
			}
		})

		function numAdd(num1, num2) {
			var baseNum, baseNum1, baseNum2;
			try {
				baseNum1 = num1.toString().split(".")[1].length;
			} catch (e) {
				baseNum1 = 0;
			}
			try {
				baseNum2 = num2.toString().split(".")[1].length;
			} catch (e) {
				baseNum2 = 0;
			}
			baseNum = Math.pow(10, Math.max(baseNum1, baseNum2));
			return (num1 * baseNum - num2 * baseNum) / baseNum;
		};



		function getWeight(num){
			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) {
					if(result.code==web_status.SUCCESS){
						if(num == '0'){
							$("#grossWeight").val(result.data)
						}else if(num == '1'){
							$("#tareWeight").val(result.data)
						}
					}
				}
			};
			$.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)
				}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>